Bluetooth+SBDBT | ↓挿入口↓ | |
---|
5 | PGEC1 | | STATUS | 10 |
---|
4 | PGED1 | | CTS | 9 |
---|
3 | GND | | RX | 8 |
---|
2 | VDD=3V | | TX | 7 |
---|
1 | RESET | | RTS | 6 |
---|
1
2
3
4
5
6
7
8
| Arduino arduino;
SBDBT sbdbt;
sbdbt.gnd = Arduino.gnd;
sbdbt.vdd = Arduino.3V ;
sbdbt.rx = Arduino.tx ;
sbdbt.tx = Arduino.rx ;
sbdbt.cts = sbdbt.rts ;
|
1
2
3
4
5
6
7
8
9
| void setup() {
Serial.begin(9600);
}
int c = 0;
void loop() {
Serial.println(c++);
delay(500);
}
|
Python + Pyserial 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| #need pyserial:
# $> pip install pyserial
import serial
seri = serial.Serial("COM11", 9600, timeout=1000)
print("Open [{}]".format(seri))
try:
while True:
line = seri.readline()
value = int(line)
print(value)
if value != 1:
print("Emergency Stop!")
break
except:
print("Error Stop!!")
finally:
seri.close()
|
|