Monday 3 March 2014

Simple Program to interface a motor with Atmega 16/32 :

#include<avr/io.h>
#include<util/delay.h>
#include<compat/deprecated.h> /* some softwares don't run well with newer versions of operating systems. using this header file will automatically resolve conflicts that may arise due to higher versions. */

void main()
{
 DDRD = 0xff; // set D as output port
 sbi(PORTD,4); // set EN1 of motor driver
 while(1)
 {
  sbi(PORTD,2);
  cbi(PORTD,3);
  _delay_ms(1000); // syntax to give delay. (In milli seconds ofcourse).
  cbi(PORTD,2);
  sbi(PORTD,3);
  _delay_ms(1000);
 }
}



No comments:

Post a Comment

Powered by Blogger.