Last active
March 18, 2025 08:00
-
-
Save Robotto/55494b012af0c0f9c9d7c048066c9290 to your computer and use it in GitHub Desktop.
Serial RX in arduino from python (receiving raw bytes) - Plays well with this gist: https://gist.github.com/Robotto/48cdc0eb75ccee3a306866d634f76f77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
const int servoPin = 9; | |
const unsigned long baudRate = 115200; | |
Servo myservo; | |
void setup() { | |
Serial.begin(baudRate); | |
myservo.attach(servoPin); | |
} | |
void loop() { | |
int rx=0; | |
if(Serial.available()){ | |
rx=Serial.read(); //Read raw byte value - Should be directly parseable as integer (0-180) ... technically uint8_t (char) but well within bounds for a regular signed int. | |
myservo.write(rx); | |
if(rx==180) Serial.println(u8"\U0001f60e"); | |
if(rx==0) Serial.println(u8"\U0001F4A9"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python code here: https://gist.github.com/Robotto/48cdc0eb75ccee3a306866d634f76f77