I was trying to print a line to the serial monitor when a button is pressed on the breadboard. But when I press the button I get some strange reading on the serial monitor.
I don't understand what this serial monitor message means.
I was trying to print a line to the serial monitor when a button is pressed on the breadboard. But when I press the button I get some strange reading on the serial monitor.
I don't understand what this serial monitor message means.
The Serial.begin statement needs to be in the setup section of your sketch, not the loop section.
Apart from the begin in the wrong place, you will see the printout repeatedly as long as you hold on to your button. Is this what you want to see or just one message until you press the button again?
I didn't care how many times it printed. I had 3 buttons on my breadboard and I was trying to control a servo using them but only one of the buttons was working. So I was trying to debug it a little bit to see if the buttons were reading correctly when pressed.
Putting the "begin" line into the start up function fixed the problem, but can someone explain why putting it in the loop caused it to print some strange line? What was that supposed to mean?
CSGuy:
I didn't care how many times it printed. I had 3 buttons on my breadboard and I was trying to control a servo using them but only one of the buttons was working. So I was trying to debug it a little bit to see if the buttons were reading correctly when pressed.Putting the "begin" line into the start up function fixed the problem, but can someone explain why putting it in the loop caused it to print some strange line? What was that supposed to mean?
Do you want to restart your computer every time you type one character on your key board? What displays on your computer screen in this case might be unexpected and inexplicable. It's irrelevant.
CSGuy:
Putting the "begin" line into the start up function fixed the problem, but can someone explain why putting it in the loop caused it to print some strange line?
You are "shearing" the outbound byte.
Thanks.