Hey everyone,
this is my current counter code and i want to set a other button to save the current counter value
example:I pressed the First button six times,then I press the other button then arduino will
save the value '6' Let me do the next operation(means second button will save the
value for press the First button number of times )
How can i do? Can anyone tell me how to write the code in arduino for second button
Tell me how to hit those code....please !!!!
const int buttonPin = 2;
const int ledPin = 13;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
buttonPushCounter++;
Serial.print("number:");
Serial.println(buttonPushCounter);
} else {
}
delay(100);
}
lastButtonState = buttonState;
}
josephcheno:
this is my current counter code and i want to set a button to save the current counter value
.please very urgent!!!!
What does "very urgent" mean? Does it mean you want to get your question answered before the other people who are ahead of you in the queue? That is not very nice!
You already have a button in your program. Do mean that you want to add a second button? If so you already have an example of almost all the code you need.
...R
Robin2:
What does "very urgent" mean? Does it mean you want to get your question answered before the other people who are ahead of you in the queue? That is not very nice!
You already have a button in your program. Do mean that you want to add a second button? If so you already have an example of almost all the code you need.
...R
I'm very sorry for 'very urgent'
Yes,i want add second button for save the current counter value(Press the First button number of times)
but i don't know how to write the code in arduino for second button
Where do you intend to save the value?
You really aren't planning to press the switch '6' times, are you? That would be 54 times. Why not just say that?
Where do you intend to save the value?
and is it OK for the Arduino to "forget" the value when it is turned off, reset or if the program is restarted ?