Author Archive
First custom PCP
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);
}
}
Basbrun.com 2.0
As you can see Basbrun.com has a brand new look. This is the first step in the redesign of the website. I’ll add a Projects section where I will discuss in more details about the projects I have published so far.
Basbrun.com Has a new look on your mobile
I installed WPTouch on my site so you can easily read your favorite blog on your mobile! :) Same url as the desktop version … basbrun.com. Try it and tell me what you think …
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! :)
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.
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:
- 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
The power of sharing
I just published a derivative to a project on Thingiverse.com (http://www.thingiverse.com/thing:18918). I love sharing designs! This is the foundation of a new way to make stuff. You need to understand the real power of sharing when time comes to decide if you keep your project for yourself or if you publish it on a sharing site like Thingiverse or Instructables.
Derivatives on Thingiverse are a good way to understand the dynamic behind design sharing. Take the “Wade’s Geared NEMA17 Extruder” by Wade as an example. This project has resulted in fourteen direct derivatives from Thingiverse users, each of which brings it’s own addition or modification to the original design, making it better and usefull for more peoples. Fourteen derivatives of a project is pretty impressive but the best part is yet to come.
One of these fourteen derivatives, the “Accessible Wade’s Extruder” by GregFrost became one of the most popular thing on Thingiverse and spawned four more variations of the extruder. That doesn’t stop there … GregFrost had better ideas for this extruder and published the “Greg’s Hinged Accessible Extruder” thing. This thing became a huge success with thirteen new derivatives and tons of “like”. The list continues with the “Tom’s guided Greg’s accessible hinged Wade’s geared extruder” from Thomas Sanladerer and then, GregFrost published again with the “Guidler for a Gregs Wade“.
The branch I followed is one among many other branches of the original project. All together, all branches are getting close to 50 different derivatives of the original design. The last version to show in this branch is the “Greg’s Wade reloaded – Guidler, Tilt Screws, Fishbone Gears” by jonaskuehling who merged different versions from other branches of the original Wade’s extruder.
But, wait, one more derivative has just been published! “Chri” just posted a new derivative called “Greg`s Wade Universal Reloaded Edition !“. As the name suggest, we are converging toward the ultimate Wade’s Extruder. How many new derivatives are yet to come? No one knows for sure. What is sure though, is that the whole process have greatly improved the original design in a very short period of time. It would have been impossible for a small or medium size company to achieve this at reasonable price.
Compare by yourself the difference between the original and the last designs. Browse trough all the derivatives to appreciate all the work that have been done in such a short time. That’s the power of sharing.












