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
1k 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, ...
Dezter's user avatar
  • 3
1 vote
2 answers
697 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 ...
Kyle Sunderland's user avatar
1 vote
1 answer
143 views

Servo keeps rotating

I use 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 ...
aaron vu's user avatar
0 votes
1 answer
423 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 ...
Mighty Ferengi's user avatar
2 votes
2 answers
413 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
100 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 ...
Diego Serrano's user avatar
0 votes
1 answer
69 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 ...
Z Dhillon's user avatar
-1 votes
1 answer
94 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)....
Faisal Alrafaei's user avatar
0 votes
1 answer
2k 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 ...
Zaffresky's user avatar
  • 183
0 votes
1 answer
80 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 ...
Zaffresky's user avatar
  • 183
-2 votes
1 answer
120 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 ...
Ant's user avatar
  • 97
2 votes
1 answer
170 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 ...
Fanch's user avatar
  • 23
1 vote
0 answers
184 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 ...
Eric Walier's user avatar
0 votes
1 answer
108 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 ...
j0h's user avatar
  • 882
1 vote
1 answer
202 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 ...
MendelumS's user avatar
1 vote
1 answer
119 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 ...
Zhelyazko Grudov's user avatar
2 votes
4 answers
514 views

Instances of a class inside another class - is there a way to control the amount?

I have a class with 12 instances of a button, to create a keypad( meaning that this is the only case I use 12 instances). But this class can be just a button array of any other number between 1-12. I'...
guyd's user avatar
  • 907
1 vote
1 answer
704 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 ...
Enna's user avatar
  • 13
9 votes
1 answer
6k 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 ...
Thomas Weller's user avatar
0 votes
1 answer
34 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 = ...
Ben Seaman's user avatar
1 vote
3 answers
169 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 ...
Marius Pretorius's user avatar
1 vote
1 answer
4k 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 ...
Murad's user avatar
  • 11
-1 votes
1 answer
74 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 ...
Anthony's user avatar
2 votes
0 answers
56 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 ...
Marius Pretorius's user avatar
1 vote
0 answers
92 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 ...
simon's user avatar
  • 133
2 votes
1 answer
123 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 ...
simon's user avatar
  • 133
2 votes
2 answers
304 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 ...
Boyfinn's user avatar
  • 95
-1 votes
2 answers
421 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 ...
mehmet's user avatar
  • 235
1 vote
1 answer
487 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 ...
gurkensaas's user avatar
1 vote
0 answers
52 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 ...
Earthbound Ruben's user avatar
1 vote
1 answer
1k 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....
yuvix_man's user avatar
2 votes
2 answers
134 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 ...
j0h's user avatar
  • 882
1 vote
3 answers
472 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 ...
kevinlinxc's user avatar
1 vote
1 answer
64 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 ...
voltaty's user avatar
  • 11
1 vote
1 answer
192 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, ...
gio xanchkava's user avatar
0 votes
1 answer
253 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?
alessandromrc's user avatar
4 votes
1 answer
49 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 ...
Jurc192's user avatar
  • 73
-2 votes
1 answer
376 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 ...
Austin's user avatar
  • 101
3 votes
1 answer
127 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:...
Crystal's user avatar
  • 71
1 vote
0 answers
28 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 ...
Zhelyazko Grudov's user avatar
1 vote
1 answer
68 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 ...
user76732's user avatar
0 votes
2 answers
44 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 ...
satan 29's user avatar
  • 157
1 vote
1 answer
2k 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&...
Boyfinn's user avatar
  • 95
1 vote
0 answers
75 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. ...
Дарина Бакута's user avatar
1 vote
2 answers
302 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. ...
E_Ja's user avatar
  • 21
2 votes
1 answer
741 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'...
Rearthbound's user avatar
1 vote
2 answers
381 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 ...
Juan Antonio's user avatar
1 vote
1 answer
103 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 ...
Sam Ruben Abraham's user avatar
1 vote
1 answer
208 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());...
Sony's user avatar
  • 110
2 votes
2 answers
262 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 ...
oreo's user avatar
  • 39

1
2
3 4 5
21