PASM, PPDB and Mysteriously lit LED?- solved
Tony B.
Posts: 356
I am teaching myself PASM and working with individual components learning to make them work. In this program I am working with a push button and one LEDon the PPDB . When I run the attached code the LED is lit dimly. This is the error. I don't understand why it is lit? When I press the push button the LED lights at full strength, just as I would expect. I release the button and it returns to the dimly lit state. I have tried different pins and LEDs with the same result. Though I have tried to discover the reason I have been unsuccessful this weekend. Insight into the cause would be most appreciated.
Tony.
Tony.
Comments
if not an electrical "free floating" input works as an antenna and will pick up noise from the air.
A wire of 10 cm is enough to make the input toggle randomly. So be sure to have a pull-up or a pull-down-resistor.
This resistor ties the input to plus 3.3V (pull-up) or 0V ground (pull-down) that the electrical conditions are constant even if the button is not pressed and the button-contact is opened.
keep the questions coming
best regards
Stefan
try this code:
its untested but you should see a few thing you forgot to add. I also changed how you handled you variables. this assumes the led is on pin 16 and your button on pin 5. don't forgrt that in pasm you need to reserve longs for your variables.
Stefan - I double checked the Propeller Professional Development Board's schematics and the push buttons are active low using a pull-up resistor to 3.3v.
Marzec309 - I will have to study your changes and try the code a little later today.
Thanks,
Tony
Thanks to those above who helped encourage me so I could get this figured out.
Edit: Marzec309 your code worked fine, but I had to remove the LED and Button res section first.
Now on to a serial LCD and Ping))) sensor.
Tony
One thing I did notice in your new code that I wanted to point out. To turn on the LED you used the "mov" instruction. That does work fine in your simple code. But if you were trying to control other pins in that same piece of code, the "mov" instruction affects every pin not just the led pin, your setting the led pin high and all others low. A better way is to use "andn" as i did in my code. Doing so you will only affect the LED pin.
You're so right about the "mov" instruction. Just yesterday I was wondering about having two buttons and LEDS and realized "mov" wasn't going to work if one was on and you press a second button. I'm going to have to get comfortable with "or, and, andn and xor".
Thanks again for all the help and encouragement!
Tony