TCS Pune

AVR: Bare-Metal Port Control

Practical lesson

AVR: Bare-Metal Port Control

Control ATmega pins directly without the Arduino framework.

◷ 45 min

Parts and tools

  • ATmega328P board
  • AVR programmer
  • LED and resistor

Lesson

Learning objective

Control ATmega pins directly without the Arduino framework.

Procedure

  1. Review the circuit and confirm the board voltage.
  2. Build and inspect the wiring before applying power.
  3. Upload the example, observe the result and record your readings.
  4. Change one parameter, predict the result and test again.

Troubleshooting

Check power, ground, pin selection, polarity, compiler target and serial output. Use a multimeter or logic analyser where appropriate.

Example code

#include <avr/io.h>
int main(void){ DDRB|=(1<<DDB5); PORTB|=(1<<PORTB5); while(1){} }

Knowledge check

Which register controls Port B direction?

Ready when you are

Need help with your laptop or computer?

Send us the model and fault details. Start your repair request online or contact TCS Pune directly.

WA