Back to Parent

int photoCellPin = A1;
int photoCellReading = 0;
int ledPin1 = D0;

int fsrPin = A0;
int fsrReading = 0;
int ledPin2 = D1;

int pressReading = 0;
int photoReading = 0;

int foodLight = 0;
int catLight = 0; 

void setup() {


    pinMode(ledPin1,OUTPUT);
    pinMode(ledPin2,OUTPUT);
    
    Spark.variable("force",&fsrReading,INT);
    Spark.variable("light", &photoCellReading, INT);
}


void loop() {
    fsrReading = analogRead(fsrPin);
    pressReading = map(fsrReading, 0, 4095, 0, 255);
    
    photoCellReading = analogRead(photoCellPin);
    photoReading = map(photoCellReading, 0, 4095, 0, 255);
    
    photoReading > 50? catLight= 0:catLight=255 ;
    pressReading < 100?  foodLight=0:foodLight=255 ;

    
    
    analogWrite(ledPin1, catLight);
    analogWrite(ledPin2, foodLight);
    delay(100);


}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0