You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
783 B
C++
54 lines
783 B
C++
bool onetriggered;
|
|
bool twotriggered;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
Serial.println("Hello");
|
|
}
|
|
|
|
void loop() {
|
|
|
|
int Trigger1 = analogRead(A0);
|
|
int Trigger2 = analogRead(A3);
|
|
|
|
Serial.println(Trigger1);
|
|
Serial.print(" ");
|
|
Serial.println(Trigger2);
|
|
Serial.print(" ");
|
|
|
|
//INPUT 0
|
|
if(Trigger1>100 && !onetriggered) {
|
|
tone(11, 80);
|
|
onetriggered = true;
|
|
|
|
Serial.println("1triggered");
|
|
}
|
|
|
|
else if(Trigger1<100 && onetriggered) {
|
|
noTone(11);
|
|
onetriggered = false;
|
|
|
|
Serial.println("1nope");
|
|
}
|
|
|
|
|
|
// INPUT 3
|
|
if(Trigger2>700 && !twotriggered) {
|
|
tone(11, 120);
|
|
twotriggered = true;
|
|
|
|
Serial.println("2triggered");
|
|
}
|
|
|
|
else if(Trigger2<700 && twotriggered) {
|
|
noTone(11);
|
|
twotriggered = false;
|
|
|
|
Serial.println("2nope");
|
|
}
|
|
|
|
|
|
|
|
delay(50);
|
|
}
|