Gets Away from Naughty

Have a protector in your room!!! Not to pick up your cheese Cheetos and other!!!!!!!!!

BeginnerProtip1 hour520
Gets Away from Naughty

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
Γ—1
5 mm LED: Red
5 mm LED: Red
Γ—1
5 mm LED: Yellow
5 mm LED: Yellow
Γ—1
5 mm LED: Green
5 mm LED: Green
Γ—1
Buzzer
Buzzer
Γ—1
Arduino UNO
Arduino UNO
Γ—1
Jumper wires (generic)
Jumper wires (generic)
Γ—1
Breadboard (generic)
Breadboard (generic)
Γ—1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

img_66131_d9hSgFSal3.JPG

Γ—
Vincule um repositΓ³rio existente


My frizing gave crap so I took a picture but you can look through the code OK
😊😊😊😊😊😊😊

Code

cheetos protetor :)

C/C++
arduino
#define trigPin 2
#define echoPin 3
#define LEDlampRed 4B
#define LEDlampYellow 5
#define LEDlampGreen 6 
#define soundbuzzer 7
int sound = 500;


void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(LEDlampRed, OUTPUT);
  pinMode(LEDlampYellow, OUTPUT);
  pinMode(LEDlampGreen, OUTPUT);
  pinMode(soundbuzzer, OUTPUT);
}
void loop() {
  long durationindigit, distanceincm;
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  durationindigit = pulseIn(echoPin, HIGH);
  distanceincm = (durationindigit/5) / 29.1;
 
  if (distanceincm < 50) {
      digitalWrite(LEDlampGreen, HIGH);
}
  else {
      digitalWrite(LEDlampGreen, LOW);
  }
  
  if (distance < 20) {
    digitalWrite(LEDlampYellow, HIGH);
}
  else {
    digitalWrite(LEDlampYellow,LOW);
  }
  if (distance < 5) {
    digitalWrite(LEDlampRed, HIGH);
    sound = 1000;
}
  else {
    digitalWrite(LEDlampRed,LOW);
  }
 
  if (distanceincm > 5 || distanceinsm <= 0){
    Serial.println("Outside the permissible range of distances");
    noTone(soundbuzzer);
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
    tone(buzzer, sound);
  }
  
  delay(300);
}

Credits

Lucas Sobral πŸ‡§πŸ‡· πŸ‘¨β€πŸ’»
7 projects β€’ 3 followers
hi im lucas im love my self an brake and make!
Contact

Comments

Please log in or sign up to comment.