This article will use one digital input pin (PortA pin 3) to readout state of push-button connected to it. Pull-up resistor must be connected to this pin to differentiate voltage on pin when push-button is pressed and when it is released. In short period of time when push-button is pressed, voltage on input pin connected to is very noisy and this can make problems. This is shown on picture on left side. Microcontroller would interpret this as multiple push-button pressing and releasing. To eliminate this we use debouncing.
You cannot imagine to use microcontroller without using any of its i/o pins. Finally its all about : taking input , processing it and generating output ! Thus i/o registers and their correct settings is indispensable part while learning to program any uC.
We will learn how to use AVR ports and actually ‘code’ for writing/reading data to/from port pins. It is slightly confusing for beginners, however once you understand it, you will certainly appreciate the way it is designed.
Here is example that is complete project with step by step guide that will show you how to use GPIO pins on ATmega8535.
When you start program use CodeWizardAVR to generate basic program structure.
In our case we used ATmega8535 so we will choose that modem from Chip tab in wizard window.
For frequency chose correct frequency that is used (external xtal, calibrated internal RC oscillator..).