Linkit One Kitchen Timer
by ThisIsSteve in Circuits > Microcontrollers
2833 Views, 19 Favorites, 0 Comments
Linkit One Kitchen Timer
In this instructable I'm going to show you how to design a kitchen timer using the Linkit One, the timer has a maximum duration of 30 minutes. And once the timer is done counting down it fires a buzzer to notify you. The time interval can be set in steps of 5 minutes and each led indicating 5 minutes. You can also increase the maximum duration by adding extra LEDs and go up to a maximum of 50 minutes due to the limited number of pins on the Linkit one.
Tools and Components
All the components you require for this instructable are -
- Linkit One
- 6 Leds
- Push Button
- Buzzer
- Jumper wires
- Breadboard
- 10k resistor
Circuit
The circuit is quite simple and all you need to do is follow the picture above. There are six LEDs and each LED indicates a 5 minute interval. By adding additional LEDs to the remaining digital pins you can improve the maximum duration of the timer circuit.
Code
Copy the below code and paste the below code in the Arduino IDE and then select a suitable COM port and upload the code to the Linkit One.
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin const int led2Pin = 12; const int led3Pin = 11; const int led4Pin = 10; // the number of the LED pin const int led5Pin = 9; const int led6Pin = 7; const int led7Pin = 6; // the number of the LED pin const int led8Pin = 5; const int led9Pin = 4; const int led10Pin = 3; const int speakerOut = 1;// variables will change: int buttonState = 0; // variable for reading the pushbutton status int tastyTimeVariable = 0; // my time variable that has 1 added int i; int n;
void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); pinMode(led2Pin, OUTPUT); pinMode(led3Pin, OUTPUT); pinMode(led4Pin, OUTPUT); pinMode(led5Pin, OUTPUT); pinMode(led6Pin, OUTPUT); pinMode(led7Pin, OUTPUT); pinMode(led8Pin, OUTPUT); pinMode(led9Pin, OUTPUT); pinMode(led10Pin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); pinMode(speakerOut, OUTPUT);
delay(3000); }
void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(ledPin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led2Pin, HIGH); } else { }
delay(1000);
buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led3Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led4Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led5Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led6Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led7Pin, HIGH); } else { } delay(1000); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led8Pin, HIGH); } else { }
delay(1000);
buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led9Pin, HIGH); } else { }
delay(1000);
buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { // add to timer tastyTimeVariable = tastyTimeVariable + 1; digitalWrite(led10Pin, HIGH); } else { }
delay(1000); digitalWrite(led10Pin, LOW); digitalWrite(led9Pin, LOW); digitalWrite(led8Pin, LOW); digitalWrite(led7Pin, LOW); digitalWrite(led6Pin, LOW); digitalWrite(led5Pin, LOW); digitalWrite(led4Pin, LOW); digitalWrite(led3Pin, LOW); digitalWrite(led2Pin, LOW); digitalWrite(ledPin, LOW);
delay(1000);
if (tastyTimeVariable == 0) { }
else if (tastyTimeVariable == 1) { digitalWrite (ledPin, HIGH); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } } else if (tastyTimeVariable == 2) { digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm }
else if (tastyTimeVariable == 3) { digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 4) { digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 5) { digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 6) { digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 7) { digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable == 8) { digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); //sound alarm } else if (tastyTimeVariable == 9) { digitalWrite (led9Pin, HIGH); digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led9Pin, LOW); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); //sound alarm } else if (tastyTimeVariable == 10) { digitalWrite (led10Pin, HIGH); digitalWrite (led9Pin, HIGH); digitalWrite (led8Pin, HIGH); digitalWrite (led7Pin, HIGH); digitalWrite (led6Pin, HIGH); digitalWrite (led5Pin, HIGH); digitalWrite (led4Pin, HIGH); digitalWrite (led3Pin, HIGH); digitalWrite (led2Pin, HIGH); digitalWrite (ledPin, HIGH); delay(300L * 1000L); digitalWrite (led10Pin, LOW); delay(300L * 1000L); digitalWrite (led9Pin, LOW); delay(300L * 1000L); digitalWrite (led8Pin, LOW); delay(300L * 1000L); digitalWrite (led7Pin, LOW); delay(300L * 1000L); digitalWrite (led6Pin, LOW); delay(300L * 1000L); digitalWrite (led5Pin, LOW); delay(300L * 1000L); digitalWrite (led4Pin, LOW); delay(300L * 1000L); digitalWrite (led3Pin, LOW); delay(300L * 1000L); digitalWrite (led2Pin, LOW); delay(300L * 1000L); for (i=0; i < 20; i++) { analogWrite(speakerOut,128); delay(250); digitalWrite(speakerOut, LOW); delay(250); } //sound alarm } else if (tastyTimeVariable > 10) { } }
Finishing
After uploading the code find a place to set it up in your kitchen and when its time to cook you can click the button multiple times to set the time duration. Each click represents 5 minutes (1 click = 5 minutes, 2 clicks = 10 minutes).