Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
TimiCreator
Published © MPL-2.0

Automatic Ball Course Dispenser

Auto dispenses marbles when inputted.

IntermediateWork in progress1,000
Automatic Ball Course Dispenser

Things used in this project

Hardware components

Servos (Tower Pro MG996R)
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
the marble course itself (starter has to have a button)
×1
Slide Switch
Slide Switch
×1
Breadboard (generic)
Breadboard (generic)
×1
tracker sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

jk

jk

Code

code for this

Arduino
you remove all the code in a new arduino code, and paste dis in
#include <Servo.h> //Includes the servomotor files that allow it to work (might need to download them)

Servo myservo; //Sets the myservo variable to later attach to pin D9

int pos = 0;   //Variable to keep the servos position
int marble = 0;  //Varialble that saya if the tracker sensor gives output
void setup() {
  myservo.attach(9); //Ataches the servo to pin D9
  Serial.begin(9600);
}

void loop(){
  marble =digitalRead(2); //Pin D2 reads the state of the tracker sensor
 delay(1);//delay
if (marble == 1) {              //If the sensor gives output (1)
  for (pos = 45; pos <= 90; pos += 5) {  //Move the servo by the amount needed to push the button 
    myservo.write(pos);  //tells the servo to move
    delay(75);                      //delay 
  }
  for (pos = 90; pos >= 45; pos -= 5) {  //Move the servo back
    myservo.write(pos);            //tells the servo to move
      delay(75);                 //delay 
  } 
 

}
}

Credits

TimiCreator
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.