This is my first successful attempt at sending a number (higher than 255) from Python to Arduino using Serial Communication. Currently it sends 3 bytes per execution.

The 1st byte for packet identification, and the 2nd and 3rd byte makes up the Base10 number we are sending. I've used bit-wise operators to maximize the number I can construct from 2 bytes. Currently the maximum number I can send is 65535. The code can still be optimized, and currently it does not support negative numbers but hey, I'm taking it one step at a time (pardon the pun).

For sample code, visit this blog post:

FYI, this exercise is part of a much larger project. You can read about it here:


Loading more stuff…

Hmm…it looks like things are taking a while to load. Try again?

Loading videos…