Hi
Spent some time without resolving problem with 'If-else if' constructs when programming a simple current sensor application and Hitachi display (early stages of development). The first code (part) works effectively - accurately displaying sensed currents correctly in milli Amps if sensed current is <0.5 and in Amps for sensed currents > 0.5A . However, in the second example current is not displayed (display blanked) despite measured current being in the 'Boolean True' range >=0.5A and <=1A. I have checked forum and other Internet sources and cant resolve the problem; the syntax seems correct and the variable being tested is a 'real' type. As a beginner programmer to C++ is there an obvious error in my code? I am using an Arduino Nano processor.
Thanks in anticipation
Hi
Thanks for your comment. Yes, suppose code readability - indentations hangover from VB / VBA days. Note your auto format advice. Ampersands in Print commands used to concatenate display text and variables. So would display:
"Current: 500mA" say, on same display row.
Checked in circuit load current with ammeter and within test parameters. Used 'Serial monitor' - code not shown to monitor converted ADC values, again within test parameters.
Re string / variable concatenation in C++, is there an alternative approach that I am not aware of when sending text strings and variables to a display? When used in this way they do work. Serial Monitor is the debugging tool part of the Arduino IDE - s orry misleading here.
Regards
Mike
Re string / variable concatenation in C++, is there an alternative approach that I am not aware of when sending text strings and variables to a display?
Why do you need to concatenate anything?
When used in this way they do work.
They would also work, and make it look like you knew what you were doing, as: