Control Lego NXT With Wiimote

by s in Circuits > Robots

38892 Views, 17 Favorites, 0 Comments

Control Lego NXT With Wiimote

SSPX0014.jpg
Ever want to build your own RC vehicle? Now you can. Your in control of its design, and as simple to use a Legos, because it is Legos. All you need is a Lego NXT, a computer with a Bluetooth dongle, and control software


I am 17 years old.

Materials

SSPX0166.jpg
You will need:
*standard NXT kit
*computer with bluetooth
*wiimote

Step 1

SSPX0167.jpg
This part is best explained visually. View pictures for guidance.

Step 2

SSPX0169.jpg
SSPX0168.jpg
View pictures for guidance.

Step 3

SSPX0170.jpg
SSPX0171.jpg
View pictures for guidance.

Step 4

SSPX0172.jpg
SSPX0173.jpg
View pictures for guidance.

Step 5

SSPX0174.jpg
View pictures for guidance.

Step 6

SSPX0175.jpg
SSPX0191.jpg
View pictures for guidance.

Step 7

SSPX0176.jpg
View pictures for guidance.

Step 8

SSPX0177.jpg
View pictures for guidance.

Step 9

SSPX0178.jpg
View pictures for guidance.

Step 10

SSPX0179.jpg
View pictures for guidance.

Step 11

SSPX0180.jpg
View pictures for guidance.

Step 12

SSPX0181.jpg
View pictures for guidance.

Step 13

SSPX0182.jpg
View pictures for guidance.

Step 14

SSPX0183.jpg
SSPX0184.jpg
View pictures for guidance.

Step 15

SSPX0185.jpg
SSPX0186.jpg
SSPX0187.jpg
View pictures for guidance.

Step 16

SSPX0188.jpg
View pictures for guidance.

Step 17

SSPX0189.jpg
SSPX0190.jpg
View pictures for guidance.

Step 18

SSPX0192.jpg
View pictures for guidance.

Step 19

SSPX0194.jpg
View pictures for guidance.

Step 20

SSPX0195.jpg
SSPX0196.jpg
SSPX0197.jpg
SSPX0198.jpg
View pictures for guidance.

Step 21

SSPX0199.jpg
View pictures for guidance.

Step 22

SSPX0200.jpg
SSPX0001.jpg
View pictures for guidance.

Step 23

SSPX0002.jpg
View pictures for guidance.

Step 24

SSPX0003.jpg
View pictures for guidance.

Step 25

SSPX0005.jpg
View pictures for guidance.

Step 26

SSPX0006.jpg
View pictures for guidance.

Step 27

SSPX0008.jpg
View pictures for guidance.

Step 28

SSPX0009.jpg
View pictures for guidance.

Step 29

SSPX0010.jpg
Plug left cable into port b. The picture is wrong.

Step 30

SSPX0011.jpg
Plug the right cable into port c. The picture is wrong.

Software

Untitled1.jpg
download glovepie from:
http://glovepie.org/glovepie_download.php

download the controller:
http://www.norgesgade14.dk/bluetoothremote.php


 After downloading extract the files.

Turn Brick On

IMG_0077.JPG
IMG_0078.JPG

Find Bluetooth

IMG_0079.JPG
IMG_0081.JPG
use left and right keys until Bluetooth is centered.

Select Bluetooth

IMG_0080.JPG
Once you find the Bluetooth icon hit the orange button.

Find On/Off

IMG_0082.JPG
Use the right and left arrows to find On/Off

Turning on Bluetooth

IMG_0083.JPG
Select On if not already.

Finding Visibility

IMG_0084.JPG
While in the Bluetooth menu find the visibility icon.

Make It Visible

IMG_0085.JPG
Select On if not already selected.

Start

Untitled2.jpg
click on the orb or hit super on your keyboard.

Control

Untitled3.jpg
Start the control panel.

Bluetooth

Untitled4.jpg
double click the Bluetooth icon.

Add Device

Untitled5.jpg
Select add device from the menu bar.

Find Device

Untitled6.jpg
After clicking on add new device a window will open. Other devices than your brick may appear. Wait until your NXT brick is found to double click on it. My bricks name was Sean, so I clicked on it.

Pairing

Untitled7.jpg
A window will open asking for the device's password.

Paring Password

IMG_0087.JPG
Look at your brick. The default password is "1234." You can change the password if you want to. Once you know what password you want to use select the check mark.

Paring

Untitled8.jpg
Enter pairing password from NXT.

Finish Pairing

Untitled9.jpg
Click connect and windows will install the drivers needed.

Wait

Untitled10.jpg
Wait until all the drivers have been installed and the brick has been successfully paired to move on.

Pairing Wiimote

Untitled11.jpg
Go back to the Bluetooth window. Your brick should now appear there. Select add new device.

Pairing Wiimote

IMG_0095.JPG
Make sure your Wii is off. Either hold down both the 1 and 2 buttons or hit sync on the back of the controller.

Find Device

Untitled12.jpg
After clicking on add new device a window will open. Other devices than the wiimote may appear. Wait until your wiimote is found to double click on it.

Connect Wiimote to Computer

Untitled13.jpg
For the password option. Select pair without password.

Finish Connecting Wiimote

Untitled14.jpg
The wiimote should pair with your computer and install drivers.

Getting Com Port

Untitled15.jpg
Go to the Bluetooth menu. Right click on your brick, select properties, then settings. After loading you will see which COM port the brick is using.

Start the Control Program

Untitled16.jpg
Double click on the controllers icon.

Enter COM Port

Untitled17.jpg
Enter the com port of the brick. Then click start.

Enable Keyboard

Untitled18.jpg
Click enable keyboard in lower right corner of the program.

Start Glovepie

Untitled21.jpg
Double click on the glovepie icon. 

Program

Here is the program. Just copy and past

if var.run == FALSE then
var.run = TRUE
HidePie
var.hidden = TRUE
endif


if ((DoubleClicked(Wiimote.Home) and Wiimote.HasClassic == FALSE) or DoubleClicked(Home) or DoubleClicked(Wiimote.Classic.Home)) and (var.hidden == true) then
ShowPie
var.hidden = FALSE
elseif ((DoubleClicked(Wiimote.Home) and Wiimote.HasClassic == FALSE) or DoubleClicked(Home) or DoubleClicked(Wiimote.Classic.Home)) and (var.hidden == FALSE) then
HidePie
var.hidden = TRUE
endif


var.home = SingleClicked(Wiimote.Home)
If var.home and var.on then
var.on = FALSE
elseif var.home and var.on = FALSE then
var.on = TRUE
endif


key.u = wiimote.a
key.j = wiimote.b
key.t = wiimote.Plus
key.g = wiimote.minus
key.y = wiimote.right
key.h = wiimote.Left
var.err = 15               //edit to change intervals. (0 - 180) are possible values

if ((wiimote.roll > var.err) && (wiimote.pitch < -(var.err)))
key.w =false
key.d =false
key.s =false
key.a =false
key.e =true
key.c =false
key.z =false
key.q =false
else
key.e =false
endif

if ((wiimote.roll > var.err) && (wiimote.pitch > var.err))
key.w =false
key.d =false
key.s =false
key.a =false
key.e =false
key.c =true
key.z =false
key.q =false
else
key.c =false
endif

if ((wiimote.roll < -(var.err)) && (wiimote.pitch < -(var.err)))
key.w =false
key.d =false
key.s =false
key.a =false
key.e =false
key.c =false
key.z =false
key.q =true
else
key.q =false
endif

if ((wiimote.roll < -(var.err)) && (wiimote.pitch > var.err))
key.w =false
key.d =false
key.s =false
key.a =false
key.e =false
key.c =false
key.z =true
key.q =false
else
key.z =false
endif

if ((Abs(wiimote.roll) <= var.err) && (wiimote.pitch > var.err))
key.w =false
key.d =false
key.s =true
key.a =false
key.e =false
key.c =false
key.z =false
key.q =false
else
key.s = false
endif

if ((wiimote.roll > var.err) && (Abs(wiimote.pitch) <= var.err))
key.w =false
key.d =true
key.s =false
key.a =false
key.e =false
key.c =false
key.z =false
key.q =false
else
key.d = false
endif

if ((Abs(wiimote.roll) <= var.err) && (wiimote.pitch < -(var.err)))
key.w =true
key.d =false
key.s =false
key.a =false
key.e =false
key.c =false
key.z =false
key.q =false
else
key.w = false
endif

if ((wiimote.roll < -(var.err)) && (Abs(wiimote.pitch) <= var.err))
key.w =false
key.d =false
key.s =false
key.a =true
key.e =false
key.c =false
key.z =false
key.q =false
else
key.a = false
endif

if (((Abs(wiimote.roll) <= var.err) && (Abs(wiimote.pitch) <= var.err)) || ((Abs(wiimote.roll) <= var.err) && (Abs(wiimote.pitch) <= var.err)))
key.w =false
key.d =false
key.s =false
key.a =false
key.e =false
key.c =false
key.z =false
key.q =false
endif


Wiimote.Led1 = var.on
Wiimote.Led2 = true 
Wiimote.Led3 = var.on 
Wiimote.Led4 = true 


if Wiimote.Battery <= 10 and var.warned == FALSE then
Say "Low Battery"
var.warned = TRUE
endif
var.bat = Wiimote.Battery / 192 * 100
debug ='Battery= '+var.bat+'%' 

Controls

hold wiimote with IR camera facing away from you and level.

tilt wiimote down to go forward

tilt wiimote backward to go backward

tilt wiimote right to turn right

tilt wiimote left to turn left

tilt wiimote down and right to go forward to the right

tilt wiimote up and right to go backward to the right

tilt wiimote down and left to go forward to the left

tilt wiimote up and left to go backward to the left

plus button increases speed

minus button decreases speed

right button on gamepad increases spin speed

left button on gamepad decreases spin speed

a button increases turn ratio

b button decreases turn ratio

double click home button to reopen glove pie

Run Glove Pie

Click run and enjoy.

I am 17 and if I can do, so can you.

Finished