Skip to content

Instantly share code, notes, and snippets.

View schappim's full-sized avatar
🎯
Focusing

Marcus Schappi schappim

🎯
Focusing
View GitHub Profile
@schappim
schappim / led-rgb-blink.rb
Created February 27, 2015 02:17
led-rgb-blink.rb
#!/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}`
#!/usr/bin/env ruby
# This script requires GPIO to be installed.
require 'rubygems'
require 'rpi_workshop'
button = Button.new(17) # Create a new button object on GPIO 17
loop do
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
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
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(11)
if input_state == False:
#!/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):