Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Matthew Chiang
Created November 18, 2015

Project Two Third Week: Final

Created a wired remote. Added fasteners. Small chassis modification.

Showcase (no instructions)66
Project Two Third Week: Final

Things used in this project

Hardware components

econowood
For the wired remote control, could've also used acrylic
×1
screws
For fastening the Arduino Uno, L298, and caster
×8
ziptie
For wire management, making everything look clean
×3
stranded wires
For the remote control leash
×6
push button
For the remote controller
×2
trigger switch
For the remote controller
×2
barrier strip
×1
Arduino Proto Shield
Arduino Proto Shield
×1

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

RC-remote AI

There are two remote control paths in this file because the controller has two layers. One layer has smaller holes for the push buttons so that they can be fastened in.

RC-chassis AI

Rounded chassis AI file

Code

rc-controls-wired.ino

Java
RC controls for a wired remote controller
// Matt Chiang
// Des Inv 90-2 Fall 2015

// Which L298 IN is hooked up to which digital pin on the Arduino?
// If you change these, make sure one IN for each motor is linked to a PWM digital pin.
// Motor 1
int IN1 = 7; // IN1 on the L298 is linked to digital pin 7
int IN2 = 6; // pwm
// Motor 2
int IN3 = 4;
int IN4 = 3; // pwm

// The buttons are hooked up to which digital pins?
const int rightTrigger = 9; // the number of the pushbutton pin
const int leftTrigger = 10;
const int leftButton = 11;
const int rightButton = 12;

// Variables
int rightTriggerState = 0; // variable for reading the pushbutton status; 1 on (pressed) 0 off (unpressed)
int leftTriggerState = 0;
int leftButtonState = 0;
int rightButtonState = 0;

const int LED = 13;

void forward() {
  digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, HIGH);
}

void turnLeft() {
  digitalWrite (IN1, LOW); // LOW for stopping
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, HIGH);
}

void turnRight() {
  digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW); // this IN2 could not be working. CHECK IF SOLDERED CORRECTLY
  digitalWrite (IN3, LOW); // LOW
  digitalWrite (IN4, LOW);
}

void reverse() {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);
}

void reverseLeft() {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);
}

void reverseRight() {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, LOW);
}

void brake() {
  digitalWrite (IN1, LOW);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, LOW);
}

void setup() {
  pinMode(IN1, OUTPUT); // Set the pin IN# to behave as an output
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  // Set up the buttons and triggers
  pinMode(rightTrigger, INPUT);
  pinMode(leftTrigger, INPUT);
  pinMode(leftButton, INPUT);
  pinMode(rightButton, INPUT);
}

void loop() {
  rightTriggerState = digitalRead(rightTrigger);
  leftTriggerState = digitalRead(leftTrigger);
  leftButtonState = digitalRead(leftButton);
  rightButtonState = digitalRead(rightButton);

  // Move forward by pressing both triggers
  if (rightTriggerState == 1 && leftTriggerState == 1) {
    forward();
  } else if (leftTriggerState == 1) {
    turnLeft();
  } else if (rightTriggerState == 1) {
    turnRight();
  } else if (leftButtonState == 1 && rightButtonState == 1) {
    reverse();
  } else if (leftButtonState == 1) {
    reverseLeft();
  } else if (rightButtonState == 1) {
    reverseRight();
  } else {
    brake();
  }

}

Credits

Matthew Chiang

Matthew Chiang

16 projects • 9 followers

Comments