Making Things Interactive

April 15, 2008

Final Project: Light Plant

Filed under: Assignments,Thomas Hendrickson — tphendrickson @ 11:54 am

My last midterm project (the interactive indo board) was cumbersome and hard to set up/transport, so for this project I wanted to make something that was easy to install and simple to set up. I thought of something that could sit in a room that people could interact with but not take up too much room or be too distracting, like an interactive decoration. So my idea was to have something that reflected a plant’s behavior, that would sense light and react.

A photosensor gets a reading of what the light is in the surrounding environment initially, and then calibrates an activation value based on this reading. When the light reaches a value that is higher than the activation value, the servo rotates a fabricated wooden gear and wooden column with a hexagonal top rises. LEDs protruding from the column light up, and the photosensor is at the top, all soldered to longer jumper wires. There are four cases to the code:

Case 1: Light is sensed as above the activation and the column is down.

  • The servo rotates the column up.
  • The LEDs light up.

Case 2: Light is sensed as above the activation value and the column is up.

  • The servo does not rotate.
  • The LEDs stay light.

Case 3: Light is sensed as below the activation value and the column is up.

  • The servo rotates the column down.
  • The LEDs turn off.

Case 4: Light is sensed as below the activation value and the column is down.

  • The servo does not rotate.
  • the LEDs stay off.

Code:

Servo servo1;

int ledPin1 = 13;
int photoPin = 0;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin5 = 5;
int readIn = 0;
int initialRead = 0;
int activateVal = 0;
int status = 0;

void setup()
{
Serial.begin(19200);

servo1.attach(15);
servo1.setMinimumPulse(800);
servo1.setMaximumPulse(2000);

pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(photoPin, INPUT);

blink(); //blinks the status LED
initialRead = analogRead(photoPin); //gets initial reading for photosensor
activateVal = (initialRead * 2) + 5; //the activation value will be double the initial
blink();

}

void loop()
{
Servo::refresh();

readIn = analogRead(photoPin);

//Case 1: Light Turned On (Servo move up, LEDs on)
if ((readIn >= activateVal))
{
servo1.write(0);
status = 1;
digitalWrite(ledPin1, HIGH);
lightLeds();
}

//Case 2: Light Turned Off (Servo move down, LEDs off)
if ((readIn < activateVal) &amp;&amp; (status == 1)) { servo1.write(90); status = 0; digitalWrite(ledPin1, LOW); turnOffLeds(); } //Case 3: Lighting the same and off (Servo off, LEDs off) if ((readIn < activateVal) &amp;&amp; (status == 0)) { status = 0; digitalWrite(ledPin1, LOW); turnOffLeds(); } //Case 4: Lighting the same and on (Servo off, LEDs on) if ((readIn >= activateVal) &amp;&amp; (status == 1))
{
status = 1;
digitalWrite(ledPin1, HIGH);
lightLeds();
}

Servo::refresh();

}

void blink()
{
digitalWrite(ledPin1, HIGH);
delay(100);
digitalWrite(ledPin1, LOW);
delay(100);

}

void lightLeds()
{
for (int i = 2; i < 6; i++) { digitalWrite(i, HIGH); } } void turnOffLeds() { for (int i = 2; i < 6; i++) { digitalWrite(i, LOW); } }[/sourcecode] The code should read '#include ' which was an imported package used to code the servo's rotation.

The wiring before soldering the LEDs and photosensor.

The servo attached to the gear.

The wiring after soldering.

The final product after hiding the hardware.

Parts List:

  • 5 1 kilo ohm resistors
  • 4 LEDs
  • 1 photosensor
  • 1 Hi-Tec Standard Servo
  • Breadboard
  • Arduino
  • Jumper wire
  • Bass wood, PCM board, balsa wood
  • Flowerpot

Here is the youtube link, but I couldn’t rotate the video after it was imported:

Advertisements

Leave a Comment »

No comments yet.

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

Blog at WordPress.com.

%d bloggers like this: