People
- Keunwoo Peter Yu
- Dylan Bowman
- Green Choi
- Taejune Ham
Group Number
8
What we built
We’ve built a lighting system that reacts to the background light and pressure. We wanted to build a lighting system that automatically dims itself to save energy when there’s enough background light, and only turns on if necessary e.g. when a person is standing in front of the door thereby applying pressure to the sensor. Our system only turns on the LED lights when there’s pressure and low background light as intended. We picked arbitrary thresholds for background light and pressure, but in the future, we’d like to select these values after a more systematic analysis.
Sketches
List of parts
- 2 10K Ohm resistors
- 2 LED Lights
- 1 Force-sensing Resistor
- 1 Photo Sensor
Instructions
Complete the circuit as shown in the picture below.
Code
// pin numbers for LED const int greenLED = 11; const int yellowLED = 10; const int lightSensor = 0; const int forceSensor = 1; const int LIGHT_MAX = 255; const int FORCE_THRESHOLD = 400; const int LIGHT_THRESHOLD = 100; // variables int light = 0; int force = 0; void setup() { pinMode(greenLED, OUTPUT); pinMode(yellowLED, OUTPUT); } void changeLight(int light) { analogWrite(greenLED, light); analogWrite(yellowLED, light); } void loop() { changeLight(0); light = analogRead(lightSensor); force = analogRead(forceSensor); if (light < LIGHT_THRESHOLD && force > FORCE_THRESHOLD) { changeLight(LIGHT_MAX); } }