|
Display LCD 16x2 |
x 1 | |
|
CMI-9605-1280TCUI Devices
|
x 1 | |
|
CF1/2W-10KΩ±5% TChian Chia Elec
|
x 4 | |
|
CF1/4W-220Ω±5% TChian Chia Elec
|
x 2 | |
|
TS02-66-150-BK-100-LCR-D |
x 4 | |
|
61300311121Würth Elektronik
|
x 1 |
|
easyEDA |
|
|
arduino IDEArduino
|
Arduino Kitchen Timer Shield
God created the heavens and the earth in the beginning. And people have created digital kitchen clocks like this one.
People have decided to make a more exciting replacement for the original concept. They said, "Let's build something better!"
The voice of the people called God, and He created the Arduino. Now people everywhere have Arduinos scattered across their continents. This was a positive result.
People have improved this kitchen timer by using an Arduino.
God saw the new kitchen timer and thought it was awful, but funny. And that's a good thing.
Description:
if you want you can transform this shield into whatever you want. It has an LCD screen, four buttons and a buzzer, which makes it usable in many projects
connections:
- button 1: 9
- button 2: 8
- button 3: 7
- button 4: 6
- buzzer: 10
- LCD:
- D7: 2
- D6: 3
- D5: 4
- D4: 5
- E: 11
- RS: 12
#include <LiquidCrystal.h>
#include <TimeLib.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buzzerPin = 10;
const int resetButtonPin = 6;
const int startStopButtonPin = 7;
const int downButtonPin = 8;
const int upButtonPin = 9;
int setupHours = 0; // How many hours will count down when started
int setupMinutes = 0; // How many minutes will count down when started
int setupSeconds = 0; // How many seconds will count down when started
time_t setupTime = 0;
int currentHours = 0;
int currentMinutes = 0;
int currentSeconds = 0;
time_t currentTime = 0;
time_t startTime = 0;
time_t elapsedTime = 0;
int resetButtonState = LOW;
long resetButtonLongPressCounter = 0;
int startStopButtonState = LOW;
int upButtonState = LOW;
int downButtonState = LOW;
int resetButtonPrevState = LOW;
int startStopButtonPrevState = LOW;
int upButtonPrevState = LOW;
int downButtonPrevState = LOW;
bool resetButtonPressed = false;
bool resetButtonLongPressed = false;
bool startStopButtonPressed = false;
bool upButtonPressed = false;
bool downButtonPressed = false;
const int MODE_IDLE = 0;
const int MODE_SETUP = 1;
const int MODE_RUNNING = 2;
const int MODE_RINGING = 3;
int currentMode = MODE_IDLE; // 0=idle 1=setup 2=running 3=ringing
// Power up --> idle
// Reset --> idle
// Start/Stop --> start or stop counter
// Up / Down --> NOP
// Reset (long press) --> enter setup
// Start/Stop --> data select
// Up --> increase current data value
// Down --> decrease current data value
// Reset --> exit setup (idle)
int dataSelection = 0; // Currently selected data for edit (setup mode, changes with Start/Stop)
// 0=hours (00-99) 1=minutes (00-59) 2=seconds (00-59)
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(resetButtonPin, INPUT);
pinMode(startStopButtonPin, INPUT);
pinMode(upButtonPin, INPUT);
pinMode(downButtonPin, INPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
startStopButtonPressed = false;
upButtonPressed = false;
downButtonPressed = false;
/*
* Reset button management
*/
resetButtonPressed = false;
resetButtonLongPressed = false;
resetButtonState = digitalRead(resetButtonPin);
if (resetButtonState != resetButtonPrevState) {
resetButtonPressed = resetButtonState == HIGH;
resetButtonPrevState = resetButtonState;
} else // Long press management...
{
if (resetButtonState == HIGH) {
resetButtonLongPressCounter++;
if (resetButtonLongPressCounter == 100) {
resetButtonPressed = false;
resetButtonLongPressed = true;
resetButtonLongPressCounter = 0;
}
} else {
resetButtonLongPressCounter = 0;
resetButtonPressed = false;
resetButtonLongPressed = false;
}
}
/*
* Start/Stop button management
*/
startStopButtonPressed = false;
startStopButtonState = digitalRead(startStopButtonPin);
if (startStopButtonState != startStopButtonPrevState) {
startStopButtonPressed = startStopButtonState == HIGH;
startStopButtonPrevState = startStopButtonState;
}
/*
* Down button management
*/
downButtonPressed = false;
downButtonState = digitalRead(downButtonPin);
if (downButtonState != downButtonPrevState) {
downButtonPressed = downButtonState == HIGH;
downButtonPrevState = downButtonState;
}
/*
* Up button management
*/
upButtonPressed = false;
upButtonState = digitalRead(upButtonPin);
if (upButtonState != upButtonPrevState) {
upButtonPressed = upButtonState == HIGH;
upButtonPrevState = upButtonState;
}
/*
* Mode management
*/
switch (currentMode) {
case MODE_IDLE:
if (resetButtonPressed) {
Reset();
}
if (resetButtonLongPressed) {
currentMode = MODE_SETUP;
}
if (startStopButtonPressed) {
currentMode = currentMode == MODE_IDLE ? MODE_RUNNING : MODE_IDLE;
if (currentMode == MODE_RUNNING) {
// STARTING TIMER!
startTime = now();
}
}
break;
case MODE_SETUP:
if (resetButtonPressed) {
// Exit setup mode
setupTime = setupSeconds + (60 * setupMinutes) + (3600 * setupHours);
currentHours = setupHours;
currentMinutes = setupMinutes;
currentSeconds = setupSeconds;
dataSelection = 0;
currentMode = MODE_IDLE;
}
if (startStopButtonPressed) {
// Select next data to adjust
dataSelection++;
if (dataSelection == 3) {
dataSelection = 0;
}
}
if (downButtonPressed) {
switch (dataSelection) {
case 0: // hours
setupHours--;
if (setupHours == -1) {
setupHours = 99;
}
break;
case 1: // minutes
setupMinutes--;
if (setupMinutes == -1) {
setupMinutes = 59;
}
break;
case 2: // seconds
setupSeconds--;
if (setupSeconds == -1) {
setupSeconds = 59;
}
break;
}
}
if (upButtonPressed) {
switch (dataSelection) {
case 0: // hours
setupHours++;
if (setupHours == 100) {
setupHours = 0;
}
break;
case 1: // minutes
setupMinutes++;
if (setupMinutes == 60) {
setupMinutes = 0;
}
break;
case 2: // seconds
setupSeconds++;
if (setupSeconds == 60) {
setupSeconds = 0;
}
break;
}
}
break;
case MODE_RUNNING:
if (startStopButtonPressed) {
currentMode = MODE_IDLE;
}
if (resetButtonPressed) {
Reset();
currentMode = MODE_IDLE;
}
break;
case MODE_RINGING:
if (resetButtonPressed || startStopButtonPressed || downButtonPressed || upButtonPressed) {
currentMode = MODE_IDLE;
}
break;
}
/*
* Time management
*/
switch (currentMode) {
case MODE_IDLE:
case MODE_SETUP:
// NOP
break;
case MODE_RUNNING:
currentTime = setupTime - (now() - startTime);
if (currentTime <= 0) {
currentMode = MODE_RINGING;
}
break;
case MODE_RINGING:
analogWrite(buzzerPin, 20);
delay(20);
analogWrite(buzzerPin, 0);
delay(40);
break;
}
/*
* LCD management
*/
//lcd.clear();
lcd.setCursor(0, 0);
switch (currentMode) {
case MODE_IDLE:
lcd.print("Timer ready ");
lcd.setCursor(0, 1);
lcd.print(currentHours);
lcd.print(" ");
lcd.print(currentMinutes);
lcd.print(" ");
lcd.print(currentSeconds);
lcd.print(" ");
break;
case MODE_SETUP:
lcd.print("Setup mode: ");
switch (dataSelection) {
case 0:
lcd.print("HRS ");
break;
case 1:
lcd.print("MINS");
break;
case 2:
lcd.print("SECS");
break;
}
lcd.setCursor(0, 1);
lcd.print(setupHours);
lcd.print(" ");
lcd.print(setupMinutes);
lcd.print(" ");
lcd.print(setupSeconds);
lcd.print(" ");
break;
case MODE_RUNNING:
lcd.print("Counting down...");
lcd.setCursor(0, 1);
if (hour(currentTime) < 10) lcd.print("0");
lcd.print(hour(currentTime));
lcd.print(":");
if (minute(currentTime) < 10) lcd.print("0");
lcd.print(minute(currentTime));
lcd.print(":");
if (second(currentTime) < 10) lcd.print("0");
lcd.print(second(currentTime));
break;
case MODE_RINGING:
lcd.print(" RING-RING! ");
lcd.setCursor(0, 1);
lcd.print(" ");
break;
}
delay(10);
}
void Reset() {
currentMode = MODE_IDLE;
currentHours = setupHours;
currentMinutes = setupMinutes;
currentSeconds = setupSeconds;
}
Arduino Kitchen Timer Shield
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(3)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Engineer
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
67 1 1 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
66 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
90 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
468 0 7 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
138 0 2 -