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
@safe_add | |
def add_input_device_ready_raw3(self, input_port, | |
mode=-1, | |
device_type=0, | |
layer=USB_CHAIN_LAYER_MASTER): | |
"""Waits until the device on the specified InputPort is ready and then | |
returns its value as a raw value. | |
""" | |
self._msg.append(Opcode.INPUT_DEVICE) |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; |
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
import ev3 | |
import direct_command | |
""" | |
The first example creates an object called fwd to which we bind the class called direct command . We can then call the functions of the direct command using the magic dot. When you type fwd. on each line a list of the available functions appear (in Spyder) which you can scroll through and choose the correct one. Then when you type ( the object inspector tells you about the commands this function accepts. | |
""" | |
# move forward | |
fwd = direct_command.DirectCommand() | |
fwd.add_output_speed(direct_command.OutputPort.PORT_C,100) |
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
import time | |
LED_off = '\x08\x00\x00\x00\x80\x00\x00\x82\x1B\x00' | |
LED_green = '\x08\x00\x00\x00\x80\x00\x00\x82\x1B\x01' | |
LED_orange = '\x08\x00\x00\x00\x80\x00\x00\x82\x1B\x03' | |
LED_red = '\x08\x00\x00\x00\x80\x00\x00\x82\x1B\x02' | |
# send commands to EV3 via bluetooth | |
with open('/dev/rfcomm0', 'w', 0) as bt: | |
bt.write(LED_red) |
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
play_tone = '\x0F\x00\x00\x00\x80\x00\x00\x94\x01\x81\x02\x82\xE8\x03\x82\xE8\x03' | |
# send commands to EV3 via bluetooth | |
with open('/dev/rfcomm0', 'w', 0) as bt: | |
bt.write(play_tone) |
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
import time | |
# command to start motor on port A at speed 20 | |
start_motor = '\x0C\x00\x00\x00\x80\x00\x00\xA4\x00\x01\x14\xA6\x00\x01' | |
# command to stop motor on port A | |
stop_motor = '\x09\x00\x01\x00\x80\x00\x00\xA3\x00\x01\x00' | |
# send commands to EV3 via bluetooth | |
with open('/dev/rfcomm0', 'w', 0) as bt: |
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
#import modules | |
import time | |
from ev3py import ev3 | |
#create a reference to the ev3 called 'mybrick' | |
mybrick = ev3() | |
# connect with EV3 via Bluetooth | |
mybrick.connect('bt') |
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
import serial | |
from dec_to_hex import h # decimal-to-hexadecimal dictionary | |
EV3 = serial.Serial('/dev/rfcomm0') | |
# message length | |
bytecount = h[44] #look up 44 in hex dictionary | |
comm_0 = '\x00' |
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
import serial | |
EV3 = serial.Serial('/dev/rfcomm0') | |
textstring = "2C000000800000841300820000820000841C018200008232008475692F6D696E6473746F726D732E726766008400" | |
command = textstring.decode("hex") | |
print(command) | |
EV3.write(command) |
OlderNewer