-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
__author__ = 'Wojciech' | ||
import RPi.GPIO as GPIO | ||
import time | ||
GPIO.setmode(GPIO.BCM) | ||
|
||
GPIO.setup(18, GPIO.OUT) | ||
|
||
GPIO.output(18,1) | ||
time.sleep(.1) | ||
GPIO.output(18,0) | ||
time.sleep(.1) | ||
GPIO.output(18,1) | ||
time.sleep(.1) | ||
GPIO.output(18,0) | ||
time.sleep(.1) | ||
GPIO.output(18,1) | ||
time.sleep(.1) | ||
GPIO.output(18,0) | ||
|
||
GPIO.cleanup() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
__author__ = 'Wojciech' | ||
import RPi.GPIO as GPIO | ||
import time | ||
GPIO.setmode(GPIO.BCM) | ||
|
||
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||
GPIO.setup(18,GPIO.OUT) | ||
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||
|
||
def button_pushed(channel): | ||
GPIO.output(18,1) | ||
|
||
def button_released(channel): | ||
GPIO.output(18,0) | ||
|
||
GPIO.add_event_detect(21, GPIO.RISING, callback=button_pushed, bouncetime=300) | ||
GPIO.add_event_detect(16, GPIO.FALLING, callback=button_released, bouncetime=300) | ||
|
||
time.sleep(10) | ||
GPIO.cleanup() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
__author__ = 'Wojciech' | ||
import RPi.GPIO as GPIO | ||
|
||
GPIO.setmode(GPIO.BCM) | ||
|
||
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | ||
|
||
while True: | ||
if(GPIO.input(16) == 1): | ||
print("Button pressed") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import time | ||
import os | ||
import RPi.GPIO as GPIO | ||
GPIO.setmode(GPIO.BCM) | ||
|
||
GPIO.setwarnings(False) | ||
|
||
GPIO.setup(17, GPIO.OUT) | ||
GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) | ||
|
||
is_high = False | ||
|
||
try: | ||
while True: | ||
if(GPIO.input(16) == True): | ||
print("Button pressed") | ||
os.system('date') | ||
print(GPIO.input(16)) | ||
if(is_high): | ||
GPIO.output(17,GPIO.LOW) | ||
is_high=False | ||
else: | ||
GPIO.output(17,GPIO.HIGH) | ||
is_high=True | ||
time.sleep(1) | ||
|
||
else: | ||
os.system('clear') | ||
print("Waiting for you to press a button") | ||
except KeyboardInterrupt: | ||
GPIO.cleanup() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
sudo python $@ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import RPi.GPIO as GPIO | ||
import time, math | ||
|
||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(27, GPIO.OUT) | ||
GPIO.setup(18, GPIO.OUT) | ||
GPIO.setup(17, GPIO.OUT) | ||
|
||
r_int = 100 | ||
g_int = 100 | ||
b_int = 100 | ||
|
||
r = GPIO.PWM(27, 60) | ||
g = GPIO.PWM(18, 60) | ||
b = GPIO.PWM(17, 60) | ||
|
||
r.start(r_int) | ||
g.start(g_int) | ||
b.start(b_int) | ||
|
||
sa = 0 | ||
|
||
for x in range(0, 1000): | ||
r_int = 90 * (math.sin(sa) + 1) / 2 + 10 | ||
g_int = 80 * (math.sin(sa - 3.141592) + 1) / 2 + 20 | ||
b_int = 100 * (math.sin(sa - 1.570796) + 1) / 2 | ||
sa += 0.04 | ||
r.ChangeDutyCycle(r_int) | ||
g.ChangeDutyCycle(g_int) | ||
b.ChangeDutyCycle(b_int) | ||
time.sleep(0.05) | ||
time.sleep(2) | ||
|
||
GPIO.cleanup() |