top of page

Assignment 5

Electronics

Objective

Combine an input and output device together and collect data for an activity connected to you. Analyze that data and make sense of it. For Example, Reverse parking assist with the help of ultrasonic sensor in automobiles.

Required Components 

-Breadboard

-Cables

-MAX7219 8X32 Matrix Display

-HC-SR04 Ultrasonic display

-Arduino UNO R3

​

CAD Modelling

The model was created using Autodesk TinkerCAD

wiring arduino.png
Code Used

// Including the required Arduino libraries for MAX7219 Display and Ultrasonic sensor

#include <MD_Parola.h>

#include <MD_MAX72xx.h>

#include <SPI.h>

#include <NewPing.h>

​

//Ultrasonic sensor pin settings

#define TRIGGER_PIN 7 // Arduino pin tied to trigger pin on the ultrasonic sensor.

#define ECHO_PIN 6 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define MAX_DISTANCE 500 // Maximum sensor distance is 500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup

​

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

​

// Define size, and output pins

#define MAX_DEVICES 4

#define CS_PIN 3

​

// Create a new instance of the MD_Parola class with hardware SPI connection MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

​

void setup()

{

      Serial.begin(9600); // Open serial monitor at 115200 baud to see ping results.

      // Intialize the object

      myDisplay.begin();

      // Set the intensity (brightness) of the display (0-15)

      myDisplay.setIntensity(1);

      // Clear the display

      myDisplay.displayClear();

}

void loop()

{

      myDisplay.setTextAlignment(PA_CENTER);

      Serial.print(sonar.ping_cm());   // Send ping, get distance in cm and print result (0 = outside set distance range)

      Serial.println("cm"); // check serial monitor

​

if(sonar.ping_cm() < 5 && sonar.ping_cm() > 0) // condition to tell if the object is too close.

​

      {

        myDisplay.print("STOP");

      }

      else{

      myDisplay.print("");

      } 

      delay(50);

}

​

​

Hardware Assembly
img_tush_DCIM.2022.jpg
IMG-0725.PNG
bottom of page