Arduino Controlled Fire Truck

Introduction: Arduino Controlled Fire Truck

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

This is a 3D printed fire truck as I have designed it. There are several improvements that could be made, however this should provide a basic understanding of the process

Supplies:

  • 3D printer + filament
  • Arduino + USB cable
  • IR remote
  • IR sensor
  • LEDs (6+)
  • Breadboard
  • Portable battery
  • Misc wires
  • Hobby motor(s) + controller
  • Hobby wheels
  • Misc nuts and bolts (#4 required for Arduino mount)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Design

Design the truck in your favorite 3D rendering software (I used SolidWorks).

Be sure when designing to take into account the physical size of components such as the battery pack, motors, and any other components that will be mounted. Also take into account how the print will complete, and design from the bottom up, or the top down.

Notice how mine all print from the top down and have no overhanging edges.

Step 2: 3D Printing

Use the parts created in 3D software in the 3D printer to to print the physical objects.

Step 3: Programming

Create the Arduino program to control the vehicle. Be sure to test your remote and the available buttons to ensure the Arduino reads the buttons correctly. My code includes a callout in the beginning of all of the buttons that are on my remote.

The IR remote library can be found on the MakeCourse website here: https://makecourse.weebly.com/week9segment1.html

The Arduino code is as follows (wouldn't allow me to upload the file):

/*********************
Created for the MakeCourse at USF Purpose: To create a Arduino program to control a fire truck Created by: Kyle Marques *********************/ #include //Includes the reqired IR remote libraries

/* Remote Codes: * [CH- = -23971] [CH = 25245 ] [CH+ = -7651 ] * [PREV = 8925 ] [NEXT = 765 ] [PAUSE = -15811] * [VOL- = -8161 ] [VOL+ = -2241 ] [EQ = -28561] * {0 = 26775] [100+ = -26521] [200+ = -20401] * [1 = 12495] [2 = 6375 ] [3 = 31365 ] * [4 = 4335 ] [5 = 14535 ] [6 = 23205 ] * [7 = 17085] [8 = 19125 ] [9 = 21165 ] *

/Declarations #define FIND 11 //IR reciever tied to pin 11 and called FIND IRrecv SENSE(FIND); //IR Sensor labeled as SENSE for pin FIND decode_results results;

#define LEDA 2 //LED set 1 tied to pin 2 #define LEDB 3 //LED set 2 tied to pin 3

//Motor pin definitions #define MOTBF 4 #define MOTBB 5 #define MOTAB 6 #define MOTAF 7

//Internal variable setup int val = 0; //Internal variable for sensor reading int lightON = 0; //On/Off for warnings int lightSWITCH = 0; //Warning set int butNUM = 0; //Button Pressed int repeat = 0; //Is repeating?

unsigned long resetINT = 250; //time after which a button not held is turned off [ms] unsigned long warnINT = 200; //time between switching warning lights[ms] unsigned long resetMillis = 0; //Variable for repeating unsigned long warnMillis = 0; //last time we switched warning lights [ms]

void setup() { //Serial.begin(9600); //Enable the serial port to verify values Remove commenting for debugging SENSE.enableIRIn();

//Pin Setup pinMode(LEDA, OUTPUT); pinMode(LEDB, OUTPUT); pinMode(MOTAF, OUTPUT); pinMode(MOTAB, OUTPUT); pinMode(MOTBF, OUTPUT); pinMode(MOTBB, OUTPUT); }

void loop() { unsigned long currentMillis = millis();

if (SENSE.decode(&results)) {val = results.value; //Set val as the result // Serial.println(val); //Remove commenting to see debug window in the serial monitor resetMillis = currentMillis; SENSE.resume();} if(currentMillis - resetMillis < resetINT) //Checks to see if the remote button is held down {repeat = 1;} else {repeat = 0;} switch (val) //Case structure for what button is pressed Change the values here for your remote {case 12495: butNUM = 1; break; case 6375: butNUM = 2; break; case 31365: butNUM = 3; break; case 4335: butNUM = 4; break; case 14535: butNUM = 5; break; case 23205: butNUM = 6; break; case 26775: butNUM = 10; break;} if(repeat == 0) //Reset if no button is pressed {butNUM = 0;}

//Number is pressed and held (1-6) for motors if(butNUM == 1 && repeat == 1) {digitalWrite(MOTAF, HIGH);} else if(butNUM == 2 && repeat == 1) {digitalWrite(MOTAF, HIGH); digitalWrite(MOTBF, HIGH);} else if(butNUM == 3 && repeat == 1) {digitalWrite(MOTBF, HIGH);} else if(butNUM == 4 && repeat == 1) {digitalWrite(MOTAB, HIGH);} else if(butNUM == 5 && repeat == 1) {digitalWrite(MOTAB, HIGH); digitalWrite(MOTBB, HIGH);} else if(butNUM == 6 && repeat == 1) {digitalWrite(MOTBB, HIGH);} else {digitalWrite(MOTAF, LOW); digitalWrite(MOTBF, LOW); digitalWrite(MOTAB, LOW); digitalWrite(MOTBB, LOW);}

//Warning Lights //On/Off if(butNUM == 10 && lightON == 0) //Turn Warnings ON {lightON = 1; butNUM = 0;} if(butNUM == 10 && lightON == 1) //Turn Warnings OFF {lightON = 0; butNUM = 0;} //Changing if(lightON == 1) {if(currentMillis - warnMillis > warnINT) {if(lightSWITCH == 0) {digitalWrite(LEDA, HIGH); digitalWrite(LEDB, LOW); lightSWITCH = 1;} else if(lightSWITCH = 1) {digitalWrite(LEDA, LOW); digitalWrite(LEDB, HIGH); lightSWITCH = 0;} warnMillis = currentMillis;}} if(lightON == 0) //RESET Warnings {digitalWrite(LEDA, LOW); digitalWrite(LEDB, LOW);} val = 0; }

Step 4: Assembly and Testing

Test the code with the Arduino and assemble the truck. Take care when attaching the LEDs as their leads are very ductile.

Be the First to Share

    Recommendations

    • Magnets Challenge

      Magnets Challenge
    • Snow Challenge

      Snow Challenge
    • Wearables Contest

      Wearables Contest

    Discussions