Table of Contents
If you want to send us your comments, please do so. Thanks
More on comments
Arduino Language Structure
Ternary operator
This can replace an if then else statement
somevariable = (condition) ? ifexpressionTrueDo : ifexpressionFalseDo;
condition is evaluated. If the result is true (not zero), then ifexpressionTrueDo is evaluated and ifexpressionFalseDo is ignored. In the other case it is the otherway arround
Example, if there is no result then use something like
(counter < 23) ? digitalWrite(LED_BUILTIN, HIGH) : digitalWrite(LED_BUILTIN, LOW) ;
else use something like
bool result = (counter < 23) ? HIGH : LOW;
result will be 1 or 0
Range based for loop
This is C++ code not found in the Arduino IDE but it works
for ( range_declaration : range_expression ) { loop_statement }
This executes a for loop over a range such as all elements in an array.
range_declaration | variable declaration (e.g. auto somevariable or int someothervariable) |
range_expression | a range like a brached-list or an array |
loop_statement | The compound sequence of instructions the for loop has to execute |
Example code
const char pins[] = {2,3,4,5,6,7,8,9}; for(setpin : pins) { pinMode(setpin, OUTPUT); }
Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy
RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.