Étape 5: Programmer le contrôleur
Le code du projet est vraiment très petit. Code compilé avec AVRGCC. Le code a été programmé dans le contrôleur via le connecteur ISP sur le contrôleur de PCB./ * Code pour un projet de bougie vacillante * /
/ * Brancher une LED blanche 1-W jaune/chaude sur * /
/ * Broche 2 - PB3 <--50 ohms R--> LED Cathode * /
/ * Broche 3 - PB4 <--50 ohms R--> LED Cathode * /
/ * Broche 5 - PB0 <--50 ohms R--> LED Cathode * /
/ * Broche 6 - PB1 <--50 ohms R--> LED Cathode * /
/ * Broche 7 - PB2 <--50 ohms R--> LED Cathode * /
/ * LED Anode à SCR
/ * Valeur courant max 30 mA pour chaque LED * /
/ * LFSR Source : http://en.wikipedia.org/wiki/Linear_feedback_shift_register * /
#include < avr/io.h >
#include < avr/delay.h >
main()
{
unsigned long lfsr = 1 ;
temp d’unsigned char ;
DDRB = 255 ;
for(;;)
{
LFSR = (lfsr >> 1) (-(lfsr & 1u) & 0xd0000001u); / * robinets 32 31 29 1 * /
Temp = (unsigned char) lfsr ;
DDRB = ~ temp ;
PORTB = temp ;
Temp = (unsigned char) (lfsr >> 24) ;
_delay_loop_2 (temp << 7) ;
}
}