Hello, folks. Been searching high and low for some information on generic code for BabyO, and apart from the given on-site resources, haven’t been able to find what I’m looking for. Since am experimenting for now, I decided to go with the default LV-168 demonstration (Demo #3). So, I coupled up the motors (am using 2xSolarbotics GM8 connected to M1A|B and M2A|B) and removed the stuff that isn’t present on the controller I have (BabyO ATMega168 - green version). So far, the code looks like this - note I’m testing the code on only one of the two motors:
#include <avr/io.h>
#define M1B PD5
#define M1A PD6
#define M2B PD3
#define M2A PB3
#define M1_FORWARD(my_valA) OCR0A = 0; OCR0B = my_valA
#define M1_REVERSE(my_valA) OCR0B = 0; OCR0A = my_valA
#define M2_FORWARD(my_valB) OCR2A = 0; OCR2B = my_valB
#define M2_REVERSE(my_valB) OCR2B = 0; OCR2A = my_valB
void motors_init()
{
PORTD |= (1 << M1A) | (1 << M1B) | (1 << M2B);
PORTB |= (1 << M2A);
DDRD |= (1 << M1A) | (1 << M1B) | (1 << M2B);
DDRB |= (1 << M2A);
OCR0A = OCR0B = OCR2A = OCR2B = 0;
TCCR0A = TCCR2A = 0xF3;
TCCR0B = TCCR2B = 0x02;
}
int main()
{
motors_init();
while (1) // loop forever
{
long sum = 0;
unsigned int avg, i;
int my_valA = 0;
int my_valB = 255;
M1_FORWARD(my_valA);
//M1_REVERSE(my_valB);
}
return 0;
}
Might sound hilarious, as I have no experience whatsoever with robotics, hence I believe the code is wrong in some spots and doesn’t fit what I’m trying to do. To put it simple, I want to test functionality of the motors I coupled up, spinning forward and in reverse. So far, everything I write up in that code makes it drive only forward o_O
Thanks in advance for your suggestions