Arduino<>Python

Arduino --> python 시리얼 통신

spring99 2025. 1. 29. 21:42

아두이노에서  1~100의 수를 python으로  시리얼 통신(단반향)으로 보냅니다.

아두이노 소스 

void setup() {
   Serial.begin(9600);
   for(int x=0;x<100;x++){
  Serial.println(x);
   }

void loop(){

}

python source

import serial

def  SCOMM():
   Data=ser.readline()
   Data=Data.decode()
   Data=Data.rstrip()
   print(Data)

ser = serial.Serial('COM19')
while True:
 SCOMM()