Friday, August 19, 2011

Serial Communication

Onward with the projects! I have a few things on the go at the moment, working 9 to 5:30 breaks up my creative flow for outside projects, but I've gotten the Arduino and my computer conversing nicely using serial communication. First I used a potentiometer to control the screen background in Processing (thanks to Jeremy Blum for his fantastic arduino video tutorial series, I recommend it to absolutely anyone and everyone). Next came using Processing to control the Arduino, first with an LED on/off button approach, next using sliders to control PWM brightness. I used the controlP5 sliders, you can download the controlP5 library for free (google it).

Here are the sliders on my computer screen:
And here's the results as laid out on my new breadboard (from proto-pic, where I bought the original Arduino kit):

And a blurry dark photo to emphasise the different light levels:

I could not have done this without the help of Jeremy Blum's tutorials, Lucky Larry's tutorial on Arduino/Processing serial communication, and the ControlP5 slider example by Andreas Schlegel. The LEDs are on PWM-enabled pins 10 and 11.

I ended up with this Ardunio code:

int redPin = 10;
int yelPin = 11;
int buff[2];
void setup()
  pinMode(redPin, OUTPUT);
  pinMode(yelPin, OUTPUT); 

void loop()
  if(Serial.available() >= 2 ){
    buff[0] =;
    buff[1] =;
    analogWrite(redPin, buff[0]);
    analogWrite(yelPin, buff[1]);

And this processing code:
import processing.serial.*;
import controlP5.*;
ControlP5 controlP5;
Serial port;

int redval = 0;
int yelval = 0;

void setup() {
  port = new Serial(this, "COM3", 9600);
  controlP5 = new ControlP5(this);
void draw() {

void red(float redi) {
  redval = round(redi);

void yellow(float yeli) {
  yelval = round(yeli);

Which, I'll be honest, was a lot easier and shorter than I thought it was going to be. There's probably a better way of doing this (leave a comment if you know one!) but I'm happy with it for a first try. Learning with Arduino always seems to be fast, and I'm constantly surprised how simple things are. The electronics have actually been the harder part of this experience, trying to catch up after 15 or so years.

Still, having fun!

Monday, August 15, 2011

Arduino-programming girlfriend

My girlfriend picked up my Arduino, pre-wired into a 16x2 character LCD screen, and looking at a simple example has programmed it to display messages, flash text, use functions and loops, all with no previous programming experience. Jealous? Yeah, you're totally jealous. I think it also helped her understand a little of what I do at work (I'm essentially a programmer).

Personally I have a few ideas for some projects. I'd like to do some previously buillt projects first though, maybe starting with a knock sensor, then moving on to a controls-to-usb-controller-output macro thingy. i lost my last controller so I'm going to have a good time re-mapping the key matrix. At some point I have to face my fear of motors and continuous rotation servos so I can get on my way to my LOGO robot! I wonder what the torque is like on my mini servo...?

My second order from proto-pic is still awaiting fulfillment. If they're ordering in a 22mF capacitor to complete my order because I didn't check that they were out I will kick myself extra hard. My purchase from hobbytronics was cheap, very affordable postage, arrived the next day, neatly packaged, and it fit through my letterbox, so very happy with them!

Edit: Oh yes, my office is now in full force, with a workbench and a lamp for arduinoy goodness, although my notebook makes arduino work pretty mobile, and even more so when I get my components box!

Saturday, August 6, 2011

Life and Arduino running parallel

Well, lifewise my Dad's come up to help me out with a handful and a half of tasks to take the pressure off. This will, combined with my Mum's book-keeping skills, keep the stress and stress-related conditions hopefully at bay until work calms down come September (and I can have a holiday).

In Arduino news I have a few ideas. I like the idea of an ethernet or wifi-controlled robot, I like the idea of a web-access sensor, I like many ideas, but I'd really like to try to build a LOGO turtle drawer robot. One you can firstly program using the USB connection, and later program using wifi or rfid or somesuch, and after that program using the buttons on the actual chassis. Wish me luck!

Firstly I need to buy a chassis, some tracks or wheels and get them working as I need. Also, I'd like to get some EEPROM memory and learn how to use it. I should learn a lot on this project.