// First test script to verify if the processor/programming is working
// brurn led 6 on port D
#include <avr/io.h>
#include <avr/delay.h>
// define what pins the LEDs are connected to.
// in reality, PD6 is really just '6'
#define LED PD6
#define output_low(port,pin) port &= ~(1<<pin)
#define output_high(port,pin) port |= (1<<pin)
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)
// wait procedure
void delay_ms(uint8_t ms)
{
uint16_t delay_count = F_CPU / 17500;
volatile uint16_t i;
while (ms != 0)
{
for (i=0; i != delay_count; i++);
ms--;
}
}
int main(void) {
// initialize the direction of PORTD #6 to be an output
set_output(DDRD, LED);
while (1)
{
// turn on the LED for 200ms
output_high(PORTD, LED);
delay_ms(200);
// now turn off the LED for another 200ms
output_low(PORTD, LED);
delay_ms(200);
// now start over
}
}