This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'pi_piper' | |
| red_pin = PiPiper::Pin.new(:pin => 17, :direction => :out) | |
| green_pin = PiPiper::Pin.new(:pin => 27, :direction => :out) | |
| blue_pin = PiPiper::Pin.new(:pin => 22, :direction => :out) | |
| loop do | |
| red_pin.on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' # Tells ruby that we want to be able to import libraries from Rubygems | |
| require 'pi_piper' # This gem allows us to control our Raspberry PI GPIO Ports. | |
| # Tell Ruby that we want to create a new variable called 'red_pin' | |
| # ':pin => 17' tells Ruby that the pin is on GPIO 17 | |
| # ':direction' tells the system that we want to make the pin an output | |
| red_pin = PiPiper::Pin.new(:pin => 17, :direction => :out) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' # Tells ruby that we want to be able to import libraries from Rubygems | |
| require 'pi_piper' # This gem allows us to control our Raspberry PI GPIO Ports. | |
| # Tell Ruby that we want to create a new variable called 'red_pin' | |
| # ':pin => 17' tells Ruby that the pin is on GPIO 17 | |
| # ':direction' tells the system that we want to make the pin an output | |
| red_pin = PiPiper::Pin.new(:pin => 17, :direction => :out) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| loop do | |
| (0..1024).step(64) do |level| | |
| `sudo gpio pwm 1 #{level}` | |
| sleep 0.01 | |
| end | |
| (0..1024).step(64).reverse_each do |level| | |
| `sudo gpio pwm 1 #{level}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from smbus import SMBus | |
| import time | |
| # Code based on http://ciaduck.blogspot.com.au/2014/12/mpl3115a2-sensor-with-raspberry-pi.html | |
| # Special Chars | |
| deg = u'\N{DEGREE SIGN}' | |
| # I2C Constants | |
| ADDR = 0x60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RPi.GPIO as GPIO | |
| import time | |
| # blinking function | |
| def blink(pin): | |
| GPIO.output(pin,GPIO.HIGH) | |
| time.sleep(1) | |
| GPIO.output(pin,GPIO.LOW) | |
| time.sleep(1) | |
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RPi.GPIO as GPIO | |
| from time import sleep | |
| GPIO.setmode(GPIO.BOARD) # Select a numbering scheme for the board (BOARD or BCM) | |
| GPIO.setup(12, GPIO.OUT) # Tell the Pi to set pin 12 as an output | |
| red_led = GPIO.PWM(12, 100) # Tell the Pi that we want to use PWM on Pin 12 | |
| red_led.start(100) # Start the Red LED at 100% brightness |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import time | |
| import os | |
| import RPi.GPIO as GPIO | |
| GPIO.setmode(GPIO.BCM) | |
| DEBUG = 1 | |
| # read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7) | |
| def readadc(adcnum, clockpin, mosipin, misopin, cspin): |