Home Chipkit Chipkit UNO and LDR example

Chipkit UNO and LDR example

by shedboy71

This is a simple example which shows how to connect an LDR to a Chipkit UNO. In this example we are using Mpide and will be outputting the results via the serial monitor window

A photoresistor or light-dependent resistor (LDR) or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity.

I used a module like the following

Photo_resistor_module

Schematic and Layout

Chipkit and LDR_schem Chipkit and LDR_bb

Code

 

[codesyntax lang=”cpp”]

int sensorPin = A0; // select the input pin for the ldr
int sensorValue = 0; // variable to store the value coming from the sensor

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  sensorValue = analogRead(sensorPin);
  delay(500);
  Serial.println(sensorValue, DEC);
}

[/codesyntax]

 

Result

Open the serial monitor window and you should see something like the following depending on the amount of light that is present

chipkit and ldr output

chipkit and ldr output

Share

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More