I created an assembly and a programm that control a motor with an infrared controller. Everything's fine when i use it plugged on my computer but as soon as i plug it on a battery and activate the motor it start producing a tic-tic but doesn't move.
here's the programm:
//www.elegoo.com
//2018.12.19
#include <Servo.h>
Servo myservo;
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
myservo.attach(9);
myservo.write(90);// move servos to center position -> 90°
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results) && results.value == 16743045 ) {
myservo.write(0);
irrecv.resume();}
if (irrecv.decode(&results) && (results.value) == 16718055 ) {
myservo.write(90);
irrecv.resume();}
if (irrecv.decode(&results) && (results.value) == 16724175 ){
myservo.write(180);
irrecv.resume();
}
if (irrecv.decode(&results)){
Serial.println(results.value);
irrecv.resume();
}
}
Bob, won't that barrel connector mean that the motor is drawing 5v from the Arduino board's voltage regulator? I seem to recall a concern about overheating that with too much current. Would it be better to directly power the servo from a power source instead of through the Arduino voltage regulator? That in addition to what you've pointed out about the low-current battery.
I understand. To be completely clear, it was not my intention to needle you about how you presented your information. You know a lot more than I do, I was walking softly adding anything.