Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
milandahal213 committed Jan 23, 2020
0 parents commit 8800068
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitattributes
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 added linetracker/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions linetracker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
*.pyc
venv/
13 changes: 13 additions & 0 deletions linetracker/.vscode/extensions.json
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"
]
}
14 changes: 14 additions & 0 deletions linetracker/.vscode/launch.json
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"
}
]
}
6 changes: 6 additions & 0 deletions linetracker/.vscode/settings.json
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
}
40 changes: 40 additions & 0 deletions linetracker/linetracker.py
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 added morse_code/.DS_Store
Binary file not shown.
58 changes: 58 additions & 0 deletions morse_code/morsecode.py
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()





48 changes: 48 additions & 0 deletions roomba_test.py
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 added serial/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions serial/serial.py
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))

0 comments on commit 8800068

Please sign in to comment.