Skip to content

Instantly share code, notes, and snippets.

@JoshAshby
Created February 14, 2010 17:53
Show Gist options
  • Save JoshAshby/304151 to your computer and use it in GitHub Desktop.
Save JoshAshby/304151 to your computer and use it in GitHub Desktop.
int pwm_ramp(unsigned int value, int pin, unsigned int speed)
{
if (value < pwm_value) {
if (pin == 0) {
unsigned int i;
for (i=pwm_value; i>=value; i-= speed) {
OCR1AL = i;
pwm_value = i;
}
}
} else {
if (pin == 0) {
unsigned int i;
for (i=0; i<=value; i+= speed) {
OCR1AL = i;
pwm_value = i;
}
}
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment