You have no items in your shopping cart.

Subtotal: 0.00

How to Interface SPI-EEPROM with AVR Development Board

AVR Development Board

The AVR Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports In-system programming (ISP) which is done through Parallel/Printer port.

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

Stepper Motor

A stepper motor is a brushless, synchronous electric motor that converts digital pulses into mechanical shaft rotation. Every revolution of the stepper motor is divided into a discrete number of steps, and the motor must be sent a separate pulse for each step.

Interfacing Stepper Motor

Fig. 1 shows how to interface the Stepper Motor to microcontroller. As you can see the stepper motor is connected with Microcontroller output port pins through a ULN2803A array. So when the microcontroller is giving pulses with particular frequency to ULN2803A, the motor is rotated in clockwise or anticlockwise.

Fig. 1 Interfacing Stepper Motor to Microcontroller


Interfacing Stepper Motor with AVR Development Kit

We now want to control a stepper motor in  AVRDevelopment Board. It works by turning ON & OFF a four I/O port lines generating at a particular frequency.

The  AVRDevelopment Board has four numbers of I/O port lines, connected with I/O Port lines (PORTB.0 – PORTB.3) to rotate the stepper motor. ULN2803 is used as a driver for port I/O lines, drivers output connected to stepper motor, connector provided for external power supply if needed. Stepper Motor can connect J18 or J19 connector.

Pin Assignment with AVR Development







Connect a stepper motor with J19 or with J18

Connect PORTB with JP17 (stepper section)

Press RESET or INT0 to change the direction of stepper Motor.










Circuit Diagram to Interface Stepper Motor with AVR Development

Source Code

The Interfacing stepper motor control with AVR program is very simple and straight forward, which control the stepper motor in clockwise, counter clockwise and also a particular angular based clockwise by using switches. The I/O port lines are used to generate pulses for stepper motor rotations. C programs are written in CodeVisionAVR software.

C Program to control stepper motor using AVR


Title : Program to control stepper motor rotations


#include<mega8535.h> #include<delay.h> #define INT0 GIFR = 0x40 unsigned char i=1; void Interrupt_init(void); void main() { delay_ms(10); DDRB = 0xff; PORTB = 0x00; Interrupt_init(); while(1) { if(i==2) { PORTB=0x99; //Stepper Squence 1001,1100,0110,0011 delay_ms(5); PORTB=0xcc; delay_ms(5); PORTB=0x66; delay_ms(5); PORTB=0x33; delay_ms(5); } else { PORTB=0x33; //Sequence Data Reversed delay_ms(5); PORTB=0x66; delay_ms(5); PORTB=0xcc; delay_ms(5); PORTB=0x99; delay_ms(5); } } } void Interrupt_init(void) { DDRD = 0x00; PORTD = 0xff; MCUCR = 0x0a; MCUCSR = 0x00; GICR = 0x40; GIFR = 0x40; #asm("sei") } interrupt [EXT_INT0] void ext_int0_isr(void) { i = 2; INT0; delay_ms(1); }

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 Stepper Motor with AVR

Give +12V power supply to AVR Development Board; the Stepper Motor is connected with AVRDevelopment Board. When the program is downloading into AVR in Development Board, the LED output is working that the LED is ON some time period and the LED is OFF some other time period for a particular frequency. Now, the stepper motor is rotating.

In this code, the Stepper Motor is running in clockwise direction automatically. If you are not reading any output from LED, then you just check the jumper connections & check the LED is working.

If the stepper motor is not rotating then check the motor connections. Otherwise you just check the code with debugging mode in CodeVisionAVR.

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 the following articles,

User Manual for ATMEGA Development Kit

How to create & Debug a Project in CodeVision AVR.