I've built a turntable, and am using an Arduino with Adafruit motor shield to drive a DC motor. I have the sketch set up so it will run low (33rpm) if pin 4 is used. high (45rpm) if pin 8 is used, and off (no rpm) if pin 13 is used.
If I touch the respective pins, each speed will engage, but if I connect a wire to each one, to three different momentary switches, it acts as if all buttons are being pushed, even though they are not. Tha same thing will happen even if the wires are not connected to anything. I have 10k resistors in line with each of the three wires.
My sketch is here:
Code: Select all
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *myMotor = AFMS.getMotor(2);
int low = 4;
int high = 8;
int off = 13;
void setup() {
// put your setup code here, to run once:
AFMS.begin();
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(low) == HIGH)
{
myMotor->setSpeed(135); //0-255 - experiment with this number till you get 33.3 rpm on platter using stribe disc
myMotor->run(FORWARD);
}
// for 45 speed
if(digitalRead(high) == HIGH)
{
myMotor->setSpeed(179); //0-255 - experiment with this number till you get 33.3 rpm on platter using stribe disc
myMotor->run(FORWARD);
}
// for stop
if(digitalRead(off) == HIGH)
{
myMotor->setSpeed(0); //0-255
myMotor->run(RELEASE);
}
}