-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino_code.ino
95 lines (87 loc) · 1.84 KB
/
arduino_code.ino
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Project: Recycle Right - Womxn/Hacks 2.0
* Created by: Monica Aguilar
* Date: Jan. 18, 2020
*/
#include <LiquidCrystal.h>
//Instance variables
LiquidCrystal lcd(12,11,5,4,3,2);
int greenLED = 9;
int yellowLED = 8;
int redLED = 6;
int buttonReady = LOW;
int button = 7;
char photoResult[10];
int randomNum = 0;
void setup() {
Serial.begin(9600);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
lcd.begin(16,2);
displayTitle();
pinMode(button, INPUT_PULLUP);
digitalWrite(button, HIGH);
randomSeed(350);
}
void loop() {
displayTitle();
delay(100);
buttonReady = digitalRead(button);
//Checks if button was pressed
if (buttonReady == LOW){
//showing testing phase
activateYellow();
//
lcd.clear();
lcd.print("[Item type here]");
lcd.setCursor(0,1);
//for testing purposes
tester();
buttonReady = HIGH;
lcd.clear();
}
}
//Reseting the title
void displayTitle(){
lcd.clear();
lcd.begin(16,2);
lcd.print("Press button to");
lcd.setCursor(0,1);
lcd.print("take picture.");
}
// Taking in information
void activateYellow(){
lcd.clear();
digitalWrite(yellowLED, HIGH);
lcd.print("Taking photo...");
delay(2000);
//photoResult = photo stuff; see recvInfo()?
lcd.clear();
lcd.print("Analyzing...");
delay(2000);
digitalWrite(yellowLED, LOW);
}
// Product is not recyclable
void activateRed(){
digitalWrite(redLED, HIGH);
lcd.print("Do not recycle!");
delay(4000);
digitalWrite(redLED, LOW);
lcd.clear();
}
// Product is recyclable
void activateGreen(){
digitalWrite(greenLED, HIGH);
lcd.print("Recycle!");
delay(4000);
digitalWrite(greenLED, LOW);
}
// Generates a random number to randomly pick an option
void tester(){
randomNum = random(2,4);
if (randomNum == 2)
activateGreen();
else
activateRed();
}