Hello,
I tried writing a basic program to remotely controlling the mBot. Yet after I upladed the code, mBot would not recognize the remote. I used mBlock but here is the Adruino code (note: I’ve removed the brackets on the includes for this post. The code does include the backets): What is the problem?
#include Arduino.h
#include Wire.h
#include Servo.h
#include SoftwareSerial.h
#include MeMCore.h
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeIR ir;
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
MBotDCMotor motor(0);
void setup(){
ir.begin();
pinMode(A7,INPUT);}
void loop(){
if(ir.keyPressed(64)){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); delay(1000*0.2); motor.move(1,30); }else{ if(ir.keyPressed(25)){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); delay(1000*0.2); motor.move(2,30); }else{ if(ir.keyPressed(7)){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); delay(1000*0.2); motor.move(3,30); }else{ if(ir.keyPressed(9)){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); delay(1000*0.2); motor.move(4,30); }else{ if(ir.keyPressed(69)){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); } } } } } delay(1000*0.2); if((0^(analogRead(A7)>10?0:1))){ motor_9.run((9)==M1?-(0):(0)); motor_10.run((10)==M1?-(0):(0)); } ir.loop();
}