Controlling 9 micro servo motors with arduino & ultrasonic sensor module
hello!
i trying control 9 micro servo motors using arduino triggered ultrasonic sensor module. comes within 30cm of sensor, servos need move 180 degrees in sync each other. have managed control 3 micro servos using code:
#include <servo.h>
#define trigpin 12
#define echopin 13
servo myservo;
void setup() {
serial.begin (9600);
pinmode(trigpin, output);
pinmode(echopin, input);
myservo.attach(9);
}
void loop() {
int duration, distance,pos=0,i;
digitalwrite(trigpin, low);
delaymicroseconds(2);
digitalwrite(trigpin, high);
delaymicroseconds(10);
digitalwrite(trigpin, low);
duration = pulsein(echopin, high);
distance = (duration/2) / 29.1;
serial.print(distance);
serial.println(" cm");
if (distance >0 && distance < 30)
{
myservo.write(180);
}
else{
myservo.write(0);
}
}
however, don't think circuit has enough voltage necessary power 9 motors. wondering if had advice how should go re-wiring , changing code? need add external power supply? have far used when connected via usb.
thank in advance!
i trying control 9 micro servo motors using arduino triggered ultrasonic sensor module. comes within 30cm of sensor, servos need move 180 degrees in sync each other. have managed control 3 micro servos using code:
#include <servo.h>
#define trigpin 12
#define echopin 13
servo myservo;
void setup() {
serial.begin (9600);
pinmode(trigpin, output);
pinmode(echopin, input);
myservo.attach(9);
}
void loop() {
int duration, distance,pos=0,i;
digitalwrite(trigpin, low);
delaymicroseconds(2);
digitalwrite(trigpin, high);
delaymicroseconds(10);
digitalwrite(trigpin, low);
duration = pulsein(echopin, high);
distance = (duration/2) / 29.1;
serial.print(distance);
serial.println(" cm");
if (distance >0 && distance < 30)
{
myservo.write(180);
}
else{
myservo.write(0);
}
}
however, don't think circuit has enough voltage necessary power 9 motors. wondering if had advice how should go re-wiring , changing code? need add external power supply? have far used when connected via usb.
thank in advance!
quote
however, don't think circuit has enough voltage necessary power 9 motors.current, actually
quote
i wondering if had advice how should go re-wiring?difficult say, seeing didn't yet explain how it's wired.
quote
do need add external power supply?without question- should 1 servo. see attached pic had 3.
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Controlling 9 micro servo motors with arduino & ultrasonic sensor module
arduino
Comments
Post a Comment