728x90
반응형
import serial

PORT = "/dev/ttyUSB0"
BAUDRATE = 9600
# ser:serial.Serial = None

ser = serial.Serial(PORT, baudrate=BAUDRATE)

while True:
	msg = input()
	
	if(msg == '0'):
		break

	for c in msg:
		ser.write(c.encode())

ser.close()
void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
  while(Serial.available())
  {
    String s = Serial.readString();

    if (s == "hello")
    {
      digitalWrite(13, HIGH);
      delay(500);
      digitalWrite(13, LOW);
      delay(500);
      digitalWrite(13, HIGH);
      delay(500);
      digitalWrite(13, LOW);
      delay(500);
    }
  }
}
728x90
반응형

'Firmware & Embedded > AVR' 카테고리의 다른 글

Arduino Power Supply  (0) 2022.11.29
10 Ways to Destroy An Arduino  (0) 2022.11.16
iteration arduino  (0) 2022.10.11
attachInterrupt  (0) 2022.09.22
PWM - Timer Library  (0) 2022.09.22

+ Recent posts