Skip to content

Instantly share code, notes, and snippets.

@afestein
Forked from boseji/sqr_1ch_1k_50p.py
Created April 18, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afestein/853fb67a9e9223e4b0a01aeb122af51f to your computer and use it in GitHub Desktop.
Save afestein/853fb67a9e9223e4b0a01aeb122af51f to your computer and use it in GitHub Desktop.
Python code for Raspberry Pi to generate a square wave of 50% duty cycle on GPIO7 pin 26 of P1 with 1kHz frequency
#!/usr/bin/python
#######
# This program would generate PWM on GPIO 7 Pin 26 of P1
# with 50% Dutycyle at 1kHz
#######
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(7,GPIO.OUT)
p=GPIO.PWM(7,1190)
p.start(50.0)
raw_input("Press Enter key to Stop 1kHz PWM @ 50% duty cycle")
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment