Step 3Code It! (Or use mine)
Explaining it gets a little complicated, so I will give you a brief overview, and the rest is pretty self explanatory:
First we initialise all of the pins and features that we are going to use, to make sure that our Arduino is going to be working with them. We use the const int to indicate that the Pin that we have initialised is constant and will not change. Variables can also be initialised, but are generally not constant as they are set throughout the script. We then check to see if the button (connected to Pin 2) has been depressed or not, and if it is it lights up the next segment and adds one to out 'tastyTimeVariable'. This means that we can then use an 'if' function to state the length of the required timing depending on the value of our tastyTimeVariable. You will see that we delay for "300L * 1000L" which equates to about 5 mins, as 300,000 milliseconds = 300 seconds, and 300/60 = 5, so quite accurately 5 mins. We then tell the Arduino that if the tastyTimeVariable is equal to anything other than 0 (in other words the button was pressed, and something has been timed) to play a graphical display, and buzz the buzzer. We can vary the length of the alarm by changing the for command.
I hope this has made some sense, I have also written comments into the script to help those trying to understand how it works, and modify it for their needs.
-------------------------------- UPDATE ------------------------------
Hello, I quote a message sent to me by arduino-mega.
arduino-mega says:
I have had a go at rewriting the code for the kitchen timer as it was very long. The code i have written does the same thing but is just a fraction of the size of the original. Hope you don't mind. Here is a link to it.
This is a fantastic piece of code with some extra bits added on, so please give it a go, the installation process is the same.
Thank you very much to arduino-mega for this brilliant contribution!
Kitchen_Timer.pde11 KB| « Previous Step | Download PDFView All Steps | Next Step » |









































Thanks for your instructable. Unfortunately, I can't seem to download the Arduino sketch. It says Kitchen_Timer.pde on here, but when I download it, it is converted to .tmp with a garbage filename. Do you know of a way to convert back to .pde or do you have an alternate way which I could download the sketch? Mediafire is saying that the file is no longer available.
Thanks!
I thought that Instructables did something strange to .pde files! To change the file type just right click the file (it should look something like A94NDIWJD12NVLQ.tmp) and select rename. Then remove the .tmp from the end and add .pde. If you do this in one move rather than pressing enter in between you will be able to change the file type. Then just double click the file, and it will open in the Arduino application. It may also say that it requires the sketch to be in its own folder, but this is fine.
I hope this helps,
anonymouse197
I tried your method for changing the file type, and unfortunately it didn't work. That method has worked in other instances, though, so I never know when it will work and when it won't.
What I ended up doing was opening the .tmp file in Microsoft Word. The formatting looked a little strange, but when I copied it into the Arduino app, everything was in order.
The sketch seems to work pretty well! My only complaint is that sometimes a light other than the first one will light up when setting the timer, leaving the first few off. This restricts the full amount of time which can be set, because it will only add time until the last light is lit. A simple reset fixes this, though.
Thanks again!
It seemed to work well when I tried, so goodness knows why that didn't work for you, but it doesn't seem to have been a problem. To try and work out what might be happening with the odd LED issue I converted the .tmp file to microsoft word, then copied it into arduino and had a similar issue!
To try and combat this I have re-uploaded the .pde file to a file hosting site so that you can download it straight away and try and get rid of your LED problem. So here is the file for downloading, and I hope you can get it to work effectively.
Thanks,
anonymouse197
The download worked fine, but I still found that the first light to go on was not always the first light in the display. I made some modifications to your code here, and they seem to work. Feel free to post the modified version on here if you like the changes I've made. Anything of yours that I changed, I simply commented out, and I also made comments explaining what I had done. Let me know if you have any questions about my changes.
Also, I changed the time increment to 3 seconds rather than 5 minutes for testing purposes. I hope this isn't too much of an inconvenience!
Thanks for giving me a good place to start with your code!
- pkasavan
I'm glad the download worked for you, and thank you so much for posting your edit! I have run it myself and it works like a charm! If you don't mind I will replace the link on the instructable with the one you provided, as in my opinion it seems to be the better of the two.
I'm glad that this instructable has worked and turned out successful, and thank you so much for getting involved!
An absolute pleasure!
anonymouse197