Questions tagged [cpp]
22 questions
5
votes
1 answer
Delay() and millis() functions don't work in cpp external files
I'm currently facing an issue using delay() and millis() functions in an external cpp file.
The issue is that when I used delay() in my main program (meaning .ino file) it works well but when I call the same function in an external cpp file, I'm…
Cyril_Ram
- 53
- 2
2
votes
1 answer
How to use PWM with DRV8870?
I'm using Arduino nano and I'm struggling working with the DRV8870 IC on PWM mode.
When I use analogWrite(_pin, duty_cycle); the motor makes weird noises.
I thought it's because of the PWM frequency so I tried to change it using
TCCR1B = TCCR1B &…
KD Technology
- 41
- 1
1
vote
2 answers
Error compiling ESP32 Wrover Module in Linux Virtual Machine
SO i have been getting this error window when i compile a simple code to run different LED lights on the ESP32-S2-SOLA (Wrovere) module
Code:
int LED_BUILTIN = 2;
void setup() {
pinMode (LED_BUILTIN, OUTPUT);
}
void loop() {
…
AsmAsmAsm
- 21
- 2
1
vote
4 answers
Is there anything wrong with this code
Hi I'm pretty new to cpp.
Could someone review my code and explain any pitfalls or problems?
Below is the code and an example to read from a flow meter with a hall sensor.
Thanks in advance.
Greg
/** example
#include "flow.h"
Flow f(3);
…
Yardie
- 23
- 5
1
vote
2 answers
Nothing received from function returning array of strings
My read function returns an array of strings. i.e ssid and password
String* configuration::read() {
String rw_ssid = "";
String rw_pswd = "";
const int keys = 2;
String read_ssid_pswd [keys];
if (EEPROM.read(0) != 0) {
for…
Ciasto piekarz
- 575
- 2
- 12
- 28
1
vote
1 answer
Update class attribute with attachInterrupt
I want to refactor this code
/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int l_hour; //…
Valanthor
- 11
- 2
1
vote
1 answer
Using SoftwareSerial.h in .cpp file
I am trying to modularize the different components in my arduino build by using objects, but am having trouble with the one controlling a wireless transceiver, which uses SoftwareSerial.h
I believe I am (generally) setting up the use of these…
Snappawapa
- 159
- 8
1
vote
3 answers
Guideline in library creation
According to this example, creation of an Arduino library is quite understandable.
But a few things I would like ask (mostly regarding to what to be defined where) when a library is not that simple:
Where to put additional libraries (such as…
guyd
- 898
- 1
- 13
- 39
1
vote
1 answer
getting error 'Serial' was not declared in this scope
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the dust sensor codebase to separate library so I…
Ciasto piekarz
- 575
- 2
- 12
- 28
0
votes
0 answers
How to get the scan duration below 1sec with ArduinoBLE?
I want to scan continuously for other Bluetooth devices with my ESP32 using BLE. The scan method only accepts integers larger than 0, such as scan->start(1, false). However I want the results to be more "responsive" and a 1 second scanning duration…
Philipp
- 101
- 1
0
votes
1 answer
CPP Function param use function with multi params
I want to specify a function with parameters for a function parameter, but it doesn't come together.
////////////////////////////////////////////////////////////////////////
// Example funch...
void fileLoad(String path, String type) {
file =…
CloverField
- 11
- 3
0
votes
1 answer
Can't change pins in AM2320 code, types mismatch
I took a simple A2320 temperature sensor and connected it not to A4/A5, but to A1/A0 pins. SDA => A1, SCL => A0. (In C code they are number 15 and 14). But I can't call the library to take these pins.
The basic example from the library uses the…
user70125
0
votes
1 answer
String array length in function
I know this question has been asked a thousand times, but I can't find a solution for my case.
I what to get the length of a string array in a given function. This is for an arduino board.
#define LEN(x) sizeof(x)/sizeof(x[0])
const char* mainMenu[]…
will.mendil
- 145
- 1
- 6
0
votes
1 answer
what is causing my esp8266 setup function to reinitialise?
Here is code I have written:
#include
#include
#define MAX_WIFI_INIT_RETRY 50
#define WIFI_RETRY_DELAY 500
const char* wifi_ssid = "ssid";
const char* wifi_passwd = "password";
ESP8266WebServer…
Ciasto piekarz
- 575
- 2
- 12
- 28
0
votes
1 answer
Getting error invalid conversion from 'const char*' to 'const uint8_t*
I have written this sketch, and I am trying to populate the array of wifi hotspots to set the value in html select using javascript dynamically.
#include
#include
#include "ESP8266WiFi.h"
#include
#include…
Ciasto piekarz
- 575
- 2
- 12
- 28