NOTE - Fixes in last post by me.
Noob question about power and how to identify power issues when you only have a cheap radio shack multimeter and no clue.
My robot is a rover, I've been building it over the past few weeks. I had it operating with 4 small motors (like these, sorry no info http://www.amazon.com/Smart-Robot-Wheel-Motor-Yellow/dp/B00EBRLE7G), off an L298 dual stepper motor bridge board, along with an arduino uno r3, a SainSmart v5 Sensor Shield and 2 HC-SR04 ultrasonic sensors. It is powered by 6 AA's (new for this project). There is a power switch. The four motors are actually wired in pairs, so its not 4WD, but left side/right side (technically not 2WD).
Previous to this servo addition, and related code change, the robot works fine. I can revert it without issue as well.
I have updated the code to account for the new servo, used to rotate one of the ultrasonic sensors. The setup function is the normal pin setup stuff, followed by a series of statements activating the servo, and turning it a few times.
When I have this powered on by battery (USB not connected, turning power switch to ON), the robot appears to get stuck in the Setup phase. It kinda turns and repeats this, and the servo jiggles as it tries to perform the rotations. But it never moves past this.
When I plug in the usb from my computer (battery is still connected, power switch is off), it seems to behave as expected. It performs the setup procedure and then the serial monitor indicates it is moving on and behaving normally. (FYI - the motors will not turn in this setup, but a noise is heard likely when they try to draw power)
I know NOTHING about power, and I'm suspecting that I have exceeded the abilities of my power source (6 AA's). Is this a correct statement based on the info I've provided?
If I disconnect the new servo and disable the servo setup code, it works normally. So that tells me the issue is either with my servo control code, or the power. The pin under question is pin 4. ( HeadServopin)
Here is my related servo/pin code:
#include <Servo.h>
Servo headservo;
const int EchoPin = 2; // Ultrasonic 1 signal input
const int TrigPin = 3; // Ultrasonic 1 signal output
const int RearEchoPin = 13; // Ultrasonic rear signal input
const int RearTrigPin = 12; // Ultrasonic rear signal output
const int HeadServopin = 4; // signal input of headservo
const int leftmotorpin1 = 9; //signal output of DC geared motor
const int leftmotorpin2 = 10;
const int rightmotorpin1 = 5;
const int rightmotorpin2 = 6;
void setup() {
Serial.begin(9600); // Serial begin texting
pinMode(EchoPin, INPUT);
pinMode(RearEchoPin, INPUT);
// for (int pinindex = 3; pinindex < 8; pinindex++) {
for (int pinindex = 3; pinindex < 13; pinindex++) {
pinMode(pinindex, OUTPUT); // set pins 3 to 13 as outputs
}
Serial.println("Head servo activating.");
// headservo interface
headservo.attach(HeadServopin);
//start buffer movable head
headservo.write(90);
delay(1000);
Serial.println("Head servo 90 done.");
}