
void setup()
{
Serial.begin(57600);
}
void loop()
{
//int analogData = analogRead(0);//10 bit value, max 1023, min 0.
int analogDataPin0 = analogRead(0);//Read Current analog pin value.
Serial.print(analogDataPin0 >> 7, BYTE);//shift high bits into output byte
//same as dividing by 128 But that
//takes much longer on an arduino.
Serial.print(analogDataPin0 % 128, BYTE);//mod 128 for the small byte
Serial.print(255, BYTE);//denotes the end of a package.
delay(10);}
This particular code snippet works for one source of information, ie: a single sensor. If, perhaps there were to be two sections of information, say, a switch, there would be another Serial.print line. It would just print 0 or 1, but you could map that to some interesting effects in max.
Always be sure to watch your outputs from the zl group object to cover the extra inputs.
No comments:
Post a Comment