LED INTERFACING WITH ATMEGA 16
.................................................................................................................................
BIT WISE OPERATION: set 0v or 5 volt to microcontroller individually .
.................................................................................................................................
LED INTERFACE METHOD
|
|------------------------------ | ------------------------------|
| |
SET BY DIRECT PORT VALUE USE BITWISE OPERATION
...................................................................................................................................
1. SET BY DIRECT PORT VALUE
1. SET BY DIRECT PORT VALUE
....................................................................................................................................
#define FOSC 8000000UL //DEFINE CLOCK FREQ.
#include<avr/io.h> // INCLUDE YOUR AVR DEVICE FILES
#include<util/delay.h> // INCLUDE DELAYS HEADER FILE
void main (void) // MAIN PROGRAM STARTS HERE
{
DDRB=0XFF; // SET DIRECTION OF PORTB AS AN O/P
PORTD=0X00; // CLEAR ALL PINB OR SET 0 VOLT TO ALL PIN OF PORTB
while (1) // INFINITE LOOP
{
PORTB=0XFF; // SET ALL PINB AS 5 VOLT
_delay_ms(100); // DELAY FOR DISPLAY ITS ON
PORTB=0X00; // SET ALL PINB TO 0 VOLT
_delay_ms(100); // DELAY FOR DISPLAY ITS ON
}
}
.................................................................................................................................
BIT WISE OPERATION: set 0v or 5 volt to microcontroller individually .
.................................................................................................................................
#define FOSC 8000000UL
#include<avr/io.h>
#include<util/delay.h>
#include <stdlib.h>
#define LED_INTRFACING_PORT PORTB
#define LED_INTRFACING_PORT_dir DDRB
#define LED0 0
#define LED1 1
void main (void)
{
LED_INTRFACING_PORT_dir|=(1<<LED0)|(1<<LED1);
while (1)
{
LED_INTRFACING_PORT |=(1<<LED0); //set pin b0 to 5volt
LED_INTRFACING_PORT &=~(1<<LED1); //set pinb1 0volt
_delay_ms(100);
LED_INTRFACING_PORT |=(1<<LED1); / /set pinb1 5volt
LED_INTRFACING_PORT &=~(1<<LED0); //set pinb0 0volt
_delay_ms(100);
}
}
#include<avr/io.h>
#include<util/delay.h>
#include <stdlib.h>
#define LED_INTRFACING_PORT PORTB
#define LED_INTRFACING_PORT_dir DDRB
#define LED0 0
#define LED1 1
void main (void)
{
LED_INTRFACING_PORT_dir|=(1<<LED0)|(1<<LED1);
while (1)
{
LED_INTRFACING_PORT |=(1<<LED0); //set pin b0 to 5volt
LED_INTRFACING_PORT &=~(1<<LED1); //set pinb1 0volt
_delay_ms(100);
LED_INTRFACING_PORT |=(1<<LED1); / /set pinb1 5volt
LED_INTRFACING_PORT &=~(1<<LED0); //set pinb0 0volt
_delay_ms(100);
}
}
No comments:
Post a Comment