hello,
this is simple code whose task is checking the portb.0. if the port is set, it turns on a LED connected with porta.7. otherwise it turns it off. I compiled it and it hasn't any error but I don't know why this simple code dosent work. whould s.o please tell me where is the problem?
**********************************************
#include <avr/io.h>
#include<stdio.h>
#define LED_ON() PORTA|=0x80
#define LED_OFF() PORTA&= ~0x80
int main()
{
for(; //while(1)
{
DDRB=0x00; // set the portb as input
if ((PINB&=0b00000001)==0b00000001) // if the portb.0 is set turn on the led
{
LED_ON();
}
else
{
LED_OFF();
}
}
}
this is simple code whose task is checking the portb.0. if the port is set, it turns on a LED connected with porta.7. otherwise it turns it off. I compiled it and it hasn't any error but I don't know why this simple code dosent work. whould s.o please tell me where is the problem?
**********************************************
#include <avr/io.h>
#include<stdio.h>
#define LED_ON() PORTA|=0x80
#define LED_OFF() PORTA&= ~0x80
int main()
{
for(; //while(1)
{
DDRB=0x00; // set the portb as input
if ((PINB&=0b00000001)==0b00000001) // if the portb.0 is set turn on the led
{
LED_ON();
}
else
{
LED_OFF();
}
}
}
Last edited: