Paxlo_05
Published © GPL3+

Show the luminosity with coloured LEDs

It's a little and easy project using the photoresistor and LEDs

IntermediateShowcase (no instructions)-60 minutes733
Show the luminosity with coloured LEDs

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
5 mm LED: Red
5 mm LED: Red
×8
Resistor 220 ohm
Resistor 220 ohm
×8
Through Hole Resistor, 1 kohm
Through Hole Resistor, 1 kohm
×1
Elegoo 74hc595 IC
×1
Photo resistor
Photo resistor
×1
Male/Male Jumper Wires
×16

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

photocell_1

photocell_2_xdRu1yPzZc.png

Code

Photocell.ino

Arduino
It's the program to run the project. It small and easy to redo if you can not download it.
int lightPin = 0;
int latchPin = 11;
int clockPin = 9;
int dataPin = 12;

int leds = 0;

void setup() 
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
}
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}
void loop() 
{
  int reading  = analogRead(lightPin);
  int numLEDSLit = reading / 57;
  if (numLEDSLit > 8) numLEDSLit = 8;
  leds = 0; 
  for (int i = 0; i < numLEDSLit; i++)
  {
    leds = leds + (1 << i); 
  }
  updateShiftRegister();
}

Credits

Paxlo_05

Paxlo_05

2 projects • 0 followers

Comments