Go Down

Topic: Arduino vending machine project (Read 5634 times) previous topic - next topic

sck2258c

Mar 28, 2011, 12:00 am Last Edit: Nov 01, 2014, 04:08 am by sck2258c Reason: 1
xxxx

CrossRoads

Sounds like an interesting project.
What is the camera for?
You can find motors & power supplies here www.mpja.com
You will need some relays or MOSFETs to control power going to the motors.
Instead of a tact switch, a microswitch, the kind that has an arm on it, may be easier to mount and adjust.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

sck2258c

THanks for the info. And the camera is for people who try to cheat or vandalize the machine.

sck2258c

Does anyone know of a sketch that could achieve what I want?

AWOL

I don't know about a sketch, but maybe some paragraph breaks in the description of the problem might encourage me to read it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

sck2258c

I'm assuming you're thinking of a sketch like a drawing. I mean the arduino sketch like a program.

AWOL

Quote
I'm assuming you're thinking of a sketch like a drawing

I know what an Arduino sketch is, I just can't read the statement of the problem.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.



sck2258c

I  probably have to run a wire from the 5v rail of the breadboard to the switch and then back to an analog pin on the arduinio, right?

sck2258c

I kind of have this figured out. I need to run a wire from the 5v rail to an analog input pin on the arduino. Then I need to have a wire from another analog pin to a MOSFET gate pin. Connect the + terminal of the 12v power supply to the MOSFET source pin. The connect a cable to the drain pin of the MOSFET to the motor. Then wire the - terminals together. Now the only thing left is the sketch. Where should I start? 

CrossRoads

Your last post addresses a motor driver.
This is the circuit you want for that, using an N channel logic level MOSFET.  The MOSFET will turn the motor on when the arduino pin it is connected to is high (can be any of the pins, with digitalWrite (pinX, HIGH); to turn it on & digitalWrite(pinX, LOW); to turn it off.
The second diagram shows typical ways of connecting switches & LEDs to receive inputs & have user indicators.
There are plenty of tutorials available that show the bacics of a sketch, do a  little reading & try one, then post again with questions.


Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


sck2258c

#13
Mar 30, 2011, 10:58 pm Last Edit: Mar 31, 2011, 07:52 pm by cmeacham98 Reason: 1
I finished the sketch. Here it is:
------------------------------------------------------------
/*
Arduino vending machine program
*/

int mosfetPin = 8;
int coinPin = 7;
int val;


void setup() {               
  pinMode(mosfetPin, OUTPUT);     // Set mode of pin to output
  pinMode(coinPin, INPUT);     // Set mode of pin to input
}


void loop() {
  val = digitalRead(coinPin);  // Read input value and store it in val
  if (val == LOW) {  // Check if the coin hit the microswitch
  digitalWrite(mosfetPin, HIGH);   // Activate the mosfet gate
  delay(5000);              // Allow the motor to run enough to complete task
  digitalWrite(mosfetPin, LOW);    // Stop motor
  }
}
-------------------------------------------------------------
Please check out my sketch and try to point out any flaws.

AWOL

Code: [Select]
digitalWrite(8, LOW);   
You defined a nice name for pin 8 - why not use it?

(it may also help if you redefine the nice name as a "const")
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up