The Wonderful Tea-o-Matic
.
Project Description
This is a beginner mbed project, as made by a work experience student with little to no knowledge of electronics or C++. It's fairly simple to build with the aid of the cookbook, and took perhaps 2 hours to construct (including testing time and fiddling to figure out how everything worked).
The final item is a Teabag Control Device, or TCD for short, which will ensure that your tea is brewed just the way you like it every time. With 8 different settings, you're spoilt for choice! Plus, adding your own options in the Compiler is easy to do. The default settings range from 1-3 minutes brewing time with teabag dipping, or 1-5 minutes without. (Dipping involves moving the teabag up and down while brewing for enhanced flavour).
This notebook is pitched at absolute beginners, as I was when I constructed it. More experienced users probably could make this in their sleep, anyway.
Preparation
Quote:
Algorithm for making tea: Put tea bag in cup; Put hot water in cup (preferably just boiled); Leave for a few minutes to brew [Can stir/squeeze teabag]; Take tea bag out [Can squeeze teabag to get all the tasty tea out of it]; Add milk/sugar to taste; Wait until preferred drinking temperature; Drink
Convert to a more machine-orientated version, and you've got a good starting point for what you need to make. Also think about what you might need to build with.
It's also advisable to read up on C++ if you're new to it, and check out these cookbook/notebook pages;
- For the servo, http://mbed.org/cookbook/Servo
- For the LCD screen, http://mbed.org/cookbook/Text-LCD
- For debouncing the buttons, http://mbed.org/users/chris/notebook/switch-debouncing/
- For how breadboards work, http://www.sciencebuddies.org/science-fair-projects/project_ideas/Elec_primer-breadboard2.jpg
Recipe for Tea-O-Matic v.1 (TeaBasic)
Components:
- One mbed,
- A breadboard,
- A servo (plus batteries as it needs a little extra juice to run)
- A couple of buttons,
- A text LCD screen (plus a resistor, or if, like me, you didn't have any, turns out an LED will do the trick too plus providing a touch of randomly-lit-eccentric-invention chic),
- A few coils of wire,
- Some blu-tack (for affixing the servo to things and things to the servo),
- A clothes peg (for holding the tea-bag)
You will also need the libraries/programs from the Cookbook/Notebook pages above, for the code.
You will also need some kind of stand for the servo to position it at mug height. My system consists of a tupperware container balanced sideways on a notebook and weighted down with my trusty wire stripper/snippers. A cardboard box on end with some kind of weight in the base may be a better solution. The servo is attached via the medium of blu-tack, although you may wish to find something a little stronger as the servo is prone to falling off after a while.
Code (v.2.)
#include "mbed.h" #include "Servo.h" #include "TextLCD.h" #include "DebouncedIn.h" TextLCD lcd(p15, p16, p17, p18, p19, p20); DebouncedIn setbutton(p5); DebouncedIn gobutton(p6); Servo myservo(p21); DigitalOut leda(LED1); DigitalOut ledb(LED2); DigitalOut ledc(LED3); DigitalOut ledd(LED4); Timer t; Timer t2; int set(); int dip(); int set (int currentstate); int displaystate(int currentstate); int maketea(int currentstate); int dipping(); int alert(); int alertoff(); int main() { int state; state = 1; myservo = 1; lcd.cls(); lcd.printf("Start?\n"); while(1) { if (setbutton.rising()) { state = set(state); } else if (gobutton.rising()) { maketea(state); } } } int set(int currentstate) { //For setting which mode to use t.start(); //Inactivity timer lcd.cls(); displaystate(currentstate); while (gobutton != 1 and t < 10) { if (setbutton.rising()) { currentstate = currentstate + 1; //Advances state if (currentstate > 9) { //Loops back to start currentstate = 1; } lcd.cls(); displaystate(currentstate); //Update current state wait(0.25); //Debounce t.reset(); t.start(); //Reset inactivity timer } } lcd.cls(); lcd.printf("Start?\n"); //Reset screen return currentstate; } int displaystate(int currentstate) { //Displays current setting if (currentstate == 1) { lcd.printf("1 min - dip\n"); } else if (currentstate == 2) { lcd.printf("2 mins - dip\n"); } else if (currentstate == 3) { lcd.printf("3 mins - dip\n"); } else if (currentstate == 4) { lcd.printf("1 min - no dip\n"); } else if (currentstate == 5) { lcd.printf("2 mins - no dip\n"); } else if (currentstate == 6) { lcd.printf("3 mins - no dip\n"); } else if (currentstate == 7) { lcd.printf("4 mins - no dip\n"); } else if (currentstate == 8) { lcd.printf("5 mins - no dip\n"); } else if (currentstate == 9) { lcd.printf("QTEST\n"); } return 0; } int maketea(int currentstate) { //Main teamaking routine lcd.cls(); lcd.printf("Brewing...\n"); displaystate(currentstate); //Display status int time; int dip; if (currentstate == 1) { //Initialise time and dipping status time = 60; dip = 1; } else if (currentstate == 2) { time = 120; dip = 1; } else if (currentstate == 3) { time = 180; dip = 1; } else if (currentstate == 4) { time = 60; dip = 0; } else if (currentstate == 5) { time = 120; dip = 0; } else if (currentstate == 6) { time = 180; dip = 0; } else if (currentstate == 7) { time = 240; dip = 0; } else if (currentstate == 8) { time = 300; dip = 0; } else if (currentstate == 9) { time = 10; dip = 0; } myservo = 0; //Dunk teabag t.start(); //Start tea timer while (t < time) { //While there's still time left if (dip == 1) { //If dipping, dip teabag wait(1); dipping(); } if (gobutton.rising()) { //If cancelling lcd.cls(); lcd.printf("Press again to\n"); lcd.printf("stop brewing.\n"); t2.start(); //Start (secondary) inactivity timer while (t2 <= 5) { if (gobutton.rising()) { time = 0; //Resets time to run to 0, thus pulling out of main while loop break; //Pulls out of this loop } } t2.reset(); lcd.cls(); lcd.printf("Brewing...\n"); displaystate(currentstate); //Reset screen to brewing } } t.reset(); myservo = 1; lcd.cls(); lcd.printf("Done!\n"); lcd.printf("Reset?\n"); t.start(); while ((!setbutton.rising()) && (!gobutton.rising())) { //If not reset in 90 seconds, alert if (t > 90) { alert(); } } alertoff(); lcd.cls(); lcd.printf("Start?\n"); //Reset wait(1); return 0; } int dipping() { //Dipping routine myservo = 0.5; wait(1); myservo = 0; return 0; } int alert() { //Alert using on-board LEDs int y; for ( y = 0; y != 1; y++ ) { leda = 1; ledb = 0; ledc = 1; ledd = 0; wait(0.2); leda = 0; ledb = 1; ledc = 0; ledd = 1; wait(0.2); } return 0; } int alertoff() { //Resets on-board LEDs to 0 leda = 0; ledb = 0; ledc = 0; ledd = 0; return 0; }
Version History
- V.1: Original version. Functional, but some bugs with the buttons.
- V.2: Button issues fixed via debouncing and such, and extra modes added. Much of the notebook page rewritten to provide a better guide to construction.
- V.3: ???
With thanks to...
Thanks to Chris Styles and the wonderful folk at ARM, and for my colleagues for putting up with the whine of the servo and for actually seeming impressed. (They don't get to play with hardware much, you see)
5 comments on The Wonderful Tea-o-Matic:
Please log in to post comments.
Yes, pictures please!