我正在参加 Arduino 微控制器课程,并且正在研究我的期末项目:根据外壳温度工作的自动化计算机冷却系统。
我无法使用以下来源获取 NVIDIA GPU 核心温度:此 MSDN 链接或此 NVIDIA 链接。如何获取 GPU 的温度值?
我的 C# 知识很基础,我对 MSDN 中的手册或代码示例摸不着头脑。
Arduino 有一些很好的 C++ 库,我想在 PC 平台上使用它们。另一个优点是可以在 PC 上测试和调试 Arduino 代码。在PC上进行调试要容易得多。
我特别喜欢的一个库是 String 库。https://www.arduino.cc/en/Reference/String
鉴于 Arduino 库是开源的,是否可以以某种方式将 Arduino String 库导入到 Visual Studio 等 C++ IDE 中?如何才能做到这一点?
我正在尝试使用看门狗中断作为计时器,让我的 Arduino 休眠一段时间。我的问题在于,在唤醒时,我需要执行超过 8 秒的操作。
目前,我的 Arduino 将休眠 1 分钟,使用看门狗的连续中断将其唤醒并使其重新进入休眠状态。然而,1 分钟后,我开始执行超过 8 秒的操作,并且看门狗中断超时。
我想关闭看门狗定时器,进行操作,然后重新启用它并返回睡眠状态。
这是我的代码:
#include "Adafruit_FONA.h"
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#define FONA_RX 10
#define FONA_TX 9
#define FONA_RST 4
#define LED_PIN 8
// this is a large buffer for replies
char replybuffer[255];
char *SMSnumber = "6015962842";
char stack[128] = {'c'};
//Value for watchdog timer interrupt.
volatile int f_wdt = 1;
int seconds = 0;
int minutes = 1;
int hours = 0;
int interval = ((hours*60*60) + …Run Code Online (Sandbox Code Playgroud) 我使用 SIM800L 模块和 Arduino Uno 与网络服务器进行通信。我有一个 Arduino 读取的传感器。我想将传感器的值存储到我的数据库中。
在我的 Web 服务器上,我有一个 PHP 页面,用于将数据保存到数据库中。我正在使用这样的 GET 方法:http://www.isj.ir/Samples/sample.php?sen1=27.2。
我正在将这个库用于 SIM800L。
但在这个例子中我无法传递传感器的值。我很困惑!您能帮帮我并告诉我该怎么办吗?
sprintf(body, "{\"name\": \"%s\"}", "Arduino");
result = http.post("isj.ir/Samples", body, response);
Serial.println(body);
print(F("HTTP POST: "), result);
if (result == SUCCESS) {
Serial.println(response);
StaticJsonBuffer<32> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(response);
lastRunTime = millis();
waitForRunTime = root["waitForRunTime"];
print(F("Last run time: "), lastRunTime);
print(F("Next post in: "), waitForRunTime);
}
result = http.get("isj.ir/Samples", response);
print(F("HTTP GET: "), result);
if (result == SUCCESS) {
Serial.println(response);
StaticJsonBuffer<32> …Run Code Online (Sandbox Code Playgroud) 我想制作一个简单的程序,放在我的 Arduino/Genuino (SunFounder) Uno 板上,当插入时,它会调用该Keyboard.print()函数。当我编译程序来执行此操作时,它说我没有包含在内,Keyboard.h即使我实际上处于程序的开头。
#include <Keyboard.h>
void setup() {
Keyboard.begin();
Keyboard.print("Hello, world!");
Keyboard.end();
}
void loop() {
}
Run Code Online (Sandbox Code Playgroud)
当我编译代码时,出现以下错误:
KeyboardMessage:4:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
我在 Arduino 草图编辑器文件中检查了我的库文件,并且Keyboard.h它在那里。
任何帮助表示赞赏。
是的,,,我知道有很多关于这个的话题,我想我已经阅读了其中的大部分,但要么我不理解答案,要么我无法将它们适应我的“案例”。
请注意,我的背景是电子设计,而不是软件设计,所以对于你们中的一些人来说,我的问题可能看起来很愚蠢,但是......我被困住了。
我设计了一块用于物联网用途的 PCB 板。它基于 ESP32 模块。我有 5 个按钮连接到 ESP。ESP32-IDF 对我来说太复杂了,所以我尝试使用 Arduino 框架。现在事情开始变得复杂了。
为了检测和消除按钮的抖动,我创建了一个名为 Button 的 C++ 类。下面可以看到一个骨架。
class Button {
..
..
private:
void memberCallback() {
...
}
public:
Button(const uint8_t gpio ) {
..
attachInterrup(digitalPinToInterrupt(gpio), memberCallback, FALLING);
..
}
..
}
Run Code Online (Sandbox Code Playgroud)
我还没有找到任何方法来定义“memberCallback”,而不会导致编译错误或根本无法工作。
这一定是一个常见问题,所以请建议我解决方案:)
编辑。看来我表达得不够清楚,抱歉。- 我知道如果我将memberCallback设置为静态,它至少会编译。问题是我计划使用 5 个这样的实例。静态回调意味着所有实例将运行相同的代码。5 个实例意味着 5 个不同的中断。我如何识别它们。
我有一个 OLED SPI 显示屏 128x64,我使用 Adafruit_GFX 和 Adafruit_SSD1306 来控制它。我有一个类名 Engine,它有一个像这样的公共构造函数:
Engine::Engine() {
display.begin(2U, 0U, true, false);
// Define some pinmode not a problem
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
pinMode(buzzerPin, OUTPUT);
//clear the screen and display
clearScreen();
display.display();
time = 0;
}
Run Code Online (Sandbox Code Playgroud)
然后在我的 .ino 文件中我有这样的内容:
Engine engine = Engine();
void setup() {
Serial.begin(115200);
Serial.println("testing...");
}
Run Code Online (Sandbox Code Playgroud)
问题是程序有点冻结。我不知道代码是否有效(我认为没有)。我尝试调试它,如果我在设置中声明了引擎,那就没问题了。或者,如果我删除该行display.begin()并将声明保留在设置之外。为什么?我需要打电话display.begin()进去吗setup()?如何摆脱这个困境?
PS:我为此使用了视觉微型。但之后我将代码移至Arduino,问题仍然出现。
我一直在尝试通过按下相应的按钮来让我的 Arduino 上的 LED 亮起和熄灭。
我正在使用中断来实现它并且按钮按下确实被注册,但由于某种原因它没有改变全局变量的值(int button_pressed1,...);
应该发生的是,当我按下按钮 1 时,LED 1 应该亮起和熄灭,与按钮 2 和按钮 3 相同。
我真的很感谢你看一看,中断对我来说很新,所以这可能是一个小问题。<3
*我省略了按钮 2 和 3 的代码。如果我能让 LED 点亮按钮 1,我就能让它们点亮其他按钮。
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "usart.h"
#define LED_DDR DDRB
#define LED_PORT PORTB
#define BUTTON_DDR DDRC
#define BUTTON_PORT PORTC
#define BUTTON_PIN PINC
int button_pressed1 = 0; //globale variabele to turn on functions
ISR(PCINT1_vect)
{
if (bit_is_clear(BUTTON_PIN, PC1))
{
_delay_us(500); //debounce
if (bit_is_clear(BUTTON_PIN, PC1))
{
button_pressed1 = 1;
printf("button 1 pressed\n");
}
}
}
int …Run Code Online (Sandbox Code Playgroud) 我想根据常量值定义一些函数:
#define mode 5
#if mode & 2 != 0
// function 1
#endif
#if mode & 4 != 0
// function 2
#endif
Run Code Online (Sandbox Code Playgroud)
这听起来和看起来都很奇怪,但我想使用一个常量来定义和激活一些程序模块。
定义mode = 2包括功能1、mode = 4包括功能2并且mode = 6包括两个功能。有一个问题:像、、或 这样
的比较运算符似乎在指令中不起作用,并且语句总是被执行。==!=><#if
我究竟做错了什么?我是否想做一件愚蠢或不可能的事情?
我为 Arduino Nano 编写了一个代码,我遇到了这种奇怪的行为:
#define GREAT (60 * 60000)
#define STRANGE (60 * 6000)
#define ZERO_X (60 * 1000)
void setup() {
Serial.begin(115200);
Serial.println(GREAT); // Prints 3600000, that's correct
Serial.println(STRANGE); // Prints 32320, thats wrong
long zerox = ZERO_X;
Serial.println(zerox); // Prints -5536, thats also wrong, obviously
}
void loop() {}
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?
我将 MSVS2019 社区与 vMicro 一起使用
arduino ×10
c++ ×5
c ×2
arduino-c++ ×1
arduino-uno ×1
atmega ×1
c# ×1
directive ×1
esp32 ×1
gpu ×1
http ×1
interrupt ×1
led ×1
nvidia ×1
sim800 ×1
string ×1
temperature ×1
visualmicro ×1
watchdog ×1
webserver ×1