Okay... it's working now.
I finally bought a 12 volt lead acid battery,
12 volts, 1.3Ah
https://grabcad.com/library/kt-1213-12-v-1-3-ah-agm-lead-acid-battery-1
I bought a solar charge controller to to charge the battery.
MODEL: LMS2430.
BRAND: HOMPIE (not sure if this is reseller or brand?)
12/24 V, 30 A (overkill for my 24 volt, 10 watt panel)
I have the battery hooked up to the charge controller and now I hooked up the LM2596 VOLTAGE BUCK CONVERTER to the battery. The voltage is dropped down from 12 volts to 6 volts to power my 6 volt motors. They are successfully moving.
When I tested my 6 volt motors with the power supply they run at 50 mA at no load (matches with motor data sheet description).
Here is a link to the buck converter I bought:
https://www.amazon.com/gp/product/B0140SW9D8/ref=oh_aui_search_detailpage?ie=UTF8&psc=1
The website below provides more details for the specs of the buck converter:
https://www.importitall.co.za/Qunqi-LM2596-Buck-Converter-4040-to-1337V-Adjustable-StepDown-Power-Module-with-LED-Display-Voltmeter-ap-B0140SW9D8.html
I've also attached a pdf for the lm2596 chip but not the converter itself.
Here is my latest code for reference:
// Special thanks to Geo Bruce on instructables.com for his version of the code.
// Enable A and Enable B pins on dual motors h-bridge must be connected to two pwm (pulse width modulation) pins on arduino uno/micro/pro mini: 3,5,6,9,10,11.
int enA = 3; int in1 = 4; int in2 = 5; // motor azimuth adjustment
int enB = 9; int in3 = 7; int in4 = 8; // motor elevation adjustment
void setup()
{
Serial.begin(9600); // initialize the serial port
pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(enB, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); // set all the motor control pins to outputs
}
void loop()
{
// LIGHT SENSOR (in this case a Light Dependent Resistor) pin connections and analog pin on respective arduino board
int br = analogRead(0); // BOTTOM RIGHT
int tr = analogRead(1); // TOP RIGHT
int tl = analogRead(2); // TOP LEFT
int bl = analogRead(3); // BOTTOM LEFT
int delaytime = analogRead(A6)*2; // control delay time in milliseconds of LIGHT SENSOR readings
int tolerance = analogRead(A7)/4; // set range of tolerance between LIGHT SENSOR readings
//print LIGHT SENSOR values to serial monitor for debugging
Serial.println(tl); Serial.println(bl); Serial.println(tr); Serial.println(br); Serial.println(delaytime); Serial.println("ms"); Serial.println(tolerance); Serial.println("photoresistor difference"); Serial.println();
int count = 0; //start millisecond count of LIGHT SENSOR readings
count++; //incremental count increase, continues to show LIGHT SENSOR results
int avt = (tr + tl) / 2; // average value top
int avd = (bl + br) / 2; // average value down
int avl = (tl + bl) / 2; // average value left
int avr = (tr + br) / 2; // average value right
int dv = avt - avd; // average difference of top and bottom LIGHT SENSORS
int dh = avl - avr;// average difference of left and right LIGHT SENSORS
if (-1*tolerance > dv || dv > tolerance) // check if the difference in top/bottom LIGHT SENSORS is greater than tolerance
{
if (avt > avd) // if average LIGHT SENSOR values on top side are greater than on bottom side then elevation motor rotates CLOCKWISE
{
digitalWrite(in3, LOW); digitalWrite(in4, HIGH); analogWrite(enB, 254); // set speed out of possible range 0~255
Serial.println("ELEVATION MOTOR MOVES CLOCKWISE");
Serial.println(" ");
}
else // if average LIGHT SENSOR values on bottom side are greater than on top side then elevation motor rotates COUNTERCLOCKWISE
{
digitalWrite(in3, HIGH); digitalWrite(in4, LOW); analogWrite(enB, 254);
Serial.println("ELEVATION MOTOR MOVES COUNTERCLOCKWISE");
Serial.println(" ");
}
}
else if (-1*tolerance < dv || dv < tolerance) // if difference is smaller than tolerance, STOP elevation motor
{
digitalWrite(in3, LOW); digitalWrite(in4, LOW);
Serial.println("ELEVATION MOTOR STOPS");
Serial.println(" ");
}
if (-1*tolerance > dh || dh > tolerance) // check if the difference in left and right LIGHT SENSORS is within tolerance range
{
if (avl > avr) // if average LIGHT SENSOR values on left side are greater than right side, azimuth motor rotates CLOCKWISE
{
digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, 254);
Serial.println("AZIMUTH MOTOR MOVES CLOCKWISE");
Serial.println(" ");
}
else // if average LIGHT SENSOR values on right side are greater than on left side, azimuth motor rotates COUNTERCLOCKWISE
{
digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enA, 254);
Serial.println("AZIMUTH MOTOR MOVES COUNTERCLOCKWISE");
}
}
else if (-1*tolerance < dh || dh < tolerance) //if difference is smaller than tolerance, STOP azimuth motor
{
digitalWrite(in1, LOW); digitalWrite(in2, LOW);
Serial.println("AZIMUTH MOTOR STOPS");
Serial.println(" ");
}
delay(delaytime);
}
Thanks!
TS-32GZ370.pdf (263 KB)
LM2596-D.PDF (449 KB)