Matthew Garcia
Published © GPL3+

Lane Tech PCL - Matthew Garcia: coaster dispenser

It dispenses coasters remotely to signal to a person they should use a coaster because people never use them even though they should.

IntermediateFull instructions provided4 hours39
Lane Tech PCL - Matthew Garcia: coaster dispenser

Things used in this project

Hardware components

Argon
Particle Argon
×1
Stepper Motor
Digilent Stepper Motor
×1
SparkFun button
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Blynk
Blynk

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
exacto knife
Scissor, Electrician
Scissor, Electrician

Story

Read more

Code

Automatic coaster

C/C++
#define BLYNK_TEMPLATE_ID           "TMPLuOFa6xU2"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "hjMPQOpOPcUOl3g-WNq7qcRhrxl8mYU_"

#include <blynk.h> //make sure this is after the define statements or else the code breakes for the Blynk app

// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial

char auth[] = BLYNK_AUTH_TOKEN;

#include <Stepper.h>


const int stepsPerRevolution = 2048;

#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5

Stepper myStepper(stepsPerRevolution, IN1, IN3 , IN2, IN4);

int button = 7;

BLYNK_WRITE(V0)
{
  int value = param.asInt();

    Serial.println("counterclockwise");
    myStepper.step(-stepsPerRevolution);
    delay(500);
}

BLYNK_CONNECTED()
{
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

void setup()
{
    myStepper.setSpeed(17);
    
    Serial.begin(115200);
    delay(5000);
    Blynk.begin(auth);

    pinMode(button, INPUT_PULLUP);
}

void loop()
{
  Blynk.run();
  
  int btnState = digitalRead(button);

	if ( btnState == LOW )
	{
	    Serial.println("counterclockwise");
        myStepper.step(-stepsPerRevolution);
        delay(500);
    	}
}

Credits

Matthew Garcia

Matthew Garcia

1 project • 0 followers

Comments

Add projectSign up / Login