Monday, 30 September 2013

My lesson 1 mod. Flash 2 LEDs alternately.

After completing the 1st lesson I challenged myself to have two LEDs flashing alternately.

Hardware setup.

The hardware setup was straightforward and just needed another LED and an extra jumper wire. How I connected it al together.

Red lit.

Green lit.
  1. From digital pins 12 & 13 to LEDs +ve pins.
  2. LEDs -ve pins connected to ground rail.
  3. Ground rail connected to power ground pin.
  4. Done.

Software.

I built the sketch from scratch using the principals learnt in lesson 1.

// Example 01 Mod : Blinking LEDs : James Margarson 30/09/13 :
const int LED = 13; 
const int LED0 = 12;// LEDs connected to
                                   // digital pins 12 & 13
void setup()
{
pinMode(LED, OUTPUT);
pinMode(LED0, OUTPUT);// sets the digital
                                              // pins as outputs
}
void loop()
{
digitalWrite(LED, HIGH); // turns LED on
digitalWrite(LED0, LOW); // Turns LED0 off
delay(250);              // waits for 250 milliseconds
digitalWrite(LED, LOW);  // turns LED of
digitalWrite(LED0, HIGH);// turns LED0 on
delay(250);              // waits for 250 milliseconds
}

From the original example sketch I added a few extra lines of code highlighted to show my additions to control the flashing of the two LEDs.
video
The final result.

Friday, 27 September 2013

Getting started with my Arduino. Making a LED flash.

I recently bought myself an Arduino Uno board after hearing what can be done with one of these boards. Having no idea on how to program or the syntax of the Processing language.
I have got a copy of "Getting started with Arduino, 2nd Edition" by Massimo Banzi, ISBN: 978-1-449-309879, that makes learning the language easy explaining what code does what.

The 1st lesson in the book, Making a LED flash.

The 1st lesson is a simple introduction to using the hardware/software and a simple sketch (program) to make the LED flash. The hardware setup is very simple just an optional LED between pin 13 & ground is needed.
LED attached. Green light on, ready to go.
The sketch for the flashing LED is a introduction into the Processing language with a simple sketch that sets up an output and then runs a loop to turn the LED on and off as specified in the sketch.

The Sketch & my understanding of it

The first  sketch in the book was this simple sketch.

                    // Example 01 : Blinking LED
const int LED = 13;                    // LED connected to
                                                    // digital pin 13
void setup()
{
pinMode(LED, OUTPUT);        // sets the digital
                                                    // pin as output
}
void loop()
{
digitalWrite(LED, HIGH);         // turns the LED on
delay(1000);                             // waits for a second
digitalWrite(LED, LOW);        // turns the LED off
delay(1000);                            // waits for a second
}

How the sketch works.
 // - These are comments not read by the Arduino but are human readable notes, in this case used to describe the code.

const int LED = 13 - This means that LED is a number that can't be changed (constant integer), in this case LED is bound to digital pin 13.

void setup() - This tells the Arduino that the next block of code will be called setup()

{ } - Curly brackets are used to begin and end blocks of code

pinMode(LED,OUTPUT) - This sets the LED pin to be an output.

void loop() - This is for specifying the behaviour of the output, in this case it will repeat the code block until the Arduino is turned off. 

digitalWrite(LED, HIGH) - This turns on any pin that has been configured as an OUTPUT.

delay(1000) - This adds a delay of 1000ms before executing next command

digitalWrite(LED, LOW) - This turns off any pin that has been configured as an OUTPUT.


The sketch working.

I changed the on/off time to 50ms on/off as the 1 second flash rate was too slow. I just changed the delay command to delay(50) to speed it up.

The sketch in action.


Next Lesson: Using a push button switch to control the led.

Sunday, 22 September 2013

My new RF remote gadget.


My new 4 channel RF remote control gadget.


Nosing around Ebay the other week I came across a listing for a 4 channel RF remote control module and key fob remote,  http://www.ebay.co.uk/itm/181194171551  for only £2.57 with free delivery, so at that price I had to grab one.

The RF receiver module and it's remote.

The key fob remote.


Close up of the RF receiver PCB.



Board specifications.


I couldn't find any information online for the board but thank's to Nick, http://madmindcreations.blogspot.co.uk/, who came across this on a Ebay item page from a different seller.



Remote control
    Modulation method: Amplitude modulation
    Working voltage(V): DC5V
    The static current(mA): 4.5mA
    Working frequency(MHz): 315,433.92MHz(266-433MHz frequency can choose)
    Transmission distance: 50-100 meters(In the field of open receiver sensitivity  -100dbm)
    Encoder types: Fixed code
    Working temperature: -10 ? ~ +60 ?
    Receiving sensitivity (dBm) : -105DB
    With decoding receiver board
    1.The operating voltage DC5V, receiver sensitivity is -98db. Leg 7 bits, respectively, VT, D3, D2, D1, D0, the +5 V and GND. VT is a valid signal high output pin Upon receiving a valid signal, the pin output high, may also drive the relay.
    2.Size: 6.3*1.6*3.9cm/2.48"*0.63"*1.54"
    There are four buttons on the remote control, and respectively correspond to the four data bits to the receiving board output pin D0, D1, D2, and D3 of. Press the buttons transmit signals, the corresponding data bit is output high.

The remote in operation.

To give the remote a test I built a quick circuit up on breadboard and it worked perfectly.

All ready to test.


I used 4 blue LEDs hooked up to the outputs of the board to test the operation of each channel. Each LED already had the resistors soldered on from a previous project so it was just a case of jumpering the LEDs to the outputs and ground then hooking up a +5VDC power supply.

video

As each button on the fob is pressed the corresponding LED lights up to indicate the output of the receiver.

Conclusions.

For only £2.57 each these remotes are a bargain and can be used for so many things. I have even ordered a couple more to play around with as they will be handy for interfacing with my Arduino and Raspberry Pi.
I just got to decide on what to do with them now, some ideas I've had are for remote controlled household lighting, a light painting remote lighting effect controller and there's another secret project I'm working on that the remote will be perfect for.