Skip to content

Pulse Width Modulation

Tushar Semwal edited this page Oct 18, 2017 · 4 revisions
  1. digitalWriteByte(+T,_): This function writes the 8-bit byte supplied to the first 8 GPIO pins.It takes two write operations to the Pi’s GPIO hardware.
    • t: An integer value (max 255) that will be converted to 8-bit integer and written to GPIO pins 0 (lower bits) to 7 (higher bits). **Note: As a second arguement, an underscore '_' is provided.
  2. pwmSetMode(+T): The PWM generator can run in 2 modes – “balanced” and “mark:space”.
    • T: 0 for "balanced" mode and 1 for "mark:space" mode.
  3. pwmSetRange(T): This function sets the range register in the PWM generator. The default value is 1024.
    • T: Integer value for the range.
  4. pwmSetClock(+T): This function sets the divisor for the PWM clock.
    • T: Integer value for the clock.
  5. piBoardRev(-T): This function returns the board revision of the Raspberry Pi. It will be either 1 or 2. Some of the BCM_GPIO pins changed number and function when moving from board revision 1 to 2, so if you are using BCM_GPIO pin numbers, then you need to be aware of the differences.
    • T: Returns either 1 or 2.
  6. wpiPinToGpio(+Pin,-T): This function returns the BCM_GPIO pin number of the supplied wiringPi pin. It takes the board revision into account.
    • Pin: wiringPi pin number.
    • T: Value of the BCM_GPIO pin number is returned in this variable.
  7. physPinToGpio(+Pin,-T): This function returns the BCM_GPIO pin number of the supplied physical pin on the P1 connector.
    • Pin: wiringPi pin number.
    • T: Value of the physical pin number is returned in this variable.
Clone this wiki locally