Introduction: Banner With Mbed, Leds and a Cooler

This contest is almost over valentine´s day , and i know you love your wife (or girlfriend), resistors, leds, microcontrollers, and all that funny stuff, (in that order, i hope), so why don´t to put it all together!

This project has been done in a couple of days with the mbed platform that claims to be a "rapid prototyping board", i think is a really cheap device to make some funny things (like this project) if electronic design is your hobby, or rapid prototypes if your deadlines are very close in your job.

I´m from Argentina, and i hope you like this project and my first submit to instructables.

The main objetive is to make a banner with a cooler, some leds and an mbed microcontroller (if you like Arduino is very simple to replace it).


Step 1: Components Lists


- mbed microcontroller: http://www.sparkfun.com/products/9564
- 5 leds (the colour you like), red for valentine is perfect.
- 5 820ohm resistors.
- A protoboard (like http://www.sparkfun.com/products/8619 ), you can made your own, but remember the cooler is not very strong.
- A PC cooler (is better if you want to use a CC motor much stronger, but beware for the current consumption).
- A 9v battery.
- A plastic coke lid.

Step 2: The Leds Bar


1. Cut the Protoboard to obtain a 5mmx15mm rectangle.
2. Put the five leds in a row (just like in the picture) and solder them.
3. Solder  a wire to the Anode of each led

Step 3: The "main" Board

1. Cut the Protoboard to obtain a 50mmx50mm rectangle.
2. Solder the mbed microcontroller (or if you want to use it then for another project just use some pins, 20 for each side of the mbed board).
3. Add the 5 resistors (820ohm all of them) following the schematic.
4. Connect the 9v battery to Vin (pin2 in the mbed board).

Step 4: Put All Together


1. Solder the wires from the tiny board with the leds to the other side of the resistors (placed in the "main" board), according to the schematic (see the previous step).
2. Place and glue the tiny board with the leds in the border of the "main" board.
3. Place and glue the battery on the opposite side of the main board (to equilibrate the weigth).
4. Place and glue the "main" board on a Coke (Coca-Cola or similar) lid.
5. Place and glue the lid to the center of the cooler.
6. Download the "bin" to the microcontroller.
7. Turn on the cooler and call your wife or girlfriend to show her valentine´s day gift. :D

See the video in Vimeo: http://vimeo.com/19885081


Step 5: The Code

The compiler
One of the main advantages of the mbed platform is that you don´t need a compiler on your PC, there´s a "cloud" compiler (online).
First of all you must create an account on the mbed webpage (http://mbed.org/ ) and then you have access to the online cloud compiler.

The code
The code for this project is not very difficult, perhaps because the mbed platform has a lot of libraries ready to run.

#include "mbed.h"

//Defines the digital in/out ports
DigitalOut led1(p16);
DigitalOut led2(p15);
DigitalOut led3(p14);
DigitalOut led4(p25);
DigitalOut led5(p26);

//To the spanish valentine´s day message (replace it for your own)
#define MATRIX_LENGTH 11
#define MESSAGE_LENGTH 65

UINT8 heart_matrix[5][MATRIX_LENGTH]= {
{0,0,1,1,0,0,0,1,1,0,0},
{0,1,1,1,1,0,1,1,1,1,0},
{0,0,1,1,1,1,1,1,1,0,0},
{0,0,0,0,1,1,1,0,0,0,0},
{0,0,0,0,0,1,0,0,0,0,0}
};

UINT8 message_matrix[5][MESSAGE_LENGTH]={
{1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,1,0,1,0},
{1,1,1,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,1,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0},
{1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0}
};

int main()
{
    unsigned char flag_start;
    unsigned char cont;
    unsigned char image;
    unsigned char state;
   
    cont=0;
    image=0;
    flag_start=50;
    state=0;

    led1=0;
    led2=0;
    led3=0;
    led4=0;
    led5=0;
   
     while(1)
     {
          switch(state)
          {
                case 0:
                    switch(image)
                    {
                           case 0:
                               led1 = heart_matrix[0][cont];
                               led2 = heart_matrix[1][cont];
                               led3 = heart_matrix[2][cont];
                               led4 = heart_matrix[3][cont];
                               led5 = heart_matrix[4][cont];
 
                               cont++;
                               if(cont>=MATRIX_LENGTH)
                               {
                                   cont=0;
                                   image=1; //Switch to another image
                               }
                               break;
 
                         case 1:
                              led1 = message_matrix[0][cont];
                              led2 = message_matrix[1][cont];
                              led3 = message_matrix[2][cont];
                              led4 = message_matrix[3][cont];
                              led5 = message_matrix[4][cont];
 
                              cont++;
                              if(cont>=MESSAGE_LENGTH)
                              {
                                   cont=0;
                                   image=0; //Switch to another image
                                   state=1;
                               }
                               break;
                       }

                      case 1:
                          if(flag_start>0)
                          {
                               flag_start--;
                          }
                          if(flag_start==0)
                          {
                              flag_start=80;
                              state=0;
                          }
                          break;
           }
          
           //Wait 3ms to change the leds on/off, this time depends the wider the letter
           wait_ms(3);
     }
}