Loading...
Pages: 1 [2]   Go Down
Author Topic: Arduino Joystick Coding  (Read 471 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 199
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

stevekap25, Does the go-cart have automotive-type steering? If so, can your client use the steering wheel and use the joystick for throttle and brakes?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

An update to the design we're now working with involves using the joystick to control both acceleration and braking only. We will still be using the previously mentioned components for the system (actuators and drivers) in order to control the throttle and braking of the kart. We ARE NOT using a potentiometer joystick, but one with simple activation switches when pressed either up, down, left, or right.

With that said, ideally, we want the actuators to be enabled and extend when pressed either up or down (throttle or brake) and retracted whenever the joystick is placed back into its natural, neutral position. This is where we would appreciate any help with the coding aspect since we are unsure of how to enable and retract the actuators depending on which position the joystick is in.

Thanks
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 199
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

stevekap25, Does the go-cart have pedals for throttle and brakes? If so, you can add a "joystick" connected to the pedals. The linkages between the "joystick" and pedals would be made so that when the client pushes the "joystick" forward, the linkage would push the throttle pedal forward, making the go-cart run. When the client pulls the "joystick" backward, the linkage would push the brake pedal forward, stopping the go-cart. The linkage would have sliding joints so that one pedal is pushed forward at a time.
Logged

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6552
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
With that said, ideally, we want the actuators to be enabled and extend when pressed either up or down (throttle or brake) and retracted whenever the joystick is placed back into its natural, neutral position.

Code for simple "button" (or switch) operation.

Code:
//zoomkat servo button test 7-30-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}

Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Pages: 1 [2]   Go Up
Print
 
Jump to: