C̳

 һ
 ע
»̳ AIͣ python֮·ããȻ~
б
鿴: 278|ظ: 5

[Python] python֮·ããȻ~

[]
2024-5-17 20:25:57 | ʾȫ¥ |Ķģʽ
60
@FishC
python οƵŷ

רƼ:

֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

2024-5-17 20:26:12 | ʾȫ¥
ඣƵŷǺ˼

ȣΪ˿ƵŷҪ֪ͨʲôʽġһ˵ŷͨڵȦϼӵƵġȦͨʱųųʹŴ򿪻رա

ôҪPythonпƵŷأҪķ

1. ʹGPIOݮɵȵPythonĻʹGPIOŷҪȵĿ⣬RPi.GPIOȻģʽʹӦĺ򿪻رյŷ

2. ʹôͨţĵŷӵһⲿ豸ArduinoôͨͨƵŷҪPythonʹpyserial⣬ArduinoͨţȻӦָ򿪻رյŷ

ֻһŵָʵϸڿͬӲ͵ŷ졣˽һͷϵŷͺź͹Ȼصĵϣٸݾб̡

ϣЩϢףPython֮·һ˳⣬Ŷ~

ϻظ FishC AI Сδȷ⣬׷ʡ
֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

 ¥| 2024-5-17 20:27:15 | ʾȫ¥
@FishC pythonʵִͨѶأ
֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

2024-5-17 20:27:30 | ʾȫ¥
xunyu 2024-05-17 20:27
@FishC pythonʵִͨѶأ


٣ͨһڼⲿ豸֮䴫ݵķʽPythonУǿʹpySerialʵִͨšһ򵥵ʾʾʹpySerialдͨţ
import serial

# ڶ
ser = serial.Serial('COM1', 9600, timeout=1)

# 򿪴
ser.open()

# жϴǷ򿪳ɹ
if ser.isOpen():
    print("Ѵ")

# 򴮿д
ser.write(b'Hello World!')

# Ӵڶȡ
data = ser.readline()
print("յݣ", data)

# رմ
ser.close()

ʾУȴһڶָҪʹõĴںţ`COM1`Ͳʣ`9600`ȻǴ򿪴ڣǷɹ򿪡

ʹ`write()`򴮿дݣǷһַ`"Hello World!"`Ȼʹ`readline()`Ӵжȡݲ洢ڱ`data`С

ǹر˴ڡ

ע⣬ʹpySerial֮ǰҪȰװͨ`pip install pyserial`װ⡣

ϣʾܰ㣡

ϻظ FishC AI Сδȷ⣬׷ʡ
֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

2024-5-24 16:50:30 | ʾȫ¥
ƵŷҪ
֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

2024-5-25 17:40:54 | ʾȫ¥
֪Сɶ -> ilovefishc.com
ظ

ʹõ ٱ

б

ֹ

С|ֻ|Archiver|C ( ICP18085999-1 | 44051102000585)

GMT+8, 2024-6-24 02:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

ٻظ ض б