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 twython import Twython | |
| from picamera import PiCamera | |
| from time import sleep | |
| from datetime import datetime | |
| from gpiozero import Button, MotionSensor | |
| from auth import ( | |
| consumer_key, | |
| consumer_secret, | |
| access_token, | |
| access_token_secret |
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 gpiozero import Motor, OutputDevice | |
| from time import sleep | |
| motor1 = Motor(24, 27) | |
| motor1_enable = OutputDevice(5, initial_value=1) | |
| motor2 = Motor(6, 22) | |
| motor2_enable = OutputDevice(17, initial_value=1) | |
| motor3 = Motor(23, 16) | |
| motor3_enable = OutputDevice(12, initial_value=1) | |
| motor4 = Motor(13, 18) |
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 picamera import PiCamera | |
| from gpiozero import MCP3008 | |
| def scaled(a): | |
| return int(100 * a.value) | |
| camera = PiCamera() | |
| brightness = MCP3008(0) | |
| contrast = MCP3008(1) |
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
| sudo su | |
| apt-get install apache2 php5 libapache2-mod-php5 mysql-server php5-mysql -y | |
| a2enmod rewrite | |
| cd /var/www/html/ | |
| wget http://wordpress.org/latest.tar.gz | |
| tar xzf latest.tar.gz | |
| mv wordpress/* . | |
| rm -rf wordpress latest.tar.gz | |
| chown -R www-data: . |
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 requests | |
| from time import sleep | |
| url = "https://petition.parliament.uk/petitions/241584.json" | |
| def get_count(): | |
| count = None | |
| while True: | |
| r = requests.get(url) | |
| if r: |
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 gpiozero import Button, LED | |
| from signal import pause | |
| led = LED(25) | |
| button = Button(14) | |
| button.when_pressed = led.toggle | |
| pause() |
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 picamera import PiCamera | |
| from gpiozero import Button | |
| from snapchat_functions import * | |
| from time import sleep | |
| output = '/home/pi/photo.jpg' | |
| overlay = 'flowers' | |
| camera = PiCamera() | |
| left = Button(20) |
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
| n = 1.0 # start at n=1 | |
| i = 0 # counter | |
| while n > 0: | |
| i += 1 # increment counter | |
| n /= 2 # half n on every iteration | |
| print(i) # will this line ever be reached? if so, what will it print? |
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 gpiozero import MCP3008 | |
| import os | |
| class MusicPot(MCP3008): | |
| def send_to_pd(self): | |
| os.system("echo '{} {};' | pdsend 3000;".format( | |
| self._channel, self.value) | |
| ) | |
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 gpiozero import LineSensor, Robot | |
| robot = Robot(left=(9, 10), right=(7, 8)) | |
| line = LineSensor(25) | |
| speed = 0.6 | |
| while True: | |
| robot.forward(speed) | |
| line.wait_for_no_line() |