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
-3
votes
0answers
31 views

C++ Compile Error [closed]

#include<bits/stdc++.h> using namespace std; class MyConverter { private: string type; string dimension; double value; string unit; public: MyConverter() { value = 0; type = "SI"; } ...
-2
votes
1answer
56 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
97 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
21 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 ...
0
votes
1answer
54 views

Understanding the meaning of '[](){ /* Code */ }' in an argument

I have this piece of code from a library and im trying to understand the 3rd argument, I've searched google to the best of my abilities and could not find any tutorials or references in in the C/C++ ...
1
vote
0answers
48 views

Need help with my codes? for my Project: Filling and Capping using Arduino uno [closed]

HERE'S MY CODE I have a problem for my codes. Please help #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); #define IRS1 7 #define IRS2 8 #define ...
1
vote
1answer
50 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 ...
1
vote
0answers
20 views

Let Servo rotate when file has been uploaded to webpage

I'm building an installation with a NODEMCU 1.0 where I want a servo motor (MG90S) to rotate when a file has been uploaded to a webpage. For my first step I have used this tutorial: Build an ESP8266 ...
0
votes
2answers
31 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
77 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
28 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. ...
0
votes
0answers
28 views

Connect two UNO WIFI REV2 to communicate with one another through WIFI [duplicate]

I have two UNO WIFI REV2. I want the first Arduino to send a message to the other to print "hello, world" on the LCD screen of the second Arduino. Is this possible without WiFi modules? If ...
0
votes
2answers
46 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
86 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'...
0
votes
0answers
56 views

Arduino serial comm writing data in win32 program

I am passing in a data buffer from Arduino Uno to a C++ win32 program, but UNO is sending data too slowly. I am trying to send 128 character bytes but the win32 is receiving the bytes after like 92 ...
1
vote
2answers
203 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
35 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
21 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
101 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
165 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
votes
2answers
54 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
32 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
52 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
32 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
58 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
35 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
47 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
votes
1answer
71 views

Arduino simulator - generating sine wave from PWD (Oscilloscope read is rectangular)

trying to create this simple circuit where a rectangular voltage input is transferred to a sine wave output. the process is quite simple, but I couldn't see the actual sine wave when connecting an ...
1
vote
1answer
37 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
83 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
30 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
287 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 ...
1
vote
0answers
33 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
53 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
31 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 ...
1
vote
0answers
33 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
52 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
81 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
22 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
53 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
621 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
81 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
31 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
29 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() { ...
1
vote
0answers
40 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
96 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
122 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
421 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
941 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) ...

1
2 3 4 5
20