-
Notifications
You must be signed in to change notification settings - Fork 1
/
skittle-color-sorter.ino
79 lines (60 loc) · 2.54 KB
/
skittle-color-sorter.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
/**************************************************************************/
/**
Skittle Color Sorter
An Arduino UNO board sketch that programs a Skittle color sorting
machine that can sort Skittles by their color.
@file skittle-color-sorter.ino
@mainpage Skittle Color Sorter
@author Charlie Chen (CharmySoft) <Charlie@CharmySoft.com>
@section Introduction
This Skittle Color Sorter consists of a Adafruit TCS34725 Color Sensor to
measure color values, a Continuous Rotation Servo at the top to keep the
Skittles going down, a Standard Servo at the bottom to move the arm to
bring the Skittles to a desired place, and a LCD Display to show
information like the number of Skittles.
@section More
- [CharmySoft] http://CharmySoft.com/
- [Project Page] http://CharmySoft.com/app/skittle-sorter
- [Github Repo] http://CharmySoft.com/app/skittle-sorter/github
*/
/**************************************************************************/
// Include libraries
#include "Context.h" // Context (global variables)
#include "LCD.h" // LCD display
#include "TopServo.h" // Top Servo
#include "BottomServo.h" // Bottom Servo
#include "ColorView.h" // Color View
#include "ColorSensor.h" // Color Sensor
// Initialize global variables
LCD Context::lcd; // The liquid-crystal display
TopServo Context::servoTop; // The top continuous rotation servo
BottomServo Context::servoBtm; // The bottom standard servo
ColorView Context::colorView; // The color LED
ColorSensor Context::colorSensor; // The Adafruit color sensor
int Context::skittleCount = 0; // The number of skittles sorted
void setup() {
// Set up the serial for debugging purposes
Serial.begin(9600);
// Set up the LCD screen
Context::lcd.setup();
// Set up the servos
Context::servoTop.setup();
Context::servoBtm.setup();
// Set up the Adafruit color sensor
Context::colorSensor.setup();
// Print some text on the LCD screen as a welcome message
Context::lcd.setTopText("Color Sorter");
}
void loop() {
// Update the LCD
Context::lcd.update();
// Update the top servo
Context::servoTop.update();
// Update the bottom servo (arm)
Context::servoBtm.update();
// Update the color sensor
Context::colorSensor.update();
// Update the color view LED output
Context::colorView.update();
delay(100);
}