def __init__(self, board, pins): if not board: raise ArduinoNotSuppliedException # TODO: Check that pins is dict super(RGBLed, self).__init__() self._red = Led(board, pins["red"]) self._green = Led(board, pins["green"]) self._blue = Led(board, pins["blue"])
import settings from BreakfastSerial import Led, Arduino, Button, Servo, Sensor import time from time import sleep print '''PUT ASCII ART HERE BECAUSE ASCII!!! ''' User = raw_input("Please select a function to test: \n") if User == 1: Led() if User == 2: loop() if User == 3: servo() board = Arduino() sensor = Sensor(board, "A0") def loop(): value = sensor.value or 1 value = value / 2 print value sensor.on() def servo():
#! /usr/bin/env python """ This is an example that demonstrates how to use a potentiometer to fade an LED with BreakfastSerial. It assumes you have an potentiometer wired up to pin A0 and a LED on pin 9. """ from BreakfastSerial import Arduino, Sensor, Led board = Arduino() sensor = Sensor(board, "A0") led = Led(board, 9) def change_led_brightness(): led.brightness(100 * sensor.value) sensor.change(change_led_brightness) # Run an interactive shell so you can play (not required) import code code.InteractiveConsole(locals=globals()).interact()
import settings import sys from BreakfastSerial import Led, Arduino, Button from twilio import TwilioRestException from twilio.rest import TwilioRestClient board = Arduino() LED_PIN = 13 BUTTON_PIN = 2 led = Led(board, LED_PIN) button = Button(board, BUTTON_PIN) msg_sent = False def down_press(): global msg_sent print "button down" if not msg_sent: # Turn on the LED to indicate we are sending the txt message! led.on() try: client = TwilioRestClient(settings.twilio_account_sid, settings.twilio_auth_token) message = client.sms.messages.create( body="Hello from Julia's rad Arduino!", to=settings.your_phone_number, from_=settings.your_twilio_number)
#! /usr/bin/env python """ This is an example that demonstrates how to use a button to control an led with BreakfastSerial. It assumes you have an button wired up to pin 8 and an led wired to pin 13. """ from BreakfastSerial import Arduino, Led, Button board = Arduino() button = Button(board, 8) led = Led(board, 13) button.down(led.toggle) button.hold(lambda: led.blink(200)) # Run an interactive shell so you can play (not required) import code code.InteractiveConsole(locals=globals()).interact()
import settings import alsaaudio from time import sleep from BreakfastSerial import Led, Arduino, Button board = Arduino() LED_PIN = 9 LED_3 = 8 LED_2 = 11 BUTTON_PIN = 2 m = alsaaudio.Mixer() led = Led(board, LED_PIN) LED_2 = Led(board, LED_2) LED_3 = Led(board, LED_3) button = Button(board, BUTTON_PIN) def hold_cb(): print "Full Volume" led.on() m.setvolume(100) LED_2.off() LED_3.off() def down_cb(): LED_2.on() LED_3.on() print "Setting!" m.setvolume(20) led.off()
from Tkinter import * from BreakfastSerial import Arduino, Buzzer, Sensor, setInterval, Led import time board = Arduino() led = Led(board, 12) buzzer = Led(board, 8) def alert(): print "Return to base" led.blink(100) buzzer.blink(100) def oxygenAlert(): led.off() buzzer.off() led.on() #time.sleep(2) print "Current Oxygen level: |||||||||| 86 %" def dangerAlert(): led.blink(1000) buzzer.blink(800) print "Danger Approaching. Return to base" def co2Alert(): led.blink(1000)
import settings from BreakfastSerial import Led, Arduino, Button board = Arduino() led_pin = 12 led_pins2 = 13 led2 = Led(board, led_pin) led = Led(board, led_pins2) led.on() print "Led %s" % led_pin led2.on() print "Led 2 is ON"
# Run an interactive shell so you can play (not required) import code code.InteractiveConsole(locals=globals()).interact() ########NEW FILE######## __FILENAME__ = led #! /usr/bin/env python """ This is an example that demonstrates how to blink an led using BreakfastSerial. It assumes you have an led wired up to pin 13. """ from BreakfastSerial import Led, Arduino board = Arduino() led = Led(board, 13) led.blink(200) # Run an interactive shell so you can play (not required) import code code.InteractiveConsole(locals=globals()).interact() ########NEW FILE######## __FILENAME__ = light_switch #! /usr/bin/env python """ This is an example that demonstrates how to use a button to control an led with BreakfastSerial. It assumes you have an button wired up to pin 8 and an led wired to pin 13.