标签: arduino

avrdude: ser_open(): 无法为“\\.\COM3”设置 com-state

我看过其他帖子也有相同的错误消息,但找不到任何适合我的解决方案。我使用的是 Windows 10。我已完成所有必需的步骤,但仍然弹出错误。

arduino arduino-ide windows-10

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

适用于 Arduino 和 DxCore 的 Visual Studio Code IntelliSense

这里有人让 IntelliSense 在带有 DxCore 项目的 Arduino 的 Visual Studio Code 中相对完美地工作吗?我已经完成了大部分工作,但仍然存在一些问题。

对我来说,任何需要Serial.printf()用红色波浪线标记的电话。Ctrl+单击printf可以很好地显示定义。这里那里的其他事物也有相同的行为。例如,在定义va_startprintf

除此之外,在验证草图时,我得到: [Error] Failed to read or write IntelliSense configuration: {} 不认为这是一个真正的问题,但它很烦人。

这是我的c_pp_properties.json文件:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Users\\nabel\\OneDrive\\Documents\\ArduinoData\\packages\\DxCore\\hardware\\megaavr\\**",
                "C:\\Users\\nabel\\OneDrive\\Documents\\Arduino\\libraries\\**",
                "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
                "C:\\Program Files (x86)\\Arduino\\hardware\\tools\\**",
                "C:\\Program Files (x86)\\Arduino\\tools\\**",
                "C:\\Program Files (x86)\\Arduino\\libraries\\**"
            ],
        "forcedInclude": [
            "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
        ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "ARDUINO=10816", // Should be updated for version of Arduino IDE installed; …
Run Code Online (Sandbox Code Playgroud)

intellisense arduino dxcore visual-studio-code vscode-extensions

0
推荐指数
1
解决办法
2103
查看次数

将对象作为参数传递给另一个类 C++ 的构造函数

我正在尝试使用 Nokia5110 LCD 创建一个用户界面类,用于显示从 API 检索的天气预报,但是当我尝试将对 .ino 的引用传递给Adafruit_PCD8544 Object构造函数时,出现错误班级。

一些帮助将受到高度赞赏。我得到的错误:

“错误:没有匹配的函数可调用 Adafruit_PCD8544::Adafruit_PCD8544()

这是 main.ino 文件:

// Nokia 5110 LCD pinout connections to nodeMCU8266
#define CLK_PIN D1  // Serial clock out (SCLK)
#define DIN_PIN D2  // Serial data out (DIN)
#define DC_PIN  D5  // Data/Command select (D/C)
#define CS_PIN  D6  // lCD chip select (CS)
#define RST_PIN D4  // LCD reset (RST)

Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CS_PIN, RST_PIN);
UI_Nokia5110 UI(display);
Run Code Online (Sandbox Code Playgroud)

这是 UI.h 的头文件:

#ifndef UI_WEATHER_API_H
#define …
Run Code Online (Sandbox Code Playgroud)

c++ arduino

0
推荐指数
1
解决办法
184
查看次数

Platformio C++ 多重“多重定义”

我无法在我的 arduino 项目上解决这个问题。我在 vscode 上使用 Platformio。

我想使用 MFRC522_I2C 库来读取 rfid 徽章,因此我创建了一个类来使用库方法。

该库可以在这里找到:https ://github.com/arozcan/MFRC522-I2C-Library

这是我的代码:

主要.cpp:

#include <Arduino.h>
#include "rfid/Rfid.hpp" // my rfid class

Rfid _rfid;
void setup()
{
    Serial.begin(115200);
    _rfid.setupRfid();
}

void loop()
{
    _rfid.rfidLoop();
}
Run Code Online (Sandbox Code Playgroud)

射频识别.cpp:

#include "Rfid.hpp"

Rfid::Rfid(/* args */)
{
}

Rfid::~Rfid()
{
}

void Rfid::setupRfid()
{
  _rfidReader.PCD_Init();
}

void Rfid::rfidLoop()
{
    // here is my code to read the rfid
}
Run Code Online (Sandbox Code Playgroud)

射频识别.hpp:


#ifndef _RFID_HPP_
#define _RFID_HPP_

#include "../lib/rfidReader/MFRC522_I2C.h" // the MFRC522 library

MFRC522 _rfidReader(0x28);

class …
Run Code Online (Sandbox Code Playgroud)

c++ arduino multiple-definition-error visual-studio-code platformio

0
推荐指数
1
解决办法
598
查看次数

低功耗传感器模块

我的下一个项目要求我拥有高效的无线传感器模块.基本上,这些模块应该能够读取温度,光线等传感器数据并通过其无线发射器/接收器输出.它可以是任何传感器,也必须是发射器和接收器.

我怎样才能达到很低的功率?

我希望这个设置可以运行一年,也许是六个月但是我现在使用Arduino芯片的原型和每分钟发送数据的XBee模块可以在一小时内清除9 V电池.我已经阅读了很多关于这个问题的内容,并且想知道XBee是否是不可能的.我担心的不是微控制器,它是如何在保持功耗预算的同时实现高效的无线通信.基本上,那里最好的低功耗无线模块是什么?

wireless electronics arduino xbee

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

检查字符变量的值

我正在为Arduino编写一些代码,我不确定我是否正确检查了这个字符变量的值.你能告诉我这是否正确:

const char* front = "front";
const char* back = "back";

eyeballs(front);
eyeballs(back);

void eyeballs(const char* frontOrBack){ 

if (frontOrBack == "front") {
    digitalWrite(frontEyes, LOW);}//end if   
  else if (frontOrBack == "back") {
    digitalWrite(backEyes, LOW);}//end else*/
}  
Run Code Online (Sandbox Code Playgroud)

c arduino

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

arduino中的动态数组声明

我正在尝试编写一个代码,当给出正确的密码时可以打开门。但是,在这样做的过程中,我遇到了一个问题。我必须将输入的密码存储在动态数组中。我知道有一个用于制作动态数组的包,但我不知道制作动态数组的代码。我发布了到目前为止我所做的代码,即仅启动键盘。

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {

  // put your main code here, to run repeatedly:

}
Run Code Online (Sandbox Code Playgroud)

arduino dynamic-arrays

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

从字符串中删除空字符的Arduino代码

我正在使用nodemcu ESP8266并编写一个程序将一些值存储到EEPROM(分配缓冲区地址115到150来存储用户名)。

当我使用 for 循环从 115 到 150 读取 EEPROM 数据时,它将返回未知字符和字符串。当我检查空值以确定字符串何时结束时,代码不起作用。

带有奇怪字符的输出图像

我的代码:

//My Code for store username
String consumername = obj [String("USERNAME")] ;
         Serial.println("writing eeprom > Consumer Name:");
          for (int i = 0; i < consumername.length(); ++i) 
              {
             EEPROM.write(115 + i, consumername[i]);
           Serial.print("Wrote: ");
              Serial.println(consumername[i]);
          }
Run Code Online (Sandbox Code Playgroud)
//My Code for reading username
for (int i = 115; i < 150; ++i) 
 {
     ch = char(EEPROM.read(i));
     if(ch!='\0'){
     oname+= char(EEPROM.read(i));
 }
 }
     Serial .print("Name=");
     Serial .println(oname);
Run Code Online (Sandbox Code Playgroud)

embedded arduino nodemcu arduino-c++

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

为什么在这个“switch”语句中第二个表达式的计算结果也为 true?

我希望有人可以帮助我解决一个初学者问题(这是专门在 Arduino 上运行的,但我怀疑这是一个比这更基本的 C++ 问题)。

我不明白为什么以下“switch”语句同时输出“Channel 1”和“Channel 2”语句:

void setup() {
  delay(100);
  Serial.begin(57600);
  delay(100);

  int channel = 1;

  switch (channel) {
    case 1:
      Serial.println("Channel 1");
    case 2:
      Serial.println("Channel 2");
  }
}

void loop() {

}
Run Code Online (Sandbox Code Playgroud)

我读过 switch 语句“follow-though”或“cascade”,即我理解如果满足条件 1,那么代码仍然会继续检查后续条件(并且您可以添加显式的“break”命令)跳出)。这一切都很好。

但我不明白第二个表达式的计算结果为true(因为整数变量channel=1,并且只有当channel=2时它才应计算为true)。

我在这里缺少什么?

谢谢你!

c++ expression arduino switch-statement

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

Arduino中的PIN = 0不会触发电机

我试图使用if语句在Arduino Uno板上使用C控制电机.但是,当我设置为当传感器的PIN等于0时,电机将运行,它根本不起作用.我也尝试将PIN设置为不等于0和1,两者都正常工作.你们可以给它一张支票吗?非常感谢你.

int MotorL=11;
int DirectionR=12;
int MotorR=10;
int DirectionL=13;
int SensorM=0;

#include <avr/io.h>
#include <util/delay.h>


void setup() {
  pinMode(DirectionL,OUTPUT);
  pinMode(DirectionR,OUTPUT);
  pinMode(SensorM,INPUT);
  digitalWrite(DirectionL,HIGH);
  digitalWrite(DirectionR,HIGH);
  analogWrite(MotorL,0);
  analogWrite(MotorR,0);
}

void loop() {
  if(PIND &_BV(PD6)==0){ //General movement: forward
    analogWrite(MotorL,84);
    analogWrite(MotorR,97);
  }else{
    analogWrite(MotorL,0);
    analogWrite(MotorR,0);
  }
}
Run Code Online (Sandbox Code Playgroud)

c atmega arduino arduino-uno

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