embedded by Embedded Video
YouTube Direkt
embedded by Embedded Video
YouTube Direkt
Why build a DIY Segway?
The main reason that I wanted to build a DIY Segway was simply because I wanted to see if it was possible. I also liked the idea of building something that strongly interacts with humans. I will now describe how I built it.
Hardware
The motors, wheels, chain, gears and batteries came from electric scooters like the one to the right. You need hardware from two since the electric scooters only have one motor and gear setup. The motors are some cheap china unbranded ones. They are rated as 300W 24Volt, 2750 rpm
The gearing is made in one step from the small gear on the motor to the bigger gear head on the wheel. The ratio is approx 6:1, a higher ratio would be preferred to get a better torque and a lower top speed. Now the motors have to work pretty hard and currents above 30A(in total from both motors) have been registered since the fuse burned.
The fasting of the gear on the 12” wheel was based on a freewheel mechanism therefore I had to open up the freewheel and remove all the grease and then use epoxy to make it possible to drive it in both directions. In the picture below you can see the freewheel after it has been filled with epoxy as well as a tool made to be able to open it up.
There is one fixed axle on which both wheels rotate, this axle is attached with three aluminum blocks which fixates the axle with 5mm set screws.
![]() |
![]() |
![]() |
Steering, to be able to turn left and right by just tilting the handlebar a rigid joint was needed, the design was made in SolidWorks and then produced in a CNC mill. The transfer from the CAD drawing to the machine instructions (g-code) was made with CAMBAM. The same method was used to produce the box for the electronics and the assembly for the emergency brake.
![]() |
![]() |
The handlebar is a normal bicycle handlebar, the pipe on which it is connected is a 25mm hollow steel pipe. To keep the pipe centered and to give some force feedback two springs are attached with steel wires. On the handlebar there is also an emergency button which is connected to a standard car relay which directly cuts the power to the motors. Two 12V 12Ah lead batteries are used in series since the motors run at 24V
Electronics
All PCBs are custom made, the main board (top left in image above) takes care of the computation, gathers data from sensor such as gyro(ADXRS614), accelerometer(ADXL203) and a trim potentiometer which is modified and positioned in the steering joint to detect in which direction you want to turn. The main processor is an AVR AtMega168. The communication to my laptop is made over Bluetooth using a RN-41 from Roving Networks (the same is used in Sparkfuns BlueSMiRF Gold).
The two H-bridges (right-hand side in the image) which convert the control signals from the main board to the power to the motors are designed by friend named Benjamin Vedder. Each H-bridge also have an AtMega168, the communication between the boards is done via UART, originally I2C was used but due to the high currents produced by the motors too much noise was generated and was influencing the I2C communication. All the electronics run on a separate battery (a LiPo 7.4v 900mAh).
To have easy access for charging the batteries, programming the main board and changing parameters to the control loop a small box with several connectors, a switch to turn on and off the power to the electronics and trim potentiometer is positioned on the top side.
Software
The software in the microcontroller mainly consists of a filter for the gyro and accelerometer and a PD control loop. The idea from the beginning was to have the DIY Segway as a platform for testing different types of control methods. However since the power of the motors and the mass of the system was quite big it turned out that it is not such a great test platform (at least if you don’t like getting lots of bruises and destroying the interior of the place you are testing it at).
A better option would be to have a smaller balancing setup which fits on a table and with a mass of less than 1kg for this purpose.
Regarding the filtering of the gyro and accelerometer I tested both a Kalman filter and a Complemenatry filter. It turned out that the performance was very similar of the two filters but the Complementary filter required less computation and is therefore currently used.
On the computer I made an application written in Java where I can see all the sensor values and control signals, battery status etc. It’s a great way of debugging the system.
Cost
I didn’t keep a strict log over my purchases so this is mainly an estimate, however I have tried to overestimated all costs to not give a too optimistic result. The biggest cost was the motors wheels and batteries. I managed to reduce this cost pretty well by buying a second hand scooter which was malfunctioning due to an electrical error, the parts I scavenged from it makes up one setup of wheel motor and gears. Since I needed parts from two scooters I also bought a separate setup as spare parts so these were completely new. Regarding the electronics I bought several items via eBay which can give great prices.
| Hardware (200€) 2 motors, 2 wheels and 2 lead batteries 150€ Steel pipe 5€ Aluminum blocks 10€ Aluminum base plate 10€ 12mm Steel axle 5€ Handlebar 7€ Emergency brake 3€ 2 Springs 8€ |
Electronics (100€) 3 x AtMega168 ADXRS614 ADXL203 8 Mosfets Gate drivers Capacitors & resistors Double layer PCB Voltage regulator LED LiPo battery |
|
| Total 300€ | ||







Hi Peter, really good work!
I’m about to start to build a similar project. I just wonder if motor power is enough: which speed do you reach? And is it enough to climb slopes (for example 10°? 20°?)
thanks a lot.
Garo
Hi Peter,
Can u send the detailed explanation and circuit abt it to
thank you
Hi Peter,
Can u send the detailed explanation and circuit abt it to nandgatedalmeida@gmail.com
hi peter
i am a masters student and even i am working on diy segway….the mechanical designing is done. And i have already designed the motor drivers too. Right now i am working on the balancing part.
i am using atmega32 microcontroller. I wont be using gyro and accelerometer , but i will be using some other tilt sensors to control the speed as well as providing balance to the bike. Do you think its a good idea?? And can you plz send me some logic or atleast dummy codes for the processing of the inputs from these sensors.
thanks and
regards
I would to build one. Petter could you send me an electronic project circuit diagrams and firmware? the new address THX Robbi
Hello Peter you could send me the links of sites or you commanded spare parts for the construction thank you
Hi, P1R you have Skype?
I need to talk with you about Segway.
My skype is elisonlins
Hello,
excellent work, I’m impressed.
Is it possible to get some more detailed information about the electronics?
Thank you
Mitja B.
Could you send me an electronic project circuit diagrams and firmware? the new address magic_gy2@hotmail.com
thank you
Nice Vehicle but this whole Page is of no use for others who does’nt have enough knowlege to build this on their own since you are not willing to give details. On the other hand those with enough knowlege how to build it can do this on their own, but those don’t need this page also.
So its of no use for nobody except for your self-praise which makes People getting mad at you.
Hi Petter, i was wondering if you could send me the code for your Segway. I was also wondering if you could be so kind to enlighten me on what kind of potentiometer you are using to determine right or left when turning? Much appreciated.
Hi Petter, what is the type and how much motor power? some detailed control part?
Jag är en UK ex-pat, pensionerad mekanisk ingenjör – jag arbete som volontär och guide att Aeroseum; http://www.aeroseum.se. Anläggning är 22 000 m2 stort och många av oss är äldre. Din DIY Segway kunde spara mycket gångtid och trötta ben! Har du lust att hälsa på en tisdag 07oo-21oo (volontär kväll från 18oo) eller fredag 07oo-1500? Fråga efter Martin i entré kiosk, jag kommer hämta dig för en rundvandring. F.d. Chalmarister med elektronik som bakgrund samt pensionerad kretskort designer finns – mekanik ta jag och en annan kollega hand om… Mvh, Martin Bronsdon mob. 0706-788425 hem 031-198889 (Svangatan 9D, 416 69 Gbg)
Hej Martin, det låter jätte häftigt, dessvärre så har jag flyttat och bor numer i Sthlm. Men om jag är i Göteborg nån gång så ska jag förska titta förbit. Mvh
Peter
I have just discovered your self-made Segway Mobile Scooter. I am not only impressed, but very jealous. While my capabilities are not up to the ingenuity you possess, I am of the mindset ‘why cannot I do the very same thing’? In truth I cannot, however I do admire your skil.
I am disabled and have limited mobility and have long asked why I am not able to use a device such as you have designed. To be able to use this in a home setting is my thought here, as opposed to a Rollater. A ‘rolling walker’.The traditional large scale marketed Segway has been shown to be first of all priced above what the average low income individual can reasonably afford, and second is not, what I have seen as easily manuevable as your prototype. My thought here is – your device is perfect for the mobility limited individual like myself. I do believe you have a definite market. I know I would love to be able to secure (purchase) one. Possible? I definately would love to be able to use a device such as your magnificent ‘Segway’…
Than you for listening…
Sincerely
David Norris
Sacramento, California
norris299@sbcglobal.net
Hello David.
Thank you for your kind words. Regarding your idea,
it is very interesting but there are some disadvantages that you need to consider for example when not moving around the Segway is still using power just to balance itself. Therefore it is not very energy efficient compared to a three or four wheeled alternative. Another thing to consider is thresholds and similar obstacles, the Segway is not so good at climbing thresholds. You kind of need to gain some speed to “bump” over it which might be a bit hazardous in indoor environments.
Best Regards
I’m from China.Send the wrong place.Thank the authors provide technical parameters.My English is not good
Nice job I think your segway is perfect for my friend that is handycaped and I am going to try and make one that the handle bars will be replaced with a bluetooth head gear he can only use his body from the neck up
Do you think the head gear would work like the handelbars do
would love to here your thoughts on the modifications thanks for your time and giving me the idea for my friend and maybe the Disabled
Kevin
Could you send me an electronic project circuit diagrams and firmware? the new address patyukov70@gmail.com
bro its a awesome works. i would like 2 applied bt it seems the electronic circuit is new for me id u explaining more about the the electronic part of this segwat
I’m from China.Thank you for parameters
Hi Petter,
Wondering if you would be willing to supply your code as a reference for others? I have a completed segway running on an Arduino using the kalman filter, though it’s not perfect. Thinking of switching over to a less complicated complementary filter. Which do you use?
Your DIY segway is the best I’ve seen by far.
Thank you,
Shane
Can u Plz check ur Email ?!
thx in advance
Hello Peter! Your ballancibg sckoter is great. I would like to make a segway to my grandson. Can you please be so kind and disclosure the schematics and software of motor control? Thanks
Hello, If one day you decide to produce it at a good price, I could be interested in dealing it in France. Then, do not hesitate to contacted me.
Oliver 00 33 (0)7 60 74 90 90
Estoy interesado en fabricar el mio tambion en cuanto podrias venderme alguna guia para yo tambien hacerlo realidad.
hey man, cool design, listen how did you determine your pd gain values? and what is the purpose of your trim pot?
Hi, is it possible to make all the elctronics run on a smartphone?
Hej Petter! Jag heter Benjamin Dzebo och jag går tredje året på fordons programmet och jag skulle vilja att du emailar mig på Benjamin_dzebo@hotmail.com med kontakt information då jag är sugen på att göra detta som projekt arbete:) Tack så mycket i förväg, mvh Benjamin.
Здравствуй Петтер!
А кто разрабатывал данную схему?
интересно посмотреть её!
hello, could you tell me how many and what batteries did you use for the engine? Thank you!
Two 12V 12Ah lead batteries are used in series since the motors run at 24V
Hi Petter,
Good job. I am interested to built one segway. Can I get from you the eletricronic scheme and also the software from ATMega168 ?
Thanks! Costel
Hi, can any body assist me how to get this video tutorial from this web site, I have watched and listen it at this time but would like to down load it.
Hello Peter !
( kejt3@buziaczek.pl)
I am also interested in building Segway , but I got some troubles with electronics . Is there any possibility to get a electronic PDF projector from you ?
I would be so grateful .
Thanks ! Kate
Hello, Petter. Your email is XXX, doesn’t it? I would like to discuss desingning of your segway. This is a very very interestingly!
Petter, i want to ask you about your project.
I’m very interest with your DIY segway.
And now I want to make DIY segway.
I want to ask about the gyro and accelero. Should we use gyro and accelero ?Or we can use one( accelero or gyro) ?
And how to program the accelero or gyro so that the DIY segway can control the velocity of the motor ?
Thank you Petter..
found your website searching the web. I bought two electric scooter from an estate sale–neither worked for lack of parts or missing stuff. I tried to build a working scooter using the two but gave up when I fried the controller board.
I can work with metals, some electronics but not programming. Us types who lack programming skills or PCboard building really need a source for completed boards or a good kit. and of course the program. are you or anyone else working to provide such?
thanks again, great article; Gene
Hi Petters,
Your product is extremely interesting.
Can you have a look at our P-personal project – http://www.p-buggies.com/p_perso.htm – and let me know your comment ?
We are trying to go a little further than the existing Segway…
Cheers,
Franck
Hi Petter,
Just wondering if you would be so kind as to post your code for us unworthy mortals:)
I have tried the code that is supplied further up in the comments pages but it does not debug. I think it was done with an earlier version of the Arduino code.
You have gone to so much trouble to make a beautiful machine and website, all that is missing is unfortunately YOUR code.
Thanks very much.
Mart
I’m working on it, my plan is to produce new code that runs on Arduino hardware. I will make it available on Github. But still a few months before I can post it, have to many other projects consuming my time. Regards
Hej,
Jag går nu sista året på gymnasiet och är verkligen intreserad av ditt projekt.
Funderar själv på att bygga en segway (fast med ett hjul). Är detta möjligt tror du?
Hur långt tid kommer det ta och vad tror du kostnaderna för ett sådant projektarbete skulle kosta?
Tack på förhand
Mvh Marcus
Det är möjligt men det är svårare än med två hjul. Om du själv tänker sitta på den så får du själv ta hand om balansen i sidled medan motorn tar hand om balansen i frambak led. Om du ej sitter på den måste du låta ett svänghjul ta hand balansen i sidled.
Hello. Good project. I also Would like to collect on the Atmega, a stepper motor as the driving force. It will be a miniature model. Can you lay out chip cards. And a program for Atmega. I would really be grateful. Yet in Russia to not sell such devices.
Hi.is it possible for you to send me the h-bridge circuit.I´m bildding a custom made segway but i´m having problems with mosfet driving circuit.The motor that i have are 24v 250w from electric scooter like yours.I´ve also tried diferent PWM .What the frequency that you have used.
Hi Petter,
you have done a great job man, i like it very much. that makes me to start to make one too. but i have got no any idea how to find the balancing device ( H-bridges) mother board and soft wear, could you please guide me how to get them? or are you able to supply them to me? if you can supply, could you please tell me the cost.
best regards
Ray
The H-bridges is not of my design so I can’t give them away. I have seen some people using this motorcontrol: http://www.robotpower.com/osmc_info/ Regards
Where i can found the Arduino Code?
This is NOT Petters code, but maybe somewhere to start?
http://diysegway.blogspot.se/
BR //Andreas
Hi all! I´ve also started building one. Regarding motors and stuff: I bought mine at http://www.sunds-sportartikel.de/ Cheaper than the swedish firms I´ve found, and very good delivery (20 euro regardless of weight, I bought batteries as well, and about 4 days).
My problem now is the H-bridges, does anyone have an idea of instructions for building these? I will use an Arduino Mega card and 36V/500W/18A motors.
Hello Peter,
I want olso make a segway, but I don’t no where I can find the motors.
Can you sent me the page of china where you buy this.
thnks
I bought the motors and wheels from a Swedish online shop selling scooters like the one I mention in the beginning of this article. Ebay is a good place to find cheap electric motors. This type of motor can be found in different electric vehicles.
Petter,
Excellent work! Very good information on the design also.
I am planning to make one just to try. Do you think I can use Arduino UNO or Arduino MEGA as controller instead of creating board with AtMega168?
I am not good Hardware or software engineer, just trying it out as hobby.
Thanks for sharing.
-N
yes the arduinos should do, they have the same processing power, I’m running it at 20mhz but hat shouldn’t make any difference.
for the 24v motors, what is the voltage required to control the speed? is it just a 5v controller?