You are here

Blink a LED

So far so good, you've been able to setup your Jaluino environment, let's now dive into this "Blink a LED" experiment. This will ensure your Jaluino board is working properly. At least to blink a LED...

How do you say "Hello" ?

Blinking a LED is somewhat the equivalent of a "Hello World" example, if you're familiar with software computing and programming language. "Hellow World" is supposed to be the simplest program, ever, which basically prints "Hello World", claiming to the whole world it's alive.

Printing something on a screen with a microcontroller isn't that simple.

In microcontrollers world, there's also a hardware part. So this "Hello World" example also has to be very simple on that side too. Blinking a LED seems to fit both hardware and software requirements of simplicity: not much parts, easy to build, easy to program, easy to check. Claiming to the world it's alive isn't as explicit as printing "Hello World" but watching a blinking LED should be enough.

Careful though: even blinking a LED can be a hair-pulling generator1. I hope you'll find enough information to pass this exam without getting bald.

Hardware setup

You have two options here:
  • Option 1: use a breadboard and connect parts to Jaluino with wires
  • Option 2: use Crumboard shield and plug it over Jaluino board

Option 1 will require several parts:

  • a breadboard
  • a LED, a red one is good
  • a resistor, from 330 to 1K

Basically, as simple as it can be, we'll plug a LED and a resistor to one of PIC outputs, as shown in the following schematic2.

Figure 1. Blinking a LED.

When assembling Jaluino and all these components on a breadboard, you should get something like this:

Figure 2. Option 1: blinking a LED, assembling the whole using a breadboard

Double check LED pin layout, be sure it's not inverted. Longest pin is the anode, it must be connected to pin RA0. Pin on the flat side is the cathode, it must be connected to the ground.

As option 2, if you're a lucky Crumboard shield owner, you can simply plug it over Jaluino and enable LEDs by putting jumpers on JP1 and JP2. You'll get two blinking LEDs for the same price...

Figure 3. Option 2: blinking two LEDs, using Crumboard shield

1 Have you correctly inserted the LED, respecting pin layout ? Do you know your LED as a working one ? Are you sure ? What about your board ? Any bad contacts ? Any power supply issue ? Was your program correctly uploaded ? Did you compile and upload the correct sample ? Did you forget to setup pin direction as output ? Does it blink too fast ? Too slow ? Irregularly ? Does it blink only when you touch the board ? Do you have to switch off lights in the room to make it blink ? Switch on ? Is your LED on strike ? Do you think you're victim of sabotage from your wife ? Worse, your cat ? Are you tired trying to make this LED blink for five hours ? Do you badly need a drink ?...
2 Schematic only shows relevant components for this experiment. Full Jaluino schematic is available at http://www.justanotherlanguage.org/content/jaluino/user_guide/jaluino_medium_schematics
3 and because this is the one I have...
4 If you're using another programmer, you can share your knowledge and post detailed instructions to the Jaluino Group, in order to improve this documentation.
5 We're actually using a modified version of original xwisp program. This modified version removes Windows specific dependencies and improve parameters handling. Don't use original version, you may face troubles.