You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
837 B

public static final char HEADER = 'H';
public static final char A_TAG = 'M';
public static final char B_TAG = 'X';
public static final char C_TAG = 'U';
public static final char F_TAG = 'F';
void ephSerial() {
for(int i = 0; i<colorsN; i++) {
colorByteValues[i] = byte(colorValues[i]/(cellN/100));
print(colorByteValues[i] + "\t");
}
println("");
sendMessage(A_TAG, colorByteValues);
}
void sendMessage(char tag, byte[] cbv){
// send the given index and value to the serial port
port.write(HEADER);
port.write(tag);
for(int i=0; i<cbv.length; i++) {
port.write(cbv[i]);
}
port.clear();
}
void serialEvent(Serial p) {
// handle incoming serial data
String inString = port.readStringUntil('\n');
if(inString != null) {
print( inString ); // echo text string from Arduino
}
}