EDIT: I found this awesome tutorial for controlling a motor with just the SN754410 IC found on these motor shields. We could buy a dozen or so and control up to 24 motors (two per IC). They are $1.50 - $3.50 a piece depending on where you buy them. DC Motor Control
Sketch for shield:
// Motor Shield test
// by NKC Electronics
// Test Motor B
int dirapin = 12; // Direction pin for motor A is Digital 12
int speedapin = 10; // Speed pin for motor A is Digital 10 (PWM)
int speed = 250;
int dir = 0;
void setup()
{
pinMode(dirapin, OUTPUT);
}
void loop()
{
digitalWrite(dirapin, dir); // set direction
analogWrite(speedapin, speed); // set speed (PWM)
dir = ((dir == 0) ? 1 : 0); // change direction
delay(5000); // 5 seconds
}
No comments:
Post a Comment