-
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
0 parents
commit 8800068
Showing
13 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Binary file not shown.
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,3 @@ | ||
__pycache__/ | ||
*.pyc | ||
venv/ |
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,13 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
|
||
// List of extensions which should be recommended for users of this workspace. | ||
"recommendations": [ | ||
"lego-education.ev3-micropython" | ||
], | ||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||
"unwantedRecommendations": [ | ||
"ms-python.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,14 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Download and Run", | ||
"type": "ev3devBrowser", | ||
"request": "launch", | ||
"program": "/home/robot/${workspaceRootFolderName}/main.py" | ||
} | ||
] | ||
} |
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,6 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.eol": "\n", | ||
"debug.openDebug": "neverOpen", | ||
"python.linting.enabled": false | ||
} |
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,40 @@ | ||
#!/usr/bin/env pybricks-micropython | ||
|
||
from pybricks import ev3brick as brick | ||
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, | ||
InfraredSensor, UltrasonicSensor, GyroSensor) | ||
from pybricks.parameters import (Port, Stop, Direction, Button, Color, | ||
SoundFile, ImageFile, Align) | ||
from pybricks.tools import print, wait, StopWatch | ||
import utime | ||
from pybricks.ev3devio import Ev3devSensor | ||
|
||
brick.sound.beep() #program has successfully started | ||
|
||
|
||
|
||
class MySensor(Ev3devSensor): | ||
_ev3dev_driver_name='ev3-analog-01' | ||
|
||
def readvalue(self): | ||
self._mode('ANALOG') | ||
return self._value(0) | ||
|
||
|
||
left=MySensor(Port.S4) | ||
right=MySensor(Port.S1) | ||
leftM=Motor(Port.A,Direction.CLOCKWISE) | ||
rightM=Motor(Port.D,Direction.CLOCKWISE) | ||
while True: | ||
print("left",left.readvalue()) | ||
print("right",right.readvalue()) | ||
if (right.readvalue()<800): | ||
leftM.run(40) | ||
rightM.run(0) | ||
elif (left.readvalue()<400): | ||
rightM.run(40) | ||
leftM.run(0) | ||
else: | ||
leftM.run(30) | ||
rightM.run(30) | ||
utime.sleep(1) |
Binary file not shown.
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,58 @@ | ||
#!/usr/bin/env pybricks-micropython | ||
|
||
from pybricks import ev3brick as brick | ||
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, | ||
InfraredSensor, UltrasonicSensor, GyroSensor) | ||
from pybricks.parameters import (Port, Stop, Direction, Button, Color, | ||
SoundFile, ImageFile, Align) | ||
from pybricks.tools import print, wait, StopWatch | ||
from pybricks.robotics import DriveBase | ||
import utime | ||
brick.display.text("milan") | ||
utime.sleep(1) | ||
dots=[None] *10 | ||
dashes=[None] *10 | ||
t=TouchSensor(Port.S1) | ||
dot_counter=0 | ||
dash_counter=0 | ||
howmany=10 | ||
|
||
f = open('data.csv', 'w') #opens the file in write mode | ||
|
||
brick.display.text("Hold down for DOTS") | ||
f.write("Dots ,") | ||
while True: | ||
while(t.pressed()==False): | ||
print("") | ||
a=utime.ticks_ms() | ||
while (t.pressed()): | ||
print("") | ||
b=utime.ticks_ms() | ||
brick.display.text("Entry "+str(dot_counter+1)+" "+str(b-a)+" ms") | ||
dots[dot_counter]=b-a | ||
f.write(str(b-a)+",") | ||
dot_counter+=1 | ||
if(dot_counter==howmany): | ||
break | ||
|
||
f.write("\nDash ,") | ||
brick.display.text("Hold down for DASHES") | ||
while True: | ||
while(t.pressed()==False): | ||
print("") | ||
a=utime.ticks_ms() | ||
while (t.pressed()): | ||
print("") | ||
b=utime.ticks_ms() | ||
brick.display.text("Entry "+str(dash_counter+1)+" "+str(b-a)+" ms") | ||
dashes[dash_counter]=b-a | ||
f.write(str(b-a)+",") | ||
dash_counter+=1 | ||
if(dash_counter==howmany): | ||
break | ||
f.close() | ||
|
||
|
||
|
||
|
||
|
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,48 @@ | ||
#!/usr/bin/env pybricks-micropython | ||
|
||
from pybricks import ev3brick as brick | ||
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, | ||
InfraredSensor, UltrasonicSensor, GyroSensor) | ||
from pybricks.parameters import (Port, Stop, Direction, Button, Color, | ||
SoundFile, ImageFile, Align) | ||
from pybricks.tools import print, wait, StopWatch | ||
from pybricks.robotics import DriveBase | ||
import utime | ||
gg=GyroSensor(Port.S4) | ||
touch=TouchSensor(Port.S2) | ||
brick.display.text("milan") | ||
anglecounter=0 | ||
motor=Motor(Port.D,Direction.COUNTERCLOCKWISE) | ||
frontmotor=Motor(Port.A,Direction.COUNTERCLOCKWISE) | ||
dist=UltrasonicSensor(Port.S1) | ||
def reverse(): | ||
|
||
motor=Motor(Port.D,Direction.CLOCKWISE) | ||
starttime=utime.ticks_ms() | ||
b=0 | ||
while (not touch.pressed()) and (b<3000): | ||
motor.run(360) | ||
currenttime=utime.ticks_ms() | ||
b=currenttime-starttime | ||
if motor.stalled(): | ||
break | ||
motor=Motor(Port.D,Direction.COUNTERCLOCKWISE) | ||
turn(1,(gg.angle()-anglecounter*10)) | ||
|
||
def turn(dir,ang): | ||
if dir==1: | ||
frontmotor.run_angle(100,ang) | ||
else: | ||
frontmotor.run_angle(100,-ang) | ||
|
||
while True: | ||
print("angle",gg.angle()) | ||
motor.run(360) | ||
|
||
if dist.distance() <100 or motor.stalled(): | ||
motor.stop() | ||
reverse() | ||
anglecounter+=1 | ||
print(gg.angle()-anglecounter*10) | ||
|
||
utime.sleep(10) |
Binary file not shown.
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,5 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import serial | ||
s=serial.Serial("/dev/ttyACM0",115200) | ||
print(s.read(100)) |