4
votes
Accepted
How to convert a reading to percentage in Arduino
You wrote:
return (reading - 54)/(100/920);
In C++, 100/920 is zero. This is because, when both operands are
integers, the division operator performs an integer division. You can
overcome this ...
2
votes
Accepted
How to do 'for' loop over inline anonymous array
I'm trying to enrich my C++ skills & be fancy
The Arduino Mega is probably not the right platform to learn fancy C++.
The development environment doesn't support all the modern C++ stuff. In
...
1
vote
Accepted
Create member object using constructor arguments, or pass reference to object via constructor
When you define
HD44780LCD lcd;
at global scope, you are creating a global variable that is initialized
before main() is called. In this case, it is initialized with the
default constructor ...
1
vote
Where should unit tests go in the Arduino IDE
One way to do it is to use preprocessor conditionals. Name your project file and unit-test files with .cpp extensions and put them in a subfolder (called "sources" in my example). Then your ....
1
vote
How to do 'for' loop over inline anonymous array
Edgar Bonet answers why for (int pin : {DIP5, DIP4, DIP3, DIP2, DIP1, DIP0}) { isn't working. What you would get (where supported) with this syntax is an initializer_list which itself is not an array ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
c++ × 1011arduino-uno × 277
programming × 200
arduino-ide × 118
c × 81
serial × 70
arduino-mega × 65
library × 48
esp8266 × 46
array × 41
class × 40
string × 39
led × 37
sensors × 34
arduino-nano × 28
esp32 × 25
interrupt × 24
pointer × 21
sketch × 20
variables × 18
servo × 17
compile × 17
memory-usage × 17
i2c × 16
lcd × 16