Download Print this page

Sparkfun Electronics RedBot Getting Started page 5

Advertisement

Push the small reset button to restart the program.
language:c
/*******************************************************************************
/ SimpleRedBotDrive Code - no libraries
/
/ Simple example code showing how to spin the right and left motors and braking.
/ This example requires no libraries to run, and has all of the pins used on the
/ RedBot Mainboard defined.
/
/ Before uploading this code to your RedBot, make sure that the RedBot is in a safe
/ place. It will start moving immediately after you upload the program. We suggest
/ placing the RedBot on it's end so that the wheels are up.
/
/ Push the small reset button on the board to run the program again.
/
/ Note: The RedBot Mainboard programs as an Arduino Uno
/******************************************************************************/
// H-Bridge motor driver pins
#define
L_CTRL1 2
#define
L_CTRL2 4
#define
L_PWM
5
#define
R_CTRL1 7
#define
R_CTRL2 8
#define
R_PWM
6
// XBee SW_Serial pins
#define
SW_SER_TX A0
#define
SW_SER_RX A1
/*******************
/ setup function
/*******************/
void setup()
{
Serial.begin(9600);
pinMode(L_CTRL1, OUTPUT); // used as a debug pin for an LED.
pinMode(L_CTRL2, OUTPUT); // used as a debug pin for an LED.
pinMode(L_PWM, OUTPUT); // used as a debug pin for an LED.
pinMode(R_CTRL1, OUTPUT); // used as a debug pin for an LED.
pinMode(R_CTRL2, OUTPUT); // used as a debug pin for an LED.
pinMode(R_PWM, OUTPUT); // used as a debug pin for an LED.
pinMode(13, OUTPUT); // used as a debug pin for an LED.
// spin the left Motor CW
leftMotor(255);
delay(2000);
leftBrake();
delay(1000); // wait for 1000 milliseconds
Page 5 of 19

Advertisement

loading
Need help?

Need help?

Do you have a question about the RedBot and is the answer not in the manual?

Subscribe to Our Youtube Channel