Introduction: Drive by Wire Go Kart
I just got a new go kart engine, i went from 6hp to 10hp. This new kohler engine I got I think was not built to put on a go kart, so I had some trouble finding a way to attach the gas petal. Well after a few days of not really figuring anything out, I remembered that I had gotten an arduino about a week ago, and maybe I could use this to help me out.
Step 1: Power and Safety Circuit
below is a diagram of how I go power to the arduino. this way the engine will only start if the arduino is powered on. the first switch is mounted on the box that holds the arduino. the potentiometer i got has a built in switch so to turn on the arduino you have to flip the switch to the box and then turn the potentiometer. i used the led as status light to let me know that the arduino is powered on. i used the relay as a kill switch because if some how the arduino's battery died and the throttle was opened all the way up, it would be very hard to stop. I also put in a manual kill switch. Also below is what I actually did.
Step 2: Arduino
after i got the arduino i ordered the protoshield and put it together with a few modifications to allow me connect the servo and the pot a little easier. Make sure you know what wire connects to what wire especially if you use a usb port to connect the potentiometer and servo.
Step 3: Servo
Now its time to attach the servo. for this I used an "L" bracket (like the kind you would use for book shelves) and cut it in half. Next I drilled the new holes that were going to be used to mount the servo. following that i built a holder for the servo out of an erector set i had then bolted it to the cut in half "L" bracket. finnally i cut to fit the throttle linkage cable and attached it to the carb and the servo, so when the servo turns it also turns the carb. Also i put rubber spacers to absorb shock.
Step 4: Software
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
myservo.attach(9); // attaches the servo on pin 9 to the servo object
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
- The bold numbers are the numbers you change to calibrate the potentiometer and the servo, the 0, 1023 is for the potentiometer and th 0, 179 is for the servo. For me the servo is set at 123, 180. But yours will most likely be different. If you need the software you can just google it. And i think the video does a very good job of explaining what to do.
Step 5: Finnal Step
Now all you got to do is wire the potentiometer and the servo correctly (i used the video to make sure i did it right). Now test and have fun.