-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlcd.ino
More file actions
76 lines (66 loc) · 1.46 KB
/
lcd.ino
File metadata and controls
76 lines (66 loc) · 1.46 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <Servo.h> // include Servo Motor Library
#include <LiquidCrystal.h>
/* RS pin -> 14 A0
enable pin -> 15 A1
D4-D7 -> 16-19 A2-A5
*/
LiquidCrystal lcd(14, 15, 16, 17, 18, 19);
//emergency stop button
int ES = 2;
int buzz = 12; // sound for emergency stop
int signallight = 13;
//global variables
boolean start = true;
volatile boolean e_stop = false;
volatile int state = 0;
// define colour sensor
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut A7
// define servo motors (top and bottom)
Servo top;
Servo bottom;
// variables for counters and frequency
int freq = 0;
int colour = 0;
int count_red = 0;
int count_orange = 0;
int count_green = 0;
int count_yellow = 0;
int count_blue = 0;
int count_brown = 0;
int count_other = 0;
int total = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//emergency button
pinMode(ES, INPUT_PULLUP);
pinMode(signallight, OUTPUT);
delay(100);
//colour sensor
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, OUTPUT);
//set frequency scale to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
//servo motors
top.attach(9); // connect to arduino D9
bottom.attach(10); // connect to arduino D10
//lcd display
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("START");
lcd.setCursor(0, 1);
lcd.print("LOADING...");
delay(2500);
}
void loop() {
bottom.write(0);
delay(5000);
}