Skip to content

Instantly share code, notes, and snippets.

@phkahler
Created October 5, 2020 22:09
Show Gist options
  • Save phkahler/1ddddb79fc57072c4269fdd6716bfb72 to your computer and use it in GitHub Desktop.
Save phkahler/1ddddb79fc57072c4269fdd6716bfb72 to your computer and use it in GitHub Desktop.
Slow smooth blink an LED
{ // do this every 1ms or two
static int16_t x;
static int16_t a;
int16_t y = 0x4000 - (((int32_t)x * x) >> 16);
a = (a & 0x0fff) + (((int32_t)y * y) >> 16);
LED_io_pin = a >> 12;
x += 35; // slow blink speed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment