I need to modify the code in this picture so that the LED I have connected to bit 7 of PORT D blinks only when both the switches are on. I have a switch connected to bit 5 of PORT D as well. This is where the on-board LED is for my arduino. I am totally stuck. AVR C Program
1
votes
1 Answers
0
votes
I assume your led is on D.7 and switch on (active low) D.4 and D.5 (i dont know why PORT B mentioned on your code.
unsigned char x;
int main(void)
DDRD = 0b10000000;
PORTD = 0b00110000; //activate internal pull just in case
x=PIND;
x&=0b00110000; // just in case (again)
if (x&0b00110000)
{
PORTD = 0b11000000; //blinks
_delay_ms (500);
PORTD = 0b00000000; //blinks
_delay_ms (500);
}
}
if(x&0b00010000)
(pin 4 only) toif(x&0b00010000 && x&0b0010000)
(pins 4 and 5 both on). – uncleO