Uploading Arduino code into mCore


#1

Hi!

I’m trying to upload an arduino code only for the line following mode but I’m getting this error message all the time:

avrdude: ser_open(): can’t open device “COM4”: No such file or directory
ioctl(“TIOCMGET”): Inappropriate ioctl for device
ioctl(“TIOCMGET”): Inappropriate ioctl for device
avrdude: ser_send(): write error: Bad file descriptor

Can you guys tell me what is the problem? My mcore is connected and the serial port selected.
This is the code:

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

#include <MeMCore.h>

MeBuzzer buzzer;
MeLineFollower lineFinder(PORT_2);
MeDCMotor motor1(M1); //Motor1 is Left Motor
MeDCMotor motor2(M2); //Motor2 is Left Motor
MeRGBLed led(0, 30);

void setup() {
led.setpin(13);
pinMode(7, INPUT); //Define button pin as input
while (analogRead(7) > 100) {
delay(50); //Wait till button pressed to start.
}
buzzer.tone(200, 200); //Buzzer beep to indicate start
}

float MOTOR1_TUNE = -1.0; //Left motor scale factor
float MOTOR2_TUNE = 1.0; //Right motor scale factor
float turning_left = true;

void loop() {
int sensorState = lineFinder.readSensors();
switch (sensorState)
{
case S1_IN_S2_IN:
motor1.run(MOTOR1_TUNE * 255.0); //Left motor Run
motor2.run(MOTOR2_TUNE * 255.0); //Right motor Run
led.setColorAt(1, 0, 255, 0); //Set LED1 (RGBLED2) (LeftSide)
led.setColorAt(0, 0, 255, 0); //Set LED0 (RGBLED1) (RightSide)
led.show();
break;
case S1_IN_S2_OUT:
//turn left
motor1.run(MOTOR1_TUNE * 0); //Left motor Stop
motor2.run(MOTOR2_TUNE * 255.0); //Right motor Run
led.setColorAt(1, 0, 0, 0); //Set LED1 (RGBLED2) (LeftSide)
led.setColorAt(0, 0, 255, 0); //Set LED0 (RGBLED1) (RightSide)
led.show();
turning_left = true;
break;
case S1_OUT_S2_IN:
//turn right
motor1.run(MOTOR1_TUNE * 255.0); //Left motor Run
motor2.run(MOTOR2_TUNE * 0); //Right motor Stop
led.setColorAt(1, 0, 255, 0); //Set LED1 (RGBLED2) (LeftSide)
led.setColorAt(0, 0, 0, 0); //Set LED0 (RGBLED1) (RightSide)
led.show();
turning_left = false;
break;
case S1_OUT_S2_OUT:
//keep turning what it was turning
if (turning_left) {
motor1.run(MOTOR1_TUNE * 0); //Left motor Stop
motor2.run(MOTOR2_TUNE * 255.0); //Right motor Run
led.setColorAt(1, 0, 0, 0); //Set LED1 (RGBLED2) (LeftSide)
led.setColorAt(0, 255, 0, 0); //Set LED0 (RGBLED1) (RightSide)
led.show();
} else {
motor1.run(MOTOR1_TUNE * 255.0); //Left motor Run
motor2.run(MOTOR2_TUNE * 0); //Right motor Stop
led.setColorAt(1, 255, 0, 0); //Set LED1 (RGBLED2) (LeftSide)
led.setColorAt(0, 0, 0, 0); //Set LED0 (RGBLED1) (RightSide)
led.show();
}
break;
default: break;
}
}

I’e arleady have the makeblock libraries in the arduino app/contents/Java/libraries/Makeblock.

Thank you!


#2

The error you’re receiving indicates that you are not connected to the board. I’d suggest the following:

  1. Make sure that you have shut down mBlock.
  2. Make sure that you have selected the correct board/port in the Arduino environment.
  3. Make sure the mBot is on.

For what it’s worth, you should be able to delete these lines:

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

because those headers are included in MeMCore.h. It doesn’t hurt to have them there, but they aren’t needed. :slight_smile:


#3

I didn’t shut down mBlock…

Thank you :slight_smile:


#4

Glad to hear it was that simple! :smiley:


#5