Example #1
0
void main()
{
	uint8_t brightness=0;

	//Initialize PWM Channel 0
	InitPWM();

	//Do this forever
	while(1)
	{
		//Now Loop with increasing brightness

		for(brightness=0;brightness<255;brightness++)
		{
			//Now Set The Brighness using PWM
			SetPWMOutput(brightness);

			//Now Wait For Some Time
			Wait();
		}

		//Now Loop with decreasing brightness

		for(brightness=255;brightness>0;brightness--)
		{
			//Now Set The Brighness using PWM
			SetPWMOutput(brightness);
	
			//Now Wait For Some Time
			Wait();
		}
	}
}
int main(void)
{
   unsigned char brightness = 0;
  
   //Initialize PWM Channel 0
   InitPWM();
  
   //Do this forever
   while(1)
   {
      // Loop through with increasing brightness
      for(brightness = 0; brightness < MAX_GLOW; brightness++)
      {
         // Set the brightness using by setting duty cycle of PWM Output
         SetPWMOutput(brightness);

         //Now Wait For Some Time
         Wait(255);         
      }
  
      // Loop through with decreasing brightness
      for(brightness = MAX_GLOW; brightness > 0; brightness--)
      {
         // Set The Brighness using PWM
         SetPWMOutput(brightness);

         // Wait For some time
         Wait(255);
      }
   }
}
Example #3
0
File: PWM.c Project: xkyve/avr_pong
int main()
{
   //Initialize PWM Channel 0
   InitPWM();
   SetPWMOutput(128);

   //Do this forever

   while(1)
   {
   }

   return 0;
}
Example #4
0
int main()
{
	DDRD |= (1 << PORTD6);
	uint16_t flexi;
	uint16_t analogValue;

	Init_Uart();
	initPWM();
	initADC();

	printString("***Transmission begin***\n\r");

	while(1)
	{

		 analogValue = ReadACD(0);

		 printString("Analog is: ");
		 delay_ms(500);
		 serialPrintDec(analogValue);
		 printString("\n\r ");
		 delay_ms(500);

		 flexi = ((analogValue * 0.1759530792)-121);// 860-690

		 if(flexi < 1)
		 {
			 SetPWMOutput(0);
		 }
		 if(flexi >= 1 &&  flexi < 15)
		 {
			 SetPWMOutput(150);
			 delay_ms(2000);
			 SetPWMOutput(0);
			 delay_ms(1000);
		 }

		 if(flexi >= 15 &&  flexi < 30)
		 {

			 SetPWMOutput(120);
			 delay_ms(2000);
			 SetPWMOutput(0);
			 delay_ms(1000);
		 }

		 if(flexi >= 30)
		 {

			 SetPWMOutput(240);
			 delay_ms(2000);
			 SetPWMOutput(0);
			 delay_ms(1000);
		}

		 printString("Flexi is: ");
		 delay_ms(500);
		 serialPrintDec(flexi);
		 printString("\n\r ");
		 delay_ms(500);
	}
}