Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: DAC pin for analogWrite? (led strip PWM, running out of pins)

  1. #1

    DAC pin for analogWrite? (led strip PWM, running out of pins)

    Hi,

    I'm running out of pins on my current design and was wondering if it's possible to use pin 26 on a teensy LC (the DAC pin) to dim an led strip through a n-chanel mosfet? (IRLB8721)

    Can I do analogWrite(26, value)?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,184

    Cool

    Quote Originally Posted by lucasparis View Post
    Hi,

    I'm running out of pins on my current design and was wondering if it's possible to use pin 26 on a teensy LC (the DAC pin) to dim an led strip through a n-chanel mosfet? (IRLB8721)

    Can I do analogWrite(26, value)?
    Unlike the other pins, analogWrite to the DAC pin (26 on the LC) does NOT do a pwm output (i.e. turning the pin on/off rapidly to get the appearance of dimming a LED strip.

    Instead it does a true analog write, and varies the voltage from 0 to <n> volts (<n> is usually 3.3v). This is useful for producing sounds through a mono speaker with amplification. You also can't do a normal digitalWrite to the pin.

  3. #3
    Quote Originally Posted by lucasparis View Post
    Hi,

    I'm running out of pins on my current design and was wondering if it's possible to use pin 26 on a teensy LC (the DAC pin) to dim an led strip through a n-chanel mosfet? (IRLB8721)

    Can I do analogWrite(26, value)?
    Yes. See: https://www.pjrc.com/teensy/teensyLC.html

    Also, DAC analogWrite sample on page: https://www.pjrc.com/teensy/teensy31.html

    But the 3.1/3.2 pin for DAC is A14, when for LC it is A12 (which is a #define for pin 26).

    Ah, read Michaels message. The DAC is true analog indeed, with a single directly connected LED it wouldn't be a problem, but with a FET or some other driver it might. Still, nothing should broke if you'll just try if it works. The FET may get hot, though.
    Last edited by Pazi; 05-05-2017 at 07:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •