How to Interface Digital-Inputs with AVR Slicker

Interfacing Digital-Inputs with AVR Slicker

Tags: Interfacing DigitalInputs primer, Interfacing digitalInputs with AVR, C Program to switch functions using AVR, Circuit Diagram to Interface Switch with AVR, Interfacing switches with atmega8/16,
Overall rating
AVR Slicker Board

AVR Slicker Board

ATMEL’s AVR (Atmega8535), AVR Slicker Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.


A switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another. A switch may be directly manipulated by a human as a control signal to a system, or to control power flow in a circuit.

Interfacing Digital-Inputs

Fig. 1 shows how to interface the switch to microcontroller. A simple switch has an open state and closed state. However, a microcontroller needs to see a definite high or low voltage level at a digital input. A switch requires a pull-up or pull-down resistor to produce a definite high or low voltage when it is open or closed. A resistor placed between a digital input and the supply voltage is called a "pull-up" resistor because it normally pulls the pin's voltage up to the supply.


Fig. 1 Interfacing switch to Microcontroller

Interfacing digital-Inputs with AVR Slicker

We now want to control the LED by using switches (Digital-Inputs) in AVR Slicker Board. It works by turning ON a LED & then turning it OFF when switch is going to LOW or HIGH respectively.

The AVR Slicker board has eight numbers of point LEDs, connected with I/O Port lines (PORTA.0 – PORTA.7) to make port pins high. Eight switches, connected with I/O port lines PORTB are used to control eight LEDs.

Pin Assignment with AVR





Connect PORTA with J7 (Digi-Input) via FRC Cable

Connect PORTB with J8 (LED section) via FRC cable


Turn ON and OFF the DIP switch

SW6 pins to see the changes in LED’s

LEDs are turned ON while the DIP pins are turned ON

If Pull UP/DOWN switch J6 is pressed, LEDs will be turned OFF while the DIP pins turned ON


















Circuit Diagram to Interface Switch with AVR Slicker


Source Code

The Interfacing switch with AVR Slicker Board is very simple and straight forward, that controls led by using switches when it going LOW or HIGH.

C Program to switch functions using AVR


Title : Program to Blink LEDs controlling by switches



#include <mega8535.h>

#include <DELAY.h>


void main()


      DDRB = 0xFF;              //PORTA input

      PORTB= 0x00;

      DDRA = 0x00;              //PORTB output

      PORTA= 0xff;



                PORTB=PINA;            // LEDs turned  OFF while the

                               // DIP pins turned ON

                delay_ms(50);          // LEDs turned  ON while the DIP  

                               // pins turned OFF




To compile the above C code you need the CodeVision AVR software. The software has it’s own IDE and built-in AVR gcc- Compiler. They must be properly installed and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In CodeVision AVR software, you can develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The AVR Code Blaster software is used to download the hex file into your microcontroller through Parallel port.

Testing the Digital-Inputs with AVR Slicker

Give +12V power supply to AVR Slicker Board; the switches are connected with the AVR Slicker Board. Check the LED’s & switches are working or not.

If you are not reading any output signal in LED, then you just check the jumper connections. Otherwise you just check the code with debugging mode in Mplab.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.
  • More instructions are available in following articles,
       -  User Manual of AVR Slicker Board.
       -  How to create & Debug a Project in CodeVision AVR.
       -  Interfacing LED with AVR.

Join the World's Largest Technical Community

we respect your privacy.