Retractable cables

Can’t quite believe it took me so long to figure this one out, if there’s one thing that annoys me on a daily basis it’s wires. Wires everywhere. Crossed wires, tangled wires, wires to trip over, wires to catch in stuff.

My Arduino toolbox now looks less like the lair of the Medusa and more like the ordered and categorised place I wish the rest of my house was. These little beauties are dirt cheap on eBay and come in every flavour including ethernet, hooray!

20130207-224110.jpg

20130207-224155.jpg

My First Robot

This is my first attempt at building a robot. I used PICAXE because I had one, and because the Arduino code looked a bit scary back then. He isn’t very clever but knows when something’s in front of his ultrasonic rangefinder. If there is, he backs up and turns left. Only left. For this reason, at a friend’s suggestion, he’s called Zoolander.

 

Accelerometer

Took delivery of a 3-axis MMA7361 accelerometer from the nice chap at http://www.hobbycomponents.com/ for the princely sum of £6.20, and ordered a cheapy from HK for good measure.

20130207-223859.jpg

Sparkfun had a data sheet so I plugged it in to my Arduino taking my best guesses and amazingly it worked first time! Little LED on and data on all 3 channels.

There are libraries available but I thought “how hard can it be” and wrote a really short sketch to display raw data over serial. It looks like this:

/*
Accelerometer Test
Context: Arduino
Reads data from the MMA7361
and prints the raw values to the serial port
*/

// define analog inputs for the 3 channels
const int xPin = A0;
const int yPin = A1;
const int zPin = A2;

// sleep and g scale select pins
const int sleepPin = 2;
const int gPin = 3;

// initialise variables for data
int xValue = 0;
int yValue = 0;
int ZValue = 0;

void setup() {
analogReference(EXTERNAL); // need to do this as using 3.3V from MMA7361 as reference
Serial.begin(9600); // start serial comms

// set pin modes for sleep and scale select, then write to them
pinMode(sleepPin, OUTPUT);
pinMode(gPin, OUTPUT);
digitalWrite(sleepPin, HIGH);
digitalWrite(gPin, LOW);
}

// read the values then write them to serial
void loop() {
int xValue = analogRead(xPin);
int yValue = analogRead(yPin);
int zValue = analogRead(zPin);
Serial.print(xValue);
Serial.write(": ");
Serial.print(yValue);
Serial.write(": ");
Serial.println(zValue);
Serial.write("\n");
delay(200);
}

The next step is to vconvert these to voltages, which will just be a case of multiplying 3.3V (the accelerometers logic, used as a reference for the Arduino) by the reading value / 1024.

Next will be getting a value of g out of it, claims 800mV/g in the 1.5g sensitivity mode so should be straightforward but I’m not sure how linear the response is. Soon find out!