Line 4: Line 4:
 
To give a brief the Robo Controller board has a CP2102 USB to UART(Serial) convertor. We give commands to the robot from the terminal and move it. This is a very simple type and you can easily hack it. The controller board also has a atmega8 MCU with Arduino bootloader, hence we can code it from the Arduino IDE
 
To give a brief the Robo Controller board has a CP2102 USB to UART(Serial) convertor. We give commands to the robot from the terminal and move it. This is a very simple type and you can easily hack it. The controller board also has a atmega8 MCU with Arduino bootloader, hence we can code it from the Arduino IDE
 
<br />
 
<br />
<syntaxhighlight>
+
 
 
#include <Firmata.h>
 
#include <Firmata.h>
 
int MotorLeft[2] = {A0,A1};
 
int MotorLeft[2] = {A0,A1};
Line 75: Line 75:
 
   digitalWrite(MotorRight[1],1);     
 
   digitalWrite(MotorRight[1],1);     
 
}
 
}
 
</syntaxhighlight>
 

Revision as of 14:12, 27 August 2014

Intro

For this tutorial we will be using the Explore Robo kit. You may go ahead and download the schematics and other details from the link. To give a brief the Robo Controller board has a CP2102 USB to UART(Serial) convertor. We give commands to the robot from the terminal and move it. This is a very simple type and you can easily hack it. The controller board also has a atmega8 MCU with Arduino bootloader, hence we can code it from the Arduino IDE

  1. include <Firmata.h>

int MotorLeft[2] = {A0,A1}; int MotorRight[2] = {A2,A3};

void setup() { Serial.begin(9600); MotorInit(); Serial.print("*Explore Robo Mode Computer: Controlled*\n\r"); Serial.println("Commands:\n W->Forward \n S->Backwards \n A->Left \n D->Right"); }

void loop() { int command; command = Serial.read();

  1. switch(command)
  2. {
  3. case 'w': Robot_Forward(); delay(100); break;
  4. case 's': Robot_Backward(); delay(100); break;
  5. case 'a': Robot_Left(); delay(100); break;
  6. case 'd': Robot_Right(); delay(100); break;
  7. //in case the caps lock is ON
  8. case 'W': Robot_Forward(); delay(100); break;
  9. case 'S': Robot_Backward(); delay(100); break;
  10. case 'A': Robot_Left(); delay(100); break;
  11. case 'D': Robot_Right(); delay(100); break;
  12. default: break;
  13. }

}

//Intialize the motor void MotorInit() {

  1. int i;
  2. for(i=0 ; i<2; i++)
  3. {
  4. pinMode(MotorLeft[i],OUTPUT);
  5. pinMode(MotorRight[i],OUTPUT);
  6. }

} //Robot Driving Functions void Robot_Forward() {

  1. digitalWrite(MotorLeft[0],0);
  2. digitalWrite(MotorLeft[1],1);
  3. digitalWrite(MotorRight[0],1);
  4. digitalWrite(MotorRight[1],0);

} void Robot_Backward() {

  1. digitalWrite(MotorLeft[0],1);
  2. digitalWrite(MotorLeft[1],0);
  3. digitalWrite(MotorRight[0],0);
  4. digitalWrite(MotorRight[1],1);

} void Robot_Left() {

  1. digitalWrite(MotorLeft[0],1);
  2. digitalWrite(MotorLeft[1],0);
  3. digitalWrite(MotorRight[0],1);
  4. digitalWrite(MotorRight[1],0);

} void Robot_Right() {

  1. digitalWrite(MotorLeft[0],0);
  2. digitalWrite(MotorLeft[1],1);
  3. digitalWrite(MotorRight[0],0);
  4. digitalWrite(MotorRight[1],1);

}