LocaLights

Paul, Tala, Randa, Nizar

icon-car.pngKML-LogoFullscreen-LogoQR-code-logoGeoJSON-LogoGeoRSS-LogoWikitude-Logo
LocalLight Sensor

loading map - please wait...

LocalLight Sensor 31.951916, 35.930287

Code:
/*
##Testing Environment for Xively Arduino Tutorial##
This program is designed to test the sensing circuit created
in the Xively Wi-Fi tutorial. It tests the photocell as well as the
LED output. This sketch can be adapted to take sensor readings from any analog sensor.
Derived from basicSensorTestEnv by Calum Barnes and AnalogInput by Tom Igoe

By Calum Barnes 3-4-2013
MIT License – [http://opensource.org/licenses/MIT]
Copyright (c) 2013 Calum Barnes
*/

/////////////////////////////////
/////////////SETUP///////////////
/////////////////////////////////
const int analogInPin = A2; // Analog input pin that sensors is attached to (DEFAULT=A2)
int readingDelay = 10; // Delay between each reading (DEFAULT=10)
int readingsPerSample = 10; // Number of reaings per sample / loop (DEFAULT=10)
boolean singleRead = false; // Series of readings (False) or single reading (TRUE) (DEFAULT=FALSE)
boolean enableLED = true; // LED
const int ledPin = 9; // Pin that Anode of LED is attached to (DEFAULT=13)
/////////////////////////////////

//vars
int sensorValue = 0; // value read from the pot
int outputValue = 0;
int ledValue = 0;
int sval;
int sensorAvg;
int tenTot;

void setup() {
// initialize serial communications at 19200 bps:
Serial.begin(19200);

pinMode(analogInPin, INPUT); //configure pin as input
pinMode(ledPin, OUTPUT);
}

void loop() {
if(!singleRead){
//SAMPLE OF 10 READINGS
for (int i=0; i