I’m trying to use a Bluetooth serial connection to send analog input from one microcontroller to a receiving microcontroller (both Teensy 3.1), and having the receiver analogWrite the result. However, I’m having a hard time trying to keep the data intact as I send it.
My analog input has a resolution of 12, and it is saved to an int that can range from 0 to 4096. I’ve tried sending this data by simply using Serial1.write(), but that only sends a byte with a max value of 255 (so an analog read value of 256 would be written received as 0). I’ve looked at a few examples that talk about seperating the integers into two bytes, sending them, and reassembling the integer, but I’m not sure if it applies to numbers as big a 4000.
Any ideas on how I would go about this? I just want to send a number (say, 3000) through Bluetooth serial, receive it, and use that number to AnalogWrite (The teensy is capable of true analog output).
The Bluetooth modules I’m using are the Bluesmirf silvers from Sparkfun.