Changing a variable with a pulse.
![Irone](https://forums.parallax.com/uploads/userpics/183/nUZNHUMU5OHAA.gif)
Hello,
I need to know how to change a variable, I will call clock, by increasing the number with a positive pulse and decreasing it with a negative pulse. The variable will be a nib and I need to change it between 0 and 9. Thanks for any help.
I need to know how to change a variable, I will call clock, by increasing the number with a positive pulse and decreasing it with a negative pulse. The variable will be a nib and I need to change it between 0 and 9. Thanks for any help.
Comments
I read in the help file on pulsout that if the pin is negative, it reads positive for the specified time and then goes back to negative. Also if the pin reads positive, it reads negative for the specified time and then goes back to positive. I am using toggle to change my variable. I may be wrong thinking that a change in the plus or minus could change the value of my variable but I am new to BC2 and old in age. If this is not possible I will change my program to a 1 or a 0 and figure out a way to do it differently.
I am a certain believer of call and effect, If you checked my previous post a signal of plus or minus should have been made to my variable, Why would they make a function that sends a plus or minus pulse if it would not affect any other function? I am very new to BS2 but am confused,
The negative and positive terminology being used in the PULSOUT description refers to the direction of the change in signal voltage on whatever pin you are using for PULSOUT. for example: if the signal voltage on the PULSOUT pin is already at 5 volts then changes to 0 volts, that's called a "negative" pulse because it is changing from a more positive voltage to a "less" positive voltage. What it does NOT mean is the voltage is a negative value, it's just talking about the direction of "Change" in voltage. Does that help?
I reread the help file on toggle and found out it changes my variable between a 1 and an 0. It was simple to add one to my clock if the twister was 1 and subtract one if it was not. The problem now is my variable is a nib and it goes to 15. I wish to run a seven segment display (CD4056) which is ancient but I have a few. It comes from the days of decimal coded binary and makes weird displays if you go over nine. Can this be done with the BS2? I am including my code and my schematic
If you do not want wrap around, the following will stop the count at 0 or 9:
However, if you do want wrap around, then the following would work:
I think that the ENDIF should probably be before the DO...LOOP UNTIL (IN7=1) so that it executes for both Twister being 0 or 1.
Thank you so much, the first answer was what I needed. I need this to upgrade my gas grill in the garage. I have nozzles below the cooking grid and an automotive windshield pump bolted to the leg to spray water on the lava rocks. (yes I still use lava rocks) I also noticed you know how to send code. I do remember you need " " after your program (without the quotation marks) but have forgotten what to do after that.
Thanks again!
I think I know what I was doing wrong to attach a code now!
Glad to help. Just don't let any of those CD4056's fall into the fire! Those are great little chips for driving 7-segment displays.
For posting code, you use the word CODE between square brackets. To end, use /CODE between square brackets.