Questions tagged [c++]

C++ is the standard language used to program the Arduino IDE. However, the Arduino IDE does have lots of libraries built in, so functions such as "main" are not called directly in the sketch code. Most Arduino code online is written in this language.

Filter by
Sorted by
Tagged with
1
vote
1answer
513 views

Send only one packet from one ESP32 to another ESP32 without acknowledgment

I have a network consisting 10 slaves and one master. I am using ESP-NOW to send the messages between the nodes. All of the nodes are within close proximity. I do NOT need a mesh network to reach all ...
0
votes
1answer
105 views

Matrix and State Space Arduino Implementation

I wrote an Arduino Matrix class. Then I used this class to implement State Space on Arduino. During tests I stomped upon a problem. After starting the program it stops at some point. I have no idea ...
0
votes
0answers
21 views

The problem of connecting the OV7670 camera to the arduino Uno [closed]

I recently bought ov7670, but I couldn't find a normal example code. If anyone knows, write the code for the operation of this camera.
1
vote
1answer
1k views

Passing non-static member function using bind

I'm using the GxEPD2 library to communicate with an E-Paper display. I now wanted to use the drawPaged method of this library with an object display. I also have written my own class from which I ...
0
votes
1answer
41 views

On-device logging of all Serial.print calls? [closed]

My Arduino program produces debug/error output using methods like Serial.printf. I can see all this output when it's connected to the computer, but I want to also log all this same output to my board'...
7
votes
2answers
16k views

Why the need to use the volatile keyword on global variables when handling interrupts in Arduino?

I am familiar with the keyword Volatile being used to declare variables that are shared among multiple threads on a software application (basically on a multithreaded application). But why do I need ...
1
vote
1answer
165 views

ESP8266: error: 'getLocalTime' was not declared in this scope

I am getting error: 'getLocalTime' was not declared in this scope when I am compiling this code for ESP8266, however works for ESP32: #include "time.h" void gettime() { static int16_t ...
6
votes
1answer
2k views

Which C++ standard does the Arduino language support?

The "Arduino language" (as they call it) of the Arduino IDE 1 is obviously C++. Which C++ exactly? I tried to figure it out myself (Arduino IDE 1.8.13 for Arduino Uno), but I can't conclude ...
1
vote
1answer
34 views

What's is the best way to convert std::string to String?

Pardon me, I am a novice programmer. I was trying to use the toInt() function for a std::string but I noticed that toInt() only works for the String class. So, I have an std::string sliderValue and ...
1
vote
1answer
214 views

How I can send data information without work WiFi to LCD?

Hi everyone I am beginning learn coding and the second language English. I have small project I use Arduino uno , esp8266 , dht11 , lcd I2C and use blynk app in my project I have the code and work ...
1
vote
3answers
1k views

Function declared in another file not recognized (undefined reference to)

I am making a multi-file arduino project, but the compiler can't recognize a function. I am using the arduino-cli version 0.10.0 This is the error I received undefined reference to pin_init() collect2....
30
votes
4answers
54k views

Is it better to use #define or const int for constants?

Arduino is an odd hybrid, where some C++ functionality is used in the embedded world—traditionally a C environment. Indeed, a lot of Arduino code is very C like though. C has traditionally used #...
2
votes
4answers
14k views

Connect HX711 to a three wire load cell

I have the following load cells: I'm using the following HX711 amplifier Every guide i can find on the internet describes how to connect a load cell with four wires to the amplifier. How can i ...
0
votes
1answer
27 views

Trying to program a Led Counter Want a Led to flash every 5 minutes however it flashes twice every second (Noob) [closed]

Heres the code i've Wrote i feel like the issue lies in how ive used the if statement int ledPinS = 13; //Classifies pin 13 as Connected to an LED //Flashes every second int ledPinM = ...
1
vote
2answers
37 views

I need help producing 2 pwm signals

My project is to use an Arduino to control two solenoid valves with PWM and receive an input signal from a sensor as feedback. The valves direct the flow of water which cause a hydraulic actuator to ...
2
votes
1answer
85 views

TFMini Sensors with Arduino

I have three TFMini sensors I need all of them to detect. I only got one to work , pins 4,5 . My info in coding is basic . I really appreciate your help . Thanks in advance. I think the problem is ...
2
votes
1answer
79 views

How to separate a specific frequency signal from a summation of a few signals?

I want to calculate THD. SO how do I isolate the fundamental frequency from a signal with harmonics? I have a signal V which is a sum of V1, V2 and V3. V1=A1sin(w1t+phi1), V2=A2sin(w2t+phi2) and V3=...
2
votes
1answer
306 views

Need help with wire connections and code

I am currently working on a keypad door lock mechanism (Similar to this project, Keypad door lock). The issues with the code I have is that the keypad attached to my board does not allow me to type ...
1
vote
1answer
45 views

Host a webserver on esp32d that has a hyperlink that triggers an ardiuno song through a buzzer

I would like to use my ESP32D to create a wireless access point and host an html page that has a hyperlink and a few other things on it that triggers an arduino song (rickroll), and plays it through a ...
1
vote
1answer
106 views

i can't work toggle for my small project

i build my small project from a few component as this photo after finish code and project . i work run for Proteus and then the project not run perfectly because my code need toggle for data entered . ...
0
votes
1answer
322 views

Arduino Piccolo Example Script Error

So I am trying to make an audio visualizer from this tutorial listed here. So I downloaded all the files needed, and downloaded the code. But when I try to verify it, I get this Error: C:\Users\ted\...
1
vote
2answers
348 views

I want to send the last 10 minute data via bluetooth

This was for photocell data logging for 30 sec intervals, now I want to write a code which commands from the cellphone and sends back the last 10 minute data. At first I thought if I make an array of ...
0
votes
4answers
8k views

While loop not breaking

I'm trying to build a circuit that buzzes until a button is pressed, or it buzzes 5 times: void alarm() { int AlarmState = 0; //Just to get while loop going int count = 1; while(AlarmState==0) ...
1
vote
1answer
62 views

Activating a defined macro in a class from main.cpp

Sorry if this question been asked. I'm trying to activate certain function in a class using a macro defined in the class from main.cpp. I'm using jrowberg MPU6050 library if that matters. main.cpp #...
1
vote
1answer
770 views

How to get the free/used space on a SD card and transmit it

I'm using this block of code to read and sum up the bytes of all the text files I have on an SD card: long get_sd_memory_taken() { File dir = SD.open("/"); long sd_memory_taken; int c = 0; ...
-1
votes
1answer
47 views

Arduino Sleep to conserve battery - How to intergrade it to existing sketch - HELP pls

My sketch below is simply using a touch sensor to activate a servo motor to go from from initial position 0 to 180 then back to 0. then I want the Adruino NANO to go to sleep to conserve some battery ...
1
vote
1answer
84 views

Storing and sequencing output value (arduino)

I am new to Arduino programming, after days and nights trying to use array,for loop and googling a lot of article, I still unable to find the way how to store each weighing output value from int ...
2
votes
0answers
44 views

I need help making an arduino control system [closed]

My project is to use an Arduino to control two solenoid valves with pwm and receive an input signal from a sensor as feedback. As can be seen from the picture, the valves direct the flow of water ...
1
vote
1answer
13k views

How to convert char array to String in arduino?

I want to convert const char array in PROGMEM to String. How do I do this? const char charArray[] PROGMEM = "Some text";
1
vote
2answers
7k views

Dynamicly sized array as a class member

I want to create a dynamic sized array of chars as a member in a class. This is being done inside a library that I've created. I have the .h and the .cpp files created. I'm not sure how to declare ...
1
vote
0answers
33 views

Obfuscate string with on SAMD21

I'am looking for a way to obfuscate string at compile time on my personal board build with an SAMD21, i'am using Arduino IDE to compile and upload code. All solution I've found like this one for ...
2
votes
0answers
397 views

Multi-file arduino esp8266 sketch sharing a reference to server

Transferred from stackoverflow on the advice of @Gee_Bee: I can get Writing a Library for Arduino to work as well as Breaking a sketch into multiple files and Classes within Classes - ...
2
votes
1answer
54 views

Where to store AES key on Arduino board

I'm working with this library AES lib so everything works I can encrypt/decrypt data. But now I'd like to know what is the best way to store my aes private key ? My boars is a personnal board build ...
1
vote
1answer
542 views

Read Multiple Sensors Data from a text file located in SD Card in Arduino/ESP32

I am working on a small home project 'glucose meter' via non invasive techniques. I am using four sensors like RGB color sensor, two multi-wavelength photo diodes (A & B) and temperature sensor (K-...
0
votes
2answers
182 views

Is there a way to make a function take an exact number of clock cycles?

Is it possible to use something like a compiler directive to pad a function with do nothing instructions so that as you add lines of code or take them away it always executes in the same amount of ...
0
votes
1answer
516 views

How to use existing (non-arduino-specific) library with subfolders in Arduino IDE?

I have a generic c++ library that i'd like to use in an arduino project without making changes to the library code. The library contains subfolders and files in the library include other files of the ...
2
votes
2answers
103 views

How can i reduce my global variable use? Attiny85

I'm trying to compile my code but i keep exceeding my global variable memory by 12%. Is there anything i can do in my code to further reduce RAM usage? Or do i have to do modifications to the ...
0
votes
2answers
827 views

How will Arduino communicate wirelessly through XBee?

I am using one XBee S2 configured as coordinator API attached to my laptop and one XBee S2 attached to an Arduino Uno that is configured as a router AT. I want to generate an alarm on LabVIEW as I ...
2
votes
1answer
12k views

Get ESP32 Chip ID into a string variable (Arduino/C++ newbie here)

It's just a few days since I started using Arduino IDE ( programming an ESP32 ). As I learn, I am trying to write some snippets. I wanted to store the Chip ID of ESP32 into a variable (preferably ...
-1
votes
2answers
80 views

İs that possible to a function return String OR Int depends on address

Well, I'm trying to use a HMI display and this HMI storing datas in separeta addreses. Such as integers addr. is between 0x80000 to 0x9ffff and also for string's addr is between 0 to 0x1ffff. At this ...
1
vote
1answer
59 views

Relay not triggering from loop function. Variable "volume" not updating after encoder is turned to value?

I am reading a value from an encoder "volume knob" and I have a function called void fn_on were I am having sum int to zero and counting until it reaches the set value of volume. I tried ...
1
vote
3answers
77 views

Can I pass data from an Arduino Nano to a Websocket Server via USB?

I have an Arduino Nano, and a local Java WebSocket server (ws://localhost:8888) run by a .jar file on my computer. I'm wondering if it's possible to send data (text, numbers etc.) from the Arduino ...
0
votes
1answer
391 views

HID-Project problems with keycode enums

I'm having some trouble with the HID-Project using my arduino micro as a keyboard. I'm using the BootKeyboard API, I want to be able to store and recall keycodes from EEPROM eventually, but as it ...
1
vote
1answer
101 views

Read bytes from PROGMEM array

Disclaimer: I just started using C++ and I'm a bit of a beginner. Keep that in mind as your answering. So I recently bought my first Arduino. It's a customized one and it has an 8x8 display attached ...
0
votes
2answers
83 views

What are the sizes of each primitive datatype on a Metro M4 Express SAMD51?

What are the data sizes of all the primitive datatypes on a Metro M4 Express SAMD51 C++ implementation? In some C++ implementations, int has 16 bits and in other implementations it has 32 bits. Is
0
votes
1answer
182 views

How to use TimerOne while calculating time?

I'm trying to get warning with buzzer while I get same values on 3 seconds. But first warning doesn't wait 3 seconds. Second warning is correct. Code is attached. BlinkLED1() method is same BlinkLED2. ...
1
vote
1answer
67 views

Avoid using delay with the HR-S04 ultrasonic sensor

How can I measure the distance of an HR-S04 ultrasonic sensor with millis and micros?
2
votes
2answers
475 views

How to convert RGB values to Intensity

I made an arduino color sensor with tcs3200 and arduino uno. I have coded the arduino to find the RGB values when I place the color paper below the sensor. How can I derive the intensity using the RGB ...
1
vote
0answers
30 views

ATTINY13A, Servo only makes half a sweep

I have been trying to get a servo to sweep using an attiny13A. And i managed to get the servo to (kindoff) work by the help of a previous thread. But i'm now getting an issue. The servo only goes to ...
1
vote
1answer
129 views

How can I program 2 ultrasonic sensor, one on the servo motor and one attached on the front side of the car?

I want to attach two ultrasonic sensors to an obstacle to avoiding the car. One on the front of the car Second on the servo motor on the car It is an obstacle avoidance Project. I am getting the ...

1
2 3 4 5
20