Power of the Arduino Dalek

It has been a while since I’ve messed with the Dalek project, so this is just a brief update of the minor twiddling I’ve done.

Firstly, the Dalek now has a USB Type B socket on the rear of the casing replacing one of the “Dalek Bumps”, as shown:

dalekusbAcquired from Maplin (part no N57FL), this USB Panel Mount Socket is reversible, with a Type A socket on one side, and a Type B on the other.

As a PC generally has a Type A socket, and the Arduino I’m using has a Type B socket, I opted to have the Type B on the outside.

This will allow the use of a normal A-B cable to connect between the PC and the case socket, and require a short A-B cable to connect between the case socket and the Arduino (as having a 3m cable curled round inside the thing seems a bit stupid).

Sadly, getting a short USB A-B cable isn’t easy. So I had to chop up an existing cable and butcher it.

usb-cable1

usb-cable2

Now, the Arduino can be left inside the Dalek case, which can be screwed shut again.

However, when the Arduino isn’t connected via the USB link, it loses power (tenuous link to the title of the post). Luckily, the Arduino Duemilanove that I’m using has a 2.1mm socket, and will run from a 9v battery.

So we need a PP3 9V battery clip, and a 2.1mm DC power plug.

powerparts

Solder the battery clip’s black wire to the outside connection of the plug, and solder the battery clip’s red wire to the centre connection of the plug.

For clearer instructions, and clearer pictures (I have a crap camera), see the relevant page at Arduino Playground.

powerlead

The yellow tape is not being used to hide a massive solder disaster this time, but merely to keep the wires together.

So, now I have a Dalek with a battery pack for the motors (from the original casing), a battery pack for the Arduino (ok, a PP3 taped inside), and a USB socket on the casing.

Now it can be programmed, unplugged, and be left to trundle into things.

So here is some code to make it wait for five seconds, spin right for one second, wait for two seconds, spin left for one second, and repeat for ever (or until the power is removed):

// Project: Dalek control system
// Version 0.2 - Sit and spin
// Tony Blews tony@tonyblews.co.uk

int MotorDirectionR = 10;
int MotorDirectionL = 11;
int MotorPowerR     = 12;
int MotorPowerL     = 13;
long randNumber;

void setup()
{
 pinMode(MotorDirectionR, OUTPUT);
 pinMode(MotorDirectionL, OUTPUT);
 pinMode(MotorPowerR, OUTPUT);
 pinMode(MotorPowerL, OUTPUT);
   randomSeed(analogRead(0));

}

// modes for the motor control
// convention here is modeXX - where X is F for forward, 
//S for stationary and B for backwards
// first X is the left motor, second X is the right one
// for direction control, the LOW if forward and HIGH is backward
// for power control, LOW is off and HIGH is on

// all stop
void modeSS()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,LOW);
 digitalWrite(MotorPowerL,LOW);
}

// spin left
void modeBF()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, HIGH);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

//spin right
void modeFB()
{
 digitalWrite(MotorDirectionR, HIGH);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

//main program loop
void loop()
{
delay (5000);
modeFB ();
delay (1000);
modeSS ();
delay(2000);
modeBF();
delay(1000);
modeSS();
}

The next step will be to install some sensors.

 

USB Panel Mount Socket

Leave a Reply