New answers tagged

0

What works for me #include <SD.h> //Load SD card library #include<SPI.h> //Load SPI Library void loop() { Serial.print(tempSensor3); //Open existing file on SD card named PTData.txt mySensorData = SD.open("PTData.txt", FILE_WRITE); if (mySensorData) { mySensorData.print(tempSensor3); mySensorData.close(); /...


1

There is absolutely no need to use String (for anything, generally...). Instead you can either (if you have it) use std::stoi() or use strtol() on the c_str of the string. ledcWrite(ledChannel, std::stoi(sliderValue) * (10.24)); Or ledcWrite(ledChannel, strtol(sliderValue.c_str(), NULL, 10) * (10.24)); The former just converts into the latter anyway.


12

The Arduino "language" is nothing more than a set of C++ functions and classes. It does not mandate any particular C++ standard. The standard is dictated purely by the compiler that the core you are using happens to support (and is configured to use through command line flags). Different cores use different compilers. Different versions of the same ...


0

I got very similar error when I forgot to declare all the variables in the "class.cpp". The "class.h" had a declaration "class XYZ { byte test; };", but in the "class.cpp" I forgot to write "byte XYZ::test;".


0

You can't set array sizes using const int. You can with constexpr int: constexpr auto size{ 15 }; int array[size]{}; You can't use const int as case statement labels (though this does work in some compilers) Again, you can with constexpr int: constexpr auto zero{ 0 }; constexpr auto one{ 1 }; int number{ 1 }; switch (number) { case zero: Serial.println(&...


0

Although your code is formatted horribly, it does appear to be mostly correct. I also recommend making your pin numbers "const int". This tells the compiler that they cannot be changed. Otherwise you could change those values in your code accidentally. You also have un-initialized variables. Best practice would be to declare and initialise them at ...


1

If you only need two PWM pins, I suggest using hardware PWM with Timer 1. The Timer 1 library makes the process quite easy. It supports frequencies from 0.12 Hz up to a few MHz, although the resolution degrades above 7.8 kHz. Compared to an interrupt-based solution, hardware PWM has less jitter and it does not consume CPU cycles. The drawback is that you ...


0

You can try to use my AVR_Slow_PWM Library, which can provide these following features and generate 2 independent PWM signals to any GPIO pin. Certainly only if your hardware design can correctly use PWM signals. This library enables you to use ISR-based PWM channels on AVR-based boards, such as Mega-2560, UNO,Nano, Leonardo, etc., using AVR core to create ...


Top 50 recent answers are included