Posts: 12
Joined: Wed Aug 29, 2012 12:42 pm

Best ever advent calender

Wed Aug 29, 2012 1:08 pm

Here's my plan. I am tired of shop-bought junk at Christmas and also my kids opening all the advent calender doors by the 2nd December. I know its August but I think Ill need 4 months to get this to work as I am a complete beginner to Python, Pi and anything clever.

Im planning a somewhat different machine, based on projects Ive seen so far. The first is the Skutter as shown in the Mag Pi magazine and the second is either an LED or 7-segment displays to display the date. I know nothing about either!

The rough plan is:
- Have 25 push-to-make buttons on a 'calender' (to be decorated by the wife!)
- A display (LED or 7-segment displays, depending on how hard it is!) to display the day (1-25)
- Each button will make a ground which will be fed to the Pi via the GPIO
- Each button will essentially make the same ground but the Pi will only increment the the number and the day by checking the day's date.
- The present for each day will be collected from a store and handed (over a TBC structure) to the wide-eyes of my kids once the day's button is pressed, by the robotic arm as featured in the 'Skutter' project in the Magpi

What I cant do yet is:

- Creating circuitry and code for the display
- Receiving feedback from the robotic arm as to its position. I could run it open loop but suspect I will get into trouble. The Mag Pi article is due to add more detail which will hopefully be in time.

Thats it for now, if anyone can point me in the direction of helping with the things I cant do, it would be much appreciated. Otherwise Ill tick over until a last minute panic at the end of November. :shock:

Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Best ever advent calender

Wed Aug 29, 2012 4:36 pm

Sounds like an automated goldfish feeder for while you're on holiday - for creatures of similar levels of patience!

Actually the Bad Chocolate Items could be on a conveyor belt (Bruce Forsyth style) and dropped out, a few per day. A conveyor belt is a single axis robot after all. (I thought of this idea thirty ago for feeding my Dad's tropical fish, but never got started. Maybe I should have patented it.)

Seriously, getting the robot position is seriously tricky, though I notice you know what "open loop" means so you probably already know how tricky it is... I have seen a few ideas for doing it with various encoder types on that robot, see this old thread I followed for many (too many!) ideas and links to other things that apparently have worked: ... =37&t=5233

By the way I'm surprised nobody on this forum has thought of looking at cartesian robots (X,Y,Z axis things like gantry cranes), I suppose arms just look cooler.

Oh a constructive criticism - if you want it by THIS December, best start now, not November :)

Posts: 39
Joined: Fri May 25, 2012 6:49 pm

Re: Best ever advent calender

Wed Aug 29, 2012 4:44 pm

Sounds like a frickin' awesome advent calendar.... Why did I not get one of those when I was a kid?

Okay, I am a Python noob as well and I have been tinkering with the GPIO on the Pi... Don't think I could help you with the skutter arm but I can with the 7 segment display...

I have this one... It is very simple to use and pretty idiot proof. All you do is turn on each segment as if using a LED and for 99p + £1 p and p it's a bargain! ... splay.html

The cathode bit means ground... So there are 2 cathodes,or grounds. 1 for each digit. All the other pins are positive (anodes) and this is what you turn on.... Works with a 3V3 power source but use 100 ohm resistors just in case... Hope this helps!

Posts: 12
Joined: Wed Aug 29, 2012 12:42 pm

Re: Best ever advent calender

Sat Sep 01, 2012 5:35 pm

Thanks for the advice, this Christmas is the plan so I'm intensifying operations from now.

Im hoping that future copies of the MagPi will show some additional info on the Skutter project which will hopefully show some closed loop control options for the robot arm. Ill have a look at the Skutter v0.2 posts too. I think it can be done, even with a relatively 'dumb' robot arm.

I can immediately foresee a problem of running out of discrete IO. For 24 numbers generated using 2 7-segment displays, will I not need at least 14 discrete IOs? Am I missing something there or is there a better way of doing this?

I plan to post all the details here (code, circuit etc) as I go. Progress is good, I now have a throne for my Pi by my existing monitor :D

User avatar
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Best ever advent calender

Sun Sep 02, 2012 9:42 am

Yep.... Sadly that is a problem. Most likely you will need 14 IOs... UNLESS

you could use a shift register or 2! There basic use is to allow for more digital ins and outs. Truth be told I don't understand how they work or how to program them... I recently got 6 and haven't tried them yet. Do a search of the forums and see if you can find any stuff on them!

Alternately you could buy an Arduino Nano (£12 ebay)... There is a much bigger wealth of tutorials for there GPIO stuff on the internet...I would recommend this only as a last result though... You program it in C++ and your're taking away the fact that this is all done on the Raspberry Pi.

I wish you the best of luck and keep us informed to how its going! :) :) :)
Just a beginner sharing his experiences on his way to geek nirvana...

Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Best ever advent calender

Mon Sep 03, 2012 8:17 am

There are lots of 7 segment LED drivers and ways of doing it. You don't need 14!

In fact I saw a way of doing it with just a few - you have a counter (a standard 5V logic chip) and first reset it then send it, say, nine pulses very quickly so it counts up to nine. It counts too quickly to see, so the user just sees the digit appear. Suspect it works for two digits with a few modifications.

And there are other ways.

Frankly the display is easy. The robot bit will be much, much more difficult... though one of the links on the thread I mentioned seems to have done it.

EDIT: I made a mistake earlier, the thread I spotted previously was: ... =47&t=4254

On the third post there I linked the following post I found: ... er-Feedba/

As I remember it was a fiddly operation and quite involved, not much room to fit encoders for example...

Posts: 12
Joined: Wed Aug 29, 2012 12:42 pm

Re: Best ever advent calender

Sat Nov 03, 2012 7:48 pm

OK, I have made some progress. The robot arm is in place and controllable via USB and the guidance in the magpi. I have a 7-segment LED working too but have had a change in direction in the IO.

What I would like to do is have a seperate button for each day (ie 25 buttons) and an LED which lights when the button is correctly pressed (good for learning numbers too ;) ). This means 25 buttons and 25 LEDs and with my elementary knowledge of the pi, this is too many. I see some info about shift registers but think that I may be pushing the boundaries a bit far on this one.

That is,unless someone can point me in the direction where I can acheive this?????! :D :D

Posts: 91
Joined: Sat Aug 18, 2012 1:26 am
Location: Portland, OR USA
Contact: Website

Re: Best ever advent calender

Sat Nov 03, 2012 8:29 pm

Why not do a lot of this in hardware? the LEDs would be easy; just put them in line with the buttons. Something like this:

Code: Select all

VCC----------./ .------->|------/\/\/\/--+--/\/\/\/-------GND
Thus, the LED will light when the button is pressed. This solves the LEDs, but not the inputs. It can be done with 10 IO pins, however. Wire together a 5x5 grid like so:

Code: Select all

    5   6   7   8   9
    |   |   |   |   |
    |   |   |   |   |
    |   |   |   |   |
    |   |   |   |   |
    |   |   |   |   |
You then take the SIGNAL connection from the first diagram, and wire it into a plus sign in the second diagram. Thus, the SIGNAL is low when the switch is open and high when the switch is closed (you will need to find the right resistor values for this yourself).

Now, for the software side. To read, for example, the first button, you examine GPIO pins 0 and 5. If they are both high, then the button at the intersection of lines 0 and 5 is pressed, and that would be the first button.

Good luck!
Linux -- The operating system with a CLUE (Command Line User Environment)
FTC Team 4508
E=MC Squirreled

User avatar
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Best ever advent calender

Sun Nov 04, 2012 8:54 am

Hi Crazyideas, I love your modification of the skutter but I have to say its highly unlikely that the feedback article will be ready before Christmas. ... oull-need/

This instructable explains a relatively easy way of adding feedback using potentiometers. It's geared for an arduino but you could easily feed the pots into a low cost analogue to digital converter instead. I would probably go with an mcp3008 because the 10 bit resolution will allow you quite fine control, ie. To a degree or so. This tutorial gives some nice ways of using the adc chip with a potentiometer and would only need some minor modifications to the code to get it to feedback an angle rather than volume. ... -pi/script

Although, if all your chocolates will be in fixed positions, I think it would be a lot simpler to use timing instead to collect them.

Anyway, good luck, anything we can do to help... I think we'd all like to see some pictures or even a video.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 10 guests