I have some code that is running on a machine how do I modify it to be run both as is (buttons) and or by a serial com?
thanks
COUNTERmK2.ino (9.5 KB)
I have some code that is running on a machine how do I modify it to be run both as is (buttons) and or by a serial com?
thanks
COUNTERmK2.ino (9.5 KB)
If you reorganize your existing code into separate functions so loop() looks like this
void loop() {
readButtons();
doTheOtherStuff();
}
void readButtons() {
// read the buttons and save the values in global variables
}
void doTheOtherStuff() {
// use the saved button values to decide what to do
}
Then all you have to do is add an additional function (lets call it readSerialInput()) which is called from loop and also saves to the same variables that the buttons save to.
void loop() {
readButtons();
readSerialInput();
doTheOtherStuff();
}
By the way you have some unfortunate choices for variable names in "Timer" and "Delay" which could be confused with the Timer library and the delay() function. Your names will work fine - but could be confusing.
...R
Thank, the program runs fine now, just trying to last it up to a blue tooth system. My understanding is that blue tooth sends the commands via the serial port, hopefully this will get me going down the right path.