Why use “int” for everything ?
– use int8_t whenever your variable ranges from -127/+128 or uint8_t if ranging from 0 to 255
– ALL arduinos do strictly have a number of pins inferior to 255, so why use int where uint8_t would PERFECTLY fit ?
– use “int” for boolean ? Nonsense. You waste 7 bits. Use “bool” type for boolean (true/false) values.
There’s A LOT of memory waste in that simple example. And memory is very precious on MCU. You should really optimize your code.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.
What program was used here? Is it C#?
An open-source programming framework for microcontrollers called Arduino, based on Wiring (http://wiring.org.co/):
http://arduino.cc/en/Reference/HomePage
Best regards.
Thanks :D
Why use “int” for everything ?
– use int8_t whenever your variable ranges from -127/+128 or uint8_t if ranging from 0 to 255
– ALL arduinos do strictly have a number of pins inferior to 255, so why use int where uint8_t would PERFECTLY fit ?
– use “int” for boolean ? Nonsense. You waste 7 bits. Use “bool” type for boolean (true/false) values.
There’s A LOT of memory waste in that simple example. And memory is very precious on MCU. You should really optimize your code.
Maybe i am wrong, but i thing that bool in avr takes all 8bits
At least in C. Maybe in arduino c++ bool is 1 bit long
Smallest memory storage is 8 bits long. Boolean is 8 bits- even though it is only true or false. 0 for false, 1-254 for true.