Smart Button using PIC10F microcontroller
This is a button a little bit smarter. (Microcontrollers and coffee, who doesn’t like)
I i’m using it to fill my Coffeemaker with water. This way its a little bit more fun and i always get the same amount of water.
Its a simple project, and it’s a good excuse to play with a PIC10F, one really small micro-controller. Code is written in C, a nice way to start with it.
It interfaces with the user blinking one led. so you can chose how much time the valve will open ( giving a good control on the amount of water). On the current firmware settings ( and with my valve) are for 1-2-3-4 cups of coffee ( i have a big cup, 300ml).
Just keep in mind that this button can be used for other uses.
The design (and problems that where solved) are on the next page, but if you just want to build this thing go to the building instructions page and download the project files.
Arthur Benemann 2011 Brazil
In the beginning…
Things need to be as simple as possible so a small micro-controller would be perfect. Luckily i had some spare PIC10F206 on my parts box. A 100mA transformer and a 78L05 would do the power supply, and a relay to control the valve ( mains power).
All parts are set up, now the board…. ( next page)
I think i would get this one at the first try, i was so simple… ( jump this if you are not interested in failures)
Ok, it was just a question of putting building blocks together.
Power supply – -> Line – Trafo – Brige – Big Cap (100uF would do the job)- 78L05 – and done
Relay –> Resistor ( 1k will saturate the BC548) – 5v relay – protection diode (1n4004)
PIC –> Internal pull up for button – a simple LED – connection to the relay block
OK that was easy.I should work nothing wrong until where. ( schematic below).
Draw the board, tone transfer, soldering ( forwarding so we don’t blow the surprise)
Now just add some codding ( explained on the next pages), and programing with temporary wiring.
Turn it up !!! And it doest work properly :(…
Next page for the solution…
There is a picture below of the original prototype v1, it’s full of wiring and solder because of the testing…
I tried a lot of things, powering it up from a external source, changing the relay supply to before the 78l05 regulator, putting huge caps on some points of the circuit….
The i worked, i had put a direct wiring for the Microcontroller supply. Currents running to the relay was messing up with the PIC power ( one oscilloscope would be great by now ).
The picture has some highlights on this.
Problem solved, let go to v2.0.
So what can be improved:
Relay power does’t need to be regulated.
MCU position could be more away from mains voltage ( relay).
Don’t use MRCL pin, just to be sure.
Just a question of redesigning the board ans schematic. Final result is below:
This solved the problems.
I wrote a program to control the button, but it was not very friendly to the user ( i prefer not to comment it). Here i have to thak Jéssica for her idea for the program.
Button press is used to change between modes of operation,
n° press | Dose | LED
0 press – 0 off – off
1 press – 1 cup – slow blink
2 presses – 2 cups – blink
3 presses – 3 cups – fast blink
4 presses – 4 cups – on
5 presses –> return to off position
There is a timeout in “cups mode” if there isn’t a press for 2-3s it go to filling mode. And stays there until the filling timeout, that deepens on the mode.
I implemented this with a state machine, and a debouncing routine.
The on time of each mode is defined in the top of “main.c” file, this control how much water goes to the coffeemaker. Experimenting with the valve in place give me this results ( and they don’t seem to change too much because pressure is constant).
You must change this values to agree with your installation.
This is my first low end microcontroller project programed in C, i used to think that C would’t be as easy to code as assembler, and the code would be so big. I was wrong C is great,fast development and relative small code.Code was compiled with hi-tech C compiler lite (free).
For more detail: Smart Button using PIC10F microcontroller
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
JLCPCB Prototype: Only $2 for 10pcs 10×10cm, 24 hours Quick Turn, DHL Delivery in 3 days
Current Project / Post can also be found using:
- pic based home automation#spf=1
- microcontroller home automation project
- schematic 2 position switch with pic 10f
- control home appliances using pic mini project ppt