MinnowBoard Max
  • Cover
  • Introduction
  • Getting Started
  • Hardware
    • Processor
    • Peripherals
    • Interfaces
    • PCIe
  • Customization
    • Lures
  • Build Systems
    • Yocto
  • BIOS
  • Operating Systems
  • Linux
    • Installation
    • Kernel
    • Subsystems
      • UART
      • Camera
      • Audio
      • General Purpose Input Output
      • I2C
      • Pwm
      • Serial Peripheral Interface
      • Led
    • Package Management
    • Libraries
      • MRAA
      • UPM
  • Programming Languages
    • Python
      • Calamari Lure
        • Main
        • 7 Segments
        • Buttons
        • Pulse Width Modulation
        • Red Green Blue
  • SandBox
Powered by GitBook
On this page
  1. Programming Languages
  2. Python
  3. Calamari Lure

Pulse Width Modulation

#!/usr/bin/env python

import mraa
import time

class Cpwm(object):

    def __init__(self):

        self.pwmo = mraa.Pwm(22)
        self.pwmo.period_us(70)
        self.pwmo.enable(True)

        self.pwms = mraa.Pwm(24)
        self.pwms.period_us(70)
        self.pwms.enable(True)

        self.value= 0.0

    def start(self):

        while True:
            self.pwmo.write(self.value)
            self.pwms.write(self.value)
            time.sleep(0.01)
            self.value = self.value + 0.01
            if self.value >= 2:
                self.value = 0.0
PreviousButtonsNextRed Green Blue

Last updated 7 years ago