Files
embedded-programming/LED Blink Input Output/GPIO-notes-pins.md
2026-04-06 21:25:29 +10:00

89 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Digital INPUT OUTPUT
There are three registers which initialize Digital INPUT and DIGITAL OUTPUT port:
1. DDRB
2. DDRC
3. DDRD
Each pin is 1 bit of DDRx.
Here P means Port
Example: PC → Port C
Microcontroller pins are grouped as:
1. PORTB → PB0PB7
2. PORTC → PC0PC6
3. PORTD → PD0PD7
---
## Important
- In Arduino Uno, PC7 does not exist
→ PORTC is only PC0PC6
- PB6 and PB7 are used by 16MHz crystal
→ DO NOT USE
- PC6 is RESET pin
→ DO NOT USE as GPIO
→ can reset system
→ can be used but condition is if reset is disabled.
- PD0 and PD1 are Serial pins (RX TX)
→ used for USB upload and debugging
→ DO NOT USE during development
---
## SPI (just remember)
- PB3 → MOSI
- PB4 → MISO
- PB5 → SCK
→ used for SPI and programming
→ can be used as GPIO but avoid if SPI used
→ PB5 has onboard LED
---
## I2C (just remember)
- PC4 → SDA
- PC5 → SCL
→ used for I2C communication
---
## Safe pins for Digital I/O
- PORTD → PD2PD7
- PORTB → PB0PB2 (PB3PB5 usable but SPI)
- PORTC → PC0PC5 (PC4 PC5 shared with I2C)
---
## Use with care
- PB3 PB4 PB5 → SPI pins
- PC4 PC5 → I2C pins
---
## Final
Best pins to use:
PD2PD7
PB0PB2
PC0PC5
Avoid:
PB6 PB7 → crystal
PC6 → reset
PD0 PD1 → serial