Пример #1
0
import settings
from time import sleep
from BreakfastSerial import Led, Arduino, Button

board = Arduino()
LED_PIN = 9
LED_GREEN = 12
BUTTON_PIN = 2
led = Led(board, LED_PIN)
led_green = Led(board, LED_GREEN)
button = Button(board, BUTTON_PIN)

def hold_cb():
	print "Holding..."
	led.on()
	sleep(2)
	led.off()


def down_cb():
	led_green.on()

def up_cb():
	print "Up \n"


button.down(down_cb)
button.up(up_cb)
button.hold(hold_cb)

Пример #2
0
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"


  print ("I need to know what number to text")
  phone_number = raw_input(">")
  print ("What message would you like to send?")
  message = raw_input(">")

  if not msg_sent:

      # Turn on the LED to indicate we are sending the txt message!
      led.on()
Пример #3
0
#! /usr/bin/env python
"""
This is an example that demonstrates how to use a
button with BreakfastSerial.  It assumes you have an
button wired up to pin 8.
"""
from BreakfastSerial import Button, Arduino

board = Arduino()
button = Button(board, 8)

def down_cb():
  print "button down"

def up_cb():
  print "button up"

button.down(down_cb)
button.up(up_cb)

# Run an interactive shell so you can play (not required)
import code
code.InteractiveConsole(locals=globals()).interact()
Пример #4
0
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)
from BreakfastSerial import Arduino, Led, Button

board = Arduino()
led = Led(board, 13)
button = Button(board, 8)

button.down(led.toggle)
Пример #6
0
#! /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()
Пример #7
0
#! /usr/bin/env python
"""
This is an example that demonstrates how to use a
button with BreakfastSerial.  It assumes you have an
button wired up to pin 8.
"""
from BreakfastSerial import Button, Arduino

board = Arduino()
button = Button(board, 8)


def down_cb():
    print "button down"


def up_cb():
    print "button up"


button.down(down_cb)
button.up(up_cb)

# Run an interactive shell so you can play (not required)
import code
code.InteractiveConsole(locals=globals()).interact()
Пример #8
0
import settings
import sys

from BreakfastSerial import Led, Arduino, Button
from twilio import TwilioRestException
from twilio.rest import TwilioRestClient

board = Arduino()
LED_PIN = 7
BUTTON_PIN = 2

led = Led(board, LED_PIN)
button = Button(board, BUTTON_PIN)


def hold_cb():
    print "Button held"
    print "Reading messages \n"
    client = TwilioRestClient(settings.twilio_account_sid, settings.twilio_auth_token)
    for message in client.messages.list():
        print message.body


msg_sent = False
print "[================] Action [============]"

Msg = raw_input("Message: \n")
print "Message Loaded \n"
print "Press Button to send"
button.hold(hold_cb)
Пример #9
0
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()
Пример #10
0
from BreakfastSerial import Arduino, Button

board = Arduino()
button = Button(board, 8)

def print_button_pressed():
  print "Button Pressed"

button.down(print_button_pressed)
Пример #11
0
    def clear(self):
        self.shouldRun = False

########NEW FILE########
__FILENAME__ = button
#! /usr/bin/env python
"""
This is an example that demonstrates how to use a
button with BreakfastSerial.  It assumes you have an
button wired up to pin 8.
"""
from BreakfastSerial import Button, Arduino

board = Arduino()
button = Button(board, 8)

def down_cb():
  print "button down"

def up_cb():
  print "button up"

button.down(down_cb)
button.up(up_cb)

# Run an interactive shell so you can play (not required)
import code
code.InteractiveConsole(locals=globals()).interact()

########NEW FILE########
Пример #12
0
import datetime
from BreakfastSerial import Arduino, Led, Button

board = Arduino()
led13 = Led(board, 13)
ledg = Led(board, 9)
ledr = Led(board, 10)
btn = Button(board, 2)

def btn_up_cb():
    ledg.off()
    ledr.off()

def btn_down_cb():
    ledg.on()
    ledr.off()

def btn_hold_cb():
    ledg.blink(200)
    second = datetime.datetime.now().second
    print("Current second: {}".format(second))
    bspeed = second * 1000 / 60
    ledr.blink(bspeed)

if __name__=="__main__":
    btn.up(btn_up_cb)
    btn.down(btn_down_cb)
    btn.hold(btn_hold_cb)

    led13.blink(1000)
    print("Ready.")