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
45 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
41 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 ...
1
vote
0answers
77 views

no match for 'operator++' (operand type is '...') [closed]

I'm getting this error, which doesn't allow me to do increment operation on enum object. This is the code: typedef enum {GLCD1, GLCD2, GLCD3, GLCD4}GLCD; GLCD glcd_switcher = 0; void setup() { // ...
2
votes
0answers
38 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
31 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
52 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
84 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
67 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
95 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
28 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 ...
2
votes
0answers
42 views

How to learn to code properly? [closed]

So, I've just started, bought the elegoo advanced starter kit, so I have different modules to work with. The kit I bought has a tutorial but doesn't teach how to program specifically, do you guys have ...
2
votes
1answer
81 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....
3
votes
2answers
100 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
76 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
46 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
64 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?
5
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
70 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
103 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
22 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
57 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
34 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
156 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&...
2
votes
0answers
30 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
0answers
30 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 ...
1
vote
2answers
60 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. ...
3
votes
1answer
133 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
206 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
37 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
22 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
117 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() { ...
0
votes
1answer
42 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
59 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 ...
2
votes
1answer
39 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[...
2
votes
0answers
50 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
166 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 ...
2
votes
1answer
38 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 ...
2
votes
2answers
88 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
33 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
471 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
51 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
88 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
33 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
1answer
67 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
103 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
24 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
64 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 ...
2
votes
2answers
969 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
2 3 4 5
20