Add PWM pin-outs for Mayfly for optional LED exercises
aufdenkampe opened this issue · 0 comments
From an email dialog:
Question:
I'm working through the programming training I went through the optional LED portions, since I already had all the parts. The RGB LED section uses PWM and I Googled to figure out which Mayfly pins had PWM, but I didn't understand the difference between the sets of PWM pins. Conceptually I get the difference between the 8 and 16 bit, but why are there separate timers. It worked by using D6, 7, and 11, but I don't know if I just got lucky.
Answer:
That's awesome that you got the optional LED portion of the LearnEnviroDIY tutorial working with the Mayfly.
Off the top of my head, I don't know which pins on the Mayfly work with PWM (since none of the sensors I use operate with PWM). Our original version of the tutorial required an Arduino Uno for episodes 1-2. Adding PWM pin info for the Mayfly would be a good request for an update to the tutorial, here: https://github.com/EnviroDIY/LearnEnviroDIY/issues (feel free to add other suggestions too!).Since you got it to work, rather than finding the answer, I'll point you to how I would look.
- Basic pin info on the Mayfly: https://github.com/EnviroDIY/EnviroDIY_Mayfly_Logger#pin-out
- Detailed pin info on the Mayfly, via it's schematic, showing the pin mapping to the Atmega1284P MCU that it uses: https://github.com/EnviroDIY/EnviroDIY_Mayfly_Logger/blob/master/hardware/mayfly_v0p5b_schematic.png
- Atmega1284P datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega164A_PA-324A_PA-644A_PA-1284_P_Data-Sheet-40002070B.pdf
- These are a bear to dig through, but from what I can tell any of the pins labeled "OCnx" (such as OC1A, OC1B, OSCA, etc.) can use PWM. From the Mayfly schematic, this correspond to D4-D7 and D11-12. Two other OCnx pins on the 1284P chip are used for other functions on the Mayfly and are not available to the user.