• Anna Oh

Week3)The City Lights


For the third assignment, I was thinking about the idea of lighting. Since I have lived in Manhattan, watching the city night view is one of my joy while walking streets.

Inspired by this city night view, I came up with an idea which is the lighting has the shape of the building.And I thought the lighting controlled by lights using photosensor like the buildings were light up at nights.


This is a rough idea sketch for the lighting.


Actually, I was struggling and did lots of fails to figure it out to study digital input/output & analog input/output, eventually I can able to make the prototype.



For the beginning, I set up the photocell with the resistor and did a trial test to figure it out it is working for Arduino example 'analog input'.




After I confirmed the photocell setting, I set up the LED and got a test for Arduino example ' fade' and find out LED works well. And then I adjusted LED light length to the prototype of the building, started cording. It was almost 550 that photocell's value for natural light. So I make the LED light up when it's dark using map function - map(sensorValue, 0, 550, 255,0);

And I started to set up other LEDs in the same way.



This is final output of the prototype. You can see the lighting up when it's dark.




//lightSensor

int sensorPin = A0;

int sensorValue = 0;


//LED

int led1 = 9;

int led2 = 10;

int led3 = 11;

int led4 = 6;

int led5 = 5;

int brigtness = 0;



void setup() {

Serial.begin(9600);

pinMode(led1, OUTPUT);


}


void loop() {

sensorValue = analogRead(sensorPin);

Serial.print(sensorValue);

int brightness = map(sensorValue, 0, 550, 255,0);

Serial.print("");

Serial.println(brightness);


if (brightness < 10) {

analogWrite(led1,0);

analogWrite(led2,0);

analogWrite(led3,0);

analogWrite(led4,0);

analogWrite(led5,0);

} else{

analogWrite(led1, brightness);

analogWrite(led2, brightness);

analogWrite(led3, brightness);

analogWrite(led4, brightness);

analogWrite(led5, brightness);


}


}

© 2023 by Salt & Pepper. Proudly created with Wix.com