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

	controlled.c
 	Z-World, 2002

	This program is used with BL2500 series controllers
	with demo boards.
	
	Description
	===========
	This program uses costatements to vary the voltage output of
	DA0 and DA1 using pwmOut() and pwmOutVolts() functions.
		
	Connections
	===========
	Controller			Demo-board
	-----------			----------
	DA0  (J1-4)	<--->	LED1
	DA1  (J1-5)	<--->	LED2
	GND  (J1-9)	<--->	GND
	+3.3 (J1-1)	<--->	+K
	
	Instructions
	============
	1. Compile and run this program.
	2. LED1 and LED2 will vary in intensity as the outputs of
		DA0 and DA1 vary.
	
*******************************************************************/
#class auto

#define DA0 0
#define DA1 1


main()
{
	auto int count;
	auto float volt;

	
	brdInit();		//initializes PWM

	while (1)
	{
		costate		//DA0 varies by changing the count cycle
		{
			for (count=512; count>=0; count-=100)
			{
				pwmOut(DA0, count);					//led intensity increases
				waitfor(DelayMs(100));	
			}
			
			for (count=0; count<=512; count+=100)
			{
				pwmOut(DA0, count);					//led intensity decreases
				waitfor(DelayMs(100));	
			}
		}
		
		costate		//DA1 varies by changing the voltage
		{
			for (volt=0.0; volt<=1.5; volt+=0.1)
			{
				pwmOutVolts(DA1, volt);					//led intensity decreases
				waitfor(DelayMs(100));	
			}
			
			for (volt=1.5; volt>=0.0; volt-=0.1)
			{
				pwmOutVolts(DA1, volt);					//led intensity increases
				waitfor(DelayMs(100));	
			}
		}
	}
}
