Skip to content

Instantly share code, notes, and snippets.

@Robotto
Last active March 18, 2025 08:00
Show Gist options
  • Save Robotto/55494b012af0c0f9c9d7c048066c9290 to your computer and use it in GitHub Desktop.
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
#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");
}
}
@Robotto
Copy link
Author

Robotto commented Mar 17, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment