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
0answers
38 views

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

i am trying for 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 char* ssid = ...
0
votes
0answers
43 views

always shows a function-definition is not allowed here before '{' token [closed]

I don't know why it always shows that, how can I solve this problem?
1
vote
1answer
158 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
vote
0answers
25 views

How to move 3 steppers at the same time?

I am working on a Makeblock project in which I have 3 steppers. I am trying my own code and I want to move the 3 steppers at the same time (not exactly at the same time, but visually). I have my ...
-1
votes
2answers
44 views

Convert string to integer

I'm using two ESp32 in a server and client configuration and i'm sending data between them in form of strings but i want to convert the recieved data which is fom of strings but it contains numbers ...
-1
votes
1answer
24 views

Arduino RTC SD Card problem

I am using a script on an Arduino to record BME280 data onto an SD card and to display it on a lcd display. To have a valid time stamp I am also using a DS3231 RTC module. I set the time succesfully ...
1
vote
1answer
50 views

Why is my liquid crystal display not showing any output?

UPDATE: The LCD will light up only when the all my components are located in the bottom right of the breadboard. Why am I not able to use the entire breadboard for my circuit? I am trying to display ...
1
vote
0answers
27 views

How to program the joystick button to reset everything?

In this project, I'm making a stickman rush game with a joystick. Where when the joystick moves up and down, the stickman also moves up and down. And there are obstacles, that when the stickman ...
1
vote
1answer
38 views

Store button presses in an array and sequince it with the LEDs

Example: If the user presses the button sequence 1-2-2-1 then the LEDs light up in the order 1-2-2-1 int userAmount[4]; const int ledPins[] = {4, 5}; const int btnPins[] = {8, 9}; int ...
1
vote
1answer
33 views

int array passed through function has wrong values only after multiple passes

I have this code: for(int i = 0; i < its; i++) { x1 = random(0,4); y1 = random(0,4); multiLamp(new int[2] {3,1}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2); multiLamp(new int[...
1
vote
0answers
43 views

How to completely clear everything from an arduino and print something new?

I'm in progress of making a stickman rush game, Until I hit a bug that I have been stuck on. I want to make a if statement that states "If the stickman and the object are in the same place, clear ...
1
vote
1answer
36 views

How to print something when a character touches a character

I am making a stickman rush game, where it goes up and down and then there is a object that scrolls to the left. Whenever that stickman touches the object, it prints game over. However when the object ...
1
vote
2answers
61 views

Using millis() instead of delay() when playing a melody

I want to make my Arduino to play several simple melodies, and also be able to skip a melody by pressing a button and go on with the next song. therefore I cannot use delay() because the code should ...
1
vote
0answers
27 views

Create a 7 segment display out of controllable LED strips to display digits

Highschool newbie here I'm trying to create a 7 segment two-digit display (88 shaped) to display the number of times a distance sensor detects something passing in front of it Here's what I've done so ...
1
vote
1answer
91 views

HC-05 Module not receiving commands and not pairing

I'm working on a project where I'll need to establish a connection between two HC-05 modules, each connected to an Arduino, but for now I'm just trying to get one to work and connect to my phone, but ...
0
votes
0answers
21 views

Arduino MPU6050 AD0 Tricks with offset setting gives corrupted data

I am currently experimenting with two MPU6050 which the AD0 is connected via PIN 7 and PIN 8 respectively, and if this is working, I plan to add another 2 more MPU6050 to it. I am using i2cdevlib's ...
1
vote
1answer
43 views

Unable to compile c++11 libraries despite having added -std=c++11 in platform.txt

I want to use c++ data structures such as vectors, arrays, map... in my Arduino sketch. I made sure to add -std=c++11 and -std=gnu++11 in platform.txt, I am still getting the following error message: ...
1
vote
1answer
29 views

Rotating Servo Motor using Arduino

Using arduino, I'm trying to rotate a 360 servo that will move clockwise 5 seconds,pause and counterclockwise for 5 seconds and then completely stop. However, my servo just continuously keeps on ...
0
votes
0answers
31 views

Recommend development environment for Arduino on Mac in the year 2021?

I'm using a Macintosh (Big Sur) and am about to begin developing an Arduino project in C++. (I am an experienced C++ programmer.) I notice that add-ons for Apple's "XCode" editor appear to ...
0
votes
1answer
42 views

Convert a char array to Flash string

I would like to pass a formatted string to a method that accepts a __FlashStringHelper. Here is the method signature: void myMethod(const __FlashStringHelper *str); I have been using snprintf to ...
0
votes
2answers
61 views

random() Function isn't random at all

I'm using the random() to generate random coordinates for coins in a simple game console. The problem here is that the random() function is not generating random numbers, since the coin is at the same ...
1
vote
0answers
21 views

Controlling lights by XBee S1+ ESP32 without bridge

I need some help with my ideas please, I have a smart home system and I am trying to control the Philips hue light but without the bridge. I want to do that by XBee S1 + FURTHER ESP 32. so, who did ...
2
votes
0answers
30 views

Where to define web server callback functions so they can access server object? (ESP8266WebServer library)

I want my ESP8266-based device to create an accesspoint that allows the user to input their home ssid and password. There is a device object that holds most of the data defined elsewhere. I'm trying ...
1
vote
0answers
44 views

What is the function of the /// and ///// in enclosed code

/// display.clearDisplay(); display.drawRect(1, 1, display.width()-1, display.height()-1, WHITE); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(5,5); ...
3
votes
2answers
383 views

Difference between char array and unsigned char array [closed]

I have written a small test code for Arduino Uno which is as follows: unsigned char tes[4]; char testing[4]; void setup() { Serial.begin(9600); for (int i = 0; i < 4; i++) { ...
1
vote
1answer
66 views

Using lambdas as callback functions

Using the Ticker library for the ESP32, how can I use a lambda as an argument to the attach method? tickerSystemManager.attach(1000, [&](){ systemManager->sync(); }); Attempting to use the ...
0
votes
1answer
30 views

Accessing funcition in object via `->` is crashing (resetting) Arduino

I have several classes that call each other running on an Arduino Mega. I am using the ArduinoSTL library to get the std library, most notably the std::vector. The core problem is as follows: my ...
1
vote
0answers
28 views

Finding min and max value in 3rd column and printing the whole row [closed]

I am currently using an RTC module and a Dissolved Oxygen Sensor. Data is stored in a csv file and I want to find the 3rd row's min and max, but print all the rows including the time. void data() { ...
0
votes
0answers
39 views

Logging exceptions locally - SPIFF filesystem?

I am creating a system of 10 nodemcu(s) communicating and sharing data over painlessmesh. Each of these is powered by 240V to 3.3V power supplies. One of these nodes is designated to collect the data ...
0
votes
2answers
68 views

Cannot display a chr string using Wire.read() and u8g2.drawStr()

I'm still getting myself acquainted with C++, so I expect this is a very basic issue I'm facing. I've got an OLED screen connected to a Teensy LC and can display text on it just fine. The Teensy ...
1
vote
2answers
116 views

Public variable in class not incrementing

I'm not sure what is wrong with my code, but whenever I call addNewLine, the linesInserted variable is not updating correctly. When I print the value of linesInserted inside of the addNewLine method, ...
0
votes
1answer
215 views

What is the purpose of F() and FPSTR() in ESP8266WebServer -> FSBrowser?

I found this code sample from the FSBrowser (Flash File System) example in the ESP8266WebServer library: replyServerError(FPSTR(FS_INIT_ERROR)); replyBadRequest(F("DIR ARG MISSING")); I was ...
1
vote
1answer
423 views

esp32 Stack canary watchpoint triggered

I am writing a program for esp32 on Arduino IDE. On some point of execution of code for File reading I am facing this exception, Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception) ...
3
votes
1answer
102 views

How to restart ESP32 on any exception?

While developing a lot of projects (In Arduino IDE) for ESP32 one common issue I am facing is termination of program execution on unhandled exceptions. There are various exception I get. For example: ...
0
votes
1answer
84 views

Not able to build program with arduino program under clion

I'm pretty new to arduino and I just downloaded clion and installed the arduino plugin so I have an IDE that I'm used to. Here is my code: #include <Arduino.h> // Time between a switch ...
2
votes
1answer
111 views

Code is not running, servo does not even spin

I am trying to run a program which works as follows: An LDR is integrated in a box. A block is placed on top. This box is able to be rotated by a servo. The program is supposed to make the box turn ...
1
vote
1answer
50 views

Adding zero padding to decimal values

I want to add zero before the float number like this: 010.0 The code I'm using is this: if(value < 10){ lcd.print(F("0")); } lcd.print(value); But when the value is exactly 10, it ...
1
vote
1answer
30 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 ...
0
votes
1answer
53 views

defining a macro with variables [closed]

I am working on Marlin 3D program. I made some changes for xyz prop and I do not make a definition as #define PRB_GCODE_END "G92 X-" XOFF "Y" XOFF "Z" ZOFF "\ n"...
1
vote
1answer
91 views

How do I resolve error message “assignment of function 'void digitalWrite (uint8_t, uint_8)”?

I am a beginner in using Arduino and programming in c/c++. I am trying to connect a 10-segment LED and a moisture sensor to my Arduino Uno, and when the moisture level is very low, the first 2 red ...
0
votes
0answers
112 views

How to take a CHAR change it into a int increment and then back to a Char for a clock display

So I'm using the NTP on the arduino. I'm going to only ping the NTP once a day to truth up the clock. however the rest of the time I want just to use incrementing the minute and hour via ints. I'm ...
1
vote
1answer
40 views

rfm69 on M0 Express… init() doesn't work

I have already connected succesfully the rfm69 on my Feather M0 Express... but I cannot do it again. The connections are (in the order of the rfm69): Vin -> 3V Gnd -> Gnd En -> (nothing) G0 -> 9 ...
0
votes
2answers
46 views

utf8 to hex macro

I would like to replace utf8 characters to byte values for easier character display handling. The actual replacement table comes from the lcd datasheet therefore it is not utf8 to ascii conversion. ...
2
votes
3answers
40 views

When are global constuctors executed?

Apologies if this has been discussed before but I couldn't find anything. I have written a simple LED class. For illustration (it is actually a bit more complex) but it goes something like; class LED {...
0
votes
3answers
143 views

Returning struct from function generates 'does not name a type' compilation error

I have a main.ino file that contains struct EulerAngles { double roll, pitch, yaw; }; void setup() { EulerAngles angles; angles = anglesCalc(); Serial.print(angles.yaw); } void loop() { ...
1
vote
1answer
74 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 ...
0
votes
0answers
42 views

“no matching function for call to 'SimpleDHT11::read(byte*, byte*, NULL)'” error for arduino code

My code isn't working and shows up with this error message. "no matching function for call to 'SimpleDHT11::read(byte*, byte*, NULL)'" How do i fix this? This is my complete code. #include &...
1
vote
3answers
147 views

Is it necessary to set a function with always_inline attribution when the function would work maybe once?

I'm going through a library for the ILI9488 running by SPI and want to copy this library in my version. In the beginning of the source file, there's a guard for the SPI_HAS_TRANSACTION that if the ...
2
votes
1answer
207 views

Comparing a String after reading it from Serial fails

I have bought an Arduino starter kit online, everything seem to work but when I try for example to use ifs (and other conditional statements), the LEDs do not turn on. Here is a code for a little ...
0
votes
0answers
29 views

Does anybodyknow how to program Muscle Sensors v3?

#include <Servo.h> const int x = 200 //Naming the servosServo Servo servo1; Servo servo2; Servo servo3; Servo servo4; Servo servo5; Servo servo6; void setup() { Serial.begin(9600); ...

1
2 3 4 5
20