Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Mo Piper Cordova
Published © CC BY

Text Machine, Get Gumball

This project describes how to build an Arduino-based, text-controlled gum dispenser. Idea from Make Maagazine "Secret Knock Gumball Machine"

BeginnerShowcase (no instructions)5 hours707
Text Machine, Get Gumball

Things used in this project

Hardware components

Photon
Particle Photon
×1
LED (generic)
LED (generic)
×1
Servos (Tower Pro MG996R)
×1
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Maker service
IFTTT Maker service
Particle Pi
Particle Pi

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

photo_on_5-22-17_at_1_10_pm_2_cQpOGf5zgc.jpg

Code

Untitled file

C/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

Mo Piper Cordova

Mo Piper Cordova

1 project • 1 follower

Comments