//EMMANUEL'S LEGENDARY UMBRA KING FALLEN WARRIOR "BEEP WHEN IT GETS TOO CLOSE" PROJECT RANK 1
int ECHO = 11;
int TRIGGER = 12;
int BLICKERMAN = 10;
int speakerPin = 8;
int RedBlicker = 7;
int YellowBlicker = 6;
int GreenBlicker = 5;
long duration;
int dist;
void setup() {
// put your setup code here, to run once:
pinMode(ECHO, INPUT_PULLUP);
pinMode(TRIGGER, OUTPUT);
pinMode(BLICKERMAN, OUTPUT);
pinMode(RedBlicker, OUTPUT);
pinMode(YellowBlicker, OUTPUT);
pinMode(GreenBlicker, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(TRIGGER, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER, LOW);
int dist = pulseIn(ECHO, HIGH);
dist = dist / 58; // to get us CM as measurements
Serial.println(dist);
delay(1000);
if (dist >= 300){
digitalWrite(BLICKERMAN, HIGH);
digitalWrite(RedBlicker, HIGH);
tone(speakerPin, HIGH);
delay(1000);
tone(speakerPin, 250);
digitalWrite(BLICKERMAN, LOW);
digitalWrite(RedBlicker, LOW);
delay(1000);
Serial.println("300 IS WORKING");
} else if (dist >= 150) {
digitalWrite(BLICKERMAN, HIGH);
digitalWrite(YellowBlicker, HIGH);
tone(speakerPin, HIGH);
delay(100);
tone(speakerPin, 250);
digitalWrite(BLICKERMAN, LOW);
digitalWrite(YellowBlicker, LOW);
delay(100);
Serial.println("150 IS WORKING");
} else if (dist >= 50) {
digitalWrite(BLICKERMAN, HIGH);
digitalWrite(YellowBlicker, HIGH);
tone(speakerPin, HIGH);
delay(50);
tone(speakerPin, 250);
digitalWrite(BLICKERMAN, LOW);
digitalWrite(YellowBlicker, LOW);
Serial.println("50 IS WORKING");
} else if (dist > 1) {
tone(speakerPin, HIGH);
digitalWrite(BLICKERMAN, HIGH);
digitalWrite(GreenBlicker, HIGH);
tone(speakerPin, 250);
delay(30);
Serial.println("1 IS WORKING");
}
}