I have a few questions, which it would be great if anybody could answer:
1. Could anybody point me to a place, where I can find a program written in C, where if you press a button, a led lights up?
I need it, so I can see it and compare it to how we make it in the Arduino IDE.
I am especially looking for how to declare a pin as INPUT, and how to check if it's high or low.
So this tutorial would be perfect for it.
2. I already found out that to set a pin as OUTPUT, we have to do it like this:
DDRE |= ((1 << DDE4));
But didn't quite understand why shifting a bit, and doing an OR operation, can set the pin as OUTPUT.
Also, to set a pin to LOW, we do _SFR_BYTE(sfr) &= ~_BV(bit) and _SFR_BYTE(sfr) |= _BV(bit) for high. This is more clear to me.
_BV shifts the bit, then we do an AND or OR operation.
3. And also, what's the difference between DDRB and PORTB? I noticed that both can be placed as sfr arguments (in the above operations), and both have the same result.