Back to Parent

int redPin = A0;    // RED pin of the LED to PWM pin **A0**
int greenPin = D0;  // GREEN pin of the LED to PWM pin **D0**
int bluePin = D1;
  
int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255;

int redPin1 = A4;    // RED pin of the LED to PWM pin **A0**
int greenPin1 = A5;  // GREEN pin of the LED to PWM pin **D0**
int bluePin1 = A7;
  
int redValue1 = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue1 = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue1 = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;

void setup()
{
  // Set up our pins for output
  pinMode( redPin, OUTPUT);
  pinMode( greenPin, OUTPUT);
  pinMode( bluePin, OUTPUT);

  analogWrite( redPin, 255);
  analogWrite( greenPin, 255);
  analogWrite( bluePin, 255);

  pinMode( redPin1, OUTPUT);
  pinMode( greenPin1, OUTPUT);
  pinMode( bluePin1, OUTPUT);

  analogWrite( redPin1, 255);
  analogWrite( greenPin1, 255);
  analogWrite( bluePin1, 255);


  //Register our Spark function here

  Spark.subscribe(  "LocationTweetLM/PittsburghEvent" , handleDoorbellPush );


  // turn them all off...

}



void run1()
{

  myservo.attach(A6);
  analogWrite( redPin, 0);
  analogWrite( greenPin, 0);
  analogWrite( bluePin, 255);

for(pos = 180; pos >=120; pos -= 1)  // goes from 0 degrees to 180 degrees
{                                  // in steps of 1 degree
  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  delay(60);                       // waits 15ms for the servo to reach the position
}

delay(10000);

for(pos = 120; pos<=180; pos+=1)     // goes from 180 degrees to 0 degrees
{
  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  delay(60);                       // waits 15ms for the servo to reach the position
}

myservo.detach();




}


void run2()
{

  myservo.attach(A1);
  analogWrite( redPin1, 255);
  analogWrite( greenPin1, 0);
  analogWrite( bluePin1, 0);

for(pos = 180; pos >=120; pos -= 1)  // goes from 0 degrees to 180 degrees
{                                  // in steps of 1 degree
  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  delay(60);                       // waits 15ms for the servo to reach the position
}

delay(10000);

for(pos = 120; pos<=180; pos+=1)     // goes from 180 degrees to 0 degrees
{
  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  delay(60);                       // waits 15ms for the servo to reach the position
}

myservo.detach();




}
void handleDoorbellPush(const char *event, const char *data)

{
    if(strcmp(data ,"HanyuHu") == 0)
    run1();
    if(strcmp(data ,"fleuraly") == 0)
    run2();


}
Click to Expand

Content Rating

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

0