Skip to content

Instantly share code, notes, and snippets.

@klunkean
Last active August 29, 2015 14:21
Show Gist options
  • Save klunkean/c624561d043b6c5c98b1 to your computer and use it in GitHub Desktop.
Save klunkean/c624561d043b6c5c98b1 to your computer and use it in GitHub Desktop.
int main(void)
{
DDRA |= (1 << PIN_OUT1) | (1 << PIN_OUT2);
PORTA |= ( (1<<PIN_RPI) );
BITCLEAR(PORTA, PIN_OUT1);
unsigned int OLDSTATE = BITREAD(PINA, PIN_RPI);
uint8_t mode = 1;
while(1)
{
if(BITREAD(PINA, PIN_RPI) != OLDSTATE)
{
if(mode<6) mode++; else mode = 1;
OLDSTATE = BITREAD(PINA, PIN_RPI);
}
switch(mode)
{
case 1: pwmcycle(0,1);break;
case 2: pwmcycle(5,25);break;
case 3: pwmcycle(10,20);break;
case 4: pwmcycle(15,15);break;
case 5: pwmcycle(1,0);break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment