1 #define F_CPU 1000000UL // Sets up the default speed for delay.h
2 // this is the header file that tells the compiler what pins and ports, etc.
3 // are available on this chip.
6 // define what pins the LEDs are connected to.
7 // in reality, PD6 is really just '6'
10 // Some macros that make the code more readable
11 #define output_low(port,pin) port &= ~(1<<pin)
12 #define output_high(port,pin) port |= (1<<pin)
13 #define set_input(portdir,pin) portdir &= ~(1<<pin)
14 #define set_output(portdir,pin) portdir |= (1<<pin)
16 // this is just a program that 'kills time' in a calibrated method
17 void delay_ms(uint8_t ms
) {
18 uint16_t delay_count
= F_CPU
/ 17500;
22 for (i
=0; i
!= delay_count
; i
++);
28 // initialize the direction of PORTD #6 to be an output
29 set_output(DDRD
, LED
);
32 // turn on the LED for 200ms
33 output_high(PORTD
, LED
);
35 // now turn off the LED for another 200ms
36 output_low(PORTD
, LED
);
This page took 0.45636 seconds and 4 git commands to generate.