Professional Documents
Culture Documents
This is a great little project for KS3/KS4 – Depends on how much time
you want to give students and how far you want to take the project.
1. First of all you need a Raspberry Pi any of the models will work fine for this.
http://uk.rs-online.com/web/p/processor-microcontroller-development-kits/832-6274/
You will be able to get one from the Pound store if you want a cheap one.
4. You’ll need access to the basics of micro USB power, keyboard and mouse and the Pi attached
to a monitor through HDMI or a converter to DVI or VGA.
5. You’ll need a genuine Wii remote, not an import or fake version as the Bluetooth system won’t
work.
8. You’ll need a few 3-5v motors with wheels – Not easy to find wheels to fit separate 3v motors
http://www.amazon.co.uk/Yellow-Black-Wheel-Single-Geared/dp/B00BG7PFVA/ref=sr_1_11?ie=UTF8&qid=1436281581&sr=8-11&keywords=3v+motors
10. You need access to the Internet via Ethernet cable or you’ll need a Wi-Fi dongle to connect to
your Wi-Fi router.
Now you’ve got everything, you can make your robot out of Lego – The motors will need to be secure
and there needs to be enough room to place your Raspberry Pi there and either to move it off or wire
it up when needed.
You need to cut back the wires and solder them to the motor for plus and negative points and then
plug in the other ends to the Motor points in the Explorer hat.
You now need to install Bluetooth to the Raspberry Pi and download the Wii module for Python.
We now need to install the Wii module to connect the remote to the Raspberry Pi using python
programming
You now need the python code to get the Wii to control the motors. You will need to open Python
and add the code to a new window and save it. When complete run the code from a terminal window
by typing:
The code will then run and you will be asked to connect with the Wii remote – You should then be
able to move the robot with the remote. See code on next page.
The code could be developed further and your Lego robot could be developed to include various
extras that could then be programmed to work with the Wii remote.
import cwiid
import time
import explorerhat
button_delay = 0.1
#forward
def forward():
explorerhat.motor.one.forward(100)
explorerhat.motor.two.forward(100)
time.sleep(1)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
#backward
def backward():
explorerhat.motor.one.backward(100)
explorerhat.motor.two.backward(100)
time.sleep(1)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
#left
def left():
explorerhat.motor.one.forward(100)
explorerhat.motor.two.backward(100)
time.sleep(.25)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
#right
def right():
explorerhat.motor.one.backward(100)
explorerhat.motor.two.forward(100)
time.sleep(.25)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
def spin():
explorerhat.motor.one.backward(100)
explorerhat.motor.two.forward(100)
time.sleep(5)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
explorerhat.motor.two.backward(100)
explorerhat.motor.one.forward(100)
time.sleep(5)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
print ("Connected")
print ("Press something")
print ("Press Plus and Minus to disconnect")
wii.rpt_mode = cwiid.RPT_BTN
while 'True':
buttons = wii.state['buttons']