Since your reciving code is from this turorial: Serial Input Basics - updated look at example #4 to see how to receive numbers rather than text
Yes!!. That did it for me. Send in ascii and then atoi convertion.
Last question.
Would be any noticeable difference in overall speed if instead of doing it this way I send 2 bytes?
int number;
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
unsigned long a;
int dataNumber = 0;
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0';
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
dataNumber = 0;
dataNumber = atoi(receivedChars);
if (dataNumber == 512 ) {
a = 0x000000;
}
else if (dataNumber == 513 ) {
a = 0x006600;
}
else if (dataNumber == 514 ) {
trellis.show();
}
else {
trellis.setPixelColor(dataNumber , a);
}
newData = false;
}
}