4 dc motors and 5 inputs for my claw crane machine

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
ralph_reyes
 
Posts: 1
Joined: Tue Apr 10, 2012 6:42 am

4 dc motors and 5 inputs for my claw crane machine

Post by ralph_reyes »

Hey i need help how to put the code all together, cause i am making a claw crane machine, and in one button i want to pick the prize and drop it off to the prize collector box. i only started doing the code

[Edit - moderator - please use the 'code' button when submitting code]

Code: Select all

#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR12_1KHZ);
AF_DCMotor motor4(4, MOTOR12_1KHZ);
  pinmode(14,input);                       // set the pin to input
int BUTTON = digitalread(14);        // read analog pin 0 as digital and set it to a variable

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  
void loop() {
if (BUTTON == HIGH)                   // it shows pressed
and thats all i can come up to, is this right?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 4 dc motors and 5 inputs for my claw crane machine

Post by adafruit_support_bill »

You need to read your button inside the loop function.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”