After a long wait, I’m back baby! To start the year off with a bang, here’s a Mindstorms NXT car that can be controlled using Skype – by anyone, anywhere, any-when (between today, 1/1/2012 and 1/18/2012).
If you want to get going right away, here is the link for driving this car: http://www.goo.gl/7LLaU.
This is going to be a pretty lengthy post, so I’ve broken it up into the following categories: Introduction/ General Explanation, Hardware, Program-ming, Computer Tweaks, and How YOU Can Drive This Car. Click any of the categories to jump forward to it.
I’ve been creating websites for a while now, and I was trying to think of a way to combine it with Mindstorms NXT, and this project is the result of that. The webpage is fairly simple – it’s got three arrows (one forward, two to the sides) and a start and a stop button. Clicking the start arrow will begin a Skype conversation with my computer, after which the user should share their screen; the NXT standing in front of my computer (called “Jeeves”) can then “see” the webpage the user is viewing.
That’s where the cool part kicks in – when the user clicks any one of the arrows or the stop button, the page will change to a different shade of gray. This shade of gray is then picked up by Jeeves, who turns it into a Bluetooth message for the other NXT (called “Alfred”). The car then drives in the direction the user tells it to, while remaining within a fenced off area where the webcam can see it.
So, the user can drive a LEGO Mindstorms NXT car, from the comfort of his or her home, without having to install any kind of software (provided that they have Skype).
The car was fairly simple to build – it’s got two motors on the sides with the wheels attached directly (no gears), and a big ball caster attached at the back. It looks quite a bit like my line follower, actually, except for the fact that the caster is a lot bigger because the car needs to be able to drive over the power cable and because it’s on a carpet. Also, it’s got front bumpers so you all can’t break anything while driving it, a color sensor that turns on when the robot is in use, or has been in use the past minute, and a rechargeable battery that’s always plugged in. Some pictures:
The first one is a side view, and the second one is an upside down view.
Hardware – the Receiver
The receiver was a bit more tricky to build because it needed to be a specific height so its light sensor could “see” the right area of the user’s screen. The structure itself is fairly simple – the light sensor is on a big pole attached to the NXT, and it’s got a rechargeable battery that’s always plugged in at the bottom. Here’s a picture of it (without the battery; hence the delay):
For all of the coding in this project, I’ll provide a basic description of how it works, and then a download link in case you’re interested in trying to build this project yourself sometime. The first two pieces of code (for the car and the receiver) were made using RobotC, and the third (for the website) is in HTML. All of the code will be on Sourceforge.
Programming – the Car
There’s a small function for turning the motors’ PID control on or off at the beginning of the program to get rid of the peeping noise the motors make when the car is not moving.
In the main task, here’s what happens: the variables are created, the Bluetooth is turned on, and the timer is cleared. In the main while-loop, the last received message is stored, so the robot can later use that information( along with the timer) determine whether it’s been active the last minute and decide to turn the signal light on or off. Then, the robot reads the message last sent to it and plugs it into a switch. Depending on which message it received from the receiver (ah, the irony), it will move the motors. At the end of the while loop, there is a 50 millisecond wait to save battery power.
Click here for the code (first version).
UPDATE: Since the robot is now wireless, the code has changed to support some more sensors for plugging itself in. Read more about these changes here:
Click here for the code (second version w/ wireless charging capabilities).
Programming – the Receiver
The receiver also starts by initializing its variables and turning on Bluetooth, after which it connects itself with the other NXT – also using Bluetooth. The program then enters its main while loop, in which there is a series of if/ else switches designed to determine what shade of gray the screen is. The if/ else switches then plug this message into the “messageToSend” variable, which is sent out afterwards. The loop ends with a 100 millisecond wait, again to preserve battery.
Programming – the Website
There isn’t really much to explain about this one, so I’ll just give you the download link. Please note that the images on the page aren’t included, so you won’t be able to view it correctly in your browser. Screenshot below.
There were quite a few tweaks I had to make to my computer, so I decided to list them here in case, again, you want to build this project yourself someday. Keep in mind that I might be missing/ forgetting some things, so if you ever have a problem just leave a comment below.
- Turned off sleeping mode on both my screen and the computer itself;
- Skype: in the general > video settings menu, I changed the first option (“Automatically receive video and screen sharing from…”) to “anyone”;
- Skype: in the privacy > privacy settings menu, I changed everything to anyone. I also checked all the boxes;
- Skype: in the calls > call settings menu, I changed “Allow calls from…” to “anyone”, and again checked all the boxes;
- Skype: in the IM & SMS > IM settings menu, I changed “Allow IMs from…” to “anyone”;
I’m also keeping the Skype window open 24/7, so my background won’t confuse the light sensor.
- Go to http://www.goo.gl/7LLaU
- Make sure your window is maximized
- Click the “Start” button
- Go through the dialog windows you get (there will be more on IE and Firefox than on Google Chrome)
- Wait for my video to start (this can take up to 20 seconds)
- Open the “call menu” at the top bar
- Click “Share Your Screen” – it’s about 3/4th of the way down the menu
- Click “Share Full Screen”
- You should now be brought back to the webpage with the arrows. Once you see the car stop, use the arrows to drive it around.
- To stop, hover your mouse over the little screen where you see the car, and click the red phone button
This project has successfully been tested on the following operating systems:
- Windows 7
With the following browsers (newest version as of 12/31/2011):
- Google Chrome (tested best)
- Internet Explorer
So there you have it: a LEGO Mindstorms NXT car that you can drive using Skype. If you like this project and want to see more, subscribe to my YouTube page and this blog for the latest updates. Once this project ends, I’ll put some statistics on how many people tried this project up down here. Feel free to use anything on this page (the robots, the code, the website, etc.) non-commercially, as long as you give credit where it’s due.
To read more about my Skype car, click here.
Disclaimer: The Skype name, associated trade marks and logos, the Skype “Call Me” button and the “S” logo are trade marks of Skype.