Electronic

Android Mini PC

Last month I read an article on ArsTechnica about a small Android PC at 74$  and decided to give it a try. I received it yesterday and I am very impressed by the device. The small computer ships with a transformer, a mini-2-standard USB adapter, an HDMI cable and a mini-2-standard USB cable. You can connect the computer into any TV or monitor with an HDMI input port. I plugged mine into an old TV I had in my junk and connected a wireless keyboard and mouse into it.

The device is built on top of a 1.5GHz ARM processor with 1Gb of flash storage and a built-in 802.11 wireless adapter. You can extend the storage with a microSD memory card. It comes pre-installed with Android 4.0 and a couple of standard Android applications like Youtube, GMail and, of course, a web browser.

Once connected to my home WiFi network I started playing around with the device. All the user interfaces are the same as a standard Android 4.0 phone or tablet. The web browser is the default Android browser. I configured my GMail, Facebook, Twitter and Hotmail accounts with no problems. For some reason  I have not been able to connect to my YouTube account. I’ll give it an other try later.

I then went to the Google Play store to download more apps. It seems that the store recognize the Android Mini PC s a tablet PC so not all phone applications are available for download. I started by downloading the TED and Netflix applications so I can convert my old TV into a modern “intelligent” TV. Both applications worked like a charm. Since “intelligent” TVs are usually sold an extra 700$, at 74$ the device was already paying for itself.

In conclusion, if you want to add web capabilities to your actual TV, the Android Mini PC combined to a wireless keyboard and mouse is a good candidate! You want one? You can now find it under 70$ on AliExpress by searching for “Android Mini PC” with the Free Shipping option selected.

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! :)

Playing With The Beaglebone

I just received my Beaglebone and started experimenting with it. The Beaglebone is a low cost, single board Linux computer with tons of IOs to interface with the physical world.

Beaglebone A5

Beaglebone A5

My objective is to make a Python Robot using the Beaglebone as the brain and my Makerbot to build the frame. I found an excellent series of articles on how to get started with the Beaglebone on the Dan Watts’s blog.

The most interesting feature of this board is the way used to read and write to the IOs using the file system. By using the file system, the IOs are accessible trough any language you may want to install on your Beaglebone Linux distro.

I’ll post some practical examples in the following days.

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?