Skip to content

Instantly share code, notes, and snippets.

@holachek
Created August 10, 2012 03:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save holachek/3310645 to your computer and use it in GitHub Desktop.
Save holachek/3310645 to your computer and use it in GitHub Desktop.
Convenient Arduino-like pin macros
// super awesome Arduino-like pin macros save you from having to remember bitmasks
// code from Matthew T. Pandina's Demystifying the TLC5940 tutorial:
// URL: https://sites.google.com/site/artcfox/demystifying-the-tlc5940
#define setOutput(ddr, pin) ((ddr) |= (1<< (pin)))
#define setLow(port, pin) ((port) &= ~(1 << (pin)))
#define setHigh(port, pin) ((port) |= (1 << (pin)))
#define outputState(port, pin) ((port) & (1 << (pin)))
#define pulse(port, pin) do { \
setHigh((port), (pin)); \
setLow((port), (pin)); \
} while (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment