int photoCellPin = A1;
int photoCellReading = 0;
int ledPin = D0;
int ledBrightness = 0;
int tempPin = A0;
double temperature = 0.0;
double temperatureF = 0.0;
void setup()
{pinMode(ledPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Spark.variable("light", &photoCellReading, INT);
Spark.variable("temperature", &temperature, DOUBLE);
Spark.variable("temperatureF", &temperatureF, DOUBLE);
pinMode(tempPin, INPUT);}
void loop()
{photoCellReading = analogRead(photoCellPin);
ledBrightness = map(photoCellReading, 90, 2000, 255, 0);
analogWrite(ledPin, ledBrightness);
delay(100);
int reading = analogRead(tempPin);
double voltage = (reading * 3.3) / 4095.0;
temperature = (voltage - 0.5) * 100;
temperatureF = ((temperature * 9.0) / 5.0) + 32.0;}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .