Simple Arduino light meter


This Arduino project is a simple light meter using a photo-transistor. An LDR would be more appropriate but the photo-transistor is what I has spare at the time. On the other hand the photo-transistor is sensitive to infrared, so its handy for testing remote controls.

The project consists of 10 red LEDs driven by 10 BC547 transistors although any general purpose transistor will do. The base of each transistor is connected to the Arduino board digital pins D0 through to D7 via a 2.2K resistor. The LEDs are connected to a 12 volt source with current limiting resistors of 560 ohms.


The input is provided by a photo-transistor connect to the Arduiono’s analogue input on analogue pin 0. The range of the input for the photo-transistor is 0 (full light) to 1023 (full dark), 1024 in total. This output is divided by 128, that is the full range (1024) divided by the number of LEDs (8). As the result is cast as a floating point, we round it up to the nearest integer. So 7.5 become 8. Finally we subtract this result from the total number of LEDs.

A simple for loop is used to enumerate the result and light/extinguish the appropriate number of LEDs. The source below:

int sensorPin = A0;
float sensorValue = 0;
int leds = 8;
int result = 0;
int divisor = 128;

void setup()
  PORTD = B00000000;


Read more: Simple Arduino light meter

Leave a Comment

Your email address will not be published. Required fields are marked *