Yun Jin Yonggledel임동교
Published © GPL3+

Innovation Lab #7 Photocell & LED On/Off

A Bongilcheon High School Innovation Lab project.

BeginnerShowcase (no instructions)10 minutes5,466
Innovation Lab #7 Photocell & LED On/Off

Things used in this project

Story

Read more

Schematics

Photocell_LED

Photocell_LED

Code

Photocell_LED

Arduino
When dark, the LED turn on and when bright, the LED turn off.
const int sensorPin = 0;
const int ledPin = 9;
int lightCal;
int lightVal;

void setup() {
  pinMode(ledPin, OUTPUT);
  lightCal = analogRead(sensorPin);
}

void loop() {
  lightVal = analogRead(sensorPin);
  
  if (lightVal < lightCal - 50) {
    digitalWrite(ledPin, HIGH);
  }
  
  else {
    digitalWrite (ledPin, LOW)
  }
}

Credits

Yun Jin Yong
6 projects • 10 followers
Contact
gledel
100 projects • 116 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"
Contact
임동교
0 projects • 12 followers
Contact

Comments

Please log in or sign up to comment.