Workshop kit code

None of the above? Put it here! Boop!
Post Reply
gb4192
n00b
Posts: 2
Joined: Fri Nov 09, 2018 2:40 pm

Workshop kit code

Post by gb4192 » Fri Nov 09, 2018 2:51 pm

Hello,

A few months ago I purchased the YouTube Workshop kit: https://www.modmypi.com/raspberry-pi/se ... rkshop-kit and really enjoyed working with it. I did modify the code and make some progressional versions which I thought I would share here.

As this is my first post, here is the first program '3_blinky.py' from part 3 that does some alternating of the LEDs:

Code: Select all

#!/usr/bin/python

from time import sleep # import the time function from the sleep library
import RPi.GPIO as GPIO # import our GPIO library

GPIO.setmode(GPIO.BCM) # set the board numbering system to BCM

# setup our output pins
GPIO.setup(17,GPIO.OUT)
GPIO.setup(27,GPIO.OUT)

# Alternate the LED's
print "Blue on, Red off"
GPIO.output(17,GPIO.HIGH)
GPIO.output(27,GPIO.LOW)
sleep(1) # sleep for 1 second

print "Red on, Blue off"
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.HIGH)
sleep(1)

print "Blue on, Red off"
GPIO.output(17,GPIO.HIGH)
GPIO.output(27,GPIO.LOW)
sleep(1) # sleep for 1 second

print "Red on, Blue off"
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.HIGH)
sleep(1)

# Turn LEDs off
print "lights off"
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.LOW)
GPIO.cleanup() # The clean-up function will reset all the configurations made in this script.  This will stop the warnings we got from the tutorial 2.
If this post works well, then I'll post more! I've not yet added a GPLv3 license comment yet though, see 'Code license' question in the Q & A on https://www.modmypi.com/raspberry-pi/se ... rkshop-kit.

Cheers,

Gareth

gb4192
n00b
Posts: 2
Joined: Fri Nov 09, 2018 2:40 pm

Re: Workshop kit code

Post by gb4192 » Sat Nov 10, 2018 1:40 pm

This is a screen shot from Meld (an open source difference application) on Ubuntu (as running without the desktop on the Pi) showing the changes between the supplied code and 3_blinky.py above:

3_blinky_diff.png
3_blinky_diff.png (124.06 KiB) Viewed 79 times

does it help? If so when I post my other code then I'll do the same.

Post Reply