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
10 views

Read & Write String to EEPROM

I need to implement EEPROM Read & Write functionality to my project. I've been learning how to use the EEPROM on the last few days, however I'm struggling to Read & Write Strings to EEPROM. ...
0
votes
1answer
21 views

Arduino esp32 randomly corrupted variable

Every so often my variable gets corrupted. Sometimes it happens several times in a row and other times it doesn't happen in several hits. I put these logs to rule out that any of the operations ...
0
votes
0answers
8 views

Array without explicit size is not working inside another array? (re: lookup table) [migrated]

I'm trying to define a USB HID ID to PS/2 Scan Code lookup with the following structure: struct usbToPs2matrix_t { uint8_t hid_id; uint8_t ps2Make[]; uint8_t ps2Break[]; }; The HID ID is a ...
0
votes
1answer
60 views

A strange bug in my Arduino ALU

I have discovered a strange error in my Arduino. It's not in the code. I think it's a hardware bug in the ALU of the microcontroller, maybe in clone only. So there is a variable called feedLimit and ...
-1
votes
1answer
62 views

i am tying to make a automated parking lot with a gate, sensor, button, keypad, how can i time how long has each car spent inside?

the project requires a automated parking lot, I have been able to connect and function the sensor and button for exit and enter, and the led(red lights when parking is full, green when there is spots)....
0
votes
1answer
28 views

variable or field declared void Error

For a larger sketch, I have separated a chunk of code in a separate .cpp file #include "msg.h" #include <Arduino.h> #include <HTTPClient.h> #include <ArduinoJson.h> void ...
-1
votes
0answers
15 views

Inheritance of objects declarations from top of files hierarchy to 3rd level

I successfully compiled and debugged two functional modules of a complex project, and am working on the third one. The project has hierarchical structure where the 1st level includes the ino and ...
0
votes
1answer
62 views

State machine problem

I am trying to record the pulses from a water flow sensor using a state machine. My goal is to count the pulses until the flow stops (i.e. the rotor inside comes to rest). This will constitute a ...
-2
votes
1answer
61 views

How can I get an external program to change values inside the Arduino C++ code? [closed]

How can I get some constantly changing values from a separate C++ program entered and uploaded into the Arduino? I notice when I upload code to the Arduino in the IDE it takes about a second to start ...
0
votes
0answers
9 views

How to convert a char* to a char array [migrated]

I'm receiving some data over serial of variable names and values in char. The variable name gets stored in an array pointed to by the char*. I'm trying to compare the char array data I received, to ...
0
votes
0answers
6 views

Preferences NVS can not save array over 11 bytes [migrated]

Why can't I store arrays with size over 11 bytes inside Preferences using putBytes. Example: struct config_wifi_t{ int *test; }; struct configuration_t { bool result; config_wifi_t config_wifi;...
2
votes
1answer
68 views

Multiplexer 74HC4067, conflict between channels

I am currently working on an Arduino Zero with a 74HC4067 multiplexer and I am experiencing inconsistencies when testing some of the channels. My class is the following (it should be functional for 8 ...
1
vote
0answers
26 views

How to use an Arduino to play audio from an Adafruit Soundboard using audio file name

I'm trying to control an adafruit soundboard with my elegoo uno R3. I'm a beginner programer and I'm trying to get the soundboard to play a sound file by name when I press a button. I have confirmed ...
0
votes
1answer
23 views

how to put whitespace in long Serial println() input [closed]

I have this long, Serial.println() that is in quotes, on multiple lines. Arduino IDE warns: "Missing terminating character". I am certain there is a way to break the lines up, while having ...
1
vote
1answer
40 views

Should I use C or C++ for a pure code implementation of Arduino?

I have an arduino board (SAMD21 microcontroller) which supports either Arduino or CircuitPython programming. I'd like to program in pure C/C++ instead of Arduino, which seems to be possible without ...
1
vote
1answer
54 views

How to change variable/sketch through a GUI

Over the past few months, I've been working on a wearable computer mouse using an Arduino and a 9-dof sensor. Most of the sketch is complete, and works as expected. Recently, I started investigating ...
1
vote
1answer
82 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 ...
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 ...
0
votes
1answer
28 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
40 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 ...
1
vote
1answer
639 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 ...
-1
votes
1answer
53 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 ...
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
0answers
35 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
1answer
60 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 ...
2
votes
2answers
130 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 ...
-1
votes
2answers
120 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
156 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 ...
1
vote
0answers
33 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
346 views

How to fade LED in a defined time using FastLED

I'm using FastLED library, Arduino Nano and 5 addressable LEDs (WS2812B). I'd like to create the sequence in the image attached. (all in white color for example) I know how to turn ON each LED every 0....
2
votes
2answers
104 views

how can I accurately recieve potentiometer values over the USB port?

I want to read the analog values of my ardunio uno into a separate c++ program. On the Arduino I have a serial port initialized for 9600 baud: int sensorPin = A0; // select the input pin for the ...
1
vote
3answers
104 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 ...
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
1answer
78 views

how to display text to 8x8 matrix with 64-bit long integers?

I have an array of 64-bit integers to display on an 8x8 led matrix const int LEN1 = sizeof(Hours); const uint64_t Hours[] = { 0x00043c3c3c3c3c00, 0x000c3c3c3c3c3c00, 0x001c3c3c3c3c3c00, ...
1
vote
1answer
89 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?
4
votes
1answer
48 views

Custom LED toggling function: one out of three LEDs misbehave

I connected three LEDs to an Arduino Uno and wrote a simple LED class. I toggle all the leds the main loop, but for some reason one led (connected to pin7) always misbehaves, skips one toggle or stays ...
-2
votes
1answer
111 views

Do I use an LED or a pullup resistor for stopping "floating" or "ghosting" for a matrix keypad?

I know this sounds simple, but I have an Arduino Mega 2560 and I am making a matrix keypad for a claw machine. It's a 3*4 matrix keypad. Let's just say, I am making this keypad for the claw machine to ...
3
votes
1answer
106 views

Anyone know why my pushbutton is always returning HIGH?

Been trying to figure this out for a couple hours, despite how ridiculously simple it should be. I have no idea why it's always returning 1, even when i'm pushing the button. Fritzing sketch: My code:...
1
vote
0answers
23 views

Clicking a mouse based on dwell time / how to code a rolling total of sensor measurements

I'm trying to write code that should result in a click of the mouse, based on dwell time. I'm getting data from a gyroscope to move the mouse around. I'm not sure what the best way is to approach this ...
1
vote
1answer
61 views

How to send a message to my phone that my Arduino system is on when turning on my Arduino

i have installed a GSM shield on the Arduino to create security alarm system using PIR SENSOR when ever there motion I will receive a call to my phone. but i want to add also a line of code which can ...
0
votes
2answers
35 views

Unexpected output for simple code involving calculating a time interval of 10ms

I had written some code that involved doing something after 10 milliseconds had elapsed, however it was performing unexpectedly. Upon debugging, I think I have identified the error, and I wrote some ...
1
vote
1answer
313 views

ESP8266 ISO 8601 string to tm struct

I have a web service that returns timestamps in ISO 8601 format, e.g., "2021-06-25T12:00:00" I'm trying to turn the timestamp string into a tm type struct from the ESP8266 library <time.h&...
1
vote
0answers
42 views

Data output , ds18b20 , lcd1602 , yl-69, dht11

Good afternoon, I wonder if you could help me. I have the code but the data from the sensors is not correct. Perhaps there are some errors, could you fix them? I apologise for my inaccurate statement. ...
1
vote
2answers
150 views

Would someone provide an example of extracting data from a char array?

I have tried so many things now that I am just confused. I am not understanding the way char arrays work. I can't get the date and names extracted. And when I use just strings, I jam up the memory. ...
2
votes
1answer
212 views

Driving a servo with an ATTiny13A

So, I managed to fry my cheap servo/ESC (electronic speed controller) and decided to make my own using an ATTiny13A on some perfboard. But, I have run into some issues getting the servo to respond. I'...
1
vote
2answers
243 views

How do I pause a loop just once?

I´m trying to make a pause in a loop, but just for the first time it loops. The next loops i would like the program to NOT do the pause. Just once time, each time a button is pressed. Does anybody ...
1
vote
1answer
45 views

Help On Creating Derived classes in Headers

Here's a small problem I encountered while I was trying to make this small header file Devices.h: Is it possible to use templates with abstract classes ? If yes, how and how can I use that abstract ...
1
vote
1answer
33 views

Error Outputting Values Arduino Serial.print

I am experimenting with the following program I found online (with slight modifications): int x; void setup() { Serial.begin(9600); Serial.setTimeout(1); } void loop() { while (!Serial.available());...
2
votes
2answers
168 views

Use chars in quotes in const char* as name of function

I have been trying for a long time how to use a word declared as const string* word = "xxx" as name of void function declared somewhere below in my code. Here is example with ssid: const ...
1
vote
1answer
167 views

Why my arduino board does not blink properly?

I have two files blink1.cpp typedef unsigned char int8_t; typedef volatile int8_t * volatile port_type; port_type portB = (port_type) 0x25; port_type ddrB = (port_type) 0x24; void delay_500ms() { ...

1
2 3 4 5
20