标签: arduino

IR HEX比较

我是c编程的新手,并试图比较IR HEX字符串.我收到错误:左值作为左操作数的赋值.

我的问题是我的问题是在第31行.这是代码:

/* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String  stringAppleUp;  



void setup()
 {

  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
 }

void loop() {

if (irrecv.decode(&results)) {
  Serial.println(results.value, HEX);
  Serial.println ("See it");
  stringAppleUp = string('77E150BC');  //apple remote up button

if (    ???? …
Run Code Online (Sandbox Code Playgroud)

c arduino

-2
推荐指数
1
解决办法
5537
查看次数

Arduino UNO + Enc28j60 + DHT11 + PHP和Mysql(局域网模式)

我是一个arduino新手,我想为我的论文建立一个网络项目.我使用arduino uno作为微控制器,DHT11用于温度传感器,Enc28j60用于以太网屏蔽.该项目用于控制LED并通过网站监控温度和湿度.我想将arduino设置为客户端.我想在局域网模式下模拟这个项目.我想问一下:1.如何将arduino设置为客户端?2.如何从arduino接收温度数据并将其存储到数据库(mysql)?3.如何通过网站控制led?

我曾尝试将arduino作为服务器,并且它成功了.但我混淆了如何设置为客户端谢谢你,

有人可以帮帮我吗?

webclient arduino

-2
推荐指数
1
解决办法
2657
查看次数

C 中的按位运算 |=

我正在查看示例代码并发现此操作:

displayMap[x + (y/8)*LCD_WIDTH]|= 1 (shift by) shift; 
Run Code Online (Sandbox Code Playgroud)

在哪里

byte shift = y % 8;
Run Code Online (Sandbox Code Playgroud)

我理解|操作数,=但是它们两个一起做什么。

c bit-manipulation arduino bitwise-operators

-2
推荐指数
1
解决办法
3万
查看次数

我必须使用哪些命令才能通过 I²C 使用 SSD1306?

我想为 SSD1306 创建一个简单的 Linux 驱动程序,我已通过 I\xc2\xb2C 连接到我的 Raspberry Pi。

\n\n

在开始编码之前,我想了解设备以及我必须发送哪些命令。我使用 Linux 的 i2c-tools 来测试我的命令。我研究了一些Arduino项目和SSD1306的数据表,但我只能在命令行上重新创建一些命令:

\n\n

初始化设备:i2cset -y 1 0x3c 0xAE 0x20 0x10 0xb0 0xc8 0x00 0x10 0x40 0x81 0x7f 0xa1 0xa6 0xa8 0x3f 0xa4 0xd3 0x00 0xd5 0xf0 0xd9 0x22 0xda 0x12 0xdb 0x20 0x8d 0x14 0xaf i

\n\n

将数据发送到设备内存:i2cset -y 1 0x3c 0x40 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF i\n这将从当前位置向右填充一些像素。

\n\n

跳转到左上角像素:i2cset -y 1 0x3c 0xb0 0x00 0x10 i …

c linux arduino i2c raspberry-pi

-2
推荐指数
1
解决办法
2145
查看次数

如何使用加速度计确定八面体和十二面体的边长?

我有三个图形:一个立方体、一个八面体、一个十二面体。

每个人物内部都有一个加速度计。

图形的边编号在 1 到 n 之间。

任务:确定立方体、八面体、十二面体的当前边长。

对于立方体,我推导出公式:

边=圆形((Ax*1/988)+(Ay*2/988)+(Az*3/988));

变量“side”将给出区间 -3 和 3 之间的值(不带 0),这意味着立方体的当前边在 1 到 6 之间。

现在我需要对八面体和十二面体执行相同的操作。求助,我该怎么办?我是否需要额外的传感器或加速度计就足够了?

math physics arduino accelerometer stm32

-2
推荐指数
1
解决办法
193
查看次数

strncmp() 函数与 !(strncmp()) 函数

我正在编程一个锁,在哪里解锁它你必须在键盘中插入一个 PIN 码。我有以下变量:

char password_init[4] = {'1', '2', '3', '4'}; //initial password
char password[4];
Run Code Online (Sandbox Code Playgroud)

当用户按下键盘上的某个键时,该数字将存储在变量中,password并且在用户按下 4 位数字后,将比较两个变量,以确定是否可以访问锁定。

我发现这样做的一种解决方案是使用 strncmp() 函数:

if (!(strncmp(password, password_init, 4))){
Serial.println("PIN Code correct");
}
Run Code Online (Sandbox Code Playgroud)

这有效,但我不明白为什么我应该使用!(strncmo())而不是strncmo(). 如果我使用if (strncmp(password, password_init, 4)),结果将是错误的 PIN 码。

strncmp()函数逐个字符地比较两个字符串,所以有人可以解释我为什么必须以否定方式使用它来代替初始密码和用户在键盘匹配中按下的密码吗?

c arduino strncmp

-2
推荐指数
1
解决办法
106
查看次数

如何在 arduino 或 Raspberrypi 上制作 600MHz 循环?

我需要在 Arduino 或 Raspberrypi 板上每秒生成 6 亿次脉冲。我的目的是测量发射器和接收器之间的距离。接收器每秒对接收到的脉冲进行计数并估计距离。我可以用哪些方式编写代码?

c++ loops arduino frequency raspberry-pi

-3
推荐指数
1
解决办法
66
查看次数

为什么没有调用子类的虚函数

我有一个基类和派生类:

plugin.h

#ifndef PLUGIN_H
#define PLUGIN_H

// plugin states
#define PLUGIN_IDLE 0

class Plugin {
public:
  Plugin();
  ~Plugin();

  virtual void loop();
};

#endif
Run Code Online (Sandbox Code Playgroud)

plugin.cpp

#include <Arduino.h>
#include "plugin.h"

Plugin::Plugin() {
}

Plugin::~Plugin(){
}

void Plugin::loop(){
  Serial.println("Plugin::loop()");
}
Run Code Online (Sandbox Code Playgroud)

派生类

class OneWirePlugin : public Plugin {
public:
  OneWirePlugin(byte pin);
  void loop();
};

OneWirePlugin::OneWirePlugin(byte pin) {
}

void OneWirePlugin::loop() {
  Serial.println("OneWirePlugin::loop()");
}
Run Code Online (Sandbox Code Playgroud)

我期待调用派生实例的loop()方法将执行OneWirePlugin::loop().

但是,这只发生在我在派生类上下文中调用它时:

Plugin p = Plugin();
Plugin o = OneWirePlugin(ONEWIRE_PIN);
OneWirePlugin q = OneWirePlugin(ONEWIRE_PIN);
p.loop(); …
Run Code Online (Sandbox Code Playgroud)

c++ arduino

-4
推荐指数
1
解决办法
1411
查看次数

如何解决此错误“无法在C#中将类型'char'隐式转换为'string'”?

我正在将数据从Arduino发送到控制台。收到数据触发事件后。但是我现在遇到此错误“无法将类型'char'隐式转换为'string'”

在此处输入图片说明

c# serial-port arduino visual-studio

-4
推荐指数
1
解决办法
79
查看次数

如何实现Arduino Due的tone()和noTone()?

事实证明,noTone()tone()在核心的arduino API中,但似乎没有Arduino Due实现。我希望使用tone()noTone()实现此处找到的马里奥死亡声音,但是当我添加代码并对其进行编译时,出现以下错误:

trenchRun:154: error: 'tone' was not declared in this scope
trenchRun:156: error: 'noTone' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

如果您有兴趣,这里有一个SSCCE,是在Mac OS X 10.8上针对Arduino 1.5.4编译的:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  tone(1, 12345, 1000);
}
Run Code Online (Sandbox Code Playgroud)
sketch_oct24a.ino: In function 'void loop()':
sketch_oct24a:7: error: 'tone' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

由于我有Arduino Due,因此我只能使用Arduino 1.5.4。

如何实现Due 的tone()noTone() …

c arduino

-5
推荐指数
1
解决办法
6417
查看次数

四舍五入的数学函数

什么(rounding/=10.0;)意思 为什么会有斜线?

c++ arduino

-5
推荐指数
1
解决办法
63
查看次数

对多个 if 条件使用单个 else 语句

我正在为一个 arduino 项目编码,我遇到了这个问题,谁能帮帮我!

if(condition1){
//my codes here
}
if(condition2){
//my codes here
}
if(condition3){
//my codes here
}
......
if(condition100){
//my codes here
}
else{
my codes here
}
Run Code Online (Sandbox Code Playgroud)

我想检查我所有的 if 条件,如果条件为真,则执行代码,并且仅当所有 if 条件都不为真时才运行 else 语句。请注意,我无法使用,else if因为我想检查所有 if 条件,如果都不为真,我想运行 else If 条件不相互依赖

if-statement arduino

-6
推荐指数
1
解决办法
128
查看次数

如何在Arduino中进行有限循环

我是编码的初学者,尤其是Arduino.我一直在做很多项目,但我遇到了一个问题.我似乎无法弄清楚如何进行有限循环.我正在看一个类似于while循环的东西,它在四次后停止.这里是实施的地方,让您更好地了解我在寻找什么.

#include <Servo.h>

int thumbPin = 2;
int ndxPin = 3;
int midPin = 4;
int rngPin = 5;
int pnkyPin = 6;

Servo thumb;
Servo index;
Servo middle;
Servo ring;
Servo pinky;
void setup() {
  Serial.begin(9600);

  thumb.attach(thumbPin);
  index.attach(ndxPin);
  middle.attach(midPin);
  ring.attach(rngPin);
  pinky.attach(pnkyPin);
}
void loop() {
  /* I want this code in the comment to be ran four times, then continued on to the code after
  thumb.write(0);
  delay(20);
  thumb.write(0);
  index.write(0);
  middle.write(0);
  ring.write(0);
  pinky.write(0);

  thumb.write(150);
  index.write(150);
  middle.write(150);
  ring.write(150);
  pinky.write(150); …
Run Code Online (Sandbox Code Playgroud)

arduino arduino-uno

-8
推荐指数
1
解决办法
590
查看次数