final project
1
groundSensor.c
Go to the documentation of this file.
1
12
#include "
main.h
"
13
#include "lcd.h"
14
15
short
cutoff;
16
18
21
void
groundSensor_init
() {
22
oi_t
*sensors = oi_alloc();
23
oi_init(sensors);
24
}
25
27
33
char
getGroundData
(
oi_t
*sensors) {
34
cutoff = 2600;
//white tape data, to be calibrated, assuming 0=black, 2800=white
35
oi_update(sensors);
36
37
//detect hole
38
if
(sensors->cliffLeft) {
39
return
1;
40
}
41
else
if
(sensors->cliffFrontLeft) {
42
return
2;
43
}
44
else
if
(sensors->cliffFrontRight) {
45
return
3;
46
}
47
else
if
(sensors->cliffRight) {
48
return
4;
49
}
50
51
//detect tape - use cutoff value
52
if
(sensors->cliffLeftSignal > cutoff) {
53
return
5;
54
}
55
else
if
(sensors->cliffFrontLeftSignal > cutoff) {
56
return
6;
57
}
58
else
if
(sensors->cliffFrontRightSignal > cutoff) {
59
return
7;
60
}
61
else
if
(sensors->cliffRightSignal > cutoff) {
62
return
8;
63
}
64
65
return
0;
66
}
main.h
the main code for the robot to interact with the user
oi_t
iRobot Create Sensor Data
Definition:
open_interface.h:20
getGroundData
char getGroundData(oi_t *sensors)
checks the ground for tape or a hole
Definition:
groundSensor.c:33
groundSensor_init
void groundSensor_init()
initializes the ground sensors
Definition:
groundSensor.c:21
Final Project
programFiles
groundSensor.c
Generated by
1.8.13