LEGO MINDSTORMS & ARDUINO - Universiteit Twente · Goal: Become familiar with Lego Mindstorms &...
-
Upload
trinhxuyen -
Category
Documents
-
view
224 -
download
0
Transcript of LEGO MINDSTORMS & ARDUINO - Universiteit Twente · Goal: Become familiar with Lego Mindstorms &...
LEGO MINDSTORMS & ARDUINOPRACTICAL SESSION 1
Part of SmartProducts
▪ Goal: Become familiar with Lego Mindstorms &
Arduino
▪ 3 sessions: Apr. 25th, May 1 & 4th, 13:45-17:30h
▪ Introduction to Arduino powered Lego robots
▪ Mandatory assignment
PRACTICAL SESSION 1Fjodor van Slooten
W241 (Horst-wing West)
LEGO MINDSTORMS & ARDUINO
4/26/2018AppDev 2slides @ vanslooten.com/appdev
4/26/2018AppDev 3
WHAT IS LEGO MINDSTORMS?
Lego Technic + “Computer” + Sensors + Actuators
4/26/2018AppDev 4
MINDSTORMS GENERATIONS
Mindstorms NXT 1.0, 2.0, EV3
We use 2.0 and EV3 version
4/26/2018AppDev 5
SENSORS
Light sensor
Reads light intensity
and reflected light
from infrared led
Ultrasonic sensor*
Measures distance
to objects
(using ultra sound)
Sound sensor*
Read sound level
(not a microphone)
Touch sensor
Responds to
press, release,
touch
EV3:
NXT:
* does not work with EVShield
We’ve added some extra sensors
more on those next week
/ Color
4/26/2018AppDev 6
SERVO MOTORS
4/26/2018AppDev 7
ARDUINO POWERED ROBOTS
▪ Arduino hardware
▪ Arduino programming
▪ Language, IDE, Upload,
Serial Monitor, Libraries etc.
4/26/2018AppDev 8
ARDUINO UNOPROGRAMMABLE CIRCUIT BOARD (AKA MICROCONTROLLER)
Arduino Nano:
learn.sparkfun.com/tutorials/what-is-an-arduino
▪ Arduino program also called: sketch
▪ Language: C++ (similar to Java)
4/26/2018AppDev 9
ARDUINO PROGRAMMING
setup(): start of
program, runs once
loop(): runs continuously
after setup()
4/26/2018AppDev 10
ARDUINO PROGRAMMINGLEARN BY EXAMPLES
loop(): turn LED on and
off
LED_BUILTIN is the LED on the board
4/26/2018AppDev 11
RUN A PROGRAM
Select Board and Port
Click Upload
Connect USB
cable first
▪ Connect (almost) all Lego motor’s and sensors
▪ What not?:
▪ NXT Ultrasonic Sensor (EV3 version works)
▪ Sound Sensor
4/26/2018AppDev 12
EVSHIELDINTERFACE BETWEEN ARDUINO AND LEGO MINDSTORMS
attachments for Lego axles
3 RGB LED’s built-in
4 buttons
4 motor
connectors
4 sensor
connectors
power connector
dual-use servo header
Arduino headers accessible
4/26/2018AppDev 13
EVSHIELDPINS USED
Red pins can not be
used ‘normally’ but
can be used for i2c-
connections
4/26/2018AppDev 14
MOUNT ARDUINO + SHIELD + BATTERY HOLDER
Guide: vanslooten.com/2018/04/03/lego-evshield-battery-pack
▪ Libraries come
with examples
4/26/2018AppDev 15
EXAMPLES
▪ View results of
test
4/26/2018AppDev 16
EXAMPLES
Serial Monitor
Close after
disconnecting USB
cable
To wait for a press of the touch
sensor, you may use:
while (!myTouch.isPressed()) ;
▪ vanslooten.com/appdev
4/26/2018AppDev 17
EVSHIELD DOCUMENTATION
4/26/2018AppDev 18
EXAMPLES: DRIVING ROBOTS
Castor Bot
nxtprograms.com
Support wheel
Two separately
driven wheels
Easy to extend
with extra’s, eg.
sensors
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 19
EXAMPLES: DRIVING ROBOTS
TriBot
Building guide in folder “info\Lego\building_guides”
Responds to voice
commands
Grippers can hold small
objects
Touch sensor detects if it is
holding an object
Locate objects with
ultrasonic sensor
Light-sensor: stay
within area
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 20
EXAMPLES: GRIP AND MOVE
Robot Arm
nxtprograms.com
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 21
EXAMPLES: GRIP AND MOVE
RoboArm T-56
Building guide in folder “info\Lego\building_guides”
Light sensor
detects color of
object in gripper
Gripper can open
and closeRotates around
axis
Retractable arm
moves up and down
Touch sensor
detects if object in
gripper
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 22
SLINGSHOT
Catapult
nxtprograms.com
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 23
OPEN, CLOSE, LOCK
nxtprograms.com
Combination Lock Box
LockedUnlocked
These are using NXT, but
can be easily adapted to
Arduino + EVShield!
4/26/2018AppDev 24
ROTATE & CONNECT
Joining beams
Conical gear connection
‘free’: without friction ‘stiff’: some friction ‘sturdy’: rigid connection
4/26/2018AppDev 25
ROTATE
Reverse turning direction
Simple gearbox
4/26/2018AppDev 26
BUILDING GUIDES
differences
in colors!
Length = 5 holes
Length = 15 holes
Required
parts
▪ All project groups get a Mindstorms kit on loan for entire module
▪ Handle with care
▪ Lock when stored, leave them in corner of lecture room
▪ To open, remove entire cover (do not leave clips locked on one side,
this will break the cover!)
4/26/2018AppDev 27
HANDOUT MINDSTORMS BOXES
Remove all 4 clips!
→ to be returned July 4th
4/26/2018AppDev 28
POWER & BATTERY
▪ EVShield can be powered via attached USB
cable or via (9V) battery pack
▪ If powered via USB, might not supply sufficient
power to outputs!
▪ Re-connecting circuits? First, disconnect power
▪ Always remove one battery from battery pack
after use
▪ Do assignment in groups of 4!
▪ → 2 persons of project-group join other couple: ‘ad-hoc groups’
▪ Project group: get Mindstorms Box + 3 EL kits*
▪ ‘ad-hoc’ groups get 2 EV3 boxes (Core set + expansion set)
▪ All groups: get 1 Arduino kit** + 6 AA batteries
4/26/2018AppDev 29
ASSIGNMENT: GET MATERIALS
slides @ vanslooten.com/appdev
* contains breadboard, wires, Arduino Nano, basic components + Multimeter
** contains EVShield, Arduino Uno, battery holder etc
→ return everything at end of afternoon
→ project group stores 3 EL kits + 1 Arduino kit in the box
▪ If your kit is missing pieces: ask
teacher/assistant for spare parts
▪ Divide tasks!
▪ Tutorial for this assignment:
vanslooten.com > “Lego: Build Spike
with Arduino brain”
4/26/2018AppDev 30
DO ASSIGNMENT: BUILD SPIKESPIKE IS A SCORPION THAT HAS A NASTY STING
slides @ vanslooten.com/appdev
This assignment is a mandatory part of Application Development.
Show results at the end to receive ‘pass’.
Only students actually participating will receive a 'pass'.