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();

 switch(command)
{
   case 'w': Robot_Forward(); delay(100); break; 
   case 's': Robot_Backward(); delay(100); break;  
   case 'a': Robot_Left(); delay(100); break;
   case 'd': Robot_Right(); delay(100); break; 
   //in case the caps lock is ON
   case 'W': Robot_Forward(); delay(100); break; 
   case 'S': Robot_Backward(); delay(100); break;  
   case 'A': Robot_Left(); delay(100); break;
   case 'D': Robot_Right(); delay(100); break;      
   default: break; 
}     

}

//Intialize the motor void MotorInit() {

 int i;
 for(i=0 ; i<2; i++)
 {
 pinMode(MotorLeft[i],OUTPUT);
 pinMode(MotorRight[i],OUTPUT);
 }

} //Robot Driving Functions void Robot_Forward() {

  digitalWrite(MotorLeft[0],0);
  digitalWrite(MotorLeft[1],1);
  digitalWrite(MotorRight[0],1);
  digitalWrite(MotorRight[1],0);   

} void Robot_Backward() {

  digitalWrite(MotorLeft[0],1);
  digitalWrite(MotorLeft[1],0);
  digitalWrite(MotorRight[0],0);
  digitalWrite(MotorRight[1],1);  

} void Robot_Left() {

 digitalWrite(MotorLeft[0],1);
 digitalWrite(MotorLeft[1],0);
 digitalWrite(MotorRight[0],1);
 digitalWrite(MotorRight[1],0);    

} void Robot_Right() {

 digitalWrite(MotorLeft[0],0);
 digitalWrite(MotorLeft[1],1);
 digitalWrite(MotorRight[0],0);
 digitalWrite(MotorRight[1],1);    

}