Im looking to make a vending machine. I currently went out and brought a button, a dc motor, an arduino board and a motor driver. I am aiming to be able to push a button that then turns on the motor which then turns a certain amount of time at a set speed then stopping after a certain time. And i am unsure of how to do so... is there anyone that can help me with the coding and a diagram of what i need to do????
Once i get one motor and button working im aiming to have 4 buttons and 4 motors which each motor will run when the designated button is pushed.
Generally when I do a project I do the design first then buy the parts. Doing it in reverse makes it much harder to accomplish. In this case you got lucky. You should be able to make a schematic from the code, we get lots of practice here here doing that.
I do not recognize the motor driver. I have worked on hundreds, mostly all different. They range from micropower to kilowatts, I realize this is nothing near that. You can solve that problem by posting links to technical information on each of the parts, the UNO I have.
@gazbaz11, I too design before spending money. Even to the extent of using no parts whatsoever, not even an Arduino board.
See
The premier (IMO) Arduino simulator, where you could do 100 percent of the software and get a very good head start on most of the hardware all with your parked on a comfortable chair in front of your desktop machine.
The real benefit to doing is that very often such zero money just time spent will inform decisions as to what, and whether, to buy.
Only more so for noobs. I can't be sure, but it looks at this point as if software is a big mystery to you, as the functionality you seek is fairly simple coding.
It seems hardware is a mystery also. Srsly consider playing with the simulator, it has plenty of "parts" you can hook together however you want all day long with no money spent and no possibility of damaging them through mistakes in wiring or power or whatever.
#define button1 2
#define servo A0
int buttonPressed;
void setup() {
pinMode(button1, INPUT);
pinMode(servo, OUTPUT);
}
void loop() {
// Wait until a button is pressed
while (true){
if (digitalRead(button1) == HIGH)
buttonPressed = 1;
delay(2000);
break;}
switch(buttonPressed) {
case 1:
// Rotate the helical coil, discharge the selected item
digitalWrite(servo, 700); // rotate
delay(1290);
digitalWrite(servo, 1500); // stop
delay(300);
break;}
}
thats my code so far ill send in my circuit but, im aiming for me to be able to push the button and run the motor for a certain amount of seconds
Thats the circuit and it doesnt seem to do what i need it to do. I push the button and the motor doesnt turn on it just turns off the arduino.... is there anyone that can assist me so i can get it to do what i want it to do.
Spot on @alto777 You cannot use an Arduino to power a motor !! Using breadboard for it is pushing your luck too. Google will find a lot of driving motors solutions
I too design first and would re enforce that .
For a vending machine you need to work out how it will work , look at existing machines , work out the mechanics- how does it measure , how does it drop the cup , how does it heat/ cool liquids , how does it remain hygienic ??. You might find for example that a different motor type is better , or some parts can be controlled by solenoids , or it needs a Wi-Fi connection, who knows ?
Are you going to build it , how ? Or is it a desktop exercise , in which you can use leds to stand in for motors ??