Introduction: The Useless Alarmed Coke Can

About: Animation and CG enthusiast. Computer engineer in the free time.

Hi all!
This is the most useless project in the world! It consist in a Coke can attached to an Arduino trough a coaxial cable and two resistors that make a sound when an hand is near it.

Step 1: Materials and Tools

For make that I've used:

Materials:
-1x Arduino Uno Board (or equivalent)
-1x 270kOhm resistor
-1x 10kOhm resistor
-1x alligator clip (not in the photo)
- a piece of coaxial cable
- a short wire
-1x Piezo speaker
-1x rubber band (optional)
-1x full Coke can (not an empty one!)
-1x beer coaster
-2x A4 sheets of printer paper

Tools:
- scissors
- tape (of any sort, for example I've used insulating tape)
- glue stick
- fibre pen (not in the photo and optional: it' s for making the sign "FREE COKE")
- soldering iron with relative tools (not in the photo)

Step 2: Empty the Can

Take the can and, carefully, make a little hole on the bottom of it with the scissors. Let the gas come out and enlarge the hole. Then make an other one hole and make out the liquid in a glass. This is a VERY long process so be patient.

Step 3: Make the Circuit

How I've seen here, the human body is grounded, so the aluminum of the can and your hands make a sort of capacitor that has more capacitance as your hand is closer to the can.With Arduino we can know the time of charging of the "capacitor" and so the distance between the hand and the can. For make that, as you can see in the picture, we need a 270kOhm and a 10kOhm resistor, a coaxial cable and an alligator clip for connecting the Arduino to the can and a Piezo speaker for making sounds when an human body part is near the can. The making of cable for connecting the can with Arduino will be explained in the next step. For now connect only the positive(+) pin of the speaker to A0 on Arduino an the negative(-) to GND(Ground) (As you will see in next steps, i've added the rubber band for fixing the speaker to Arduino but it's mainly useless: it's an optional)

Step 4: Make the Cable

As first step you must solder one terminal of the 10kOhm resistor to the internal wire of the cable (Picture #1). Then solder the 270kOhm resistor to the internal wire where is soldered the 10kOhm and to the external shield (Picture #2 and #3). Solder to the external shield, where is the 270kOhm, a wire that will be linked to 5V pin on Arduino(Picture #3). On the other side of the coaxial cable solder the alligator clip to the internal cable (be careful to don't connect the external shield to the clip!!). If you want, you can put an heat shrink tubing on resistors and clip as I've done (Picture #4). Picture #5 shows the structure of a coaxial cable.

Step 5: Make the Pedestal of the Can

Now, you can simply connect the coaxial cable to Arduino and the can, but it isn't a nice solution. So, pick up a sheet of printer paper, make, on the longest side, an 1"-1.5" fold and past it's internal side. Continue to fold and paste the sheet until it looks like in picture #2 and #3. So, make an hole in the beer coaster with the scissors (not in the centre) and bond it to the folded sheet with a lot of piece of tape so that there is a big gap between the start and the end of the sheet, as shown in picture #5. After it, connect the free terminal of the 10kOhm resistor in our coaxial cable to Arduino's digital pin #8,  the wire starting from the shield of coaxial cable and 270kOhm resistor to 5V pin and insert the end of the alligator clip in the hole of the coaster (Picture #6). Put the coaster on the Arduino and insert the clip in the holes on the bottom of Coke can (Picture #7). It's done.

Step 6: Programming and Conclusions

This is the final step. Here, we will upload the sketch and hope that all is ok.
The sketch:

#define resolution 8
#define mains 50 // 60: north america, japan; 50: most other places

#define refresh 2 * 1000000 / mains

int minValue;

void setup() {
  //Serial.begin(9600);                          //DEBUG


  pinMode(8, INPUT);

  float temp;
  int i = 0;
  while(1){
    if(i==100)
      break;
    temp = temp + time(8, B00000001);
    //Serial.println(temp);                      //DEBUG
    i++;
  }

  minValue = temp / 100;
  //Serial.println(minValue);                    //DEBUG

}

int temp;

void loop() {       
  temp = time(8, B00000001);
  //Serial.print(temp);                          //DEBUG
  if(temp > minValue){
    tone(A0, 494);
    digitalWrite(A1,HIGH);
    //Serial.println("    ON");                  //DEBUG
  } else {
    noTone(A0);
    digitalWrite(A1,LOW);
    //Serial.println("    OFF");                 //DEBUG
  }
}

long time(int pin, byte mask) {
  unsigned long count = 0, total = 0;
  while(checkTimer() < refresh) {
    // pinMode is about 6 times slower than assigning
    // DDRB directly, but that pause is important
    pinMode(pin, OUTPUT);
    PORTB = 0;
    pinMode(pin, INPUT);
    while((PINB & mask) == 0)
      count++;
    total++;
  }
  startTimer();
  return (count << resolution) / total;
}

extern volatile unsigned long timer0_overflow_count;

void startTimer() {
  timer0_overflow_count = 0;
  TCNT0 = 0;
}

unsigned long checkTimer() {
  return ((timer0_overflow_count << 8) + TCNT0) << 2;
}


Essentially it's made of two parts: the setup and the loop. In the setup, that  stands for about 10 seconds, Arduino make the mathematical average between the values that receives during this while and set it as a "minimal value" (during those first seconds you must put your hand as near to the can as you want set the point where, after it, the alarm starts). In the loop, instead, Arduino read the current value and sees if it's bigger than the "minimal value": in this case the speaker will make a tone that will stop if only the value becomes smaller than the "minimal value". The "//DEBUG" lines are in case something comes wrong

The instructable is finished. Enjoy it. I'm sorry to all for my bad English: if you have any problems please leave a comment.

Hack It! Contest

Participated in the
Hack It! Contest