safwan092

line-follower

Jan 30th, 2018
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. const int sensorPin = 4;     // the number of the sensor pin
  2. const int ledPin =  13;      // the number of the LED pin
  3. int sensorState = 0;         // variable for reading the sensor status
  4.  
  5.  
  6.  
  7. void setup() {
  8.   pinMode(ledPin, OUTPUT);
  9.   pinMode(sensorPin, INPUT);
  10. }
  11.  
  12.  
  13.  
  14. void loop() {
  15.   // read the state of the sensor value:
  16.   sensorState = digitalRead(sensorPin);
  17.   // if the sensorState is HIGH:
  18.   if (sensorState == HIGH) {
  19.     digitalWrite(ledPin, HIGH);
  20.   }
  21.   else {
  22.     digitalWrite(ledPin, LOW);
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment