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
166 views

Cannot compile F() macro with R"string"

I am trying to compile the following code: logger.log_info(F(R"(some text here that may take multiple lines and here it is done.)")); But the compiler exists with the following ...
1
vote
0answers
30 views

Multi-array number generation

This part of my project is very hard for my brain to wrap around and comprehend. But basically I just need to go through every combination. For example: If I have an array with 255 variables and I ...
1
vote
1answer
188 views

What can I do to optimise this code?

I have optimised it as much as I feel I can and want to know what suggestions you have that could make it more efficient etc. Note: I know the array goes on forever :) volatile uint16_t IRCode[]={340,...
3
votes
1answer
1k views

Using EEPROM to write a counter value

I have made a program that increments a counter everytime the up button is pressed. I am trying to write this value to EEPROM, so that when I turn my board off and on again, the value before power off ...
0
votes
1answer
144 views

How can I use IRsend with a string or convert a char from serial to uint32_t?

I'm trying to control my arduino with a raspberry pi with python instead of C++ (which I don't know). I've found code to take a string from serial and print it, but instead I'd like to use IRsend to ...
2
votes
1answer
36 views

if(val == 0) being ignored when it contains another nested if() statement

The issue: In the following example even though complexManoeuvre == 3, Serial.print(CTA5: "); ... is executed. void loop() { if(complexManoeuvre == 0) { if(timeisup == true && ...
1
vote
0answers
28 views

Uno Wifi Rev2 - sending program via WIFI [duplicate]

My new Uno wifi rev2 just arrived and I have one problem. At the beggining I connected my board via USB and tested with example blink program from WifiNiNA and It worked fine. When program is runned ...
2
votes
2answers
1k views

Firmata: how to set a particular pin to high on boot?

I'm working on a project that use J5, so is using the standard firmata, this project is using an opto 4 channel relay, when the board is booting the pins state are set to low, so as soon as I power ...
0
votes
1answer
609 views

Arduino serial communication input string checking

I am trying to check whether the input string in my serial is inside my string array, but it seems like that the condition if(array[i]==inputString) does not print true. So here is my code: String ...
0
votes
2answers
1k views

Error message - help needed

As many of you know (if you read my bio or simply read my previous questions), I'm trying to build a rocket. The code was going well, but once I split my objects into 2 files, a .h and .cpp file, this ...
2
votes
1answer
634 views

How to send information from a web-site to the arduino?

I currently have an Arduino Mega + an Arduino Ethernet shield, I would like to know if it's possible to send data to the arduino from a web-site hosted on the shield itself. So that when someone press ...
1
vote
1answer
69 views

Value keeps incrementing even though loop has terminated, why?

I use a double called delta and use that to turn off an LCD if delta is larger than the timeout threshold. Once that happens, delta is supposed to set to 0 and then other parts of the program run. ...
1
vote
2answers
8k views

STM8 Development Board with Arduino IDE

I got one of these cheap STM8 boards from China and was hoping to find a way to use this with arduino code. Does anyone know of an arduino boot loader and board package that works with them ?
0
votes
1answer
144 views

How to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables?

I am using NeoPixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setup function (because they will initialize with certain variables only made ...
1
vote
0answers
52 views

Can't send Twilio SMS using Nodemcu esp8266

I am using Twilio for sending SMS in my project. I am measuring temperatures and if the temperature is too high, an SMS is sent. In my code I also have a read and a push to Firebase Realtime Database. ...
1
vote
1answer
128 views

cant read json data esp 32 “parseObject() failed”

hello I am just trying to make Youtube Subscribe Counter with led matrix 32*8 and esp 32 and I had this problem when I trying to get subscribers to count so what is the problem and how I can fix it? `...
1
vote
1answer
46 views

L293D motor shield

I have the L293D motor shield on top of my Arduino UNO. The L293D has a servo attached of 5 volt and a motor of 12 volt there is an external power supply. If I remove the jumper of the board and power ...
1
vote
1answer
254 views

How do i improve this Code? (or how to pass a Char String into a Function to behave like a Variable)

Sorry i am a beginner and amateur when it comes to coding, can somebody help me to make the code inside the loop() less "monkey-like" by using a proper function? I have tried a lot and at ...
1
vote
0answers
43 views

unexpected output

I wrote some arduino code but since I don't have access to an arduino, ran it on a tinkercad circuit, the code is supposed to set all the buttons values to 1 and all the password values to 0 and the ...
1
vote
1answer
803 views

How do I use lambda functions in Arduino?

I want to pass a lambda function as an argument to a method. Example: T reduce(const T initial, const std::function<T(T, T)> acc) { T value = initial; for (size_t i = 0; i < S; ++i) { ...
4
votes
1answer
217 views

why is "if" slow?

I am new to the Arduino world and I hope I can find a solution here. The code below functionally works ok. The problem I have is, at line 45 I've inserted an if statement to change dac_value. It is ...
0
votes
1answer
131 views

Arduino + Codeblocks C++

I'm writing the code for my Arduino board using Code::Blocks editor. When I create a new project, there is AVR Project and Arduino Project under Projects category. Which one do I select?
0
votes
1answer
718 views

I get an error saying, "exit status 1 expected initializer before 'void'."

I will be wiring a switch to the Arduino that controls the voltage. When the I turn the switch it can adjust the voltage from 0 to 5. The overall task is to print the output voltage. The print is to ...
8
votes
3answers
21k views

How can I program an arduino in pure C?

I am a beginner and I want to learn AVR C/C++. Can I do this using an Arduino? (I'm asking this because I already have one). If so, could someone tell me using which IDE can I write code in pure C/C+...
1
vote
2answers
203 views

How to toggle LED and motor on button press?

we want to have a LED turn on with the press of a button, and become brigther and brighter as times go by (whithin a defined time frame), and when it reaches maximum brightness to turn off for a ...
0
votes
1answer
158 views

Class member variable would not update

Code would not update variable inside drive method. The variable is updated inside the drive method, but it doesn't change in the rest of the class. I wrote a simple similar method in normal C++ and ...
3
votes
1answer
382 views

What is the logic behind Arduino inlining `HardwareSerial::_rx_complete_irq()` for receiving serial data (but NOT `_tx_udr_empty_irq()`)?

Q: What is the logic behind Arduino inlining HardwareSerial::_rx_complete_irq() for receiving serial data (but NOT _tx_udr_empty_irq()), and when is it advisable? From the bottom of the HardwareSerial ...
0
votes
3answers
253 views

What's the most direct way to assign Serial.read() bytes to an array?

I'm trying to send NMEA 0183 sentences through LoRa. Every dinstict NMEA message looks like several char arrays (sentences) followed by '\n'. In the below picture we see one NMEA distinct message: ...
0
votes
1answer
153 views

Best strategy to parse 5 byte arrays to find a pattern

Ok here it goes, my first ever question posted to stackexchange! Please be gentle on me! I am using an Arduino UNO (at the moment, will move to a faster micro later - but still use an Arduino sketch) ...
0
votes
1answer
285 views

Animation of led strip with ESP32 does not work when WiFi is in use

I am using the ESP32 for a simple project. I know how to animate an led strip using atmega328p with arduino but when I animate it on the ESP32 it does not work that great. It will be nice if I can use ...
0
votes
1answer
597 views

ESP32 send data to another ESP32 without establishing a wifi connection

Originally I was creating a project consisting of the Atmega328P and NRF24L01 to create multiple arduinos that could talk to each other. Basically I was creating something like this: As the network ...
1
vote
0answers
202 views

Using NRF24L01 as transmitter and receiver (transceiver)

I am using the NRF24L01 module to communicate between multiple Arduinos. For this example I will have a master transmiter (tx) Arduino and a salve receiver (rx) Arduino to illustrative better my ...
1
vote
0answers
45 views

Arduino SD card module failure

I am recieving SD card failuer and I did everything I could. I use the correct SPI pins; CS > 10 MOSI > 11 MISO > 12 SCK > 13 VCC > 5v GND > GND I did format my SD card to FAT32 I ...
0
votes
1answer
27 views

DS2413 One Wire IC read and store the addresses of individual IC's

Hy, Here I using 10 DS2413 to control gpios, it works very well with arduino ,I read the 10 ic address and store it in a 2D array, I want to control the individual IC using their address .Here all ...
1
vote
1answer
59 views

More effecient datalogging code

Background: I am using a Teensy 3.6 to data log over a dozen sensors. I am printing to Serial1 for local Serial access, Serial3 for remote access (via xbee, same data is on Serial1 as on Serail3, just ...
0
votes
1answer
403 views

ARDUINO expected ';' before 'delay' [duplicate]

I want to shine LED in 64 of 255 duty cycles = level of brightness but it pops up this error (see picture). Can anybody tell me why and help me ? Thank you. void setup() { // put your setup code ...
1
vote
1answer
291 views

Code for 2 ultrasonic sensors

This is my code: int trigPin=13; //Sensor Trig pin connected to Arduino pin 13 int echoPin=11; //Sensor Echo pin connected to Arduino pin 11 float pingTime; //time for ping to travel from sensor to ...
0
votes
0answers
45 views

Integrating blinking light code and time on/off code

I'm trying to integrate code from one of my projects with another. One is code that blinks some Adafruit Neopixel LED strips at a specific rate and the other is a time on/off circuit here is the code ...
0
votes
1answer
113 views

Weird RTC DS3231 Output only when saving the dates to variables

I am sorry to ask this question as I think it has more to do with my mediocre C++ programming skill than with the arduino. I do have a project where I want to use an RTC DS2131. I started out by using ...
0
votes
1answer
83 views

Use callbacks in Arduino with pointers to functions (will functions persist in memory?)

As I been learning Arduino (micro controllers, c++, etc) I have learned that memory is very limited. I already understand how memory works when it comes to variables. But I do not understand how ...
2
votes
7answers
16k views

Better cycling through the RGB colors

I have been trying to achieve a way to tap into the 16 million colors RGB provides for this LED strip. I thought of using LEDS.setBrightness(); but I have not been successful in my attempts. I have ...
1
vote
2answers
498 views

What exactly does the return type do in a function?

something I've never understood and still don't is, what does the return type do specifically? Everyone in tutorials just say that void returns nothing and int returns int, etc. But what does that ...
-2
votes
1answer
74 views

Question About The Error In This Code

Could someone point out what exactly I'm screwing up here and provide a specific solution. Here's the error message: Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno" sketch_jul24g:38:11: ...
0
votes
2answers
1k views

Receive an array of characters using SIM900 module

I tried to receive an array of characters using SIM900, but I couldn't. I can receive just one character like 'G', but I want to receive a string "abcd". When I used char* to save the SMS, I failed. ...
1
vote
2answers
55 views

Serial port usage in code

I want to write a function that defines a serial port based on a flag but I'm not sure it's possible. For example: void writeToSerial(bool useSerial1) { SerialPortClass serialPortObject; // Is ...
1
vote
1answer
229 views

Is it required to delete variables before going to sleep?

This tutorial shows how to put the arduino to sleep and use a watchdog to wake up at intervals: https://youtu.be/urLSDi7SD8M I been studding c++ and as I am getting better I am instantiating objects ...
0
votes
1answer
656 views

How can I assign the value of a char array to a uint8_t array?

I have a char array variable that has a value. I need to send this value through LoRa. The library I use for the LoRa implementation accepts an array of uint8_t. How can I pass the value of a char[] ...
90
votes
22answers
18k views

What are the other IDEs for Arduino?

The basic Arduino IDE lacks a lot of the sophistication present in other IDEs such as code completion, code collapsing, folder organisation, etc. Are there other IDEs that allow programming in C or C++...
1
vote
1answer
365 views

Controlling keyboard LEDs with USB Host Shield

I've got a USB keyboard connected to my Arduino Uno with a USB Host Shield. I'm reading keystrokes using this example from the USB Host Shield library. I need to toggle the LEDs in the keyboard (that ...
-3
votes
1answer
557 views

Any limitation on array size in Arduino Mega 2560?

I am writing an Arduino code with 3 arrays. Two of those are double and other one is int. Further first two arrays have nearly 420 elements for each. Now I noticed that with more that 89 elements on ...

1 2 3
4
5
20