# Pin declaration byte/int

**URL:** <https://forum.arduino.cc/t/pin-declaration-byte-int/1053620>\
**Category:** Programming\
**Created:** [November 14, 2022, 9:36pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620 "2022-11-14T21:36:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DvdLagemaat](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dvdlagemaat/32/1013044_2.png) [@DvdLagemaat](https://forum.arduino.cc/u/DvdLagemaat)\
**Post date:** [November 14, 2022, 9:36pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/1 "2022-11-14T21:36:22Z")

</div>

In examples is see:  
const int ledPin = 13; and  
const byte ledPin = 13;  
What best to use?

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 14, 2022, 9:39pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/2 "2022-11-14T21:39:00Z")

</div>

a second

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [November 14, 2022, 9:39pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/3 "2022-11-14T21:39:21Z")

</div>

const byte ledPin = 13;

---

<div class="post-metadata">

**Author:** ![woolsey](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/woolsey/32/238912_2.png) [@woolsey](https://forum.arduino.cc/u/woolsey)\
**Post date:** [November 14, 2022, 9:40pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/4 "2022-11-14T21:40:58Z")

</div>

The use of "byte" is not recommended any more and is planned to be phased out in the future.  
"int" works, but uses more storage than a "byte". You can get the same effect of using "byte" by using "uint8\_t" instead, which is an 8-bit unsigned integer.

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 14, 2022, 9:42pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/5 "2022-11-14T21:42:48Z")

</div>

> [@woolsey](#):
>
> The use of "byte" is not recommended any more and is planned to be phased out in the future.

If it will occurred in the future you can always define the byte with typedef with uint8\_t.  
So I still use byte type

---

<div class="post-metadata">

**Author:** ![DvdLagemaat](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dvdlagemaat/32/1013044_2.png) [@DvdLagemaat](https://forum.arduino.cc/u/DvdLagemaat)\
**Post date:** [November 14, 2022, 10:10pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/6 "2022-11-14T22:10:26Z")

</div>

Tx for the advise

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [November 14, 2022, 10:36pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/7 "2022-11-14T22:36:21Z")

</div>

Regarding memory - Most of the time it won’t matter as long as you use const in the definition  
The optimizer will get rid of the variable and patch it’s value directly where it’s needed in assembly code.

If you use arrays then the story might be different depending on how you use the index

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 13, 2023, 10:37pm UTC](https://forum.arduino.cc/t/pin-declaration-byte-int/1053620/8 "2023-05-13T22:37:02Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
