Arduino Project Hub

Final Project

arduino bluetooth vehicle (final designed chassis)h

  • 547 views
  • 0 comments
  • 2 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Tens70
9V battery (generic)
×1
Adafruit industries ada830 image 75px
4xAA battery holder
×1
Adafruit nRF8001 Bluefruit LE
×1
Rhxvhx2dhljmbtloxexc
Arduino Proto Shield
×1
09670 01
SparkFun Dual H-Bridge motor drivers L298
×1
DC motor (generic)
×2
DC motor wheels
×2

Necessary tools and machines

Lasercutter
Laser cutter (generic)

About this project


old prototypes

drawings 


inspiration



Before I even began to think about how my final chassis was going to look like I became obsessed with the idea of eliminating all of the useless space that plagued my previous designs. I wanted to reduced the car to its most essential components. So I began with what I knew I absolutely couldn't live without

1 arduino 

1 adafruit nRF8001 Bluefruit LE


1  proto shield 

1 9v battery 

4 AA batteries 

1 l298n h-bridge


I spend many hours thinking about the many possible ways that I could arrange these components together trying to optimize for the least amount of empty space. Ultimately I opted for a vertical arrangement  and made a box to house all of the components with the h bridge connected from the outside, again to have as little empty space as possible. 

I named this box "the heart".  

The idea behind "the heart" was that by having a clear understanding of the space I needed to house all of the electrical components of the car. I simultaneously gave myself the most amount of freedom to design the rest of the car.

Now the only constraint I had was that whatever I ended up settling on had to have a 8 x 6.5 cm carriage to house "the heart", with the added benefit that I could take "the heart" on and off for testing, or that i could have multiple chassis iteration that use the same "heart"





After making the heart and testing that it functioned properly I moved on to designing the main carriage that would hold the car. Again placing a great deal of emphasis on making something that didn't have have anything extra.

what I came up with was basically two walls, a floor that only covered half of the space created by the walls and three columns to keep the two walls at equal distances from each other.  

this can be best understood in the drawing underneath. 


after creating the heart and the carriage next I begun working on the caster wheel which would be located in between the two walls of the carriage. though it's design was rather straightforward getting the suspension to work properly required a great deal of rubber bands which in turn required many hours of testing what worked and what didn't. 

after making the caster wheel I set off to create the two arms that would carry the the two motors. again being obsessed with this idea of utilizing the least amount of material possible. I decided to make the arms out of  a single sheet of plywood. In addition to this I wanted to laser cut a bending pattern in one section of the arm and use rubber bands to shape the arm into a specific form. 

I was very exited about this idea because I thought that bent wood and tension forces could work really well together. 

Though the wood came out much better than I anticipated and worked in conjunction with the rubber bands just I had imagined I soon realized that bend wood wasn't going to work for this project, as  it created another degree of freedom that I had not  accounted for since the beginning of the design.

given that the suspension was going to be so central to the design of the car I had to make sure that the parts that were supposed to be solid (the wood) was indeed solid, and didn't move in unexpected ways.

Looking forward I have to say that if i had 2 more weeks to work on this I am confident that I could have created a vehicle from a single piece of plywood that was bend into shape by way of rubber bands. But given that this wasn't the case and I didn't have 2 more weeks. I became growingly concerned with the functionality of my vehicle, so I scraped the bend wood plan all together and opted for creating solid arms. 


when thinking about the shape of these arms I was inspired by the work of Frank Stella. 


originally my idea was to only have a set of arms that would be connected to the main carriage by way  rubber bands, but I ran into some problems given that the arms tilted toward the carriage from the force of the rubber bands and didn't stay perpendicular to the ground. This in turn forced me to increase the length of the stick running through the carriage and to added a second set of walls to pull the arms from the side opposite to the carriage so as to keep the arms perpendicular to the ground.  

Because the second set of wall were only kept up by the stick running through the carriage they had a tendency to spin out of position. to fix this i connected the walls of the carriage to the second set of walls via rubber bands. 

Even after all this the car still performed rather poorly as the components were far too loose. this forced me to add a two columns connecting the two arms caring the motors, so as to assure that they always remained equidistantly from one another. 


towards the end I let go of my resolution to make the most basic car ever and steered instead to making something that worked properly first and foremost. I am certain that if i'd followed through with my initial rigor all the way till the end the results would have been much better but given the time constraints I am satisfied with what I was able to accomplish. 


finally I should note that another of the main ideas behind this chassis design was to design  vehicle that was held entirely by rubber bands, which I'm happy to say i achieved. NO glue was used in the creation of this vehicle




CODE


my original code was malfunctioning in the sense that it only registered when a button was pressed and not when it was released so whenever I  pressed a button the car just kept going on forever, and the only way to stop it was to power it off. 

To fix this I looked at the Adafruit website as well as my classmates code to see how they'd gotten it to work.  apparently each time a button is released a package of 4 bytes is send which contains data for identifying the type button and whether the button is being pressed or released, using this information it is possible to use if / else statements to define the behavior of the car using the up down left right arrows in such a way that when no buttons are pressed the car stops.

iI got the idea to use if / else statements from  Matt's and Sahil's code. 




Schematics

schematic
Fullsizerender

Code

bluetooth motor control for vehicle from modified callback echo Arduino
/*********************************************************************
This is an example for our nRF8001 Bluetooth Low Energy Breakout

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/1697

Adafruit invests time and resources providing this open source code, 
please support Adafruit and open-source hardware by purchasing 
products from Adafruit!

Written by Kevin Townsend/KTOWN  for Adafruit Industries.
MIT license, check LICENSE for more information
All text above, and the splash screen below must be included in any redistribution
*********************************************************************/

// This version uses call-backs on the event and RX so there's no data handling in the main loop!

#include <SPI.h>
#include "Adafruit_BLE_UART.h"

#define ADAFRUITBLE_REQ 10
#define ADAFRUITBLE_RDY 2
#define ADAFRUITBLE_RST 9

Adafruit_BLE_UART uart = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);

boolean messageReceived = false;
uint8_t message[20];

// L298 dual H-bridge to Arduino connections 

// DC Motor 1
int M1_1 = 6; // M1_1 connected to digital pin 6 
int M1_2 = 5; // M1_2 connected to digital pin 5 

// DC Motor 2
int M2_1 = 4; // M2_1 connected to digital pin 4 
int M2_2 = 3; // M2_2 connected to digital pin 3 

// defines button input 
char button = '0';

/**************************************************************************/
/*!
    Motor control functions
*/
/**************************************************************************/

void up() {
  digitalWrite (M1_1, HIGH);
  digitalWrite (M1_2, LOW);
  digitalWrite (M2_1, LOW);
  digitalWrite (M2_2, HIGH);
}

void left() {
  digitalWrite (M1_1, HIGH); 
  digitalWrite (M1_2, LOW);
  digitalWrite (M2_1, HIGH);
  digitalWrite (M2_2, LOW);
}

void right() {
  digitalWrite (M1_1, LOW);
  digitalWrite (M1_2, HIGH); 
  digitalWrite (M2_1, LOW); 
  digitalWrite (M2_2, HIGH);
}

void down() {
  digitalWrite (M1_1, LOW);
  digitalWrite (M1_2, HIGH);
  digitalWrite (M2_1, HIGH);
  digitalWrite (M2_2, LOW);
}

void stopp() {
  digitalWrite (M1_1, LOW); 
  digitalWrite (M1_2, LOW);
  digitalWrite (M2_1, LOW);
  digitalWrite (M2_2, LOW);
}


/**************************************************************************/
/*!
    This function is called whenever select ACI events happen
*/
/**************************************************************************/
void aciCallback(aci_evt_opcode_t event)
{
  switch(event)
  {
    case ACI_EVT_DEVICE_STARTED:
      Serial.println(F("Advertising started"));
      break;
    case ACI_EVT_CONNECTED:
      Serial.println(F("Connected!"));
      break;
    case ACI_EVT_DISCONNECTED:
      Serial.println(F("Disconnected or advertising timed out"));
      break;
    default:
      break;
  }
}

/**************************************************************************/
/*!
    This function is called whenever data arrives on the RX channel
*/
/**************************************************************************/
void rxCallback(uint8_t *buffer, uint8_t len)
{
  Serial.print(F("Received "));
  Serial.print(len);
  Serial.println(F(" bytes: "));
  for(int i=0; i<len; i++)
   Serial.print((char)buffer[i]); 

  Serial.print(F(" ["));

  for(int i=0; i<len; i++)
  {
    Serial.print(" 0x"); Serial.print((char)buffer[i], HEX); 
  }
  Serial.println(F(" ]"));


  // vehicle control

   if ((char)buffer[1] == 'B') { // char is a  data type that takes up 1 byte of memory that stores a character value
    if((char)buffer[3] == '0') {
      button = '0';    //creates a state when no buttons are pressed so that the car stops instead of continuously performing the task of the last button pressed 
    } else {
      button = (char)buffer[2];     // selects direction, which creates a specific motor output.
    }
  }

  if (button == '0') {
    stopp();                  // stop  
  } else if (button == '5') { // up
    up();
  } else if (button == '6') { // down 
    down();
  } else if (button == '7') { // left 
    left();
  } else if (button == '8') { // right 
    right();
  }


  /* Echo the same data back! */
  uart.write(buffer, len);
}

/**************************************************************************/
/*!
    Configure the Arduino and start advertising with the radio
*/
/**************************************************************************/
void setup(void)
{ 
  Serial.begin(9600);
  while(!Serial); // Leonardo/Micro should wait for serial init
  Serial.println(F("Adafruit Bluefruit Low Energy nRF8001 Callback Echo demo"));

  uart.setRXcallback(rxCallback);
  uart.setACIcallback(aciCallback);
  uart.setDeviceName("GABO"); /* 7 characters max! */
  uart.begin();

  pinMode(M1_1, OUTPUT); // makes it so that pins connected to h-bridge work as outputs
  pinMode(M1_2, OUTPUT);
  pinMode(M2_1, OUTPUT);
  pinMode(M2_2, OUTPUT);
}

/**************************************************************************/
/*!
    Constantly checks for new events on the nRF8001
*/
/**************************************************************************/


void loop()
{
  uart.pollACI();
  
}

Comments

Author

Andres Duarte
  • 9 projects
  • 2 followers

Published on

February 7, 2017

Members who respect this project

Avatar?size=thumb

and 1 other

See similar projects
you might like

Similar projects you might like

Easiest Way to Add A Full Color LCD Display

by Ushijima

  • 4,595 views
  • 2 comments
  • 5 respects

Happy birthday melody on Arduino Nano with 3-way polyphony

Project tutorial by Liss

  • 1,453 views
  • 6 comments
  • 21 respects

Kaleidoscope Infinity Mirror

Project tutorial by Lucas Ainsworth

  • 3,163 views
  • 0 comments
  • 29 respects

Pet Feeder

by Namsulee

  • 908 views
  • 0 comments
  • 5 respects
Add projectSign up / Login