i have 3 switches set up to select the level 1,2 and 3. when the big red button is pressed that sends the level to gobetwino and it opens the playlist i want. The only problem i have now is that the "vallev" in my code is always "0" zero. how would i fix that? I am very sorry for the simple questions.
thanks
demir
/*
* Emergency Party Button
* Sends serial commands to the program gobetwino through serial port
*/
int inputPin1 = 5; // sets the input pins
int inputPin2 = 6;
int inputPin3 = 7;
int inputPin4 = 8;
int vallev=0; //stores level value
int val = 0; // variable for reading the pin status
void setup() {
Serial.begin(9600);
pinMode(inputPin1, INPUT); // declares pushbuttons as input
pinMode(inputPin2, INPUT);
pinMode(inputPin3, INPUT);
pinMode(inputPin4, INPUT);
}
void loop(){
val = digitalRead(inputPin1); // read input value
if (val == HIGH) { // check if the input is HIGH
vallev == 1; // send to vallev
delay(1000); // delay to limit to 1 value per button press
}
val = digitalRead(inputPin2); // read input value
if (val == HIGH) { // check if the input is HIGH
vallev == 2; // send to vallev
delay(1000); // delay to limit to 1 value per button press
}
val = digitalRead(inputPin3); // read input value
if (val == HIGH) { // check if the input is HIGH
vallev == 3; // send to vallev
delay(1000); // delay to limit to 1 value per button press
}
val = digitalRead(inputPin4); // read input value
if (val == HIGH) { // check if the input is HIGH
Serial.print("#S|LEVEL"); // send command by serial port
Serial.print(vallev);
Serial.println("|[]#"); // Gobetwino intperets this as a single line
//looking like this "#S|LEVEL(vallev)|[]#"
delay(1000);
}
}