Making Things Interactive

March 6, 2008

Midterm – Interactive Indo Board

Filed under: 7: Mid-Term Project,Assignments,Thomas Hendrickson — tphendrickson @ 9:33 pm

For my midterm project I remained with my original idea of adding interactive elements to my indo board. I originally had thought that my additions would reflect how many times the board was tipped, but realized that it is much more challenging (and more of a workout) to focus on keeping the board as flat as possible.

I used 18 LEDs in 9 columns of 2, in three different colors. Each column is controlled by a digital output on the arduino. The outputs are based on the status of two separate rolling ball tilt switches that are attached to the indo board. Each tilt switch reads if the board is tilted a certain amount on either side. If kept completely horizontal, the tilt switches are activated at 30 degrees, so the switches must be altered a little (bent less horizontal) so that it is feasible to keep the board level long enough to light up the LEDs.

The switches each complete a circuit that act as inputs to the arduino, and the LEDs light up (green to yellow to red) based on how long the switches are NOT activated. When the switches are not activated, that implies that the indo board is balanced. Each LED column lights up a second after the last one has lit up. A ‘while’ statement in the code checks that both switches are not activated, a counter increments every half second however long the switches are not activated, and a series of ‘if’ statements light up the LEDs based on the counter value.


int runPin = 13;      //arduino LED light
int ledPin_1 = 12;    //LED pins
int ledPin_2 = 11;
int ledPin_3 = 10;
int ledPin_4 = 9;
int ledPin_5 = 8;
int ledPin_6 = 7;
int ledPin_7 = 6;
int ledPin_8 = 5;
int ledPin_9 = 4;
int switchPin_1 = 2;  //tilt switch inputs
int switchPin_2 = 3;
int switchStatus_1;
int switchStatus_2;
int counter;   

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin_1, OUTPUT);
  pinMode(ledPin_2, OUTPUT);
  pinMode(ledPin_3, OUTPUT);
  pinMode(ledPin_4, OUTPUT);
  pinMode(runPin, OUTPUT);
  pinMode(switchPin_1, INPUT);
  pinMode(switchPin_2, INPUT);

}

void loop()
{
    counter = 0;

    digitalWrite(runPin, LOW);    //everything is turned off at the start of the loop
    digitalWrite(ledPin_1, LOW);
    digitalWrite(ledPin_2, LOW);
    digitalWrite(ledPin_3, LOW);
    digitalWrite(ledPin_4, LOW);
    digitalWrite(ledPin_5, LOW);
    digitalWrite(ledPin_6, LOW);
    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_8, LOW);
    digitalWrite(ledPin_9, LOW);

    switchStatus_1 = digitalRead(switchPin_1);
    switchStatus_2 = digitalRead(switchPin_2);

    while ((switchStatus_1 == LOW) && (switchStatus_2 == LOW))  //both switches are not activated for the LEDs to light up
    {
      digitalWrite(runPin, HIGH);      //checks that the while loop is working

      if (counter > 1)
      {
        digitalWrite(ledPin_1, HIGH);

        if (counter > 2)
        {
          digitalWrite(ledPin_2, HIGH);

          if (counter > 3)
          {
            digitalWrite(ledPin_3, HIGH);

            if (counter > 4)
            {
               digitalWrite(ledPin_4, HIGH);
            }

              if (counter > 5)
              {
               digitalWrite(ledPin_5, HIGH);
              }

                if (counter > 6)
                {
                 digitalWrite(ledPin_6, HIGH);
                }

                  if (counter > 7)
                  {
                   digitalWrite(ledPin_7, HIGH);
                  }

                    if (counter > 8)
                    {
                     digitalWrite(ledPin_8, HIGH);
                    }

                      if (counter > 9)
                      {
                       digitalWrite(ledPin_9, HIGH);
                      }
          }
        }
      }

        counter++;      //the counter increments
        switchStatus_1 = digitalRead(switchPin_1);
        switchStatus_2 = digitalRead(switchPin_2);

        delay(500);    //the while loop is delayed half a second before starting again

    }

}

After the circuits and code are completed, I cut about 4, 8 foot wires to keep the LEDs away from the indo board. The switches were placed on a smaller breadboard and duct taped down to the indo board, making sure the breadboard was level.Materials:

  • 11 1K Ohm resistors
  • 6 green LEDs
  • 6 yellow LEDs
  • 6 red LEDs
  • Jumper wire
  • 2 rolling ball tilt switches
  • Arduino
    Advertisements

    1 Comment »

    1. This is totally sweet.

      Your code hurts my head though. Instead of lines 52-95, why not:
      for (int ledPin = 1; ledPin < counter; ledPin++) {
      digitalWrite(ledPin, HIGH);
      }

      I’m sorry.

      Comment by mistertwo — March 22, 2008 @ 4:08 pm | Reply


    RSS feed for comments on this post. TrackBack URI

    Leave a Reply

    Please log in using one of these methods to post your comment:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    Create a free website or blog at WordPress.com.

    %d bloggers like this: