The Start


Hi, What and Why

Plug it in

Rule number 1

Water Sensor

Sound Sensor

Joystick

Tri Colour LED

RTC (Real Time Clock) DS1302

RTC (Real Time Clock) DS3231

Matrix LED step 1

LCD

Stepper Motor

LCD revisited with PCF8574T

Humidity Sensor

Shift Register

RFID tags (RC-522)

7 Segment display

Ultrasonic distance sensor

5V regulator

analogRead and analogWrite

Wiring an Array of Switches

The next step


Other things I have bought

Infra red and Processing

Programming a separate arduino chip

Creating your own PCB

L293D for a DC motor

4 digit 7 segment display

Starting with motors

RF433 Wireless Comms

Sort a character array

More stuff


I2C devices (SDA,SCL)

I2C scanner

SPI devices (MOSI,MISO)

HMC5883L Compass

MMA7361 Accelerometer

Added projects


Message Display System

4WD robot car
4WD robot car II

4WD robot car COMPLETE

MP3 Player

A 4WD remote controlled car part II

The car was going; forwards, backwards and at two speeds. The code was an extension of a tutorial and needed to be rewritten for easier development.
The next step was experimenting with turns, and using LEDs for 2 x reverse lights, 2 x brake lights, and 4 x indicators.

The turns were hugely successful; stopping the wheels on one side made it spin on a sixpence. The code is below.

Shift register

The other thing required was to use a shift register, to reduce the # of arduino pins. The speed controls had to use the PWM pins, but the L293D inputs could be put to the shift register. Here is the code post-tutorial.

/*
 4WD Car chassis.
 Paul Goodliffe, May 2014
 */
 
 
//L293 Pin assignments

const int FULL       = 255;
const int SLOW       = 0;

//Motor one
int m1_enable        = 3;  // Must be PWM for speed control
int m1_forward       = 2;  
int m1_backward      = 4;   

//Motor two
int m2_enable        = 5;  // Must be PWM for speed control
int m2_forward       = 7;   
int m2_backward      = 6;  
//Motor 3
int m3_enable        = 10;  // Must be PWM for speed control
int m3_forward       = 8;
int m3_backward      = 9;

//Motor 4
int m4_enable        = 13;      // Must be PWM for speed control
int m4_forward       = 12;
int m4_backward      = 11;


void setup(){
  pinMode(m1_enable, OUTPUT);  //Set the three pins for bridge 1 & 2 to outputs
  pinMode(m1_forward, OUTPUT);
  pinMode(m1_backward, OUTPUT);

  pinMode(m2_enable, OUTPUT);  //Set the three pins for 3 & 4 to outputs
  pinMode(m2_forward, OUTPUT);
  pinMode(m2_backward, OUTPUT); 
  
  pinMode(m3_enable, OUTPUT);  //Set the three pins for bridge 1 & 2 to outputs
  pinMode(m3_forward, OUTPUT);
  pinMode(m3_backward, OUTPUT);

  pinMode(m4_enable, OUTPUT);  //Set the three pins for 3 & 4 to outputs
  pinMode(m4_forward, OUTPUT);
  pinMode(m4_backward, OUTPUT);  
}

void loop()
{
  setMyspeed(FULL);
  goForwards();
  delay(1000);
  goBackwards();
  delay(1000);
  
  turnLeft();  // WOW ! Turns on a ninepence !!
  goForwards();
  delay(1000); // 1 second of max turn is about 180 deg :-) )

  turnRight();
  goBackwards();
  delay(1000);

  turnLeft();
  goForwards();
  delay(1000);

}

void turnLeft()
{
brakeAll();
setLeftSpeed(SLOW);
setRightSpeed(FULL);
}
void turnRight()
{
brakeAll();
setLeftSpeed(FULL);
setRightSpeed(SLOW);
}

void setLeftSpeed(int newSpeed)
{ // Motors : Front is 2 and 1. Rear is 3 and 4. Left is 2 and 3. Right is 1 and 4.
  analogWrite(m2_enable, newSpeed);
  analogWrite(m3_enable, newSpeed);
}
void setRightSpeed(int newSpeed)
{ // Motors : Front is 2 and 1. Rear is 3 and 4. Left is 2 and 3. Right is 1 and 4.
  analogWrite(m1_enable, newSpeed);
  analogWrite(m4_enable, newSpeed);
}


////// Motor One Routines  ////////////
void goForwards()
{
  brakeAll();
 digitalWrite(m1_forward, LOW); 
 digitalWrite(m1_backward, HIGH); 
 digitalWrite(m2_forward, LOW); 
 digitalWrite(m2_backward, HIGH); 
 digitalWrite(m3_forward, LOW); 
 digitalWrite(m3_backward, HIGH); 
 digitalWrite(m4_forward, LOW); 
 digitalWrite(m4_backward, HIGH); 
}

void goBackwards()
{
  brakeAll();
 digitalWrite(m1_forward, HIGH); 
 digitalWrite(m1_backward, LOW); 
 digitalWrite(m2_forward, HIGH); 
 digitalWrite(m2_backward, LOW); 
 digitalWrite(m3_forward, HIGH); 
 digitalWrite(m3_backward, LOW); 
 digitalWrite(m4_forward, HIGH); 
 digitalWrite(m4_backward, LOW); 
}   

void setMyspeed(int newSpeed)
{
  analogWrite(m1_enable, newSpeed);
  analogWrite(m2_enable, newSpeed);
  analogWrite(m3_enable, newSpeed);
  analogWrite(m4_enable, newSpeed);
}

void brakeAll()
{
 digitalWrite(m1_forward, LOW); 
 digitalWrite(m1_backward, LOW); 
 digitalWrite(m2_forward, LOW); 
 digitalWrite(m2_backward, LOW); 
 digitalWrite(m3_forward, LOW); 
 digitalWrite(m3_backward, LOW); 
 digitalWrite(m4_forward, LOW); 
 digitalWrite(m4_backward, LOW); 
 delay(500); // Give the motors time to react
}   		
		
My 4WD car chassis kit.
The chassis has the protecting layer on at the mo.
4 motors, one already fixed in. 4 wheels.

There's also another 'wheel' to attach inside the chassis, that you can just see. I think it can be used for measuring distance. More on that later.
4WD car kit