My code is not working


#1

Hello,

I have created a new mbot project. I work on it and when I upload it on my mbot arduino card, it’s write an error message. It’s write :

compilation terminated.
Erreur de compilation. (Compilation error)

or

RDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\SoftwareSerial -IC:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src C:\Users\JAUNEC~1\AppData\Local\Temp\build4036469759547372272.tmp\project_lumi_reMagic4_4.cpp -o C:\Users\JAUNEC~1\AppData\Local\Temp\build4036469759547372272.tmp\project_lumi_reMagic4_4.cpp.o
project_lumi_reMagic4_4.ino: In function ‘void setup()’:
project_lumi_reMagic4_4.ino:186:46: error: no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’
project_lumi_reMagic4_4.ino:186:46: note: candidate is:
In file included from C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeMCore.h:69:0,
from project_lumi_reMagic4_4.ino:5:
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: void MeLEDMatrix::showNum(float, uint8_t)
void showNum(float value,uint8_t = 3);
^
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: no known conversion for argument 1 from ‘StringSumHelper’ to ‘float’
no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’

(Sorry for my bad English… I speak french (Quebec) and I try to not use google translate to practice it.)

Click the link to download the sb2 project. Some blocks are not attached because I am not using them and I want to keep them if I have to re-use them. I am using the mblock software v3.4.11 and I am on windows 10. My mbot is connected to my pc with the included USB cable.

My Arduino code :

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

#include <MeMCore.h>

MeDCMotor motor_9(9);
MeDCMotor motor_10(10);

void move(int direction, int speed)
{
int leftSpeed = 0;
int rightSpeed = 0;
if(direction == 1){
leftSpeed = speed;
rightSpeed = speed;
}else if(direction == 2){
leftSpeed = -speed;
rightSpeed = -speed;
}else if(direction == 3){
leftSpeed = -speed;
rightSpeed = speed;
}else if(direction == 4){
leftSpeed = speed;
rightSpeed = -speed;
}
motor_9.run((9)==M1?-(leftSpeed):(leftSpeed));
motor_10.run((10)==M1?-(rightSpeed):(rightSpeed));
}

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double __var__108_117_109_105_110_111_115_105_116_233;
double mode;
double bruit;
double x;
double pv;
double pv2;
double joueur;
MeRGBLed rgbled_7(7, 7==7?2:4);
MeRGBLed rgbled_3(3, 3==7?2:4);
MeLEDMatrix ledMtx_1(1);
MeBuzzer buzzer;
unsigned char drawBuffer[16];
unsigned char *drawTemp;
double currentTime = 0;
double lastTime = 0;
MeIR ir;
double getLastTime(){
return currentTime = millis()/1000.0 - lastTime;
}
MeSoundSensor soundsensor_4(4);

void setup(){
ledMtx_1.setColorIndex(1);
ledMtx_1.setBrightness(6);
ir.begin();
rgbled_7.setColor(0,0,255,0);
rgbled_7.show();
rgbled_3.setColor(0,0,255,0);
rgbled_3.show();
_delay(1);
__var__108_117_109_105_110_111_115_105_116_233 = 0;
mode = 1;
bruit = 0;
x = 0;
pv = 20;
pv2 = 20;
ledMtx_1.drawStr(0,0+7,“YO!”);
buzzer.tone(65, 250);
delay(20);
buzzer.tone(73, 250);
delay(20);
buzzer.tone(82, 250);
delay(20);
buzzer.tone(87, 250);
delay(20);
buzzer.tone(98, 250);
delay(20);
buzzer.tone(110, 250);
delay(20);
buzzer.tone(123, 250);
delay(20);
drawTemp = new unsigned char[16]{0,16,32,64,68,34,19,3,3,19,34,68,64,32,16,0};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
_delay(1);
lastTime = millis()/1000.0;
pinMode(A7,INPUT);
while(!((ir.keyPressed(69)) || ((0^(analogRead(A7)>10?0:1)))))
{
_loop();
ledMtx_1.drawStr(x,0+7,“DUEL MAGIC BIENTOT!”);
x += -1;
_delay(0.1);
if((getLastTime()) > (12)){
lastTime = millis()/1000.0;
x = 0;
}
}
while(!(ir.keyPressed(69)))
{
_loop();
joueur = random(1,(2)+1);
_delay(0.001);
if(((joueur)==(1))){
drawTemp = new unsigned char[16]{0,0,0,24,60,126,219,153,24,24,24,24,24,24,24,24};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
}
if(((joueur)==(2))){
drawTemp = new unsigned char[16]{24,24,24,24,24,24,24,24,153,219,126,60,24,0,0,0};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
}
}
if(((joueur)==(1))){
drawTemp = new unsigned char[16]{0,0,0,24,60,126,219,153,24,24,24,24,24,24,24,24};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
}
if(((joueur)==(2))){
drawTemp = new unsigned char[16]{24,24,24,24,24,24,24,24,153,219,126,60,24,0,0,0};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
}
_delay(5);
drawTemp = new unsigned char[16]{255,129,137,143,0,255,129,129,129,255,0,253,0,253,0,253};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
buzzer.tone(262, 250);
delay(20);
buzzer.tone(294, 250);
delay(20);
buzzer.tone(330, 500);
delay(20);
rgbled_7.setColor(0,255,128,0);
rgbled_7.show();
x = 0;
lastTime = millis()/1000.0;
while(!(ir.keyPressed(13)))
{
_loop();
if((((mode)==(0))) && (((0^(analogRead(A7)>10?0:1))) || (ir.keyPressed(21)))){
buzzer.tone(262, 125);
delay(20);
mode = 1;
}
if((((mode)==(1))) && (((0^(analogRead(A7)>10?0:1))) || (ir.keyPressed(21)))){
buzzer.tone(262, 125);
delay(20);
mode = 0;
}
if(((mode)==(0))){
if((((bruit)==(1))) && ((soundsensor_4.strength()) > (600))){
bruit = 0;
buzzer.tone(262, 500);
delay(20);
}
}
if(((mode)==(1))){
rgbled_3.setColor(0,255,128,0);
rgbled_3.show();
}
if((((bruit)==(0))) && ((soundsensor_4.strength()) > (500))){
bruit = 1;
buzzer.tone(262, 500);
delay(20);
}
if(((bruit)==(1))){
rgbled_3.setColor(0,255,255,255);
rgbled_3.show();
}
if(((bruit)==(0))){
rgbled_3.setColor(0,0,0,0);
rgbled_3.show();
}
ledMtx_1.showNum(pv,3);
if(ir.keyPressed(25)){
pv += -1;
_delay(0.2);
}
if(ir.keyPressed(64)){
pv += 1;
_delay(0.2);
}
if(ir.keyPressed(7)){
pv2 += -1;
_delay(0.2);
}
if(ir.keyPressed(9)){
pv2 += 1;
_delay(0.2);
}
}

}

void loop(){

drawTemp = new unsigned char[16]{0,128,64,96,72,142,15,15,15,15,142,72,96,64,128,0};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
buzzer.tone(262, 500);
delay(20);
buzzer.tone(294, 500);
delay(20);
buzzer.tone(330, 1000);
delay(20);
rgbled_7.setColor(0,255,0,0);
rgbled_7.show();
rgbled_3.setColor(0,255,0,0);
rgbled_3.show();
drawTemp = new unsigned char[16]{255,152,148,243,0,195,255,255,195,0,255,144,144,240,0,253};
memcpy(drawBuffer,drawTemp,16);
free(drawTemp);
ledMtx_1.drawBitmap(0,0,16,drawBuffer);
buzzer.tone(262, 500);
delay(20);
buzzer.tone(294, 500);
delay(20);
buzzer.tone(330, 1000);
delay(20);

_loop();

}

void _delay(float seconds){
long endTime = millis() + seconds * 1000;
while(millis() < endTime)_loop();
}

void _loop(){
ir.loop();

}

lumière Magic.sb2 (76.4 KB)


#2

Ohhhhhh… Annoter error code is show with this file… :sleepy:

sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: no known conversion for argument 1 from ‘StringSumHelper’ to ‘float’
no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’

Utilisation de la biblioth鑡ue Wire prise dans le dossier : C:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire
Utilisation de la biblioth鑡ue SoftwareSerial prise dans le dossier : C:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
Utilisation de la biblioth鑡ue MakeBlockDrive prise dans le dossier : C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock

C:\Program Files (x86)\mBlock\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\SoftwareSerial -IC:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src C:\Users\JAUNEC~1\AppData\Local\Temp\build9002191772201071967.tmp\project_lumi_reMagic4_4.cpp -o C:\Users\JAUNEC~1\AppData\Local\Temp\build9002191772201071967.tmp\project_lumi_reMagic4_4.cpp.o

lumière Magic.sb2 (76.4 KB)


#3

I’m on a Mac (shouldn’t make a difference) and just uploaded and ran your code with no problems so you can be assured that the program works! :slight_smile:

However, that is cold comfort if you can’t get it to work. You might want to try reinstalling mBlock and make sure that you have permissions to write to the location where you are installing it.

@tech_support should probably have a peek at this too if that doesn’t solve your problem.

I would also encourage you to use custom blocks to contain chunks of your code. As the program gets longer, mBlock will begin to slow down because it has to parse all of the blocks and the underlying Scratch 2.0 offline editor doesn’t handle that well. :slight_smile:


#4

Hi NexXor_the_dark,
I’ve also tested with the program you provided, no problem, uploaded successfully.
Try chuckmcknight’s suggestion, reinstall your mblock software under C drive (if not work, can also try D drive), and make sure run the software as administrator account.


#5

Not working too… I uninstall mblock and reinstall it and another error code.

project_lumi_reMagic4_5.ino:186:46: error: no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’
project_lumi_reMagic4_5.ino:186:46: note: candidate is:
In file included from C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeMCore.h:69:0,
from project_lumi_reMagic4_5.ino:5:
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: void MeLEDMatrix::showNum(float, uint8_t)
void showNum(float value,uint8_t = 3);
^
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: no known conversion for argument 1 from ‘StringSumHelper’ to ‘float’
no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’

Same error code in English :

RDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\SoftwareSerial -IC:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src C:\Users\JAUNEC~1\AppData\Local\Temp\build2926974983524831538.tmp\project_lumi_reMagic4_5.cpp -o C:\Users\JAUNEC~1\AppData\Local\Temp\build2926974983524831538.tmp\project_lumi_reMagic4_5.cpp.o
project_lumi_reMagic4_5.ino: In function ‘void setup()’:
project_lumi_reMagic4_5.ino:186:46: error: no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’
project_lumi_reMagic4_5.ino:186:46: note: candidate is:
In file included from C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeMCore.h:69:0,
from project_lumi_reMagic4_5.ino:5:
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: void MeLEDMatrix::showNum(float, uint8_t)
void showNum(float value,uint8_t = 3);
^
C:\Program Files (x86)\mBlock\Arduino\portable\sketchbook\libraries\makeblock\src/MeLEDMatrix.h:246:8: note: no known conversion for argument 1 from ‘StringSumHelper’ to ‘float’
no matching function for call to ‘MeLEDMatrix::showNum(StringSumHelper&, int)’

There exist an online editor or a new offline one that it`s work with mbot?

I have only one drive (c:\) so I can`t install it on the D drive. Thank you for your answers.


#6

:star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck::star_struck:

I find how!!!

The block show face port 1 number : do not support | symbol ! I remove the symbol and upload with no problem!


#7

Great job being persistent!


#8

Thanks!
:slightly_smiling_face:


#9

There are apparently several characters that are not supported (link). The current code generator declares all variables as doubles, so you can’t really set a variable with a string.

LED Matrix Special Symbols (US Keyboard)

Symbol Appears on LED Matrix Description
! Yes Exclamation mark
@ No 'At' sign
# Yes Hash mark
$ No Dollar sign
% Yes Percent sign
^ No Caret
& No Ampersand
* Yes (but looks like an X) Asterisk
( Yes Left parentheses
) Yes Right parentheses
_ No Underscore
- Yes Minus sign
+ Yes Plus sign
= Yes Equals sign
~ Yes Tilde
` No Left tick mark
{ No Left curly brace
} No Right curly brace
[ No Left square bracket
] No Right square bracket
| Yes Vertical pipe
\ No Backslash1
; Yes Semi-colon
: Yes Colon
" Yes Double quote2
' No Single quote
< Yes Left angle bracket
> Yes Right angle bracket
, Yes Comma
. Yes Period
? Yes Question mark
/ Yes Forward slash

1 Causes compilation error unless entered as \\ because the backslash is used as an escape character in C strings.

2 Must be entered as \" to avoid a compilation error due to how C strings work.


#10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.