The Goal: Use a button to make a bar graph (in processing) increment upon each button press w/ the number of button presses recorded on top of the bar.
The Problem: When the button is pressed, the bar graph increments and shows how many times the button has been pushed, Great! Except there appears to be a glitch. When I push the button the 2nd time, the bar graph increments but displays my result as "3", as if I had pushed the button 3 times (though it's actually 2). Everything is fine incrementing afterwards, it's only when it gets to the 2nd press! What's going on?
If I do a println of the button presses, it displays the correct results. I've only hit the button twice. Yet it's just the graphics window that just records a different result (it says "3" instead of "2" button presses).
Please help!
[code]
//Read the Yes button from the Arduino in Processing:
if (sensors[0] > 0) {
yesValue = yesButton; //number of button presses
yesButton++; //increment graph on each button press.
yesButtonGraph(); //show graph.
//The graph:
fill(0,255,0); //green bar
rect(30, 1050, 240, -yesValue); //draw the bar as the Yes button is pressed.
text("YES: " + yesValue, 150, height-yesValue+275); //Put a text above the bar and tell me how many times
the button was pressed.
[/code]
The Problem: When the button is pressed, the bar graph increments and shows how many times the button has been pushed, Great! Except there appears to be a glitch. When I push the button the 2nd time, the bar graph increments but displays my result as "3", as if I had pushed the button 3 times (though it's actually 2). Everything is fine incrementing afterwards, it's only when it gets to the 2nd press! What's going on?
If I do a println of the button presses, it displays the correct results. I've only hit the button twice. Yet it's just the graphics window that just records a different result (it says "3" instead of "2" button presses).
Please help!
[code]
//Read the Yes button from the Arduino in Processing:
if (sensors[0] > 0) {
yesValue = yesButton; //number of button presses
yesButton++; //increment graph on each button press.
yesButtonGraph(); //show graph.
//The graph:
fill(0,255,0); //green bar
rect(30, 1050, 240, -yesValue); //draw the bar as the Yes button is pressed.
text("YES: " + yesValue, 150, height-yesValue+275); //Put a text above the bar and tell me how many times
the button was pressed.
[/code]
1