Hello! Below I posted some c code. I am currently using WinAVR and writing my Arduino code in the C programming language. I have a question that is probably a basic answer that I seem to be missing or not understanding. Basically if I deploy my code with one line it works but with an alternative line it doesnt work and it would seem both should work so I am curious as to what is wrong with this line of code for detecting a low on the input:
!(PORTB & (1<<PINB0))
This line however for detecting a low on the input works fine:
bit_is_clear(PINB,PINB0)
Below is my complete project:
#include <avr/io.h>
#include <avr/delay.h>
int main(void)
{
DDRB = (1<<PINB5);
PORTB = (1<<PINB0);
while(1)
{
if(bit_is_clear(PINB,PINB0))
{
PORTB |= (1<<PINB5);
}
else
{
PORTB &= ~(1<<PINB5);
}
}
}