Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PWM pins for PIC32 PINGUINO MICRO (with updated LedDimmer.c)
20-01-2013, 01:37 PM,
#1
PWM pins for PIC32 PINGUINO MICRO (with updated LedDimmer.c)
LedDimmer.c included in IDE is not updated for PINGUINO PIC32 MICRO, which has only D1, D2, D3 and D4 pins enabled for PWM output (IDEpin 10, 11, 12 and 13).
D1/IDEpin10 is connected to internal yellow led (LED2).

Here it is an updated sketch.

Code:
/*    ----------------------------------------------------------------------------
    Led Dimmer
    ----------------------------------------------------------------------------
    author:            Régis Blanchot
    description:    This example shows how to fade onboard LED
                    using pwm functions.
    first release:    25/02/2012
    last update:    20/01/2013 by JumpJack fo PINGUINO MICRO
    pinguino ide:    > 9.5
    ----------------------------------------------------------------------------
    wiring:            pin 0 ----- +LED- ----- 330 Ohm Resistor ----- GND
    ----------------------------------------------------------------------------
    NB:                PIC18 PINGUINO        can only use pins    D11, D12
                    PIC32 PINGUINO        can only use pins    D0, D1, D2
                    PIC32 PINGUINO OTG    can only use pins    D0, D1, D2
                    PIC32 PINGUINO 220    can only use pins    D2, D3, D11, D12, D13
       PIC32PINGUINO MICRO can only use pins D1, D2, D3 and D4
    --------------------------------------------------------------------------*/


u8 i = 0;
s8 dir;

void setup()
{
    // Frequency must be high to avoid blinking effect
    PWM.setFrequency(5000);
}

void loop()
{
    // Duty Cycle from 10% to 90% and back
    if (i > 100) dir = -1;
    if (i < 2) dir =  1;
    i = i + dir;
    // Duty Cycle is a percentage measure of the time that the LED is physically on.
    // Place here instructions for PWM-enabled LEDs (see source header):
PWM.setPercentDutyCycle(10, i);
    PWM.setPercentDutyCycle(11, i);
    PWM.setPercentDutyCycle(12, i);
    PWM.setPercentDutyCycle(13, i);
    // Delay of 50 ms
    delay(50);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)