I bought a Make It Robotics kit since I'm pretty green in this space:
Kit: http://comingsoon.radioshack.com/make-it-robotics-starter-kit/2770168.html#.VZh42xNViko
Code: GitHub - RadioShackCorp/2770168-MakeItRobotics-Starter-Kit: Support files, user's guide, library files, and example sketches for RadioShack Make: it Robotics Starter Kit (SKU 2770168)
I'm trying to understand how the motor shield works so I can use it in other ways. I see that they send power to the motors using:
#define DC_SEND_HEADER 0x56
#define DC_RECV_HEADER 0x76
#define DC_CMD_DIRA 0x73
#define DC_CMD_DIRB 0x74
...
#define DC_CMD_PWMA 0x80
#define DC_CMD_PWMB 0x81
...
#define FW 0xff
#define BW 0x00
void MakeItRobotics::line_following_turn_left(int speed)
{
int duty = 0;
int half = 0;
if(speed == 0)
{
duty = 0;
half = 0;
}
else if(speed >= 255)
{
duty = 1;
half = 128;
}
else
{
duty = 257 - speed;
half = 257 - speed*3/4;
}
dc_write(DC_CMD_DIRA, BW);
dc_write(DC_CMD_DIRB, FW);
dc_write(DC_CMD_PWMA, half);
dc_write(DC_CMD_PWMB, duty);
...
}
...
void MakeItRobotics::dc_write(int type, int value)
{
Serial.write(DC_SEND_HEADER);
Serial.write(type);
Serial.write(value);
delay(20);
}
And this makes almost no sense to me--it's all very new. Please point me in the correct direction.
First, what is the purpose of DC_SEND_HEADER?
Second, when I do something like Serial.write(0x56), what am I accomplishing?
My guess is that the shield is taking its instructions from the serial port, rather than getting a message from a pin, and these are triggers or specialized messages for the embedded microcontroller. When I say that, I sound like I know what I'm talking about, but I don't...
Thanks for any help!