8x8 led display con by max msp. Newbie problem

Hi.
First time here.

Just getting strated

Im trying to cotrol an 8x8 led display (cjmcu 8x8) with max.- using Neopixel)

If i set i to be position of led it does work

but if i set i to be one of the 3 RGB doesnt

any idea?

#include <Adafruit_NeoPixel.h>

#define PIN 3
#define NUMPIXELS 64

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{

Serial.begin(9600);
pixels.begin();
}

void loop() {

int i=Serial.read() ;

pixels.setPixelColor(i, pixels.Color(1,24,34));
pixels.show();

}

That code is all wrong, please read Serial basics
If you read from the serial port and there is nothing in the buffer you will read 255.

And while you are at it please read he how to use this forum sticky post, it will tell you how to post code correctly.

From your ‘Serial Monitor’ send a 9 to the Arduino.

What do you think is received at the Arduino?

Grumpy_Mike:
That code is all wrong, please read Serial basics
If you read from the serial port and there is nothing in the buffer you will read 255.

And while you are at it please read he how to use this forum sticky post, it will tell you how to post code correctly.

Thanks for the reply.

Good name thou

Grumpy_Mike:
If you read from the serial port and there is nothing in the buffer you will read 255.

No, you will read -1

Same thing, it is bit pattern 0xFF hex or 11111111 in binary or 255 as an unsigned byte or -1 as a signed byte.

The important thing is is not what the op wants.

By the way I wonder if you know that posts with your name next to them just show blank?

Grumpy_Mike:
Same thing, it is bit pattern 0xFF hex or 11111111 in binary or 255 as an unsigned byte or -1 as a signed byte.

No, it’s not the same thing.
He’s reading the result into an “int”, where the representation of -1 is 0xFFFF.

Yes, I do know the reason, bit I’m not telling.

TheMemberFormerlyKnownAsAWOL:
Yes, I do know the reason, bit I'm not telling.

Oh come on! :roll_eyes:

Paul__B:
Oh come on! :roll_eyes:

'cos I broke the forum