MaiTaiSui / boblight

Automatically exported from code.google.com/p/boblight
GNU General Public License v3.0
0 stars 0 forks source link

PWM detect for Arduino mega in boblight_arduino_pwm.pde #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
PWM pin selection can be done with following.

There are basically two types of Arduino regarding PWM pins: Arduino Mega and 
non-Mega.

They can be automatically detected by compiler based on processor type.

//on the Arduino megam, 12 pwm outputs are available, on the duemilanove there 
are 6
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  uint8_t outputs[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
#else
  uint8_t outputs[] = {3, 5, 6, 9, 10, 11};
#endif

Original issue reported on code.google.com by neuros...@gmail.com on 19 Jan 2012 at 4:59

GoogleCodeExporter commented 8 years ago
Thanks for pointing this out, but I'm already aware that this can be done.
However if a new arduino mega is released with a different microcontroller then 
this will break, it has already happened once before.
So I've decided to leave the board selection up to the user instead.

Original comment by bob.loo...@gmail.com on 19 Jan 2012 at 6:29