Arduino circuit with an LDR to get an analogue value of light, prints data to Serial Monitor.
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.
Schematic:
Code:
/*
Oliver Holden
Created 28/10/2014
Components:
* Arduino UNO
* LDR
* 10K resistor
- Gets an analogue value of Light from an LDR
Prints the data to the Serial Monitor
Schematic for this project is on
http://breadboarder.blogspot.co.uk/
*/
int LDRPin= A2; // LDR Reading Pin
int LDRReading = analogRead(LDRPin); // Reading analogue value from LDR
void setup()
{
Serial.begin(9600); // Opening serial connection at 9600bps
Serial.println("Light"); //Printing Serial Monitor header
Serial.println("\n-----------------");
}
void loop() {
Serial.println(LDRReading); // Printing data to Serial Monitor
delay(1000); // Printing data once a second
}
No comments:
Post a Comment