Making some progress???

So here’s what I’ve got going so far…it doesn’t look like much right now, but it will make a huge difference once I actually have it all set up in the real trash bin I intend to use. Right now I’m just trying to get everything to work.

I’ve go the IR sensors detecting which bin (recycling or waste) was used, and the Winbond chip changes tracks and plays back the appropriate sound depending which side was just used. I’m having a bit of a problem with the Windbond chip, though. When it needs to change tracks it won’t play back the sound after it has moved forward. It’ll only play the sound the next time that side of the bin is used. I can’t figure out how to fix it in my code, but I don’t think it’s a huge problem…just strange. My code is posted at the end of this blog post.

I also have the Arduino counting how many times each side has been used. A green or yellow LED will light up when one side is used more than the other (green = you’ve recycled more, yellow = you’ve wasted more).

Alos, I assembled my XBee transceivers. It took FOREVER to solder everything – I even got injured in the process (one of the pins got shoved under my fingernail…awesome.). I haven’t set them up to work yet…but that’s going to happen in the next day or two. For now, all data from the bin can be seen through the serial reader in Arduino. I’ve posted a screenshot of it below.

Lastly, I started playing with some big FSR’s to use as a rough scale/weight measurement for now. Next task for me is to figure how I’m going to normalize their numbers in my code…I have no clue how I’m going to do that…

Here’s some pics:


The inside of my ‘bin’…not pretty, but semi-functional at least!




Had to show off my awesome soldering job…male and female header pins all in a row, just so I can mount a silly XBee on it.


Screen shot of Arduino serial reader showing my bin data…with some lovely notes included in red.
PING Documentation from Katrina Bekessy on Vimeo.

Current problems I’m having:

-getting my Windbond chip to change tracks and play back the sound right after
-normalizing my FSR inputs to numbers that actually mean something
-keeping the stupid IR sensors consistent. Everytime I turn them on they start with different readings than before

Next things I need to do:

-include FSR’s and photoresistor (for lid of bin) with rest of my circuit using a multiplexer
-get XBee’s to send bin data to computer wirelessly
-build working circuit into actual trashbin
-refine code to make readings more accurate

Am in way over my head? Yes, yes I am…

Here’s my long Arduino code thus far. I’m sure it could be written much more succinctly/efficiently…

#define NUMREADINGS1 10
#define NUMREADINGS2 10
#define NUMREADINGS3 10
#define NUMREADINGS4 10

int readings1[NUMREADINGS1];
int index1 = 0;
int total1 = 0;
int average1 = 0;

int readings2[NUMREADINGS2];
int index2 = 0;
int total2 = 0;
int average2 = 0;

int readings3[NUMREADINGS3];
int index3 = 0;
int total3 = 0;
int average3 = 0;

int readings4[NUMREADINGS4];
int index4 = 0;
int total4 = 0;
int average4 = 0;

int IR1 = 0;
int valIR1 = 0;

int IR2 = 1;
int valIR2 = 0;

int IR3 = 3;
int valIR3 = 0;

int IR4 = 4;
int valIR4 = 0;

boolean readBin = true;

int playPin = 2;
int fwdPin = 3;
int trackCount = 1;

int wasteCount = 0;
int recCount = 0;
int greenLED = 4;
int yellowLED = 5;

void setup()
  pinMode(playPin, OUTPUT);
  pinMode(fwdPin, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  for (int i = 0; i < NUMREADINGS1; i++){
    readings1[i] = 0;
  for (int j = 0; j < NUMREADINGS2; j++){
    readings2[j] = 0;
  for (int h = 0; h < NUMREADINGS3; h++){
    readings3[h] = 0;
  for (int k = 0; k < NUMREADINGS4; k++){
    readings4[k] = 0;

void loop()
  digitalWrite(fwdPin, HIGH);
  digitalWrite(playPin, HIGH);
  if(readBin == true){
    total1 -= readings1[index1];
    readings1[index1] = analogRead(IR1);
    total1 += readings1[index1];
    index1 = (index1 + 1);
    if (index1 >= NUMREADINGS1){
      index1 = 0;
    average1 = total1 / NUMREADINGS1;
    total2 -= readings2[index2];
    readings2[index2] = analogRead(IR2);
    total2 += readings2[index2];
    index2 = (index2 + 1);
    if (index2 >= NUMREADINGS2){
      index2 = 0;
    average2 = total2 / NUMREADINGS2;
    total3 -= readings3[index3];
    readings3[index3] = analogRead(IR3);
    total3 += readings3[index3];
    index3 = (index3 + 1);
    if (index3 >= NUMREADINGS3){
      index3 = 0;
    average3 = total3 / NUMREADINGS3;
    total4 -= readings4[index4];
    readings4[index4] = analogRead(IR4);
    total4 += readings4[index4];
    index4 = (index4 + 1);
    if (index4 >= NUMREADINGS4){
      index4 = 0;
    average4 = total4 / NUMREADINGS4;
    if(average1 > 365 || average2 > 365){
      readBin = false;
      recCount ++;
      if(trackCount == 1){
      } else {
        digitalWrite(fwdPin, LOW);
        digitalWrite(fwdPin, HIGH);
        trackCount = 1;
    if(average3 > 365 || average4 > 365){
      readBin = false;
      wasteCount ++;
      if(trackCount == 2){
      } else {
        digitalWrite(fwdPin, LOW);
        digitalWrite(fwdPin, HIGH);
        trackCount = 2;
  if(recCount > wasteCount){
    digitalWrite(greenLED, HIGH);
    digitalWrite(yellowLED, LOW);
  else if(wasteCount > recCount){
    digitalWrite(yellowLED, HIGH);
    digitalWrite(greenLED, LOW);
  else {
    digitalWrite(yellowLED, LOW);
    digitalWrite(greenLED, HIGH);

void playBack(){
  digitalWrite(playPin, LOW);
  digitalWrite(playPin, HIGH);
  readBin = true;