Friday, December 13, 2013

At the expo


Final Product





Complications

Originally the Arduino was meant to power everything on the car. Unfortunatley too many complications with the remote controls we had lead to many problems. Our new code is simple, it just turns the dc motor on and off. Our remote control shifts into high gear on the car when the joystick is pushed forward, and low gear when it is pulled back. Left and Right controls are still controlling the steering.

New code

// named constants for the switch and motor pins
int motorPin =  9; // the number of the motor pin

void setup() {
  // initialize the motor pin as an output:
  pinMode(motorPin, OUTPUT);  
}
void loop() {
// turn motor on:
digitalWrite(motorPin, HIGH);
//analogWrite(motorPin, 100);
}

Thursday, December 12, 2013

Code

#include <Servo.h>

Servo shifterServo;   // Create Servo object for sensor head servo
Servo steerServo;        // Create Servo object for second servo

const int LEDPin = 13;    //control pin for led indicator
const int DcMotorPin = 8; //control in for propulsion
int button1 = 1;
int button2 = 2;
int button3 = 3;
int button4 = 4;






void setup() {
  Serial.begin (9600);
  
  pinMode(LEDPin, OUTPUT);       // Use LED indicator (if required)
  pinMode(DcMotorPin, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  pinMode(button4, INPUT);
  shifterServo.attach(10);
  steerServo.attach(9);
  
  //shift into neutral and point straight ahead
  shifterServo. write (90);
  steerServo.write (90);
}
  
  
  //point straight
  
  void pointStraight(){
    steerServo.write (90);
  }
  
  // stopping
  void stopMotor() {
    Serial.println ("stopping");
    digitalWrite(DcMotorPin, LOW);
    digitalWrite(LEDPin, LOW);
  }
  
  // move forward
  void startMotor() {
    Serial.println ("Moving Forward");
    digitalWrite(DcMotorPin, HIGH);
    digitalWrite(LEDPin, HIGH);
  }
  
  //turn right
  void turnRight() {
    Serial.println("Turning Right");
    steerServo.write(30);
    digitalWrite(LEDPin, HIGH);
  }
  
  //turn left
  void turnLeft() {
    Serial.println("Turning Left");
    steerServo.write(160);
    digitalWrite(LEDPin, HIGH);
  }
  
  //shift high
  void shiftHigh(){
    Serial.println("Shifting High");
   shifterServo.write(75);
   digitalWrite(LEDPin, HIGH);
  }
  
  //shift low
  void shiftLow() {
    Serial.println("Shifting Low");
    shifterServo.write(105);
    digitalWrite(LEDPin, HIGH);
  }
  
  void loop() {
    
    //if throttle is opened
    if (button1 == HIGH){
      shiftHigh();
      startMotor();
    if (button2 == HIGH){
      shiftLow();
      startMotor();
    if (button3 == HIGH){
      turnRight();
    if (button4 == HIGH){
      turnLeft();
    }
    else{
      pointStraight();
    }
    }
    else{
      pointStraight();
    }
    }
    else {
      stopMotor();
    }
    }
    else {
      stopMotor();
    }
  }
      

Controls

27MHz
  • Push joystick forward 
    • Car moves forward in low gear
  • Push joystick backward
    • Car moves forward in high gear
  • Left
    • Car turns left
  • Right
    • Car turns right

Car prototype