Welcome to my first instructable,
I decided to make a rather simple project to enter the instructable world. This project is about making a simple kitchen timer with a Arduino Uno. Thus I will give a little introduction to the 2.2" tft display, and to timer interrupts.
I will start out with how to assemble the hardware and putting the parts together. Afterwards I will introduce you to the tft display, it´s libraries and the timer interrupt which is the key to the kitchen timer.
The use of an soldering iron and a 3D-printer is recommended but not absolutely necessary.
Step 1: Assembling/Printing the Parts
The parts you need for this project are:
-A case for the timer. I designed myself a case with the open source program SketchUp and printed it with a 3D printer. I attached the .std files if you are interested to print yourself the same case. However you don´t necessarily need to print a case. An old Tupperware case should do it´s job as well.
-Secondly you need an Arduino. I used the Arduino Uno for this instructable.
-The 2.2" adafruit tft display.
-A piece of a strip-board.
-4 buttons to configure the time
-1 flip switch to be able to turn the timer off and on
- 9V battery with the matching wire, to ensure the power of the timer
-Piezo element to play the alarm melody
-4 M2x15 screws with the matching nuts to fix the display to the cover
-4 4x15 screws to fix the cover to the case.
-Some Arduino wires
Step 2: Embedding the Buttons in the Case
In the 3D model which I attached in step 1, you can see that there is a groove to assure the position of the buttons. Make sure that you place them the right way, so that you know where to connect the ground and the Vcc. In addition, you can glue them to ensure that they won´t slip away when solder the wires to the buttons.
Step 3: Fixing the Display to the Timer Cover
Bring the tft display in the right position. When you got that, you are able to fasten the tft display with the 4 M2x15 screws and the matching nuts to the cover.
Step 4: Drill a Hole in the Case and Fix the Power Switch
Drill a hole with the right size in the case. For the flip switch I am using 6mm were fine. Solder the wires to flip the switch before you fasten it to the case.
Step 5: Placing the Piezo Element
Glue the piezo element on the inside of the case.
Step 6: Wiring
The wiring is customized to my proper code, if you use a different code the wiring is different as well.
The buttons are connected with the pins: 4,5,6,7 and with the strip-board which is connected to GND.
The piezo element is connected to the pin 3 and with the strip-board which is connected to GND.
The wiring of the display:- GND of the display to GND of the arduino
-VIN to 3.3V or 5V (display support both)
-D/C to pin 9
-RESET to pi 8
-CS to pin 10
-MOSI to pin 11
-MISO to pin 12
-SCKL to pin 13
The 9V battery is connected to the flip switch and the GND of the Arduino. The flip switch again is connected to the VIN of the Arduino.
I decided not to work with a breadboard to save some space. This way you have to solder all the wires, but it is worth the effort.
Step 7: The Code
The code is the tricky part of the project that´s why I am describing this step a bit more detailed than the others.
There are some comments in the code which explain what is does. But first I will introduce you to the libraries you need. I used a adafruit 2.2" 18-bit color TFT LCD display with microSD card breakout. It is a very good display for Arduino and works with the master/slave principle which means that you need less ports than on a 8 bit LCD. That is good if you don´t have much pins like on the Arduino Uno. To use the display you need to download the following libraries:
To use the timer interrupts you need the TimerOne library.
To use the piezo element you need the Tone-V0005 library.
You need to put there libraries in your Aduino library folder in order to use them.
A good test to see if the display works is the graphicstest program which is included in the library.
The timer interrupt:
A timer interrupt always tiggers a methode after a certain time, the so called ISR(Interrupt service routine).Timer interrupts allow you to perform a task at specifically timed intervals regardless of what else is going on in your code. In this case we want to trigger that interrupt every second and reduce the global variable of the time by 1 second. This way the time is reduced by 1 every second no matter what else is going on in the code.
In the ISR, the interrupts are detached which means interrupts can´t be triggered in the ISR. The delay() function also works with interrupts. That´s the reason you can´t call that function in an ISR. If you absolutely need a delay in your ISR you can work with millis
For the exact syntax check out the code.
If you have questions, feel free to ask.
Step 8: Enjoying the Timer
When you have uploaded the code and finished the construction you can turn the timer off and on with the switch flip and configure the time with the 3 buttons and start/stop the time with the forth. When the time left is at 00:00:00, you can hear the Star Wars theme music.
If you enjoyed the instructable feel free to vote for it in the HACK YOUR DAY CONTEST and to leave feedback in the comment section.
Thank you and have a nice day!