The Occupy Mars Learning Adventure

Training Jr. Astronauts, Scientists & Engineers

Radar Project 6 for the USA Occupy Mars Tiger Teams

Leave a comment

Students on the USA Tiger Teams are working on special projects that will help occupy Mars.   We are building our collection of solutions and will present that at the Mars Society Convention in Irvine, California in September, 2017.

Arduino Radar

by J.B. Wylzan

Project 25:  Radar Scanner Display
This project shows how objects are detected and displayed on your computer screen imitating a radar monitor. A separate software called Processing 3.0a10 was used to interact with the Arduino R3 IDE.

Hardware:
Microservo SG90
Ultrasonic Sensor
connecting wires
breadboard
Arduino R3 UNO board

Code # 25:

/*
iHacklab Radar Monitor Display
This project, inspired by Dejan Nedelkovski,
was modified to fit the display into a standard computer monitor
reprogrammed by JBWylzan

Using Graphics Interface provided by Processsing 3.0
The example code is public domain */

import processing.serial.*;
import java.awt.event.KeyEvent;
import java.io.IOException;

Serial myPort;
String angle=””;
String distance=””;
String data=””;
String noObject;
float pixsDistance;
int iAngle, iDistance;
int index1=0;
int index2=0;

void setup() {
size (1000, 500);
smooth();
myPort = new Serial(this,”COM4″, 9600);
myPort.bufferUntil(‘.’);
}

void draw() {
fill(98,245,31);
noStroke();
fill(0,4);
rect(0, 0, width, 1010);
fill(98,245,31); // green
drawRadar();
drawLine();
drawObject();
drawText();
}

void serialEvent (Serial myPort) {
data = myPort.readStringUntil(‘.’);
data = data.substring(0,data.length()-1);
index1 = data.indexOf(“,”);
angle= data.substring(0, index1);
distance= data.substring(index1+1, data.length());
iAngle = int(angle);
iDistance = int(distance);
}

void drawRadar() {
pushMatrix();
translate(500,480);
noFill();
strokeWeight(2);
stroke(98,245,31);
arc(0,0,1000,1000,PI,TWO_PI);
arc(0,0,800,800,PI,TWO_PI);
arc(0,0,600,600,PI,TWO_PI);
arc(0,0,400,400,PI,TWO_PI);
arc(0,0,200,200,PI,TWO_PI);
line(-500,0,500,0);
line(0,0,-500*cos(radians(30)),-500*sin(radians(30)));
line(0,0,-500*cos(radians(60)),-500*sin(radians(60)));
line(0,0,-500*cos(radians(90)),-500*sin(radians(90)));
line(0,0,-500*cos(radians(120)),-500*sin(radians(120)));
line(0,0,-500*cos(radians(150)),-500*sin(radians(150)));
line(-500*cos(radians(30)),0,500,0);
popMatrix();
}

void drawObject() {
pushMatrix();
translate(500,480);
strokeWeight(9);
stroke(255,10,10); // red
pixsDistance = iDistance*22.5;
if(iDistance<30){
line(pixsDistance*cos(radians(iAngle)),-pixsDistance*sin(radians(iAngle)),500*cos(radians(iAngle)),-500*sin(radians(iAngle)));
}
popMatrix();
}

void drawLine() {
pushMatrix();
strokeWeight(9);
stroke(30,250,60);
translate(500,480);
line(0,0,500*cos(radians(iAngle)),-500*sin(radians(iAngle)));
popMatrix();
}

void drawText() {
pushMatrix();
textSize(14);
fill(98,245,60);
translate(500,490);
text(“90°”,0,5);
text(“www.iHackLab.blogspot.com        0°”,250,5);
text(“180°”,-500,5);
popMatrix();
}

Challenge:
Use the sketch above and your previous projects on Servo and Ultrasonic to detect objects and monitor them on a radar-like screen display.

Actual Layout:



Procedure:
1. Build the prototype as shown above
2. Run the Processing Interface
3. Select File > New
4. Copy Code #25 above
5. Paste Code #25
6. Click File > Save
7. Click Run
8. Wait for the Screen to display
9. Open previous projects on ultrasonic or servo
10. Upload sketch and run your hands on the ultrasonic

Advertisements

Author: Kids Talk Radio

Bob Barboza is an educator, STEM journalist, software designer and founder of The Occupy Mars Learning Adventures and the Barboza Design and Space Centers. He leads a team of scientists, engineers and STEAM++ educators. They are training students to become Jr. astronauts, scientists and engineers. His team provides internships and workshops in STEAM++ and the integration of Common Core State Standards and Next Generations Science Standards. Contact information: Bob.Barboza@Gmail.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s