PROJECT
When your system is in the idle mode, RGB module’s color in your system stays in Red. This
represents the default state of your system.
As the next step, use the key board array (4 x 4 pushbuttons) in the kit to get the one of
your group member’s e-id. The e-id and student name must be displayed on the LCD panel.
If it is the right e-id, your system is enabled, otherwise there is no way you can enable the
system. Here, your system should sound differently depending on the e-id, for example, if
correct, sounds something good, if not, sound something weird.
Once you have the system enabled correctly, change the color of RGB module into Green.
Your system also has a push button to start a stepper (or a servo) motor. It is your choice
whether you want to use stepper or servo motor.
When you keep the button pressed, the motor keeps rotating. (Note that 5 turns may
simulate a complete part machining cycle)
When the motor rotates 5 full turns, turn your RGB module into Blue. After 5 seconds,
change the color of your RGB into Green.
Each time your motor makes 5 full turns, you need to count up the number of machined
parts by “1” and display total number of machined parts on a “4 digital tube” included in the
kit.
There is another push button with which you can finish the whole process and get out of
the process. If you push this button, you cannot continue. The only way you start over is to
input the right e-id number of your own group again. In other words, this button makes the
state of your system back to idle.
I have done till here so far
#include <LiquidCrystal.h>
#include <Wire.h>
#include <Keypad.h>
const byte rows = 4;
const byte cols = 4;
char* ourCode = "1234";
int currentPosition = 0;
char keys[rows][cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A3, A2, A1, A0};
byte colPins[COLS] = {10, 9, 8, 7};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int greenLED = 6;
int redLED = 13;
int blueLED = 1;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16,2);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(blueLED, OUTPUT);
digitalWrite(redLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(blueLED, LOW);
}
void loop() {
char key = keypad.getKey();
if (key == ‘0’|| key!='ourCode') {
lcd.setCursor(0,0);
- lcd.print("Invalid input");
// Print a message to the LCD.
digitalWrite(redLED, HIGH);
if (key==’ourCode’) {
digitalWrite(greenLED, High);
digitalWrite(redLED,LOW);
lcd.setCursor(2, 0);
lcd.print("Name:james!");
// print the number of seconds since reset:
lcd.setCursor(2, 1);
lcd.print("YOUR ID:1234");
}
}