User Tools

Site Tools


arduino:arduino_crash_course:light_meter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

arduino:arduino_crash_course:light_meter [2012/11/06 01:19] – created mithatarduino:arduino_crash_course:light_meter [2012/11/06 01:32] (current) mithat
Line 3: Line 3:
 Using serial communication and a CdS cell as a primitive light meter. Using serial communication and a CdS cell as a primitive light meter.
  
 +<file c 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
 +}
 +</file>
  
arduino/arduino_crash_course/light_meter.1352164752.txt.gz · Last modified: 2012/11/06 01:19 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki