我可以使用Python(使用pyfirmata)来读取和使用连接到Arduino的陀螺仪的数据吗?

时间:2013-05-16 00:09:37

标签: python arduino accelerometer gyroscope

我将Arduino通过串口连接到我的计算机上,并且可以使用Python(使用pyfirmata库)对Arduino进行基本的数字写入操作。所以我想知道的是我是否可以使用带有pyfirmata的陀螺仪和加速度计?

1 个答案:

答案 0 :(得分:0)

是的,你可以。

我对pyfirmata了解不多,但看起来它基于pyserial。我在传递中使用了一下。 我会告诉你我对pyserial的了解

上的

void setup() {
 // open the serial port at 9600 bps:
 Serial.begin(9600);
 }

在PC python终端上

>>> ser = serial.Serial()
>>> ser.baudrate = 9600         <--same as the arduino void setup()
>>> ser.port = 0                <--Name of the virtual com port
>>> ser.open

当你从另一个人那里写下来时,你可以从另一个人那里读到。

http://arduino.cc/en/Reference/Serial http://pyserial.sourceforge.net/shortintro.html