#!/usr/bin/env python # -*- coding: utf-8 -*- # This program is copyright (c) 2016, P. Lutus and is released # under the GPL (http://www.gnu.org/licenses/gpl-3.0.en.html). import sys, math, time, signal import RPi.GPIO as G G.setmode(G.BCM) G.setwarnings(False) # scope synchronization output pin sync_pin = 5 # pulse-width modulated output pin io_pin = 6 G.setup(io_pin,G.OUT) G.setup(sync_pin,G.OUT) # waveform frequency f = 440 count = 0 size = 8 mod = size+1 invsize = 1.0/size twopi = 2 * math.pi try: while True: a = time.time() * twopi * f ss = math.sin(a) * 0.5 comp = (count % mod) * invsize - 0.5 G.output(io_pin,ss >= comp) G.output(sync_pin,ss >= 0) count += 1 except: G.cleanup() print('So long for now.')