For Tech Demo 3, Rachel and I decided to make a simple gumball dispenser. A string attached to a servo operated by a switch uses a simple pulley mechanism to pull up the flap for gumballs to drop out.
To make the box and the spool for the pulley, we simply used the laser cutter. We had some trouble exporting the box to dimensions, so we had to improvise in order to get the box to fit in the laser cutting program. Rachel designed the spool using Autofusion 360.
#include <Servo.h> Servo wiggling_servo; const int SERVO_PIN = 9; const int SWITCH_PIN = 2; void setup() { // put your setup code here, to run once: Serial.begin(9600); // Initialize the Servo object to use the given pin for output. wiggling_servo.attach(SERVO_PIN); pinMode(SWITCH_PIN, INPUT); } void loop() { // put your main code here, to run repeatedly: int switchValue = digitalRead(SWITCH_PIN); int knockValue = analogRead(KNOCK_PIN); if (switchValue == 1) { wiggling_servo.write(360); } else { wiggling_servo.write(0); } }
Leave a Reply
You must be logged in to post a comment.