Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Firefly

Project Members: 
Laura Greig

Description

A firefly that lights up when you cup your hands around him.

Components

  • Sculpy body
  • Tiny green LED
  • 220Ohm resistor
  • 10KOhm resistor
  • Photo resistor

 

Arduino Code

int sensorPin = 0; // select the input pin for the sensor
int ledPin = 11; // select the output pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}
void loop() {
val = analogRead(sensorPin);
int val1 = 230-val/4; //offset it by a little... full brightness is rare

int pulse = 0;
for(pulse=0; pulse<val1; pulse++){
analogWrite(ledPin, pulse);
delay(10);
}

pulse = val1;
for(pulse=val1; pulse>0; pulse--){
analogWrite(ledPin, pulse);
delay(10);
}

//Serial.println(val1);
delay(50);
}

FireflyFirefly
breadboardbreadboard


Powered by Drupal - Design by Artinet