Feedback!

Heartduino

Views: 2555 Difficulty: 2 Status: Development
Heartduino_main

The heartduino is a heart-shaped arduino clone complete with onboard sensors and a 70 pixel LED matrix.

A fully-functioning Arduino-clone shaped like a heart, ready to be worn, and complete with an LED display, as well as temperature, light, and sound sensors. You can get one at our store. This is a stand-alone version of our Heart Matrix LED display with an arduino-clone ATMEGA328p and a bunch of sensors. It is great if you don't have an Arduino yet, but want to start soldering. The same code can run the Heartduino and the Heart Matrix, so all our other Heart Matrix tutorials will work. Just download our Heart Matrix Arduino Library to get it running. You can connect the LED Display to twitter, use it to display sound waves, control it wirelessly with an XBEE, or make it into a love clock!

Kit Contents

Kit_white
Here you see everything that comes in the heartduino kit. Check the parts list below for the specifics.

Heartduino The Heart-Shaped Arduino Clone Video

The Heartduino has an on-board electret microphone for sound-sensing with the audio amplifier LM386 chip, as well as a TMP36 temperature sensor, buttons and a potentiometer.

Step-by-Step Instructions

Step 0 Get The Heartduino DIY Kit

First, get yourself a Heartduino kit at the LucidTronix store. You will also need a soldering iron, solder, pliers and wire cutters or cutting pliers. Some scotch tape and a damp sponge to clean your iron will also be handy. Make sure your soldering area is well-ventilated and use eye-protection when cutting metal with the wire cutters.

Step 1 Insert all 10 ohm resistors

Insert all the 10-ohm resistors. Their are 11 slots, but you should have 12 in the kit, in case one gets misplaced. The 10 ohm reistors have a brown band follow by two black bands and then a gold band. Resistors are symmetric so the orientation you insert it in doesn't matter.

Step 2 Insert all 10K resistors

Now insert the 10K-ohm resistors, in their 10 slots. The 10K resistors have color bands brown black orange and then gold. The orange stands for the 3rd exponent of ten, and the brown and black make 10, so we end up with 10,000 ohms. More about resistor color codes here.

Step 3 Solder the resistors down

Now you can solder the resistors in place. Feel free to solder them on the same side you inserted them, as shown in the image. This way you wont mess up the nice clean white of the silkscreened circles.

Step 4 Insert and solder Thumb wheel Potentiometer

Now is a good time to insert the thumbwheel potentiometer. It is the black and white knob looking thing with the philips-head screw scores on its front, and three pins coming out. You definitely need to insert this before you solder the shift registers down, otherwise you wont be able to reach the pots pins to solder.

Step 5 Clip the Thumbwheels pins

Make sure to clip the pins of the thumbwheel with your cutting pliers after it is soldered down. Otherwise those pins will prevent the 74HC595 shift register from fitting snugly in its footprint.

Step 6 Insert and Solder 74HC595 Shift Registers

Speaking of the 74HC595 shift registers, lets go ahead and insert those guys and solder them down. These are the 3 ICs in the kits with two rows of 8 legs. Keep in mind you may want to pinch those rows of pins together with a ruler or a stapler before you try to insert them in the PCB. Also here orientation DOES matter. The silkscreened 1 on the PCB has to match up with pin one on the IC. Pin 1 is the pin directly to the left of the U-shaped depression at the top of the shift register. Use the image as a guide.

Step 7 Insert the LM386 Audio Amplifier Chip

Now to make the Heartduino sound-sensitive we msut amplify the small signal from the electret microphone. We use the LM386 audio amplifier to do this. This chip has 8 legs in two rows of four. Pinch those rows together and insert the LM386 so that the circular depression at top left lines up with the '1' silkscreened on the PCB.

Step 8 Insert the 16Mhz Crystal

For the arduino to keep up with the constant updates of the LED dot matrix we need a quick heart beat for our circuits brain.. The silver 16Mhz crystal oscillator gives the nice steady clock signal to our Atmega328 MCU.

Step 9 Insert the 22pf Capacitors

Now insert the 22 pico farad capacitors on either side of the crystal. These yellow capacitors have the number 220 printed on them. Their legs are bent into corners that you may want to straighten to more easily slip them into the PCB. These guys help maintain a nice steady clock signal. Engineer's Secret: sometimes you can get away without these caps, but its a good idea to have them just in case.

Step 10 Now add the 10uf and 0.047uf capacitor

The 10uf capacitor is blue. You may have a ceramic one or a little radial electrolytic one, both work fine. The 0.047 capacitor is yellow with corner-bent legs and the number 473 printed on it.

Step 11 Last Capacitors: 0.1uf

Finally, insert you two yellow 0.1uf capacitors. These guys have the numbers 104 on onse side and 232 on the other. They are yellow with straight legs.

Step 12 Chop Off Their Legs!!

Now, time to be an electronic lumberjack and chop all those metal legs of with your cutting pliers. Use eye-protection and gloves.. Be careful friends!

Step 13 Insert the first LED matrix in the Correct Orientation.

Insert one of the LED matrices in the orientation shown in the photo. The matrix must be on the same side of the PCB as the silkscreen and the letters printed on the side of the PCB should be facing the same way as the image shows.

Step 14 Insert the other LED Matrix in the Same Orientation.

Now insert the second LED Dot Matrix in the same orientation as the first one.

Step 15 Tape the matrices down

This step is optional, but its a good idea to tape the LED matrices down so that they aligned together nicely before you solder them in. After they are soldered, it will be difficult to fix a small gap between them.

Step 16 Insert the MODE and SELECT buttons

Insert the two buttons under the silkscreened labels 'MODE; and 'SELECT'. The buttons have four legs and a little black circular depressor.

Step 17 Insert the switch and the Electret Condenser Microphone

Now place the power switch and the electret condenser microphone into their proper spots as shown in the labelled image and solder them down.

Step 18 Last Step: battery clip and Battery Pack

Almost done!! Just pop the little white plastic JST battery connector in the spot labelled at the Heartduino's side. Load the battery pack with 3, AAA batteries and get ready for some wearable electric bling! Congratulations! If you got the kit from us, your Atmega has been pre-programmed with the code below. If you are rolling your own, than you will need to upload the code onto the Atmega328, using the 6 ISP pins. Either way, if you want to hack the Heartduino use the code below as a starting point.

Heartduino Arduino Code for Sound Sensing, Text Display, and Temperature Sensing

This code has three modes: sound sensing, text display, and temperature sensing. We use the mode variable to shift between the three modes. The sound mode shows the pixel level access that our Heart Matrix library gives you. You will need the FrequencyTimer2 library and our Heart Matrix Arduino library which you can download here, at the original Heart Matrix Tutorial.
/* LucidTronix write messages on the Heart Matrix.
 * For instructions details and schematic, See:
 * http://www.lucidtronix.com/tutorials/18
 * Connect the data, latch, and clock pins
 * to the corresponding pins on the heart matrix
 */

#include <FrequencyTimer2.h>
#include <HeartMatrix.h>

// dataPin is on 2, Latch is on 3, and clock is on 4
HeartMatrix hm = HeartMatrix(3,4,5);

const int buffer_size = 10;
int noises[buffer_size];

const int num_cols = 12;
int volumes[num_cols+1];
int cur_index = 0;
int mode = 0;
int btn1 = 6;
unsigned int last_shift = 0;

void setup() {
   FrequencyTimer2::disable();
   // Set refresh rate (interrupt timeout period)
   // if things break try making this number bigger
   FrequencyTimer2::setPeriod(2000);
    // Set interrupt routine to be called
   FrequencyTimer2::setOnOverflow(displayer2); 
   pinMode(btn1, INPUT);
   for (int i = 0 ; i < num_cols+1; i++) volumes[i] = 7;
   
  

}

void loop() {
  if (mode==0){
   // read the value from the sensor:
   cur_index = (cur_index + 1) % buffer_size;
   noises[cur_index] = analogRead(1) ;
   int var = variance(noises, buffer_size); 
   if (millis() - last_shift > 40){
     last_shift = millis();
     for (int i = 1 ; i < num_cols+1; i++){
      volumes[i-1] = volumes[i];
     }
   }
   volumes[10] = constrain((var / 45), 0, 8);
   for (int i = 0 ; i < num_cols; i++){
     for (int j = 0 ; j < volumes[i]; j++){
       hm.set_pixel(i, j, true);  
     }
     for (int j = volumes[i] ; j < 8; j++){
       hm.set_pixel(i, j, false);  
     }
   }   
   delay(40);
  } else if (mode == 1){
    hm.on();    
  } else if (mode == 2){
    hm.on(); 
    int temp_in = analogRead(2);
    float voltage = 4.0*temp_in;
    voltage /= 1024;
    float celsius = (voltage - 0.5) * 100 ; 
    float fehrenheit = ((9.0/5.0)*celsius) + 32;
    String temps = "Celsius:" + String((int)celsius) + "  Fehrenheit:"+ String((int)fehrenheit);
    hm.set_message(temps);
  }
  if (digitalRead(btn1) == HIGH){
    if ( mode == 0){
      hm.set_message("Hello I'm the Heartduino");
      mode = 1;
    }else if ( mode == 1){
      mode = 2;
    }
    else if ( mode == 2){
      hm.animate();
      mode = 0;
    }
    delay(500);
  }
}

void displayer2(){
  hm.displayer();
}

int average(int* array, int length){
  int sum = 0;
  int i;
  for(i = 0; i < length ; i++){
    sum += array[i];
  }
  int avg = sum / length ;
  return avg;
}
int variance(int* array, int length){
  int dif_sum = 0;
  int i;
  int mean = average(array, length);
  for(i = 0; i < length ; i++){
    dif_sum += (abs(array[i] - mean));
  }
  int var = dif_sum / length ;
  return var;	
}
20120519_163335 sam: Download link up...
Missing_profile nomadchris: When I try to ve...

Parts

Title Description # Cost Link Picture
PCB Heartduino Standalone heart matrix arduino clone PCB. 1 $9.0 Link Screen_shot_2013-04-03_at_12.31.10_am
ATMEGA168A-PU IC MCU AVR 16K FLASH 28PDIP Value: 16KB (8K x 16) 1.8 V ~ 5.5 V 1 $2.54 Link Screen_shot_2012-12-28_at_7.40.44_pm
Temperature Sensor TMP36 IC SENSOR TEMP 2.7/5.5 TO-92-3 Value: 2.7 V ~ 5.5 V -40°C ~ 125°C 1 $1.42 Link To-92-3(standardbody)_to-226_straightlead
LED Dot Matrix Displays Dot Matrix Panel 35LED Green Row CA Column CC 12-Pin DIP Value: 2.8v Green 2 $0.99 Link 2005497
Electret Condenser Microphone MIC COND ANALOG OMNI -44DB Value: -44dB ±2dB 20Hz ~ 20kHz 1 $0.96 Link Screen_shot_2012-12-28_at_7.35.36_pm
LM386 IC AMP AUDIO PWR .325W MONO 8DIP Value: 4 V ~ 12 V 1 $0.93 Link 8-dip
Potentiometer POT ROTARY, Linear 10K OHM 9MM SNAPIN Value: 10k 1 $0.76 Link Screen_shot_2012-12-28_at_7.41.04_pm
Shift Register IC 8-BIT SHIFT REGISTER 16-DIP Serial to Parallel Tri-State 2 V ~ 6 V Value: 74HC 3 $0.63 Link Screen_shot_2012-12-28_at_7.40.34_pm
Capacitor Ceramic Capacitors CAP CER 0.1UF 50V 20% RADIAL Value: 0.1µF 1 $0.24 Link Screen_shot_2012-12-28_at_7.39.17_pm
Button 6mm Through Hole Tactile Switch Through Hole SPST-NO 0.05A 12V Value: 0.05A @ 12VDC 2 $0.1 Link Screen_shot_2012-12-28_at_7.41.40_pm
Resistor RES 10K OHM 1/4W 5% CF MINI Value: 10k 5 $0.08 Link Screen_shot_2012-12-28_at_7.28.15_pm
Resistor RES 10 OHM 1/4W 5% CARBON FILM Value: 10 10 $0.08 Link Screen_shot_2012-12-28_at_7.27.43_pm
Permalink: http://lucidtronix.com/tutorials/34
Combine an electret microphone, Arduino and a heart matrix for a sound-sensitive wearable device....
Two LED matrices give 70 LEDs to light up a necklace with messages....
Connecting the DS1307 real-time clock chip and our Heart Matrix you can show the time with love....
Control the Heart Matrix LED display wirelessly, using XBEE radio modules....
Rainbow flower necklace using the TLC5940....
Wearable digital compass displays the direction in green LEDs....
The Wearable Wayfinder is a totally programmable, beautiful little computer for your wrist packed wit...
Standalone programmable Heart-Shaped LED display....