ardu.accel.mc.jpg (2999347Bytes)
Hello
I am trying to build a segway, I know how I am going to make it, but I have been struggling to get the motorcontroller to work for days now.
I attached an accelerometer and a motorcontroller to an arduino uno. When I tilt the accelerometer 2 indicatorlights on the motorcontroller change, so this signal must be right. But when I measure the voltage at the motor output I get only 10-60 mV.
I tried using more and using less Volt (5-15 V) on the m.c. board itself. (I attached it to an old model train transformator)
Please Help
Datasheet motor controller: http://blog.pennybuying.com/down/f/F815A.pdf
Accelerometer adxl335 : http://www.ebay.com/itm/ADXL335-3-Axis-Accelerometer-Breakout-for-MultiWii-MWC-KK-ACM-Flighter-/271015397818?pt=LH_DefaultDomain_0&hash=item3f19c6c9ba
Motorcontroller: http://www.ebay.com/itm/150979837048?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
Code:
const int ypin = A2; // y-axis
int s;
// motor A
int dir1PinA = 2;
int dir2PinA = 3;
int speedPinA = 9;
//motor B
int dir1PinB = 4;
int dir2PinB = 5;
int speedPinB = 10;
unsigned long time;
int Speed;
int dir;
void setup(){
pinMode(dir1PinA, OUTPUT);
pinMode(dir2PinA, OUTPUT);
pinMode(speedPinA, OUTPUT);
pinMode(dir1PinB, OUTPUT);
pinMode(dir2PinB, OUTPUT);
pinMode(speedPinB, OUTPUT);
time = millis();
Speed = 255;
}
void loop(){
analogWrite(speedPinA, Speed);
analogWrite(speedPinB, Speed);
s = analogRead(ypin);
//set direction
if(s>520){
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
digitalWrite(dir1PinB, HIGH);
digitalWrite(dir2PinB, LOW);
} else if(s<490){
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinB, HIGH);
digitalWrite(dir1PinB, LOW);
}else if(490<=s<=520){
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinB, LOW);
digitalWrite(dir1PinB, LOW);
}
}
https://www.youtube.com/watch?v=f5CBetSD7hU