Python Forum
Seemingly unstable GPIO output while executing from RetroPie
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Seemingly unstable GPIO output while executing from RetroPie
#6
My guess is you have to wait for the current duty cycle to complete. This should work to bring the light up and leave it on.
import RPi.GPIO as GPIO
from time import sleep
 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
 
# Using PWM ramp power from 0 to 100% 
pwm=GPIO.PWM(11,100)
pwm.start(0)
for x in range(100): 
    pwm.ChangeDutyCycle(x)
    sleep(0.01)
pwm.stop()
sleep(0.01)  # Wait length of 1 duty cycle
GPIO.output(11, GPIO.HIGH)
When I was looking at the rpi stuff I remember reading the default PWM frequency is 1000Hz. I don't know why the examples set it at 100Hz.
Reply


Messages In This Thread
RE: Seemingly unstable GPIO output while executing from RetroPie - by deanhystad - Feb-18-2021, 11:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why does VS want to install seemingly unrelated products? db042190 3 694 Jun-12-2023, 02:47 PM
Last Post: deanhystad
  function return boolean based on GPIO pin reading caslor 2 1,230 Feb-04-2023, 12:30 PM
Last Post: caslor
  class Update input (Gpio pin raspberry pi) caslor 2 847 Jan-30-2023, 08:05 PM
Last Post: caslor
  Webhook, post_data, GPIO partial changes DigitalID 2 1,038 Nov-10-2022, 09:50 PM
Last Post: deanhystad
  Pexpect timesout before executing whole output eagerissac 0 1,539 Jun-23-2021, 03:30 AM
Last Post: eagerissac
  Seemingly simple loop Weber585 7 3,570 Mar-21-2021, 07:19 PM
Last Post: jefsummers
  Picture changing triggered by GPIO q_nerk 2 2,622 Dec-14-2020, 03:32 PM
Last Post: DeaD_EyE
  GPIO high if network IP has good ping duckredbeard 3 2,392 Oct-12-2020, 10:41 PM
Last Post: bowlofred
  raspberry pi tank gpio help jatgm1 1 2,446 May-06-2020, 09:00 PM
Last Post: Larz60+
  Where should I place GPIO.cleanup() shallanq 2 2,214 Apr-11-2020, 05:02 AM
Last Post: shallanq

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020