Advertisement
STANAANDREY

arduino sensor

Nov 30th, 2023
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. #define IS_ANALOG_LOW(x) x < 50
  4.  
  5. void setup() {
  6.   // initialize digital pin LED_BUILTIN as an output.
  7.   pinMode(A1, INPUT);
  8.   Serial.begin(9600);
  9. }
  10.  
  11. // the loop function runs over and over again forever
  12. void loop() {
  13.   delay(1);
  14.   int value = analogRead(A1);
  15.   if (IS_ANALOG_LOW(value)) {
  16.     Serial.println("Obstacle");
  17.   } else {
  18.    
  19.   }
  20.   delay(500);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement