Esempio n. 1
0
# This demo makes your PC talk to an EV3 over Bluetooth.
#
# This is identical to the EV3 client example in ../bluetooth_client
#
# The only difference is that it runs in Python3 on your computer, thanks to
# the Python3 implementation of the messaging module that is included here.
# As far as the EV3 is concerned, it thinks it just talks to an EV3 client.
#
# So, the EV3 server example needs no further modifications. The connection
# procedure is also the same as documented in the messaging module docs:
# https://docs.pybricks.com/en/latest/messaging.html
#
# So, turn Bluetooth on on your PC and the EV3. You may need to make Bluetooth
# visible on the EV3. You can skip pairing if you already know the EV3 address.

# This is the address of the server EV3 we are connecting to.
SERVER = 'CC:78:AB:D8:4E:F6'

client = BluetoothMailboxClient()
mbox = TextMailbox('greeting', client)

print('establishing connection...')
client.connect(SERVER)
print('connected!')

# In this program, the client sends the first message and then waits for the
# server to reply.
mbox.send('hello!')
mbox.wait()
print(mbox.read())
Esempio n. 2
0
'''

# Initialize the EV3 Brick
ev3 = EV3Brick()

# Initialize speaker
ev3.speaker.set_volume(100)
ev3.speaker.beep()

# Trun off lights
ev3.light.off()

# The server must be started before the client!
saySomething('Waiting for server', 2)

client = BluetoothMailboxClient()
client.connect('mike')

client1 = TextMailbox('client1', client)

# Initialize EV3 touch sensor and motors
motorA = Motor(Port.A)
motorB = Motor(Port.B)
''' 
Define threaded function to save button value updates
'''


# Initialize a loop that waits for instructions from the server
def eventLoop():
Esempio n. 3
0
# The server must be started before the client!
import random
import threading

from pybricks.ev3devices import (Motor, InfraredSensor, UltrasonicSensor)
from pybricks.hubs import EV3Brick
from pybricks.media.ev3dev import SoundFile, ImageFile
from pybricks.messaging import BluetoothMailboxClient, TextMailbox
from pybricks.parameters import Port, Button
from pybricks.tools import wait

import constants

# set up the client
client = BluetoothMailboxClient()
mbox = TextMailbox('greeting', client)
client.connect(constants.SERVER)

# set up the ev3
ev3 = EV3Brick()

# set up the speaker
ev3.speaker.set_speech_options('fr', 'm1', 150, 35)
ev3.speaker.beep()

# set up the sensors
ir_sensor = InfraredSensor(Port.S4)
ultrasonic_sensor = UltrasonicSensor(Port.S3)

# set up the motors