safwan092

Untitled

May 20th, 2022
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. int sensorPin = A0;
  2. int buzzerPin = 7;
  3. int sensorValue = 0;
  4.  
  5. void setup() {
  6. Serial.begin(9600);
  7. pinMode(buzzerPin, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11.  
  12. sensorValue = analogRead(sensorPin);
  13. Serial.println(sensorValue);
  14.  
  15. if (sensorValue > 500) {
  16. digitalWrite(buzzerPin, HIGH);
  17. }
  18. else {
  19. digitalWrite(buzzerPin, LOW);
  20. }
  21.  
  22. delay(100);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment