CART
  • Cart is empty.

    ItemQuantityPrice

    Total: $0

LED's on TB-1


Controls LED's on TB-1 peripheral board

Toolkit:AVR Development System

Location:/bipom/devtools/WinAVR/minimaxavrc/Examples/Labs/tb1led

Code Example


#define	YELLOW_LED_PIN			PB4
#define	YELLOW_LED_DIR			DDRB
#define YELLOW_LED_W_PORT 		PORTB
#define YELLOW_LED_R_PORT 		PINB

#define	GREEN_LED_PIN			PB5
#define	GREEN_LED_DIR			DDRB
#define GREEN_LED_W_PORT 		PORTB
#define GREEN_LED_R_PORT 		PINB

#define	RED_LED_PIN				PB6
#define	RED_LED_DIR				DDRB
#define RED_LED_W_PORT 			PORTB
#define RED_LED_R_PORT 			PINB

#define LED_PORT				PORTB

#define	LED_ON(led)				(LED_PORT  &=~_BV(led)) 
#define	LED_OFF(led)			(LED_PORT |=_BV(led)) 

#define LED_DELAY		100

// ****************************************************************************

int main (void)
{

	// Allow Power Up peripheral devices 

 	_delay_ms(500);
 	
	/* UART */
	uart1Init(19200);		// Initialize uart0

	
	/* Send messages to terminal window */
	uart1Printf("\n\rBIPOM MINI-MAX/AVR");
	uart1Printf("\n\rTB-1 LEDs TEST EXAMPLE");
	uart1Printf("\n\rVERSION: 1.01");
	uart1Printf("\n\r");
	 	
	// Configure LED outputs

	RED_LED_DIR |= _BV(RED_LED_PIN);
	YELLOW_LED_DIR |= _BV(YELLOW_LED_PIN);
	GREEN_LED_DIR |= _BV(GREEN_LED_PIN);
	
	// Switch all LED's OFF

	LED_OFF(RED_LED_PIN);
	LED_OFF(YELLOW_LED_PIN);
	LED_OFF(GREEN_LED_PIN);
	
	// LED test

	for(;;)
	{
		LED_ON(RED_LED_PIN);
		_delay_ms(LED_DELAY);
		LED_OFF(RED_LED_PIN);
		_delay_ms(LED_DELAY);
		LED_ON(YELLOW_LED_PIN);
		_delay_ms(LED_DELAY);
		LED_OFF(YELLOW_LED_PIN);
		_delay_ms(LED_DELAY);

		LED_ON(GREEN_LED_PIN);
		_delay_ms(LED_DELAY);
		LED_OFF(GREEN_LED_PIN);
		_delay_ms(LED_DELAY);
	}
	
	return 0;	
}