Servo Motor

The code for the servo motor.


#include <Servo.h>
Servo servoRight; // Define right servo

int angle = 0; // servo position in degrees
void setup() {

servoRight.attach(9); // Set right servo to digital pin 9


void loop() { // Loop through motion tests

delay (1500); // Example: move forward

delay (1500); // Example: move forward

// Motion routines for forward, reverse, turns, and stop
void forward() {


void reverse() {


Setting up a servo is extremely easy. The red cable is for power, black for ground and white for signal. An easy setup for servo’s is 5v into the breadboard, power and ground go into the relevant pins and signal will go into a digital output say pin 9.


Happy Accident

While working on the PWM project, I changed one part of the code which was the

redValue = max(0, min(redSensorValue * 1.4 – 840, 255));

greenValue = max(0, min(greenSensorValue * 0.9 – 400, 255));

blueValue = max(0, min(blueSensorValue * 0.8 – 250, 255));



// redValue = redSensorValue 255;
// greenValue = greenSensorValue 255;
// blueValue = blueSensorValue 255;


What this does is blink the light red and blue depending on light source,  and stops when covered.

Example here:

PWM (Pulse Width Modulation)

Using PWM to create a three colour light sensitive LED.

To create this project I striped the board apart from the red power cable and the black ground cable connected between the Arduino board and breadboard. Then I added:

Three photo-resistors one for green, blue and red.  These when then attached to grounding resistors (10K), analogue A0,A1,A2 pins and power from the opposite side of the board by a wire attached across one end to the other.

Next was to add the Multi-colour LED ( cathode) which has a Red pin, then the cathode pin (for grounding), then the Blue and Green pins.  Once in each pin has to be powered by a Digital PWM pin (3,9,10,11,12) or any pin with a tilde sign ~  and then each grounded by 220 ohms…..code time.

Here is an image of my code working and the project working.

WP_20140529_023 WP_20140529_024 WP_20140529_025WP_20140529_026

Temperature guage

Creating a temperature gauge with 3 LED’s and a TMP analogue temperature sensor.

Screen Shot 2014-05-29 at 14.18.31

Here is my code working with the Serial monitor showing up the value, voltage and the degrees (C).

To make this project work I setup up once again 3 LED’s but this time set them up too connect to a photo resistor which when hit a certain degree in temp would turn on each of the LED’S.


LED StarShip

Screen Shot 2014-05-29 at 12.14.34

Here is my code for this project (not I added an extra delay function so that there is a time delay between the last red light and the green.

To create this project i connected up 3 led’s that would trigger once the push button was activated. it would then go from a green light to a red then to the second red and back to green.

this worked by using delay statement which acts as a timer for high and low pins.

WP_20140529_011 WP_20140529_012 WP_20140529_013 WP_20140529_014

Lesson 4 (LED)

The last LED lesson was to have both buttons light up the LED individually. To do this you have to change the circuit so that the buttons get power through the resistor individually, so a wire goes from the resistor to the second button (as the first button is already inline with the resistor it is getting power) then we connect the first button with the large leg of the LED and the second button with the large led on the LED, the small leg still just connected to the ground and done.

We have both buttons connected individually to the  LED.

Lesson 3 (LED)

Next step was to see exactly how the circuit worked. By placing another button on the breadboard and connecting it within the circuit we now have to press both buttons for the LED to light up.

Note: i just moved the LED down a few slots and placed a wire from button to button then to the longer leg of the LED.






Lesson 2 (LED)

WP_20140529_007 WP_20140529_008

Adding a resistor 220ohms (how to calculate between the different resistors will be posted soon) to a power slot in the breadboard and any prototyping slot, followed by the adding of a button (in the centre of the board, and an LED (anywhere within the prototyping area with power).

Next I added a ground wire from the (-) to a slot inline with the small leg of the LED (has to be inline with the LED otherwise it won’t be grounded) and another wire from button to the longer leg of the LED to complete the circuit.

Now when you plug in the Arduino board and press the button it lights up.

Lesson 1 (LED)

Setting up the Arduino. Quick and easy set-up, followed by the first lesson. Creating an L.E.D blink. Using the RED cable as power from the power pin in the Arduino board to the power (+) in the breadboard to give the circuit power and the BLACK cable as the grounding cable from the grd pin in the Arduino board to the ground (-) on the breadboard.