SHUBHAM AGIWAL
Newbie level 4
hey friends i am trying to interface an ir sensor wih atmega 32 which gives a ttl output such that when an obsatcle is detected it glow the led. but sadly the led glows all the time. i want it to glow only when the obstacle is detected.
here is the code
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRA=0xf0;// PA0 is the input
// PA7 is the led pin
while(1)
{
if(PINA & 0b00000001)
{
PORTA=0x80;
_delay_ms(10);
PORTA=0x00;
_delay_ms(10);
}
}
}
here is the code
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRA=0xf0;// PA0 is the input
// PA7 is the led pin
while(1)
{
if(PINA & 0b00000001)
{
PORTA=0x80;
_delay_ms(10);
PORTA=0x00;
_delay_ms(10);
}
}
}