Cours:InfoS2 tdInput corrige
// Compiler: Avrgcc device: atmega328
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
int main()
{
// led PD0
DDRD|=(1<<PD0);
//colonne 3 en sortie :
DDRB |= (1<<PB2);
// colonne 3 à 0
PORTB &=~(1<<PB2);
//ligne 1 en entrée
DDRC &=~(1<<PC2);
//pull-up sur ligne 1
PORTC |= (1<<PC2);
while(1)
{
if (bit_is_clear(PINC,PC2))
{
PORTD|=(1<<PD0);
}
else
{
PORTD&=~(1<<PD0);
}
}
}