Arduino
Quiz Buzzer System
Last Christmas I built a Quiz Buzzer System for my mother. She is a big fan of television quizzes and love to organize some with her friends and family. The particularity of this project is that you can choose your team buzzer sound from a list of more than 30 digital sounds.
The system is composed of a main console, 8 buttons, a power supply and a set of telephone cables. The core of the console, built in a plastic project box, is made of an Arduino Duemilanueve micro-controller coupled with an Adafruit wave shield. The 8 buttons are made out of small project boxes and arcade buttons, again from Adafruit. The buttons are connected to the main console using telephone jack and cables.
For this project I am using all the IO available on a standard Arduino board. I even have to use the pins #0 and #1 to achieve my goal. To drive the buttons LEDs I am using a 74HC595 shift register chip. To drive the control panel LEDs without using additional IO pins I am using two 74LS32 OR gate chips. Finally, to drive the cluster of LEDs I am using a L293 driver chip.
To change your team buzzer sound you maintain the main console button pressed and push any button of the team who wants to change it’s buzzer sound. Every tie you push the team button, the next sound in the list is played. When you find the perfect sound for your team you release the main console button and voilà …
You can find the Arduino source code on my Github at https://github.com/pchretien/quiz.
Next I will …
- Publish the schematics on github
- Post more details about the code (wave shield, 74hc595, …)
- Make a short video to demonstrate how the machine works
First custom PCB
This is my first working printed circuit board. I used the toner transfer method to draw the traces on the copper board. The purpose of this circuit board is to drive a stepper motor. This is a proof of concept for the final board version that will complete my equatorial mount project. The equatorial mount will be my first project in my new “Projects” section. I will begin with the conception and the making of this board.
I have designed the PCB using Fritzing, an open source circuit designer. You can find the project and the PDF of the circuit on my github. More details to come in the Projects section … hopefully in a few days.
I had a bit of troubles soldering the power connector because I drilled the holes too large. I’ll have to renew my stocks of small drill bits … I broke two 1/32″ bits while doing this board!
Keypad & LCD Display
While I was still trying to figure out what to do these 10 keypads, I received an LCD Display I ordered on eBay. It’s friday, I have no better idea than plug them both on an Arduino and code something.
I started from the circuit of the Keypad article and moved the wires connected to pins 7 & 8 to analog pins 0 & 1. There is no good reason to that shift except that it makes it easier to have the LCD wires all connected to the same side of the Arduino.
I will not go in details with the wiring since Limor Fried, founder of Adafruit Industries published an excellent demo on how to connect the display to an Arduino. This will require an additional 6 pins on your Arduino. I used the same pins as in the Lady Ada demo, 7, 8, 9, 10, 11 and 12.
Now let’s jump into the code. This is a very simple demo and you will not find anything mind blowing. The hard part has been coded for you in the LiquidCrystal library, included with the Arduino IDE.
Thanks for reading …
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6
#define TITLE "KeyPad & LCD __"
#define READY "Ready ... "
#define EMPTY " "
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// you can change the overall brightness by range 0 -> 255
int brightness = 255;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
//connect to the row pinouts of the keypad
byte rowPins[ROWS] = {2, 3, 4, 5};
//connect to the column pinouts of the keypad
byte colPins[COLS] = {6, 14, 15};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(TITLE);
lcd.setCursor(0,1);
lcd.print(READY);
brightness = 100;
Serial.begin(9600);
}
int index = 1;
char digits[2] = {' ',' '};
void loop(){
char key = keypad.getKey();
if (key != NO_KEY)
{
index = !index;
if(key == '*')
{
index = 1;
digits[0] = ' ';
digits[1] = ' ';
lcd.setCursor(0,0);
lcd.print(TITLE);
lcd.setCursor(0,1);
lcd.print(READY);
}
else if(key == '#')
{
// Animation
for(int i=0; i<15;i++)
{
lcd.setCursor(0,1);
lcd.print(EMPTY);
lcd.setCursor(i,1);
lcd.print(digits);
delay(100);
}
lcd.setCursor(0,1);
lcd.print(EMPTY);
lcd.setCursor(14,0);
lcd.print(digits);
index = 1;
digits[0] = ' ';
digits[1] = ' ';
lcd.setCursor(0,1);
lcd.print(READY);
}
else
{
digits[index] = key;
lcd.setCursor(0,1);
lcd.print(digits);
lcd.print(EMPTY);
}
Serial.println(key);
}
}
Cheap Keypad and Arduino
I just received a package of 10 flexible keypads I bought on eBay for 15.88$, shipping included. Having a keypad in your project opens so many possibilities, at 1.59$ each I think it’s a deal!
I found a keypad library for Arduino on the Arduino Playground. I made some minor modifications to the sample code they provide on that page. I changed the order of the rowPins and colPins arrays to match the order of the pins on my keypad. I also had to switch the # and the * to match my keypad.
There is however a bad side to this type of keypad … the number of pins required. This is a matrix type keypad that requires 7 IOs to run. For many projects, finding 7 IOs is simply not possible. There are two solutions to this problem. The most simple and most expensive one is to switch to the Arduino Mega. The cheap but more complex solution would be to use an IO port extender like the MCP23008.
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
}
I think I will revisit my KidsClock project so I will not have to re-upload the program to change the wake up time or to switch to day light saving time. What would you do with a keypad and an Arduino? Leave your comment in the comment section of this post …
Tweetbot … the code
You can now find the code of the twitter robot on my github at: https://github.com/pchretien/tweetbot Feel free to fork … copying is not stealing! :)
Twitter Controlled Robot
I presented this project at the 28th Montréal Python meeting. I posted the slides of the presentation in my previous post here.
The objective of this project was to demonstrate the use of pyserial and XBee to wirelessly control a robot. This project was also my first attempt at using the Tweepy library. The requirements for the project were the following:
- The communication with he robot must be wireless
- The connection to the Twitter website is made by a separate computer using the Python library Tweepy
- The robot should move according to the messages it receives
- In addition to the movement, the robot should have a servo that indicate its direction
The code running in the Arduino is a very simple program. The micro-controller read on the serial port to get a char command. The commands are text integers. The robot moves according to the command it receives. You can find the code to drive the robot in my previous post Arduino Motor Controller Using an L293D Chip. The following loop() function of the Arduino program receives commands from a computer trough the serial port. Depending on the nature of the command, the robot will perform different actions.
void loop()
{
if ( Serial.available())
{
char ch = Serial.read();
switch(ch)
{
case '1': // forward
servo.write(90);
forward();
delay(RUN_DELAY);
stop();
break;
case '2': // backward
servo.write(90);
backward();
delay(RUN_DELAY);
stop();
break;
case '3': // right
servo.write(180);
right();
delay(TURN_DELAY);
forward();
delay(RUN_DELAY);
stop();
break;
//...
}
}
}
On the computer we are running a Python that connects to Twitter.com, read it’s messages and send commands to the robot that are related to the content of the messages.
import tweepy
import time
import serial
consumer_key=""
consumer_secret=""
access_token=""
access_token_secret=""
ser = serial.Serial('COM8', 19200, timeout=0)
# Initialize the tweepy API
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
api.update_status('Start listening at ' + time.strftime("%Y-%m-%d %H:%M:%S"))
print "Start listening at " + time.strftime("%Y-%m-%d %H:%M:%S")
print
# This is where we should send the command to the robot ...
def process_text(author, text):
print author
print text
print
if text.lower().find("cmd1") > -1:
ser.write('1')
if text.lower().find("cmd2") > -1:
ser.write('2')
if text.find("#mpr-bye") > -1:
quit = True
quit = False
lastStatusProcessed = None
lastMessageProcessed = None
while True:
for status in tweepy.Cursor(api.friends_timeline, since_id=lastStatusProcessed).items(20):
if lastStatusProcessed is None:
lastStatusProcessed = status.id
break
if status.id > lastStatusProcessed:
lastStatusProcessed = status.id
process_text(status.author, status.text)
for msg in tweepy.Cursor(api.direct_messages, since_id=lastMessageProcessed).items(20):
if lastMessageProcessed is None:
lastMessageProcessed = msg.id
break
if msg.id > lastMessageProcessed:
lastMessageProcessed = msg.id
process_text(msg.sender.name, msg.text)
if quit:
break
time.sleep(15)
api.update_status('Bye! ' + time.strftime("%Y-%m-%d %H:%M:%S"))
print "Bye!"
The Twitter anti-spam filter will block you to send twice the same tweet to someone. it is then difficult to use specific commands to control the robot since you can’t send it more than once.
The solution is to use common words as commands and to incorporate it into your tweets. That way you can send multiple variations of the same command simply by decorating the command with more text.
A video of the presentation should be available on my Youtube channel soon …
Montreal Python #28

Today at 18:30h, I’ll make a short presentation at the 28th edition of the Montreal Python. I’ll present my PyGame Wireless Game Controller and a robot controller by the web.
More details about the presentation on the Montreal Python Website:
http://montrealpython.org/2012/03/montreal-python-28-lithographic-lobotomy/
You can get the slides of the presentation here:
https://docs.google.com/presentation/d/1KTqljkl-fSZyuhXonCrQN10HsEFdp5AsavMEvj8bdRU/edit#slide=id.p
Atmega328 Vcc pin
I received a comment from “N00B” on my Build an Arduino Clone post pointing out a mistake I made by connecting 5V power to the pin #6 instead of pin #7 of the Atmega328 micro-controller.
He was right and I changed the text of the article from pin #6 to pin #7 but, what puzzled me is that the circuit I made for this article was actually using pin #6 to power the micro-controller.
I still have this circuit all wired up in my lab. I validated that it works as well powered on pin #6 as on pin #7. How can that be? Anyone can explain that one to me?
The Maker Faire World in New York
Following the Open Hardware Summit I went to the Maker Faire World in New York city. This event was held in the same location as the OHS, at the New York Hall of Science.
3D printers were all over the place! Of course there was the 3D printing village where Makerbot, Makergear, Ultimaker, Botmill and other companies were exposing their stuff but you could also see a Makerbot in almost every booth of the exhibition.
Of course, there was not only 3D printers at the Maker Faire … We had a gigantic dinosaur/dragon throwing fire, a car covered with dancing fish and lobsters, bamboo bicycles and much more …
These are only 1% of all the great stuff you can find at the Maker Faire. This alone totally worth the trip from Montréal to New York!
For more information visit the Make Magazine website at makezine.com.

















