Project 1 - Controlling a DC motor using PWM and monitoring its Running status
Q 1
The DC motor can be controlled by using L293 motor driver.
- The speed of a DC motor can be controlled by varying its input voltage, for doing this is to use PWM (Pulse Width Modulation).
- L293D IC is a typical Motor Driver IC which allows the DC motor to drive on any direction.
SOLUCTION:
#include <avr/io.h>
#include <time.h>
#include "avr/interrupt.h"
#define F_CPU 16000000
#include <util/delay.h>
int main(void)
{
int a=0;
DDRB=0XFF;
DDRC=0XFF;
PORTD=(1<<3)|(1<<2);
sei();
GICR=(1<<7)|(1<<6);
while (1)
{
PORTB=(1<<2);
a++;
_delay_ms(1000);
if (a==10)
{
cli();
}
}
}
ISR(INT0_vect)
{
PORTC=(1<<3);
}
ISR(INT1_vect)
{
PORTC&=~(1<<3);
}

#include<avr/io.h>
#include<time.h>
#include 'avr/interrupt.h'
#define F_CPU
#INCLUDE<util/delay.h>
int main (void)
{
int a=0;
DDRB=OXFF;
DDRC=OXFF;
PORTD=(1<<34)|91,2);
sei();
GICR=(1,,7)|(1<<6);
While(1)
{
PORTB=(1<<2);
a++;
_delay_ms(1000);
if(a==10)
{
cli();
}
}
}

THE-END