OK. So after a little more testing I can answer this myself now. It wasnt working because the USB power connection will power the Orion board…but not the motor outputs. So when I was testing, no motors were running because the battery pack was switched off. Once i realised that I found my code was working. For those interested, here is the initial code I am using to drive the starter robot using single letters passed over the serial/USB connection. Each letter will correspond to a voice commend processed on the Pi by Jasper.
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <MeOrion.h>
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double iSonicSensor;
MeUltrasonicSensor ultrasonic_3(3);
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
char myChar = ‘z’;
void setup()
{
Serial.begin(9600);
}
void loop(){
if (Serial.available()) {
myChar = Serial.read();
}
if(myChar==‘h’){
//need to call a function to halt
halt();
}
if(myChar==‘f’){
//need to call a function to go forward
forward();
}
if(myChar==‘l’){
//need to call a function to turn left
left();
}
if(myChar==‘r’){
//need to call a function to turn right
right();
}
if(myChar==‘b’){
//need to call a function to go backward
back();
}
}
void halt(){
motor_9.run(0);
motor_10.run(0);
}
void forward(){
motor_9.run(-100);
motor_10.run(100);
}
void left(){
motor_9.run(100);
motor_10.run(100);
}
void right(){
motor_9.run(-100);
motor_10.run(-100);
}
void back(){
motor_9.run(50);
motor_10.run(-50);
}