arduino_code_efficiency
Table of Contents
If you want to send us your comments, please do so. Thanks
More on comments
Code efficiency
Declaring strings
It does not matter for the size of the code is const is put in front of
- char variable[ ]= “Text”;
- String variable = “Text”;
or not
Boolean Constants
true and false
HIGH and LOW
bool test = false; pinmode (7, INPUT_PULLUP); // Define pen 7 as an input with a pullup so when not connected it is a HIGH if ( test ) { // is the same as if ( test == 1 ) { // is the same as if ( test == true) { // This is the preferred syntax if ( digitalRead(7) ) { // is the same as if ( digitalRead(7) == 1 ) { // is the same as if ( digitalRead(7) == HIGH ) { // This is the preferred syntax if ( !test ) { // is the same as if ( test == 0 ) { // is the same as if ( test == false) { // This is the preferred syntax if ( !digitalRead(7) ) { // is the same as if ( digitalRead(7) == 0 ) { // is the same as if ( digitalRead(7) == LOW ) { // This is the preferred syntax
Toggle
test = !test // Test becomes the opposite of itself. From true to false or from flase to true. // This is the same as test = test ^ 1 // XOR. This is the same as test ^= test // XOR. This is the preferred method. It saves 4 bytes in the executable
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.
arduino_code_efficiency.txt · Last modified: 18-06-2020 01:01 by wim