Things used in this project

Hardware components:
Photon new
Particle Photon
×1
09590 01
LED (generic)
×1
Servo (generic)
×1
12002 04
Breadboard (generic)
×2
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Xidmhfnahh6gnduppwzf
Particle Pi
Hand tools and fabrication machines:
Lasercutter
Laser cutter (generic)

Schematics

photo_on_5-22-17_at_1_10_pm_2_cQpOGf5zgc.jpg
Photo on 5 22 17 at 1 10 pm 2 cqpogf5zgc

Code

Untitled fileC/C++
int ledR = D4;
int ledG = D3;
int servoPin = D0;

Servo gumballServo; 

void setup()
{
   gumballServo.attach(servoPin);
   pinMode(ledR, OUTPUT);
   pinMode(ledG, OUTPUT);
   pinMode(servoPin, OUTPUT);

   Particle.function("knock",knockDetector);

   digitalWrite(ledR, LOW);
   digitalWrite(ledG, LOW);
   gumballServo.attach(servoPin);
   gumballServo.write(360);
 }

void loop(){
}

    


int knockDetector(String command){

    if(command=="Knock")
    {
        digitalWrite(ledR,LOW);
        digitalWrite(ledG,HIGH);
        gumballServo.attach(servoPin);
        gumballServo.write(55);
        delay(2000);
        gumballServo.write(360);
        delay(2000);
        gumballServo.detach();
        return 1;
    }
    else if (command=="no")
    {
        digitalWrite(ledR,HIGH);
        digitalWrite(ledG,LOW);
        gumballServo.attach(servoPin);
        gumballServo.write(360);
        delay(1000);
        gumballServo.detach();
        return 0;
    }
    else 
    {
        return -1;
    }
}

Credits

Photo on 5 5 17 at 11 29 am llm9fhyujm
Mo Piper Cordova
1 project • 1 follower
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login