User Tools

Site Tools


arduino:arduino_crash_course:light_meter

Light Meter Example

Using serial communication and a CdS cell as a primitive light meter.

LightMeter.ino
/*
 LightMeter
 Report the light intensity at an arbitrary scale to the serial port.
 */
 
const int inputPin = A0;  // use analog 0 (A0) input pin
int lightLevel = 0;       // used to store the input value
 
void setup() {
  Serial.begin(9600);  // initialize serial communication at 9600 bits/second
}
 
void loop() {
  lightLevel = analogRead(inputPin);  // get a reading      
  Serial.println(lightLevel);         // print out reading
  delay(500);                         // delay between reads
}
arduino/arduino_crash_course/light_meter.txt · Last modified: 2012/11/06 01:32 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki