the error message says [object Object] for some very strange reason

I am not sure if anything is wrong with this code to make the error message say [object Object]. and I do not know what it means. Given that the code is
const int red = 9;
const int green = 10;
const int blue = 11;
const int redLDR = A0;
const int greenLDR = A1;
const int blueLDR = A2;
int redlightlevel;
int greenlightlevel;
int bluelightlevel;
void setup(){
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop(){
redlightlevel = analogRead(redLDR);
greenlightlevel = analogRead(greenLDR);
bluelightlevel = analogRead(blueLDR);
redlightlevel = map(redlightlevel, 0, 1023, 0, 255);
redlightlevel = constrain(redlightlevel, 0, 255);
greenlightlevel = map(greenlightlevel, 0, 1023, 0, 255);
greenlightlevel = constrain(greenlightlevel, 0, 255);
bluelightlevel = map(bluelightlevel, 0, 1023, 0, 255);
bluelightlevel = constrain(bluelightlevel, 0, 255);
analogWrite(red, redlightlevel);
analogWrite(green, greenlightlevel);
analogWrite(blue, bluelightlevel);
}
, then what is the problem? I hope you can fix it.

Compiles okay for me with Uno selected in IDE 1.8.5.

const int red = 9;
const int green = 10;
const int blue = 11;
const int redLDR = A0;
const int greenLDR = A1;
const int blueLDR = A2;
int redlightlevel;
int greenlightlevel;
int bluelightlevel;
void setup(){
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop(){
redlightlevel = analogRead(redLDR);
greenlightlevel = analogRead(greenLDR);
bluelightlevel = analogRead(blueLDR);
redlightlevel = map(redlightlevel, 0, 1023, 0, 255);
redlightlevel = constrain(redlightlevel, 0, 255);
greenlightlevel = map(greenlightlevel, 0, 1023, 0, 255);
greenlightlevel = constrain(greenlightlevel, 0, 255);
bluelightlevel = map(bluelightlevel, 0, 1023, 0, 255);
bluelightlevel = constrain(bluelightlevel, 0, 255);
analogWrite(red, redlightlevel);
analogWrite(green, greenlightlevel);
analogWrite(blue, bluelightlevel);
}

please use code tags when posting your code. It will help others help you. Also, on the IDE, there is a handy little "Copy error messages" button so you can copy and paste the exact error you are seeing.

That being said, the above code compiles without complaint for me..

blh64:
please use code tags when posting your code. It will help others help you. Also, on the IDE, there is a handy little "Copy error messages" button so you can copy and paste the exact error you are seeing.

That being said, the above code compiles without complaint for me..

but when i upload it, it says [object Object]

Where does it say that?

Is that all it says?

Expand the bottom of the IDE, and copy the whole error message seen when you Upload, the part after the compiler says

Sketch uses 1406 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 15 bytes (0%) of dynamic memory, leaving 2033 bytes for local variables. Maximum is 2048 bytes.

CrossRoads:
Expand the bottom of the IDE, and copy the whole error message seen when you Upload, the part after the compiler says

Sketch uses 1406 bytes (4%) of program storage space. Maximum is 32256 bytes.

Global variables use 15 bytes (0%) of dynamic memory, leaving 2033 bytes for local variables. Maximum is 2048 bytes.

There is nothing after that.

pon00009:
There is nothing after that.

It doesn't say "[object Object]" either.

gfvalvo:
It doesn't say "[object Object]" either.

It says [object Object] on top of the compiler.

1 Like

What do you mean by "on top of the compiler"?

Really hard to figure out what you're talking about. While it's rarely helpful to post a screen shot, it may be in this case.

Sorry to come back to this ageing thread, I got this error on a completely unrelated-to-Arduino website the other day:

Screen Shot 2019-01-02 at 16.37.11.png

It's a popup window in Safari browser on MacOS. I think it's a javascript error or something similar.

I think the OP must be using the online web editor IDE and it's being a bit temperamental.

Screen Shot 2019-01-02 at 16.37.11.png

For whatever it is worth, I just got the same error message using the Arduino Create cloud IDE.

The code compiles fine on the cloud IDE and will upload from the desktop IDE, but it fails with the [object Object] error during upload on the cloud IDE. The cloud IDE does recognize that the board is plugged in.

The debug console shows a different error message (during upload) about a package certificate being signed by an unknown authority. I have added a screenshot.

1 Like

Here's an explanation of the cause of the error and a workaround from someone who experienced it:
http://forum.arduino.cc/index.php?topic=590962.msg4023404#msg4023404

This is also relevant:
http://forum.arduino.cc/index.php?topic=590962.msg4036725#msg4036725