Introduction: Recycled Arduino Lolly Dispenser

This is a quick photo instructable to show how me and my friend Nick built a lolly dispenser to show off the kinds of projects we create at the UTS Robotic Society. It's a project designed to allow us club executives to engage with new members on days like O'day and have a fun talking point.

This project was almost 100% made with parts and materials that were found around our lab, through dumpster diving and lying around the house which makes this project extremely sustainable and is something that the university likes to encourage.

Our website: utsroboticsociety.org

Step 1: Materials + Tools

Picture of Materials + Tools

This project was made almost most entirely from recycled parts found around the uni.

Some of the parts included:

  • Heavy weighted stand (off some scientific analytical machine)
  • Large plastic jar (big pack of pretzels)
  • Spiral (stretched out soldering iron holder / stand)
  • Cardboard tube (postage tube)
  • Quirky heat sinks (from iMac G3, the old CRT all in one model)
  • Screws (from pulled apart electronics)
  • Flat cardboard
  • Packing foam
  • Zip ties + tape + super glue

As for the tools:

  • Pliers
  • Screwdrivers
  • Scissors
  • Drill + drill bits
  • 3D printer

Step 2: Attaching the Jar to the Base

Picture of Attaching the Jar to the Base

Step 3: Attaching Spiral to Servo

Picture of Attaching Spiral to Servo

Step 4: Cardboard Lolly Chute

Picture of Cardboard Lolly Chute

Step 5: Arduino Wiring + Programming

Picture of Arduino Wiring + Programming

Essentially a sonar sensor connected to a servo with and LED indicator light. Use the definitions in the code to know where to put the wires.

The code:


#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 0;
int trigPin = 4; //Trig - green Jumper
int echoPin = 2; //Echo - yellow Jumper
long duration, cm, inches;

void setup() {
//Serial Port begin
Serial.begin (9600);
myservo.attach(9);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(13, OUTPUT);
}

void rotate(){
// goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(100);
delay(2000);
myservo.write(0);
delay(2000);

}

void check(int cm){
int temp;
temp = 0;
temp = cm;
if(temp < 5){
//delay(1000);
digitalWrite(13, HIGH);
rotate();
}else{

digitalWrite(13, LOW);
myservo.write(95);
}
}

void loop()
{


// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);

// convert the time into a distance
cm = (duration/2) / 29.1;
inches = (duration/2) / 74;

Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
//delay(2000);
myservo.write(95);
check(cm);

delay(100);
}

Comments

MuraliK52 (author)2017-11-04

tell me the connections bro

Lord_Wiader (author)2016-03-23

Hi, could you explain how and where to connect the wires ?

About This Instructable

1,336views

28favorites

Bio: I love science, lights and robotics! My dad is a builder so i've always grown up building things, pulling stuff apart and experimenting!
More by Jake Morton:Recycled Arduino Lolly DispenserMadonna's Disco BallRevolution (LED Chandelier)
Add instructable to: