NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Everything Else » Sending decimal values through PySerial

November 14, 2010
by RSW
RSW's Avatar

Hello, I was experimenting with PySerial and I noticed that the write( ) function can only send strings. Is there any way to send number (int, float, etc.) values to my nerdkit? Thanks.

November 14, 2010
by RSW
RSW's Avatar

Figured it out: send the numerical value as a string, followed by "\n".

November 15, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi RSW,

Glad you figured it out. In case someone stumbles on this thread with the same question, the answer is indeed to send the value as a string. On the MCU side you can use one of the scanf family of functions to read the value into a variable. Check out the print and scanf tutorial for more on those functions.

Humberto

Post a Reply

Please log in to post a reply.

Did you know that the microcontroller's crystal oscillator can be used to keep accurate time? Learn more...