• Recent
    • Docs
    • Github
    • 百度网盘
    • Onedrive
    • Official
    • Shop
    • Register
    • Login

    Coolpi PWM

    Scheduled Pinned Locked Moved Maker
    4 Posts 2 Posters 779 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      macthree
      last edited by

      任何人都可以解释如何在 coolpi 上使用 PWM 吗?

      大法师大 1 Reply Last reply Reply Quote 0
      • 大法师大
        大法师 @macthree
        last edited by 大法师

        @macthree 有部分GPIO支持硬件PWM功能,当然也可以用GPIO模拟PWM功能。

        https://www.cool-pi.com/topic/80/coolpi-4b硬件扩展五-pwm

        jack@cool-pi.com

        M 1 Reply Last reply Reply Quote 0
        • M
          macthree @大法师
          last edited by

          @大法师

          使用 raspberry pi wiring.h 需要包含访问 PWM,如下所示.
          coolpi 需要包括什么?

          C Program

          /*
          Change the Intensity of LED using PWM on Raspberry Pi
          http://www.electronicwings.com
          */

          #include <wiringPi.h>

          #include <stdio.h>
          #include <stdlib.h>

          const int PWM_pin = 1; /* GPIO 1 as per WiringPi, GPIO18 as per BCM */

          int main (void)
          {
          int intensity ;

          if (wiringPiSetup () == -1)
          exit (1) ;

          pinMode (PWM_pin, PWM_OUTPUT) ; /* set PWM pin as output */

          while (1)
          {

          for (intensity = 0 ; intensity < 1024 ; ++intensity)
          {
            pwmWrite (PWM_pin, intensity) ;	/* provide PWM value for duty cycle */
            delay (1) ;
          }
          delay(1);
          
          for (intensity = 1023 ; intensity >= 0 ; --intensity)
          {
            pwmWrite (PWM_pin, intensity) ;
            delay (1) ;
          }
          delay(1);
          

          }
          }

          大法师大 1 Reply Last reply Reply Quote 0
          • 大法师大
            大法师 @macthree
            last edited by

            @macthree
            这是软PWM,需要重写封装WiringPi

            jack@cool-pi.com

            1 Reply Last reply Reply Quote 0
            • 大法师大 大法师 moved this topic from Hardware on
            • 1 / 1
            • First post
              Last post