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 …

  1. Publish the schematics on github
  2. Post more details about the code (wave shield, 74hc595, …)
  3. 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.

Arduino Stepper Motor Controller PCB

Arduino Stepper Motor Controller PCB

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.

PCP Details

PCP Details

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.

 

Keypad & LCD Display

Keypad & LCD Display

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!

Cheap Keypad and Arduino

Cheap Keypad and Arduino

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:

  1. The communication with he robot must be wireless
  2. The connection to the Twitter website is made by a separate computer using the Python library Tweepy
  3. The robot should move according to the messages it receives
  4. In addition to the movement, the robot should have a servo that indicate its direction
Tweeter Controlled Robot

Tweeter Controlled Robot

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;

        //...
    }
  }
}
Twitter Robot

Twitter Robot

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.

A basic Arduino clone

A basic Arduino clone - Vcc on pin#6 !!!

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?

Stars Trackers

I posted these two barndoor mounts on Thiniverse a few days ago. One is manually operated while the other is motorized.

Manual Stars Tracker kit:
http://www.thingiverse.com/thing:11376

Manual Stars Tracker

Manual Stars Tracker

 

Motorized Stars Tracker kit:
http://www.thingiverse.com/thing:10756

Motorized Stars Tracker

Motorized Stars Tracker

Since I have not that much time on my hands, I decided to merge both projects so that I can chose between the portability of the manual version and the ease of use and accuracy of the motorized version.

The new manual version looks pretty much like it’s ancestor with some minor modifications. The length of the device has been cut in half and some minor bugs have been fixed.

New version of the manual Stars Tracker

New version of the manual Stars Tracker

I am now working at motorizing this new version of the manual Star Tracker. I want to make it simple to switch from the manual to the motorized version by reusing as much parts as possible.

I ended up today with this motor support that should replace the actual wheel of the Star Tracker.

Motor Mount for the Motorized Stars Tracker

Motor Mount for the Motorized Stars Tracker

I am using the same type of attachments as the frame of the Makerbot. This technique is pretty cheap and allows strong assemblies using plastic and wood.

Next step will be to design a coupling to attach the motor to the 1/4″ threaded rod of the tracker. I think I’ll use the same type of coupling as the Reprap 3D printer.

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.

Maker Faire World 2011 New York

Maker Faire World 2011 in New York city

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.

Tony Buser showing its 3D prints

Tony Buser at the Makerbot booth

3D printed Molecules

3D printed Molecules

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 …

Steel and Fire

Steel and Fire

Fish/Lobsters Car

Fish/Lobsters Car

Bamboo bike in construction

Bamboo bike in construction

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.