// Servo myservo;
// int pos = 0;
void setup(){
pinMode(A5, OUTPUT);
pinMode(D0, INPUT_PULLUP);
pinMode(D2, OUTPUT);
digitalWrite(D2, HIGH);
delay(500);
digitalWrite(D2, LOW);
// RGB.control(TRUE);
Particle.subscribe("feedCat", myHandler);
}
void loop(){
int buttonState = digitalRead(D0);
if (digitalRead(D0)== LOW){
analogWrite(A5, 170);
Particle.publish("cat is fed");
delay(1000);
// RGB.color(0,255,0);
}//else{
if (digitalRead(D0)== HIGH){
analogWrite(A5, 20);
delay(1000);
// analogWrite(A5,20);
// // detach();
// delay(1000);
}
}
void myHandler(const char *event, const char *data){
digitalWrite(D2, HIGH);
delay(500);
digitalWrite(D2, LOW);
analogWrite(A5, 170);
Particle.publish("cat is fed");
delay(1000);
analogWrite(A5, 20);
delay(1000);
}
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. .