Friday, March 26, 2010

Introducing Susi and the PScheduller library

Susi

What's Susi? It's a Super Simon game.
Why is it super? Because it features:
  • Normal 4-buttons-4-leds-1-buzzer behaviour.
  • Ongoing button monitor to fail if a button is pressed when it's not the user's turn.
  • Time out on excessive delay in the user's turn.
  • A 7-segments display to show animations, count-down time and final score controlled by a 595 shift register.
  • A servo to show the progress.
  • Two user controllers: my generic control panel and a Lego Technic one.
And all controlled with an Arduino, of course.
Do you want to see it working? Watch the video.



If we all know the world is plenty of Simon games, why did I make another Simon? Because it's a good demonstration for my PScheduller library, the real motivation of this post, and because my children have fun with it.

PScheduller

Let's introduce PScheduller. PScheduller is a library for Arduino developed with two goals in mind:
  1. To have a simple way to run several tasks simultaniously. This is, a kind of multithreading.
  2. To implement a state machin (FSM) that allows the programmer to focus on what really matters depending on the state of the program.
PScheduller is a library mainly written in C++. You can download it from my GitHub repository. There you'll find the directory PScheduller that you have to put under hardware/libraries/ at your arduino's installation directory. You'll find too the full code of Susi (named PSimon) that you have to put in your Arduino projects directory.

In future posts I'll describe PScheduller and its usage, and the code of PSimon. If you download and open PSimon, don't get scary. PSimon it's a relatively complex program due to the number of components it controls. With simpler programs, the code is really clear and straightforward.

The lego version

The version of the video avobe uses my generic control panel (you'll have a future post on it too). I constructed a Lego Technic panel for Susi to be more useful for my children. They like to play with it!
You can see a video of this second version in action:


In this version I've substituted the momentary push buttons of the generic panel by four limit switches. They are actually well integrated in the Lego structure and produce the "click" that you can heard in the video each time the user presses a color. Look at the picture below.


By the way, this was my first "real" project combining electronics with a Lego structure. And I learned an important lesson: you have to plan what you want to do before doing it. I just started to construct the structure, to place components and to solder long wires to avoid problems when I plug the terminals in the Arduino or a breadboard. But when it was time to plug it all, I discovered that it was dificult to have a comfortable layout. In fact you can see in the video how the 7-segments is in a strange position...


Summing up

Ok, it's enough for today. I don't like long posts.
To complement this post I'll comment in future posts:
  • In depth explanation of PScheduller with some easy samples.
  • In depth explanation of Susi (PSimon) code as a sample of a more complex program using PScheduller.
  • An introduction to my generic controller. It's really useful.
If you have any preference or suggestion about more topics regarding this post, please, leave a comment and I'll try to respond (the comments are moderated just to avoid spammers).

Wednesday, March 10, 2010

Welcome!

Hello and Welcome to my blog.
In this blog I'll post about my two current hobbys: Arduino (electronics) and Lego, specially Lego Technic. I'll document here my progress in merging this two technologies to make amazing -I hope- projects.
Get fun!

Disclaimer. I apologize for my poor english. Although my mother tongues are spanish and catalan, I prefere to write in english to reach a wider audience who can enrich this blog with its comments. Of course, you are welcome to correct my writings ;)