Antony Prasad
Published

Blind Object Scanner

Detecting objects that coming in front of Star Wars vehicle, depends on detecting the monitor gives real time warning in graphical interface

IntermediateShowcase (no instructions)4 hours1,433
Blind Object Scanner

Things used in this project

Hardware components

Photon
Particle Photon
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Capacitor 1 µF
Capacitor 1 µF
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Male/Male Jumper Wires
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1

Software apps and online services

Processing

Story

Read more

Custom parts and enclosures

Background Image

Background image that used in Processing application

Jedi Font

True type font used in the Processing application.

Schematics

Voltage Regulator

Code

Processing Code

C/C++
Code to generate graphical interface
import processing.serial.*;

PImage BackgroundIMG; //Background Image for the application
PFont JediFont; //SqaureFont.ttf from insattled fonts

Serial myPort;  // Create object from Serial class

int   y, 
      MaximuMDistance = 25; // Maximum distance range to be set here
      
float i,
      DistanceRange = 0, // Average pulse rate to be stored accprding to the distance
      DistancePercentage = 0, // Presentage of distance
      ObjectDistance = 0, // Actual object distance with the set range
      DetectorSize = 40, // Maximum size of the detector pulse
      DangerBar = 0; // Danger bar

String ObjectStatus = "", // Object satatus to be displayed
       Weaponstatus = ""; // Weapon status to be displayed
       

void setup() {
  //Size and Background mage setting
  size(1200, 675); 
  BackgroundIMG = loadImage("jedibg.png");
  
  //Load font
  JediFont = createFont("SquareFont",24);
  String portName = Serial.list()[2];
  
  //Setting serial baud rate
  myPort = new Serial(this, portName, 9600);
}

void draw() {
  background(BackgroundIMG);
  
  if ( myPort.available() > 0) {  
    ObjectDistance = myPort.read(); 
  }
  
  noFill();
  strokeWeight(2); 
  stroke(255, 255, 51);
  rect(20, 20, 100, 635);
   
  fill(255, 255, 51, 200);
  textFont(JediFont);
  text("DISTANCE", 880, 50);
  text(ObjectDistance+"CM", 1050, 50);
  
  text("OBJECT", 880, 80);
  text(ObjectStatus, 1050, 80);
  
  text("WEAPON", 880, 110);
  text(Weaponstatus, 1050, 110);
  
  text("PERCENTAGE", 880, 140);
  text(DistancePercentage+"%", 1050, 140);
  
  if (ObjectDistance < MaximuMDistance){
    text("OBJECT DETECTED IN RANGE", 440, 650);
    ObjectStatus = "DETECTED";
    Weaponstatus = "ARMED";
  }else{
    text("NO OBJECTS DETECTED IN RANGE", 420, 650);
    ObjectStatus = "UNDETECTED";
    Weaponstatus = "UNARMED";
    DistancePercentage = 0;
  }
  
  if (ObjectDistance < MaximuMDistance){
  
      DistanceRange = DetectorSize-((ObjectDistance/MaximuMDistance)*DetectorSize);
      DangerBar = 625-((ObjectDistance/MaximuMDistance)*625);
      DistancePercentage = 100-((ObjectDistance/MaximuMDistance)*100);
    
      
      if(DangerBar < 208){
        fill(153, 255, 51, 180);
      }else if(DangerBar > 208 && DangerBar < 416){
        fill(255, 255, 51, 180);
      }else if(DangerBar > 416){
        fill(255, 51, 51, 180);
      }
      
      noStroke();
      rect(25, 650-DangerBar, 91, DangerBar);
    
      translate(width/2, height/2);
      noStroke();
      fill(255, 255, 51, 120);
      ellipse(0, 0, 5, 5);
      ellipse(0, 0, 10, 10);
      
      
      fill(255, 255, 51, 90);
      
      scale(i);
      ellipse(0, 0, 15, 15);
      ellipse(0, 0, 20, 20);
    
      i = i + 2;
      
      if(i>DistanceRange){
        i=0;
      }
  }
}

Photon Code

C/C++
Code to upload to photon, which will make serial communication and writing ultrasonic sensor's data to serial.
int trigPin = D0;    //Trig - green Jumper
int echoPin = D1;    //Echo - yellow Jumper
long duration, cm, inches;

void setup() {
  //Serial Port begin
  Serial.begin (9600);
  //Define inputs and outputs
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop()
{
  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);

  // convert the time into a distance
  cm = (duration/2) / 29.1;

  Serial.write(cm);

  delay(100);
}

Credits

Antony Prasad

Antony Prasad

1 project • 8 followers
You know me...

Comments