Tuesday, September 8, 2009
Prototype 1
GOAL: Create a circuit that would respond to the movement.
PROCESS: Simple circuit with one single color LED and Arduino script.
RESULT: The LED blinking is effected by the light and shadow.
CODE:
//
// This example shows one way of using an LED as a light sensor.
// You will need to wire up your components as such:
//
// + digital2
// |
// < // > 100 ohm resistor
// < // | // | // -----
// / \ LED, maybe a 5mm, clear plastic is good // -----
// | // | // + digital3 //
// What we are going to do is apply a positive voltage at digital2 and
// a low voltage at digital3. This is backwards for the LED, current will
// not flow and light will not come out, but we will charge up the
// capacitance of the LED junction and the Arduino pin. //
// Then we are going to disconnect the output drivers from digital2 and
// count how long it takes the stored charge to bleed off through the
// the LED. The brighter the light, the faster it will bleed away to
// digital3. //
// Then just to be perverse we will display the brightness back on the
// same LED by turning it on for a millisecond. This happens more often
// with brighter lighting, so the LED is dim in a dim room and brighter
// in a bright room. Quite nice. //
// (Though a nice idea, this implementation is flawed because the refresh
// rate gets too long in the dark and it flickers disturbingly.)
// #define LED_N_SIDE 2 #define LED_P_SIDE 3 void setup() {} void loop() { unsigned int j;
// Apply reverse voltage, charge up the pin and led capacitance
pinMode(LED_N_SIDE,OUTPUT);
pinMode(LED_P_SIDE,OUTPUT);
digitalWrite(LED_N_SIDE,HIGH);
digitalWrite(LED_P_SIDE,LOW);
// Isolate the pin 2 end of the diode
pinMode(LED_N_SIDE,INPUT);
digitalWrite(LED_N_SIDE,LOW);
// turn off internal pull-up resistor
// Count how long it takes the diode to bleed back down to a logic zero for ( j = 0; j <>
SOURCE:
http://www.arduino.cc/playground/Learning/LEDSensor
Labels: K.A.A.S., Living Architecture, Pratt, Responsive Architecture
Post a Comment