Steering is one the most important part while making your own segway.
I'm going to explain you this concept in this article that how steering works. So at first, things that you will require are as follows :
1) Accelerometer ADXL335 (analog 3 axis)
2) Rotary potentiometer
3) Microcontroller (I've used Arduino Uno)
4) Mechanical structure of handle bar (steering)
So why these items?
Mount your accelerometer on handle bar in a suitable position so that is remains fixed on bar.
Basically Accelerometer will sense the tilting of your handle bar as that will send the analog inputs to your microcontroller and as the controller senses these inputs the microcontroller will produce PMW signals that are being put by you in arduino (code) thus these PWM signals will go to you motor driver and thus your motors will actuate accordingly.
If you don't want to use accelerometer you can also use potentiometer beneath your steering and produce analog signals by change in resistance. This part is little complicated so I don't prefer using only potentiometer but you can also use accelerometer as well as potentiometer which will help to bring smoothness in your ride.
The accelerometer module has 5 pins, namely
I'm going to explain you this concept in this article that how steering works. So at first, things that you will require are as follows :
1) Accelerometer ADXL335 (analog 3 axis)
2) Rotary potentiometer
3) Microcontroller (I've used Arduino Uno)
4) Mechanical structure of handle bar (steering)
So why these items?
Mount your accelerometer on handle bar in a suitable position so that is remains fixed on bar.
Basically Accelerometer will sense the tilting of your handle bar as that will send the analog inputs to your microcontroller and as the controller senses these inputs the microcontroller will produce PMW signals that are being put by you in arduino (code) thus these PWM signals will go to you motor driver and thus your motors will actuate accordingly.
If you don't want to use accelerometer you can also use potentiometer beneath your steering and produce analog signals by change in resistance. This part is little complicated so I don't prefer using only potentiometer but you can also use accelerometer as well as potentiometer which will help to bring smoothness in your ride.
The accelerometer module has 5 pins, namely
- GND-To be connected to Arduino's GND
- VCC-To be connected to Arduino's 3.3V
- X-To be connected to Analog Pin A0
- Y-To be connected to Analog Pin A1
- Z-To be connected to Analog Pin A2
Released under the MIT License - Please reuse change and share //Simple code for the ADXL335, prints calculated orientation via serial ////////////////////////////////////////////////////////////////// //Analog read pins const int xPin = 0; const int yPin = 1; const int zPin = 2; //The minimum and maximum values that came from //the accelerometer while standing still //You very well may need to change these int minVal = 265; int maxVal = 402; //to hold the caculated values double x; double y; double z; void setup(){ Serial.begin(9600); } void loop(){ //read the analog values from the accelerometer int xRead = analogRead(xPin); int yRead = analogRead(yPin); int zRead = analogRead(zPin); //convert read values to degrees -90 to 90 - Needed for atan2 int xAng = map(xRead, minVal, maxVal, -90, 90); int yAng = map(yRead, minVal, maxVal, -90, 90); int zAng = map(zRead, minVal, maxVal, -90, 90); //Caculate 360deg values like so: atan2(-yAng, -zAng) //atan2 outputs the value of -π to π (radians) //We are then converting the radians to degrees x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI); y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI); z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI); //Output the caculations Serial.print("x: "); Serial.print(x); Serial.print(" | y: "); Serial.print(y); Serial.print(" | z: "); Serial.println(z); delay(100);//just here to slow down the serial output - Easier to read }
For more help in details visit : ADXL335 IN DETAILS