-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I am trying to relearn the use of AVR's after far to long of not using
them. And I am struggling to get something incredibly simple working.
Whats more, I can't seem to find any useful documentation on it.
Put simply, I want to use the input from switch to toggle an LED.
I have an Atmega168.
There is an LED attached to PC4 and a switch between PD0 and +5v.
I then have:
/* set PC4 to output */
DDRC |= (1<<DDC4);
/* set PD0 to input and enable pullups */
DDRD = (0<<DDC0);
PORTD = 0x00;
while(1)
{
uint8_t x;
x = PIND;
if( x != 0)
{
/* Toggle PC4 */
PORTC ^= (1<<PC4);
}
}
The code compiles fine. It just doesn't seem to do something. I am sure
I have missed something really simple. I just can't find a good example
of someone reading a single input pin. I did find a few examples of
using 8 inputs, but even they they didn't help much.
Thanks in advance.
J
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFHfrld42M0lILkmGIRAtQaAKDANqgiH2RU6hyDKrbByLZPyosZFgCgqyWj
nM1+wD6xlTg1dduGoA4qxEk=
=tpIn
-----END PGP SIGNATURE-----
_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat