Processing sending 32bit color codes to arduino
in
Integration and Hardware
•
26 days ago
I'm having issues trying to send 32bit color codes to arduino
Processing code to upload
- void upload() {
- while(INdex < 20){
- String HEX = "<" + "0xFFFFFF" + ">";
- myPort.write(HEX);
- INdex++;
- }
- if(INdex >= 20){
- INdex = 0;
- }
- }
Arduino code to receive:
- long RX(){
- // Verify packet "<DATA>"
- while(Serial.available() > 0){
- char aChar = Serial.read();
- if(aChar == '<'){
- started = true;
- index = 0;
- inData[index] = '\0';
- }
- else if(aChar == '>'){
- ended = true;
- }
- else if(started){
- inData[index] = aChar;
- index++;
- inData[index] = '\0';
- }
- }
- // Packet verified and now converting packet from ASCII to INTEGER
- if(started && ended){
- inInt = strtol(inData, NULL, 16);
- started = false;
- ended = false;
- index = 0;
- inData[index] = '\0';
- }
- return inInt;
- }
strtol doesn't seem to be parsing the char array of the 32bit value sent. Not sure if I'm even doing this right :(
1