Hot answers tagged

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 ...
user avatar
  • 36.2k
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 ...
user avatar
  • 36.2k
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 ...
user avatar
  • 36.2k
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 ....
user avatar
  • 14.5k
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 ...
user avatar
  • 3,913

Only top scored, non community-wiki answers of a minimum length are eligible