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
0 votes
1 answer
22 views

Create member object using constructor arguments, or pass reference to object via constructor

I'm not entirely sure about the proper C++ terminology, so I'll just illustrate what I'm trying to achieve by giving a Java example since it should be pretty obvious: public class LcdDecorator { ...
user avatar
  • 313
2 votes
1 answer
79 views

Where should unit tests go in the Arduino IDE

I have an Arduino project where the file structure looks like this myProject/ myProject.ino ImportantClass1.hpp ImportantClass1.cpp ImportantClass2.hpp ImportantClass2.cpp ...
user avatar
0 votes
0 answers
27 views

Fail passing ArduinoJSON [duplicate]

I'm storing parameters file on ESP8266 flash, using LittleFS.h and ArduinoJSON.h. In case of a failure getting stored values from flash, local defaults are used (stored locally in myIOT_defs[]). When ...
user avatar
  • 820
0 votes
2 answers
63 views

How to do 'for' loop over inline anonymous array

I have a bunch of pins given names in the header: #define DIP5 53 #define DIP4 52 #define DIP3 51 #define DIP2 50 #define DIP1 49 #define DIP0 48 If it's not obvious, I have a bunch of DIP switches ...
user avatar
  • 313
0 votes
0 answers
16 views

ADXL 355 Self Test Failure using Teensy 3.2

I am currently having difficulties reading out data from the EVAL-ADXL355Z FIFO register using a Teensy microcontroller. I have confirmed 2KHz ODR I2C communication between the Teensy and the ...
user avatar
  • 1
1 vote
1 answer
39 views

How to convert a reading to percentage in Arduino [closed]

I am using this example on how to use a photoresistor to detect the value of light that the sensor is getting but I want to convert the reading of the resistor to a percentage but I can't use the map()...
user avatar
2 votes
0 answers
91 views

Same code working on Arduino IDE but not in PlatformIO IDE

I'm running into this weird problem. My code is working just fine when I upload it to an ESP32 from Arduino IDE. That same code is not working when I upload it using PlatformIO IDE. The same libraries ...
user avatar
-1 votes
1 answer
34 views

How to shift binary into a shift register (serial in, parallel out) sequentially

I'm trying to make a continuity tester at work where I connect the input and output of a harness into a test fixture powered by an Arduino. This tester tests whether the position of the connects are ...
user avatar
2 votes
1 answer
226 views

What is wrong with the way I write and or read the EEPROM adresses?

Consider: #include <EEPROM.h> byte guifactor1 = 1; byte guifactor2 = 2; byte guifactor3 = 3; byte guifactor4 = 4; byte guifactorgas = 5; byte guifactorwater = 6; volatile unsigned long ...
user avatar
0 votes
1 answer
42 views

Using a 5 pin button with Arduino Correctly

I am trying to build a simple motor test sketch, currently, to test a NEMA 23 stepper motor and the DM542T stepper driver. Here is the code, and I am having trouble figuring out how to properly wire ...
user avatar
  • 350
0 votes
0 answers
49 views

How to display Serial data in console [closed]

I'm using an ESP32 for a project. I use one Serial with a 115200 baudrate, and Serial2 with 9600 baudrate. I need to receive a message on Serial2, and I want to display it on Serial for debugging ...
user avatar
-1 votes
1 answer
54 views

Getting more Hz while working with 3 serial ports (IMU sensors)

im doing a university project where we use 2 IMU sensors and a SD card reader to save the data from sensors. As you will probably see from the code, we specify the sensor port we listen to, save data ...
user avatar
-1 votes
0 answers
22 views

14-Step Step Motor RPM Calculations are not the right RPM Readings

I am in a after-school group at my school, and it is based off of STEM. We are currently working on a hoverboard-like project powered by 4 ATV batteries, And it includes magnets inside of a 14-step ...
user avatar
  • 1
0 votes
1 answer
26 views

Having trouble reading multiple thermistors w/ Arduino 2560

I'm trying to get my code to read multiple thermistors and I can't quite seem to get it correct using my arduino 2560. The first issue is it's not reading more than the first thermistor. The next ...
user avatar
0 votes
1 answer
65 views

Integer division

I want to divide two integers and get how often one of them fits into the other completely, so there will always be an integer as an output. In python you do this kind of operation with //.
user avatar
0 votes
0 answers
78 views

ESP8266 - What is the difference between PSTR() and PROGMEM specifier?

While saving ESP8266 RAM spaces I am confused by the usage of PSTR(), PROGMEM, and lots of _P functions. What I know now is PROGMEM only applies to global or static strings, while PSTR() can only be ...
user avatar
  • 1
1 vote
1 answer
98 views

How to pass non-static class member to callback on avr platforms?

I am using the PubSubClient library in my own Arduino library. I'm having trouble with trying to assign a class member as the client library setCallback callback function. MyClass.cpp: #include <...
user avatar
2 votes
3 answers
153 views

why is my char array empty

following sketch will run totally fine and as expected : #include <Wire.h> #include "SparkFun_External_EEPROM.h" ExternalEEPROM ExtEEPROM; char username[33] = ""; char ...
user avatar
  • 147
2 votes
2 answers
113 views

How to install the application + its configuration to many devices of the same kind? (ESP32)

Being the newbie in the Arduino area... Having more devices, how can I upload some configuration parameters after the code was uploaded? Is it possible? Situation: I have the simple application for ...
user avatar
  • 137
7 votes
4 answers
969 views

Optimizing code for ATtiny10

I'm trying to squeeze code onto an ATtiny10, but I'm just not getting there. I'm using 1060 bytes and only have space for 1024 bytes. The code is simple enough; I need to read a button pin. If high it ...
user avatar
1 vote
1 answer
51 views

ESP8266 Pulling Credentials from SD makes esp unable to connect

I'm trying to set up a wifi SD server and i want to put the wifi credentials in a config.txt file on the sd. The entire code works fine. when i dont use the sd credentials but when i do i run into ...
user avatar
0 votes
1 answer
249 views

7-Segment Display w/ Potentiometer

(Backstory) So, I took an computer engineering class in high school (grade 11 level), where I learned a bit about breadboarding as well as arduinos (I would like to stress a bit). It has been 5 years, ...
user avatar
  • 3
1 vote
2 answers
310 views

uint8_t issues when linking libraries outside of INO file

I've been trying to start my project out split into multiple files, knowing it will grow. I was templating it off of how I've done C++ files in the past: classes in an individual .h/.cpp pair and ...
user avatar
1 vote
1 answer
65 views

Servo keeps rotating

I used a 360° servo with a program I made on an Arduino Uno. The program was meant to control two separate servos with two potentiometers on a breadboard. When I used 180° and 90° servos, it worked ...
user avatar
0 votes
1 answer
72 views

Why is the value of this uint32_t always 0?

Setting up a method to calculate ID3 frame sizes, but the variable frsz always returns 0. I need to pass this variable back to another method so the program can loop through the ID3 frames. void ...
user avatar
2 votes
2 answers
62 views

Read & Write 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. ...
user avatar
0 votes
1 answer
51 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 ...
user avatar
0 votes
1 answer
64 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 ...
user avatar
-1 votes
1 answer
69 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)....
user avatar
0 votes
1 answer
62 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 ...
user avatar
  • 183
0 votes
1 answer
64 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 ...
user avatar
  • 183
-2 votes
1 answer
75 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 ...
user avatar
  • 97
2 votes
1 answer
88 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 ...
user avatar
  • 23
1 vote
0 answers
49 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 ...
user avatar
0 votes
1 answer
34 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 ...
user avatar
  • 838
1 vote
1 answer
58 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 ...
user avatar
1 vote
1 answer
69 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 ...
user avatar
1 vote
1 answer
273 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 ...
user avatar
  • 13
6 votes
1 answer
3k 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 ...
user avatar
0 votes
1 answer
31 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 = ...
user avatar
1 vote
2 answers
48 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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
  • 11
-1 votes
1 answer
62 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 ...
user avatar
2 votes
0 answers
47 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 ...
user avatar
1 vote
0 answers
46 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 ...
user avatar
  • 133
2 votes
1 answer
73 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 ...
user avatar
  • 133
2 votes
2 answers
184 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 ...
user avatar
  • 95
-1 votes
2 answers
242 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 ...
user avatar
  • 205
1 vote
1 answer
252 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 ...
user avatar
1 vote
0 answers
42 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 ...
user avatar

1
2 3 4 5
21