So I don't have to Google it, what is max/msp?
It is a modular programing language from Cycling 74. I use it in Ableton Live ( digital audio workstation) to comunicate with hardware.
Im biulding a cotroller with Adafruits Neotrellis led/button boards with a Teensy 4.0 controller board.
To make my question clearer.
I need to send integers from 0 to 600 to teensy. And sending directly the int to serial (in max/msp) I could only do 0-255.
Using a different code, with end marker, and playing around with " atoi" and "itoa" I managed to solve that obstacle.
But since I dont understand the different data types and convertions I have a, hopefully, last and more concrete obstacle.
On max/msp , I convert a number (lets say 512) to asccii, append a 10 (endline) at the end and send it to serial module.
On teensy I think I get an array but I need to use integers and cant do the convertion.
Here the code
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
unsigned long a;
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) {
if (receivedChars == 512 ) {
a = 0x000000;
}
else if (receivedChars == 513 ) {
a = 0x006600;
}
else if (receivedChars == 514 ) {
trellis.show();
}
else {
trellis.setPixelColor(receivedChars , a);
}
newData = false;
}
}
Here is the error I get
Nuevito: In function 'void showNewData()':
C:\Users\Moris\Desktop\Nuevito\Nuevito.ino:104:26: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (receivedChars == 512 ) {
^
C:\Users\Moris\Desktop\Nuevito\Nuevito.ino:108:31: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (receivedChars == 513 ) {
^
C:\Users\Moris\Desktop\Nuevito\Nuevito.ino:112:31: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (receivedChars == 514 ) {
^
C:\Users\Moris\Desktop\Nuevito\Nuevito.ino:117:44: warning: invalid conversion from 'char*' to 'uint16_t {aka short unsigned int}' [-fpermissive]
trellis.setPixelColor(receivedChars , a);
^
In file included from C:\Users\Moris\Desktop\Nuevito\Nuevito.ino:1:0:
C:\Users\Moris\Documents\Arduino\libraries\Adafruit_seesaw_Library/Adafruit_NeoTrellis.h:82:8: note: initializing argument 1 of 'void Adafruit_MultiTrellis::setPixelColor(uint16_t, uint32_t)'
void setPixelColor(uint16_t num, uint32_t color);
^