-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino
36 lines (34 loc) · 1.49 KB
/
Arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int button1Pin = 2;
int button2Pin = 3;
int button3Pin = 4;
int button4Pin = 5;
int button5Pin = 6;
int button6Pin = 7;
int threshold = 500; //Change This
int volume;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(button1Pin,INPUT);//set button as digital input
pinMode(button2Pin,INPUT);//set button as digital input
pinMode(button3Pin,INPUT);//set button as digital input
pinMode(button4Pin,INPUT);//set button as digital input
}
void loop() {
// put your main code here, to run repeatedly:
int button1State = digitalRead(button1Pin);
int button2State = digitalRead(button2Pin);
int button3State = digitalRead(button3Pin);
int button4State = digitalRead(button4Pin);
int button5State = digitalRead(button5Pin);
int button6State = digitalRead(button6Pin);
if(volume>=threshold){
Serial.print(button1State);Serial.print("; ");Serial.print(button2State);Serial.print("; ");Serial.print(button3State);Serial.print("; ");
Serial.print(button4State);Serial.print("; ");Serial.print(button5State);Serial.print("; ");Serial.print(button6State);Serial.print("; ");Serial.print(0);Serial.println(";");
}
else{
Serial.print(button1State);Serial.print("; ");Serial.print(button2State);Serial.print("; ");Serial.print(button3State);Serial.print("; ");
Serial.print(button4State);Serial.print("; ");Serial.print(button5State);Serial.print("; ");Serial.print(button6State);Serial.print("; ");Serial.print(0);Serial.println(";");
}
delay(1000);
}