Hi,
I don't know if it is bug aerror in my script. I have push button on PIN2 with a capacitor and a pull-up resistor.
When the button is pressed In want to switch variable "sequenceNo" between 1 and 2. What is weird, is that in my debug output I get this.
Button Pressed
New Sequence No: 21
Button Pressed
New Sequence No: 21
Script:
//Parameters for sequence No:
const int button = 2; // Select button on pin 2
int switchState;
int sequenceNo = 1; // Default sequence
void setup() {
// put your setup code here, to run once:
// Sequence Button Setup
pinMode(button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
getSequenceNo();
}
// Functions for Led Strips
void getSequenceNo() {
switchState = digitalRead(button);
if (switchState == LOW) {
Serial.println ("Button Pressed");
if (sequenceNo == 1) {
sequenceNo = 2;
}
else {
sequenceNo == 1;
}
Serial.print ("New Sequence No: ");
Serial.println (Serial.print(sequenceNo));
}
}
Thanks.