If the character was a 1 it would send the remaining 3 characters as an integer to the servo. Then I finally had a value I could manipulate. So understanding this I wrote a loop that converted the inbound into a string, character by character, subtracting 48 from each individual DEC. Simon later explained to that the was a DEC, and I just had to subtract 48 from the numerical values I received. However I found trying to get the whole value in a nice manipulable variable was iffy at best as whenever I tried to do anything with it it would use the 49 value. So I wrote a for loop that did a Serial.write() of the each character in the inbound. So I found that Serial.write() printed the character I wanted. This confused me to no end because of the aforementioned lack of understanding all this character-level stuff. This managed to read the inbound as the character, so I tried to print out the first character from the inbound, i.e. The Instructable in the previous post had a bit of code that turned an LED on and off. Now at this point I had no understanding of how ASCII worked, so I needed to figure out a way to convert the HEX into its glyph equivalent.Īs an example: 1139 was coming in as 31 31 33 39. The transmission was coming in fine, but as HEX. The VirtualWire library had a couple examples of this, so it worked pretty well. Getting this transmitting was no problem. Broadcasting something like 1139, 1072 or 1008. This three character string would be then prefixed by the one character ID. So essentially '139' would remain unchanged, '72' would be prefixed with a '0' to make the string '072', and '8' would be prefixed with two '0's to make '008'. Then this number was converted into a string, and prefixed with a number of '0's to ensure the string length was 3 characters. This was generated by a potentiometer reading being mapped from 0-1023 to 0-170. The 0-170 value was so that the receiver could forward this onto the servo, which would then the volume knob. The goal was to set up the transmitter sending a numerical ID and a value between 0 and 170. It wasn't quite as hard as I expected, but still took a little while to get sorted. Getting the transmitter transmitting data other than the binary ones and zeros went kinda well.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |