Shop OBEX P1 Docs P2 Docs Learn Events
BS2P40 - Single button code entry, MP3 Module Control and X10 Module control — Parallax Forums

BS2P40 - Single button code entry, MP3 Module Control and X10 Module control

Need help consolidating my BS2P40 code
Let me start with a brief explanation of what the attached code does, and I will follow up with what I would like to add to it.
The code I wrote allows the user to enter a sequance of numbers, using a single push buttton. The numbers that the user enters are then compared to the "security code" stored in the EEPROM, if they match and momentary and constant out put is triggered. Besides the single button that is used to enter the security code, there are 15 other buttons that are assigned dedicated tasks. Buttons connected to IN0 to IN7 control MP3 module and send on/off commands to preprogrammed devices (IN0=X10 Unit1, IN1=X10 Unit2....,etc). While buttons connected to IN8 to IN14 control MP3 Module (a high signal on IN8, will play track 9 on the MP3, IN9 will play track 10,.... etc.).

Currently the code takes up almost all of the EEPROM, which is a bit problematic as I still need to add 1 function to the code. What I would like the stamp to do is to send a command to the MP3 module and X10 unit just once even if the button remain pressed. The only time the command would get resend is if the button is pressed again.

Comments

  • The BS2p40 has 8 program slots, and you're only using one. You could move some of the functions to another slot to free up some memory in the main slot. See the RUN command in the Stamp Manual. But note, everything at the top of your program with the exception of the DATA statement needs to be in each module, so all the variables are preserved as you jump between them. And also note that the RUN command takes you to the top of the program in each slot, it doesn't work like GOSUB, so you have to use it with those restrictions. But with the way your program is structured, it should not be hard.

  • Thanks for your suggestion, what I will try to do is separate the "security button" function from the main program to its own slot. I also want to add IR to X10 conversion functionality.

    Lastly I also noticed a flaw in my code. In my code I use the INS variable with case select statement. The INS variable is a problem because if two of my push buttons are pressed at once case values will no longer apply. I will work out this bug, and post new code later today.

    Thanks Sapphire for your suggestions.


  • I've replaced select case statement for INS, with If then command for each of the 16 pins. Now I can have high input on multiple pins and basic stamp will send proper mp3 and x10 commands.

Sign In or Register to comment.