int photoCellPin = A0;
int fsrPin = A1;
int photoCellReading = 0;
int fsrReading = 0;
int ledPin = D0;
int ledBrightness = 0;
void setup(){
pinMode(ledPin, OUTPUT);
Spark.variable("force", &fsrReading, INT);
Spark.variable("light", &photoCellReading, INT);
}
void loop() {
fsrReading = analogRead(fsrPin);
photoCellReading = analogRead(photoCellPin);
if((fsrReading>1000)||(photoCellReading<50)) ledBrightness=255;
else ledBrightness = 0;
//else ledBrightness = 0;
analogWrite(ledPin, ledBrightness);
delay(100);
}
Click to Expand