我有一个连接到从属arduino的OPT101以测量光强度。我想将从OPT101电路接收到的数据发送到主arduino,它将在串行监视器上打印数据。当我测试代码时,屏幕上没有任何显示。(我知道这不是我的i2c连接,因为我通过发送“ hello”进行了测试)。我使用arduino leonardo作为奴隶,使用arduino uno作为主人。
OPT101电路的代码为:
#define inPin0 0
void setup() {
Serial.begin(9600);
Serial.println();
}
void loop() {
int pinRead0 = analogRead(inPin0);
double pVolt0 = pinRead0 / 1024.00 * 5.0;
Serial.print(pVolt0, 4 );
Serial.println();
delay(100);
}
Run Code Online (Sandbox Code Playgroud)
我很累将奴隶代码和我的OPT101代码结合起来以获取此信息:#include
#define inPin0 0
void setup() {
Wire.begin(2);
}
void loop() {
Wire.beginTransmission(2);
Wire.onRequest(requestEvent);
Wire.endTransmission();
}
void requestEvent()
{
int pinRead0 = analogRead(inPin0);
int pVolt0 = pinRead0 / 1024.0 * 5.0;
Wire.write((byte)pVolt0);
}
Run Code Online (Sandbox Code Playgroud)
这是我的主代码:
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(14400);
Wire.requestFrom(2, 8);
while(Wire.available())
{ …Run Code Online (Sandbox Code Playgroud) 我最近在 Arduino Uno 板上工作,我坚持使用我的代码,我无法在 ArduinoIde 中使用 print() 进行调试。所以我下载了 AtmelStudio 6.2 进行调试。当我设置断点并尝试构建时。我收到警告 当前不会命中断点。无法在目标上设置请求的断点。当前选定的设备无法在运行时设置断点
请帮我解决这个问题
如何在 Ubuntu 上用 C 编写我的 Arduino。我听说过 avr-gcc,但所有在线教程似乎都非常乏味,并且没有带有 Arduino 引导加载程序的 AVR 芯片的选项。谁能用更简单的方法帮助我在 Ubuntu 上安装 avr-gcc 并开始用 C 语言为 Arduino 编程?
我真的需要一些帮助。没什么坏的,只需要一些指导。我有一个Arduino Uno和AdaFruit CC3300 Wifi Shield。我建立了一个运行良好的太阳能气象站,并已使所有模拟和数字IO饱和。一切都与IDE配合良好,我的wifi示例代码运行完美。尽管过去没有做过任何事,但是我正在使用IBM Bluemix并学到了很多东西。我是一名计算机工程师,在整个职业生涯中都做过一些软件,主要是嵌入式硬件。
不幸的是,尽管有很多优化,我只是没有足够的空间让MQTT客户端在Uno上运行。关于此以及有关Bluemix本身的很多很好的指导,但是我不能使用它。
这是我的问题;
我认为网络套接字是使事情保持最佳状态的最佳方法。 - - - 那正确吗?----实际上,我需要在5分钟内传递约300个字符(所有传感器数据和其他内容)的JSON字符串。而已。我只是不知道如何使用Node Red将其提升到Bluemix应用程序(也学习JavaScript)。也有一个Web套接字节点。在任何我至少能找到凡人都能理解的地方,都没有很好地解释。我也为该wifi库运行了webclient示例,但是无法跳转。只是没有经验明智。
我相信AdaFruit CC3300 Wifi防护库可以在客户端设置Web套接字,因此不会再增加空间负担。 - - 那正确吗?-----
我的目标只是能够将这些JSON格式的数据传递到我的Bluemix应用程序中,并显示在Node Red调试控制台中。我已经在Bluemix上完全设置好了。
感谢任何指导以正确方向指导我。dpguitarman
我刚拿到一个拉力云盾.要将它连接到我的arduino uno,它说我必须"快捷"重置按钮旁边的引脚.http://wiki.dragino.com/index.php?title=Yun_Shield#Connect_to_Arduino_Uno
但是我的arduino没有那些针脚.IMG:

顺便说一下,我以为我没有必要这样做,因为在我成功运行wifi上的闪烁草图之前.当我再次尝试这样做时,它返回了这个错误:
avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
Run Code Online (Sandbox Code Playgroud) 我有2段代码,它们执行的功能完全相同,但是实际上并没有用。谁能解释为什么?
该代码通过spi将数据发送到运行显示器的FPGA。我几乎没有足够的代码存储在芯片上,因此我正在尝试尽可能地减少代码。下面的更改由于某种原因而最终中断,该程序的其余部分与之完全相同。
//Looping to execute code twice doesnt work
for (byte i = 0; i < 3; i++)
{
temp2 = temp % 10;
temp /= 10;
temp2 |= 0x40;
for (byte k = 0; k < 2; k++)
{
SPI.transfer(reg[j]);
delayMicroseconds(10);
SPI.transfer(temp2);
delayMicroseconds(10);
}
reg[j] -= 1;
}
Run Code Online (Sandbox Code Playgroud)
。
//But copy-paste does
for (int i = 0; i < 3; i++)
{
temp2 = temp % 10;
temp /= 10;
temp2 |= 0x40;
SPI.transfer(reg[j]);
delayMicroseconds(10);
SPI.transfer(temp2);
delayMicroseconds(10);
SPI.transfer(reg[j]);
delayMicroseconds(10); …Run Code Online (Sandbox Code Playgroud) 我正在为学校项目建造机器人。我目前正在使用Arduino Uno,两个直流电动机和一个超声波传感器。这两个电机是通过Arduino Motor Shield v3控制的。我希望该机器人具有自主性,因此它必须能够使用超声波传感器自行移动。
这是我的源代码的最新版本:
#include <Servo.h> // include Servo library
#include <AFMotor.h> // include DC motor Library
#define trigPin 12 // define the pins of your sensor
#define echoPin 13
AF_DCMotor motor2(7); // set up motors.
AF_DCMotor motor1(6);
void setup() {
Serial.begin(9600); // begin serial communication
Serial.println("Motor test!");
pinMode(trigPin, OUTPUT); // set the trig pin to output to send sound waves
pinMode(echoPin, INPUT); // set the echo pin to input to receive sound waves
motor1.setSpeed(105); // …Run Code Online (Sandbox Code Playgroud) 我使用的是Arduino Uno和Windows 7.我的目标是让LED指示灯闪烁,当它闪烁时,它会打印出"Blink"到串行监视器.
当我运行下面的代码时,我能够每隔2秒将"闪烁"打印到串行监视器,但是,灯仍然一直打开.当我删除该行
Serial.begin(9600);
Run Code Online (Sandbox Code Playgroud)
指示灯会闪烁,但不会打印任何内容.我运行的代码如下:
int LED3 = 0;
void setup() {
// When I comment out the line below, the lights flash as intended, but
// nothing prints. When I have the line below not commented out,
// printing works, but the lights are always on (ie do not blink).
Serial.begin(9600); // This is the line in question.
pinMode (LED3, OUTPUT);
}
void loop() {
Serial.println("Blink");
digitalWrite (LED3, HIGH);
delay(1000);
digitalWrite (LED3, LOW);
delay(1000);
}
Run Code Online (Sandbox Code Playgroud)
我不清楚导致这种行为的原因,并希望解释为什么会发生这种情况以及如何避免这个问题.谢谢!
import serial
import numpy
import matplotlib.pyplot as plt
from drawnow import *
data = serial.Serial('com3',115200)
while True:
while (data.inWaiting() == 0):
pass
ardstr = data.readline()
print (ardstr)
Run Code Online (Sandbox Code Playgroud)
在这里,我试图从arduino获取数据,但它是以格式输入的b'29.20\r\n'。我想要以格式显示数据,"29.20"以便对其进行绘制。
我尝试过ardstr = str(ardstr).strip('\r\n'),ardstr.decode('UTF-8')
但没有一个在工作。我的python版本是3.4.3。
我该怎么做才能得到结果"29.40"而不是"b'29.20\r\n'"?
好的,我正在尝试使用 VS Code (Visual Studio Code) 进行编码并上传到 Arduino。当我尝试上传或验证 Arduino 代码时,会弹出以下错误:
如果你看不到这一点,它会说:
[Starting] Verify sketch - ir_remote\ir_remote.ino [Warning] Output path is not specified. Unable to reuse previously compiled files. Verify could be slow. See README. Arduino: This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted. [Error] Exit with code=1
非常感谢您的帮助。几周前我开始摆弄 Arduino,并且我已经使用 VS Code 很长时间了。
另外:代码在 Arduino IDE 上运行完全正常,我希望能够使用 VS Code 进行编码并上传到 Arduino。
我也尝试在 Arduino 论坛上发布此内容,但没有人回复。
arduino-uno ×10
arduino ×6
atmelstudio ×1
avr-gcc ×1
c ×1
c++ ×1
debugging ×1
ibm-cloud ×1
matplotlib ×1
node-red ×1
python ×1
python-3.x ×1
robot ×1
ubuntu ×1
websocket ×1
wifi ×1