Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Yanyu ZhongWendy ZhangYu11Katrina JiYufei Shen
Created April 16, 2019

Reversing Radar

Have you ever experienced the pain of parking your car? Reversing Radar is an automatic parking system that allows your car to park itself.

Full instructions provided74
Reversing Radar

Things used in this project

Hardware components

EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1
Grove Starter Kit for LaunchPad
Seeed Studio Grove Starter Kit for LaunchPad
×1
Breadboard (generic)
Breadboard (generic)
×1
Grove - Ultrasonic Ranger
Seeed Studio Grove - Ultrasonic Ranger
×1
Seeed Studio Grove - Buzzer
×1
Seeed Studio Grove - 4-Digit Display
×1
Slide Switch
Slide Switch
×1
DC motor (generic)
×1
Gears
×1
Jumper wires (generic)
Jumper wires (generic)
×1
1N4004 diode
×1
PN2222A transistor
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Through Hole Resistor, 150 ohm
Through Hole Resistor, 150 ohm
×1
Resistor 100 ohm
Resistor 100 ohm
×1

Software apps and online services

Energia
Texas Instruments Energia

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Car Components CAD

This is a zip file that contains all the CADs and DWGs we used to build the car. The CADs are created using Solidworks.

Schematics

Motor and Switch Circuit Diagram

Code

Main Code

Arduino
/* Macro Define */
#define BUZZER_PIN               37            /* sig pin of the Grove Buzzer ,J16 on booster board*/

int length = 1;         /* the number of notes */
char notes[] = "c"; //notes in the song
int beats[] = {1}; //length of each note
int tempo = 200; 

 
#include "TM1637.h" 
#include "Ultrasonic.h"

/* Macro Define */
#define CLK               39              /* 4-Digit Display clock pin J14 on booster board */
#define DIO               38              /* 4-Digit Display data pin */
#define ULTRASONIC_PIN    24              /* pin of the Ultrasonic Ranger *,J6 on booster board*/

/* Global Variables */
TM1637 tm1637(CLK, DIO);                  /* 4-Digit Display object */
Ultrasonic ultrasonic(ULTRASONIC_PIN);    /* Ultrasonic Ranger object */
int distance = 0;                         /* variable to store the distance to obstacles in front */
int8_t bits[4] = {0};                     /* array to store the single bits of the value */
const int switchpin = 31;                 /* switch pin PF4 on board */
const int motorpin =23;                   /* motor  pin PD0 on board */

void setup() {
  /* set switch pin as input */
  pinMode(switchpin, INPUT);
  /* set buzzer pin and motor pin as output */
  pinMode(BUZZER_PIN, OUTPUT); 
  pinMode(motorpin, OUTPUT);
  /* Initialize 4-Digit Display */
    tm1637.init();
    tm1637.set(BRIGHT_TYPICAL);
}

void loop() {
  int switchval;
  switchval = digitalRead(switchpin);             /* read the value from switch pin (LOW ==0, HIGH ==1)*/
  distance = ultrasonic.MeasureInCentimeters();   /* read the value from the sensor */ 
  /*Turn off motor if switch is off*/
  if (switchval == LOW){
    analogWrite(motorpin, 0);
  }
  /*Turn on motor if switch is on and distance is greater than 20cm */
  if (switchval == HIGH && distance >= 20){
    analogWrite(motorpin, 200);
  }
  /*Turn off motor if switch is on and distance is smaller than 10cm */
  else if (distance <10){
    analogWrite(motorpin, 0);
  }
  /*If switch is on and distance is small than 10cm, play buzzer with an interval based on distance */
  if (distance < 20 && switchval ==HIGH){
    playNote(notes[0], beats[0] * tempo);
    delay(distance*20 );
  }
   for(int i = 3; i >= 0; i--) 
      {   
        /* Convert the value to individual decimal digits for display */
        bits[i] = distance % 10;
        distance = distance / 10;  
        tm1637.display(i, bits[i]);                 /* display on 4-Digit Display */
      }
  delay(20);
}
/* play tone */
void playTone(int tone, int duration) 
{
  for (long i = 0; i < duration * 1000L; i += tone * 2) 
  {
    digitalWrite(BUZZER_PIN, HIGH);
    delayMicroseconds(tone);
    digitalWrite(BUZZER_PIN, LOW);
    delayMicroseconds(tone);
  }
}

char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

void playNote(char note, int duration) 
{
  
  
  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) 
  {
    if (names[i] == note) 
    {
      playTone(tones[i], duration);
    }
  }
}

Credits

Yanyu Zhong
1 project • 0 followers
Contact
Wendy Zhang
0 projects • 0 followers
Contact
Yu11
0 projects • 0 followers
Contact
Katrina Ji
2 projects • 0 followers
Contact
Yufei Shen
0 projects • 0 followers
Contact
Thanks to Simon Monk.

Comments

Please log in or sign up to comment.