Advertisement
STANAANDREY

tank ino

Jul 8th, 2024
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   pinMode(A2, INPUT);
  9.   Serial.begin(9600);
  10. }
  11.  
  12. // the loop function runs over and over again forever
  13. void loop() {
  14.   delay(1);
  15.   int value1 = analogRead(A1);
  16.   int value2 = analogRead(A2);
  17.   if (IS_ANALOG_LOW(value1) || IS_ANALOG_LOW(value2)) {
  18.     Serial.println("Obstacle");
  19.   } else {
  20.  
  21.   }
  22.   delay(500);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement