﻿/*
 * HsinRu1to7.c
 *
 * Created: 2015/1/18 下午 08:40:51
 *  Author: Hsin-Ru
 */ 

#include <avr/io.h>

//Define functions
//Forward Declarations
//=================================================
void ioinit(void);
void delay_ms(uint16_t x);
//=================================================



int main(void)
{
	unsigned char led;
	ioinit(	);//setup IO pins and defaults
	
	while(1)
	{
		led = 1;
		for(unsigned char i=0; i<7; i++) {
			PORTC = led;
			
			delay_ms(2000);
			
			led=led+1;
		}
	}
	return 0;
}

void ioinit(void)
{
	
	//1= output, 0 = input
	DDRB = 0b11111111;  // All pins to output
	DDRC = 0b11111111; //  All pins to output
	DDRD = 0b11111111; //  All pins except the RX on PD0 are set to high
	
}

void delay_ms(uint16_t x)
{
	uint8_t y, z;

	for (; x > 0; x--)
	{
		for(y = 0;y < 90; y++)
		{
			for(z = 0; z < 6; z++)
			{
				asm volatile ("nop");
			}
		}
		
	}
}
