Sunday, May 22, 2011

SuperBlink

Now that I have had a chance to play around with various INPUTS and OUTPUTS, I think I need to show you some of my own creations. This is what is so good about Arduino. You can easily build from the experience of others, and introduce your own creative flair.

When I got my Arduino out of it's packaging, I did not know how fragile it was, I was so scared that I was going to break it. You'll soon find out that it is not as fragile as it looks, but I tend to treat it like an Egg anyway.

Getting Started:
Before you even plug your Arduino into your computer, you are going to need some software to program the little gizmo. Luckily the software is FREE ! Get it here.

Actually, I would recommend that you read the "Getting Started Guide" at the Arduino Web site: and follow the links for your operating system. I use Windows 7 - so this is the guide that I used - here.
I am not going to repeat all of that information, that would be a waste of time.

If you have read the guide, you would have played with the famous "Blink" program. Now its time to supercharge that sucker.


Blink THIS !!

Here is an Arduino sketch that requires the following components.
  • 10 x LEDs (5 Red, 5 Yellow)
  • 9   x 330 ohm resistors
  • 10 x wires to connect it all together.
The Sketch



The video:


The Arduino Code: (Updated Aug 2014)


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

/* ========================================================
       Project : SuperBlink
        Author : ScottC
       Created : 21st May 2011
   Description : A super-charged Blink program
============================================================
*/

void setup(){
  //Initialise the LEDPins to OUTPUT
  for(int i=4; i<14; i++){
    pinMode(i, OUTPUT);
  }
}

void loop(){
  redYellow(3);  //3 replicates of the redYellow sequence
  curtain(2);    //2 replicates of the curtain sequence
  fastSlow(2);   //2 replicates of the fastSlow sequence
}

void redYellow(int Reps){
  for(int k=1; k<(Reps+1); k++){
    for(int i=4; i<14; i=i+2){
      blink(i,200,20); //Call the blink method below
    }
    for(int i=13; i>3; i=i-2){
      blink(i,200,10); //Call the blink method below
    }
  }
}

void curtain(int Reps){
  for(int k=1; k<(Reps+1); k++){
    for(int j=1; j<257; j=j+j){
      int LEDCounter=1;
      int LEDSwitch=1;
      for(int ledPin=4; ledPin>3 && ledPin<14; ledPin=ledPin+LEDCounter){
        if(LEDSwitch){
          digitalWrite(ledPin, HIGH);
          delay(j);
        }else{
          digitalWrite(ledPin, LOW);
          delay(j);
        }
        if(ledPin>12){
          LEDCounter*=-1;
          LEDSwitch=0;
          digitalWrite(13, LOW);
          delay(j);
        }
      }
    }
  }
}

void fastSlow(int Reps){
  for(int k=1; k<(Reps+1); k++){
    for(int j=1; j<257; j=j+j){
      int LEDCounter=1;
      for(int i=5; i>3 && i<14; i=i+LEDCounter){
        blink(i, j, 10); //Call the blink method below
        if(i>12){
          LEDCounter*=-1;
        }
      }
    }
  }
}


void blink(int LEDPin, int LEDOnTime, int LEDOffTime){
  digitalWrite(LEDPin, HIGH);
  delay(LEDOnTime);
  digitalWrite(LEDPin, LOW);
  delay(LEDOffTime);
}

If you like this post please support me here:

Friday, May 20, 2011

Shopping List

If you have just heard about Arduino and are thinking about getting one, don't just buy the board on it's own. You don't buy a PlayStation / XBox without buying a game, and the same goes for the Arduino. If you just buy the Arduino by itself, you will get bored pretty quickly. In fact, I don't know why the Arduino doesn't automatically come with a breadboard, some wires and a few LEDs. Having said that, there are a few companies out there that have put together some pretty good kits.

I am not going to list them, because I am sure you know how to Google, and I am not going to tell you which one to buy, however I will tell you that I decided to buy the Sparkfun Inventor's Kit. You can work out which one suits you.

The Sparkfun inventor's kit not only comes with an Arduino UNO, but also a wide array of bits and pieces to muck around with. You can buy it in Australia from Australian Robotics.

•Arduino Uno USB
•Arduino and breadboard holder
•Printed 36-page Oomlout manual
•12 color circuit overlays
•Clear Bread Board
•74HC595 Shift Register
•2N2222 Transistors
•1N4148 Diodes
•DC Motor with wires
•Small Servo
•5V Relay
•TMP36 Temp Sensor
•Flex sensor
•Softpot
•6' USB Cable
•Jumper Wires
•Photocell
•Tri-color LED
•Red and Green LEDs
•10K Trimpot
•Piezo Buzzer
•Big 12mm Buttons
•330 and 10K Resistors
•Male Headers

The manual that comes with the kit is not the best manual in the world, but it does redirect you to a much more useful site online. I thoroughly recommend this kit for beginners. It will point you in the right direction, and once you start tinkering, there is no turning back. You won't stop talking about it. Totally awesome.

And when you get through the 12 sketches (and their recommended variations), you can't help but feel a sense of power. The power to create light, create sound, create movement, and the ability to discover the world around you like you never have before.

Regardless if you decide to buy a kit or not, there are a few individual items that are essential. If you don't buy them now, you will later on.
  • Multimeter
  • Soldering iron
  • Helping hands with magnifyer - good for holding that component / wire when you need a 3rd hand
  • Alligator clips
  • Breadboard
  • Wires - to connect your sensors/motors etc  (Male/Male wires) and (Female/Female wires)
  • LEDs
  • A button or a switch of some sort - preferably one that can be put on a breadboard.
  • Resistors (330K and 10K)
  • External Power supply for Arduino board :  to liberate your Arduino

Feel free to put a recommended kit in the comments.

Tuesday, May 17, 2011

From Blank to Blink

I have to start somewhere, so why not start NOW.
This blog aims to capture my journey of discovery as I dive head first into the world of electronics, armed with an Arduino in one hand and a borrowed multimeter in the other.

I aim to share my learnings with you, and not only highlight my successes, but also my failures.
I have a curious mind, so I hope I don't set anything on fire.
If you decide to follow in my footsteps, you do so at YOUR own risk.

I would prefer if you used me as an example of what NOT to do, but if I inspire you, please let me know.


Image made with Fritzing : http://fritzing.org