首先,这可能不是arduino代码或arduino的问题,但我想我应该在这里发帖,因为我真的不知道哪里出了问题。
我在这个项目上工作只是为了好玩,通过键盘发送击键,通过计算机,并通过USB到我的arduino mega。这里没有额外的硬件,只有计算机、arduino和USB电缆。
我正在使用Microsoft Visual Studio Express 2012编写代码来接收键击并将其发送到USB。这是我使用的代码:
#include "stdafx.h"
#include "conio.h"
using namespace System;
using nam
我开发了一个应用程序,它通过套接字将一个字符串/命令发送到另一个PC应用服务器,并通过串口将一个字符串发送到Arduino。
问题是:如何向Arduino发送字节?
通过串口发送字符串的应用服务器的C#:
using System;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.IO.Ports;
public class senddata
{
private void Form1_Load(object sender, System.EventArgs e)
采用USBTTL型PL2303芯片实现了XBee模块与Pi的接口,解决了这一问题。这就是问题所在。它的驱动程序没有得到RPi2的正确支持。
我正在尝试通过连接到我的树莓Pi2上的XBee模块从python脚本中发送一个字符串(可能是一个数字)到Arduino Uno。发送的数据在Arduino端被曲解了。当我在X-CTU上使用终端并通过它发送字符串时,它正确地显示在Arduino IDE的串行监视器上。
下面是我使用的Python代码
import time
import serial
ser = serial.Serial("/dev/ttyUSB0",9600)
ser.i
我一直在尝试编写读取文本文件的python代码,使其成为变量并使用i2c发送。这是代码:
import serial
import smbus
import time
import sys
from time import sleep
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)
# This is the address we setup in the Arduino Program
address = 0x04
loopvar = 1
while loopvar ==
我对阿迪诺和C++都很陌生。我想做一个植物浇水系统。我找到了这个。它是用捷克语写的,但是你可以找到一段代码来处理潮湿的传感器。这个程序运行时没有任何问题。我决定把这个算法包含在一个类中,这样我就可以更容易读了。我跟踪了。
MoistSensor.h
#ifndef MoistSensor_h
#define MoistSensor_h
#include "Arduino.h"
class MoistSensor {
public:
MoistSensor(int analogPin, int digitalPin, int vccPin);
void m
我正在尝试用Python和Arduino构建一个CPU监视器。Arduino运行良好,但我在使用Python时遇到了问题。我的问题是我不能让PySerial发送一个整型或字符串。
如果我尝试发送一个Int,我会得到:
TypeError: 'int' object is not iterable
如果我将Int转换为字符串,则错误为:
TypeError: an integer is required
这似乎很奇怪..。
以下是我的代码:
import psutil
import serial
ser = serial.Serial(2)
while True:
lin
我希望你的帮助,了解一些代码,这将极大地帮助我的项目。在不涉及太多细节的情况下,以下是给我带来这么多问题的原因:
bool Serial::WriteData(char *buffer, unsigned int nbChar)
{
DWORD bytesSend;
//Try to write the buffer on the Serial port
if(!WriteFile(this->hSerial, (void *)buffer, nbChar, &bytesSend, 0))
{
//In case it d
我搞砸了一个简单的异或校验和计算在一个cstring字符阵列的电报。
奇怪的是:校验和的解码工作。这是一个Arduino应用程序,从一个Arduino向另一个Arduino发送电报。
这是要发送的电报,包括*之后的正确校验和。
$GPS,52.534015,3.9,13.496394,2.5,0.053,0,44.6,6.2*65
你看上去是对的:这就像一条涅姆亚的信息。
下面是校验和计算的代码
MessageStr.toCharArray(MessageBuffer, MessageStr.length()); //Arduino String Class
for (int x =
这是我的密码:
import serial
print('Arduino is setting up')
# Setting up the Arduino board
arduinoSerialData = serial.Serial('com4', 9600)
while True:
if arduinoSerialData.inWaiting() > 1:
myData = arduinoSerialData.readline()
myData = str(myData)
myData = m
基本上,我是遵循的教程代码为LED条形图。我没有电位器,所以我想通过使用串行写入来模仿它,这是基于中比较暗淡的例子。我将sensorReading值设置为来自处理应用程序的输入(将其网格更新为1023个元素),如下所示:
int sensorReading;
if (Serial.available()) {
// Read the most recent byte (which will be from 0 to 1023):
sensorReading = Serial.read();
}
这将根据我在处理应用程序中的网格中的鼠标位置来点亮LED。然而,
我目前正在进行一个项目,该项目通过串行端口将数据从java应用程序发送到arduino。
我遇到的问题是,我需要将一个整数分割成两个字节,然后在Arduino中将它们组合成一个整数。但反过来(Arduino->java)只会给我带来麻烦。arduino部分并没有那么难,工作起来很有魅力,但是尽管我查看了已经发布在这里的相关问题和答案,但我还是想不出如何正确地将字节组合成int。
以下是拒绝工作的java代码:
int in = 500;
byte[] data = new byte[2];
data[0] = (byte)(in & 0xFF);
data[1] = (byte
我对Python和Arduino都很陌生。如果你需要更多的信息,尽管告诉我。
我想做的是:我想用arduino控制几个伺服。我想在PC(后来的RPi)上的图形用户界面中改变伺服的角度,并通过串行通信将它们发送到Arduino
我的Arduino代码看起来像这样:
#include <Servo.h>
int angle;
int pinServo1 = 5;
Servo servo1;
int min = 0.547;
int max = 2.47;
void setup()
{
Serial.begin(9600);
pinMod
每次我输入002这样的值时,长度都是1,但是它应该是3,我的代码是:
list1 = int(input("Enter a number"))
list1 = [int(x) for x in str(list1)]
print (len(list1))
如果我在空格后键入一个数字,我会得到一个错误消息:
File "C:\\practice11.py", line 2, in <module>
list1 = [int(x) for x in text]
File "C:\\practice11.py", line 2, in
如何设置处理程序以接收来自Arduino UNO的pyfirmata中的消息?
我有以下Python代码:
from logic.ModuleClass import Module
from events.EventDispatcherClass import Event
from pyfirmata import Arduino, util
import pyfirmata
class Comm(Module):
"""
Handles the communication between python and arduino
AttachTo