Display LDR value on LCD connected to chipkit UNO

In this example we keep the LCD shield connected to our Chipkit UNO and this time we will connect an LDR to A4, read the value in and display it on the LCD display

I used an LDR breakout but its basically shown in the schematic below

LDR and LCD

Code

[codesyntax lang=”cpp”]

#include <LiquidCrystal.h>

const int analogInPin = A4;  // Analog input pin that the LDR is attached to
int sensorValue = 0;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
void setup() 
{
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("LDR reading!");
}
 
void loop() 
{
  sensorValue = analogRead(analogInPin);
  // set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  delay(1000);
  // print the LDR reading
  lcd.print(sensorValue);
}

[/codesyntax]

Related posts

Chipkit Max32 and ADXL335 accelerometer example

Chipkit Max32 and LSM303 Accelerometer example

Chipkit Max32 and LSM303 Magnetometer example

1 comment

chipKIT Uno32 with Arduino LCD Shield » chipKIT Development Platform 2nd April 2015 - 10:34 pm
[…] to get your chipKIT Uno32 up and running with the Arduino LCD Shield! For a more useful example, check out this example for how to connect and display a Photoresistor or LDR (Light Dependent Resistor) to your circuit […]

Comments are closed.

Add Comment

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