arduino uno, nano 보드 D0, D1핀은 시리얼 통신, 팜웨어 업로드의 기능을 갖고 있습니다. 그러므로 다른 용도로 사용하기에는 한계가 있습니다.
그래서 통신단자를 다른 핀 단자로 이용할 수 있다. 소스에서는 아나로그 단자 A0,A1를 통신단자로 사용한 예이다.
bluetooth 모듈을 연결한 상태에서 해봅니다.
rxPin(A0)-->blue TX핀, txPin(A1)-->blue Rx
장치관리자에서 통신 포트를 화ㅏㄱ인합니다.
python으로 나노 보드에 내장되어 있는 LED_BUILTIN를 On Off 해 봅니다.
#include<SoftwareSerial.h>
const int rxPin = A0;
const int txPin =A1;
char data;
SoftwareSerial mySerial(rxPin,txPin);
void setup(){
mySerial.begin(9600);
pinMode(LED_BUILTIN,OUTPUT);
}
void loop(){
while (mySerial.available()){
data =mySerial.read();
}
if(data=='a')
digitalWrite(LED_BUILTIN,HIGH);
else if(data=='b')
digitalWrite(LED_BUILTIN,LOW);
}
'Arduino<>Python' 카테고리의 다른 글
4x4 keyPad pytion (0) | 2025.02.12 |
---|---|
arduino uno, nano rxPin, txPin LED Bluetooth python 제어 (0) | 2025.02.03 |
arduino_python 양방향 통신 (0) | 2025.02.02 |
arduino_python_PC_Bluetooth 통신 (0) | 2025.02.01 |
python 시리얼 통신과 디코드 (0) | 2025.02.01 |