Sunday, June 23, 2013

Week 3/4: Programming Made (Sort of) Easy

Figuring out wiring and circuitry is only half the battle; these systems need to be told what do, along with all the specifics that go with those actions. We're programming a small robot to perform certain commands, and once we have it down, we'll build a larger one. Here's where the biology comes in: instead of a small microchip giving commands, it'll be bacteria acting as the robot's brain.

For programming, we've been using Arduino, a microcontroller board that acts like a mini-computer with its own power source.


We used the Arduino UNO, but there's also the Leonardo,  Lilypad (a circular platform),  Nano, Yun, and many more. They offer different sizes, power sources, and functionality.
The UNO is about the size of a playing card, and uses its own type of code as a simpler substitute for C++, a notoriously hard code to understand.

I won't go into the nitty gritty specifics of the code, but it's a lot more straightforward. Assign a device (LED, sensor, motor) to a one of thirteen ports, and you can control under what circumstances the devices are powered through the Arduino.

Using a do-it-yourself Arduino kit with next to no instructions, we were able to put together a moving robot with four-wheel drive  and an ultrasonic sensor that could execute various commands as given by the computer; move forward, move backward, turn right and left, rotate the sensor, and record distance via ultrasonic echoes.

All four motors are connected to the Arduino through the breadboard, as is the motor rotating the sensor on the right.

Right now, the motors for the wheels are controlled by the computer; enter a positive value for moving forward, negative for reverse, and two other arbitrary variables for turning. Speed is controlled by the value entered: the higher it is, the faster the wheels move.


The circuit on the breadboard with the black chip is called an H-bridge, which can direct current in either direction. This is what allows the wheels to spin one way or the other.
Our next step is to have the sensor take over this job; much like the bacterial interface we'll install, it will send distance data to the Arduino and eventually the motors to move in a certain direction. Once we figure out the basic skeleton of the code and wiring, it's just a matter of making sure the bacteria fit in.

It's hard to see here, but we've used an H-bridge already built into a breadboard/chip to use less space. If  you take the tape off, the whole thing doesn't fall apart, I promise.


Was that not the most entertaining and interesting post ever? Maybe I'll search for the Holy Grail next week and write about that to make up for it.

Cheers,
Ben

No comments:

Post a Comment