🇮🇹 IT 🇬🇧 EN

⚡ START HERE · THE ONLY LESSON YOU NEED

It's not magic.
Arduino is just a wardrobe with drawers and switches.

Inside the microcontroller there are 256 drawers (registers). Each one has 8 switches (bits).Switch #5 in drawer #5 turns on the LED onboard. That's it.

🗄️ ATmega328P — I/O REGISTERS (addresses 0x00 - 0x0F) First 16 drawers
0x00 (0x20) res
-
-
-
-
-
-
-
-
0x01 (0x21) res
-
-
-
-
-
-
-
-
0x02 (0x22) res
-
-
-
-
-
-
-
-
0x03 (0x23) PINB
7
6
5
4
3
2
1
0
0x04 (0x24) DDRB
7
6
5
4
3
2
1
0
0x05 (0x25) PORTB
7
6
5
4
3
2
1
0
0x06 (0x26) PINC
-
6
5
4
3
2
1
0
0x07 (0x27) DDRC
-
6
5
4
3
2
1
0
0x08 (0x28) PORTC
-
6
5
4
3
2
1
0
0x09 (0x29) PIND
7
6
5
4
3
2
1
0
0x0A (0x2A) DDRD
7
6
5
4
3
2
1
0
0x0B (0x2B) PORTD
7
6
5
4
3
2
1
0
0x0C (0x2C) res
-
-
-
-
-
-
-
-
0x0D (0x2D) res
-
-
-
-
-
-
-
-
0x0E (0x2E) res
-
-
-
-
-
-
-
-
0x0F (0x2F) res
-
-
-
-
-
-
-
-

There are 256 drawers. Here only the first 16. Our drawer 0x05 (PORTB) is highlighted. Memory addresses (0x20-0x2F) in parentheses.

📦 Drawer 0x05 · PORTB
address 0x05 (0x25)

Inside this drawer there are 8 switches. Switch number 5 is connected to the LED on the board.

7
6
5
D13 · LED
4
3
2
1
0
LED on board (D13):
Off
sbi 5,5 ; turn on switch 5 of drawer 5 → LED ON cbi 5,5 ; turn off switch 5 of drawer 5 → LED OFF

📌 This is not magic. It's just opening and closing a switch.

⚡ You understood the atom of Arduino.

Most people use pinMode and digitalWrite without knowing they're just opening and closing a switch in a drawer.

Now you know that:

This is the whole truth. Everything else is just different ways to say the same thing.

⚡ Try it now with a real Arduino

2 euro. One USB cable. Go to costycnc.it/avr1, write sbi 5,5, compile, upload. The LED turns on. Then cbi 5,5 and it turns off. You just modified the chip's "DNA".