-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLineRunner.pde
More file actions
47 lines (34 loc) · 833 Bytes
/
LineRunner.pde
File metadata and controls
47 lines (34 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// #include <Arduino.h>
#include <LineController.hpp>
const uint8_t left_led = 4, right_led = 5;
LineRunner lines = LineRunner(2, 3, 20);
bool led = true;
uint8_t sensor_status;
void setup() {
// Serial.begin(9600);
}
void loop() {
sensor_status = lines.check();
switch (sensor_status) {
case LEFT_SENSOR_TRIGGERED:
digitalWrite(left_led, HIGH);
digitalWrite(right_led, LOW);
break;
case RIGHT_SENSOR_TRIGGERED:
digitalWrite(left_led, LOW);
digitalWrite(right_led, HIGH);
break;
case BOTH_SENSOR_TRIGGERED:
digitalWrite(left_led, HIGH);
digitalWrite(right_led, HIGH);
break;
case NO_SENSOR_TRIGGERED:
digitalWrite(left_led, LOW);
digitalWrite(right_led, LOW);
break;
default:
break;
}
analogWrite(13, led);
led = !led;
}