this tutorial will show you small demonstration about bit-wise manipulation.we are working on atmega32 operated at 1MHZ frequency. 8 parallel leds are connected to PORTB of controller.
Proteus design
code
after setting PORTB as output port. single bit of variable 'a' and 'b' is shifted by one to right and left respectively with delay of one second. the process being repeated up-to 4 cycle (within a for loop) then restarted again each time.
complete code
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0XFF; //output port
while(1)
{
int a,b;
a=0b10000000;
b=0b00000001;
for(int i=0;i<4;i++)// led converge
{
PORTB=a+b;
_delay_ms(1000);
a=a>>1;
b=b<<1;
}
}}
VIDEO
Category: