Simple Arduino posemètre

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.

Simple Arduino light meter

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;
  pinMode(0,OUTPUT);
  pinMode(1,OUTPUT);
}

void loop() {
  sensorValue = analogRead(sensorPin);
  result = leds - round(sensorValue / divisor);
  for(int i = 0;i < leds;i++) {
    if(i < result) {
      digitalWrite(i,HIGH);
    } else {
      digitalWrite(i,LOW);
    }
  }
}

The results can be seen in this quick video showing how the LEDs react when a torch is brought near the photo-transistor:

 

For more detail: Simple Arduino posemètre


A Propos De L'Auteur

Ibrar Ayyub

Je suis expérimenté, rédacteur technique, titulaire d'une Maîtrise en informatique de BZU Multan, Pakistan à l'Université. Avec un arrière-plan couvrant diverses industries, notamment en matière de domotique et de l'ingénierie, j'ai perfectionné mes compétences dans la rédaction claire et concise du contenu. Compétent en tirant parti de l'infographie et des diagrammes, je m'efforce de simplifier des concepts complexes pour les lecteurs. Ma force réside dans une recherche approfondie et de présenter l'information de façon structurée et logique format.

Suivez-Nous:
LinkedinTwitter

Laisser un Commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

fr_FRFrench
Faire défiler vers le Haut