cputampa:
I have a simple task that I just can't wrap my head around. I have a simple toggle switch that I want to act as a button. I want to turn the toggle switch on and it send a pulse (not constant HIGH) and when I turn the toggle off it sends another pulse. So basically like a keyboard keystroke, everytime I turn the toggle on or off it's sends a single keystroke or pulse.You basically cannot have a toggle switch operate like a momentary push button switch without some other external circuitry added. And while that is possible, it is kind of wasteful way to do it because you can perform that kind of action in your program sketch. You just create a flag variable that you set when your program detects a change of state on the input pin that the toggle switch is wired to.
If you can point me in the right direction that would be great, I'm not sure if any additional hardware would be needed or this could be done with just the arduino code but I've looked everywhere and can't find an answer.
Software is the way to go, but you first have to learn and understand C/C++ coding structure and how it's operators work. Perhaps someone here will show you a basic method. Often you will not be able to 'find' a given software function that you require, but rather you have to create it in code by turning your requirement into a working C/C++ function, that's what learning to program is all about.
BTW this video below is the closest answer I have found and it works in minecraft but how do I get it in the Real World?
Cute video and I guess it does visual describe the function you wish to create and use in a sketch, but not much use in helping you to figure out how to code it in C/C++ language is it?
Leftyhttp://www.youtube.com/watch?v=O6rDntYgUkU
Thanks in advance,
Kevin