3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Easy build self balancing electric skateboard

Step 47Full code (potentiometer steering)

Full code (potentiometer steering)
This version of the code is almost the same as previous one except we are now using a 10K potentiometer to steer and another to fine-tune the balance point insted of the rocker switches described in this instructable.
It is attached as a text file to copy and paste into a new arduino sketch, compile and save.

Open this sketch. We need to adjust the value of 338 to fine tune the balance point as before:
How to do this:
As when we tweaked the IMU tester: alter the value of 338 (if you need to) in this line of code in for the value you wrote down for accsum when running IMU tester and holding your board level: x_accdeg = (float)((accsum - 338) * 0.862);

Recompile the balance code with this new value in and you are now ready to try it out.
NOTE:
Updated February 25th 2012.
It works with Arduino V22. They have now released a newer version (V1.0) with a new softserial library with slightly different softserial commands so it might not work with very latest version of Arduino.






If you open up a proper Nintenso Wii Nunchuck (with special 3 lobed "Nintendo" screwdriver you have to buy on ebay) you will see that under thumb joystick is catually just 2 x 16 k potentiometers, one for side to side movement (steering) and another for forward/back (fine tune balance point). If you have a Chinese copy the potentiometer is about 3.5K, you can tell difference by the price as they look identical. You can actually solder wires onto the 3 pins of each potentiometer if you are careful and also 2 wires to one of the end buttons to use as a the deadman switch. Good thing about these potentiometers is that they self-centre at about 5-7 K Ohms.

Use multicore cable and run it back to your arduino board and you have a neat hand controller.
You may possibly have to alter values slightly in the code for the readings on analog ports on a scale from 0 - 1023
« Previous StepDownload PDFView All StepsNext Step »
3 comments
May 4, 2012. 9:28 PManiles jr says:
In this code dose it have to highest the motors can go is 50%?


dreniles

thank you
May 12, 2012. 4:11 AManiles jr says:
thank you how long do you thing it will take me to get it to balence
May 17, 2012. 1:16 AManiles jr says:
i appercatie all your help john i cant thank you enough i did the motor test and the IMU test and it worked perfect. but when i let go of the kill bottom it stops hard when it post to go to the next % this is how it went 10.00 20.00 30.00 40.00 50.00 40.00( let go of the kill switch) and then finish with the 40.00 then is stops hard when you let go of the kill switch is it post to stop keep balancing?




Thank you very much
May 8, 2012. 3:28 PManiles jr says:
For the main code can i limit it to 50%. and when im useing the POT to steer do i turn the POT to the middle and then turn left to right?
May 10, 2012. 12:09 AManiles jr says:
and how do i wire the pot's
Jan 11, 2012. 12:17 PMtracer11lb says:
Hi,

I know its been awhile since the last comment but I was just wondering if I can use a motor with built in motor controller? thanks
Nov 6, 2011. 1:13 PMbschulth says:
Has anyone updated this program to work with the UNmodified Wii nunchuck? I am about 2 weeks of stuff away from attempting it myself, but I'm still working on some other fabricating. I'd like to be able to control the steering by using the accelerometers in the nunchuck but the other (excellently written) instructable is set up to export the accel readout as a varible voltage to feed to another microporcessor instead of directly into the code to the motor controller. Didn't want to reinvent the wheel if it wasn't needed.

BTW, Thanks to all for all the support so far. It's funny that the more DIY stuff I do the more I feel the support comes from so many others. I a very big way, none of us do anything entirely on their own :)

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
127
Followers
10
Author:XenonJohn