Data types on an 8-bit chip
// WHAT YOU WILL LEARN
uint8_t holds 0–255, uint16_t 0–65535; pick the smallest that fits; 255 + 1 wraps to 0.
// LESSON NOTES
Your chip counts to 255… and then it shows 0?! 🤯
1️⃣ ONE BYTE: uint8_t is 1 byte = 8 bits. 8 bits give 2⁸ = 256 values, so it holds 0 to 255.
2️⃣ NEED MORE? uint16_t is 2 bytes (16 bits): 0 to 65,535. int8_t is signed: bit 7 is the sign, so it holds −128 to 127.
3️⃣ OVERFLOW: a = 255; a = a + 1; → 11111111 + 1 needs a 9th bit… there isn't one, so a becomes 0. For unsigned types this wrap-around is normal, defined C.
📌 The ATmega328P on your Uno has only 2 KB of RAM: pick the smallest type that fits.
TESTED CODE · ec03_data_types.c · avr-gcc
// EC L03 - sizes matter on an 8-bit chip
#include <avr/io.h>
#include <stdint.h>
volatile uint8_t a = 255; // 1 byte : 0 .. 255
volatile uint16_t b = 65535; // 2 bytes: 0 .. 65535
volatile int8_t c = -128; // 1 byte : -128 .. 127
int main(void) {
a = a + 1; // 255 + 1 wraps to 0
while (1) { }
}Read the voiceover (transcript)
- Your chip counts to two fifty-five... then zero?!
- You int eight is one byte: eight bits, zero to two fifty-five!
- Need more? Sixteen bits go up to sixty-five thousand. Signed int eight: minus one twenty-eight to one twenty-seven.
- Now add one to two fifty-five. It wraps to zero!
- Pick the smallest type that fits!
- Next: binary and hex! Follow for part four!
Related lessons
// NEWSLETTER · FREE
Get new lessons + early access to the full course
One email when new lessons drop. No spam, unsubscribe any time.
✓ You're on the list. Check your inbox to confirm.
By joining you agree to the privacy policy.




