const uint8_t PIN = 4; void setup() { // $ stty -F /dev/ttyUSB0 | grep speed Serial.begin(115200); pinMode(PIN, OUTPUT); } void loop() { // https://www.arduino.cc/reference/en/language/functions/communication/serial/read/ if (Serial.available() > 0) { // $ printf '\0' > /dev/ttyUSB0 // $ printf '\x01' > /dev/ttyUSB0 digitalWrite(PIN, (Serial.read() > 0) ? HIGH : LOW); } }