Processing code-
import [Link].*;
Serial myPort;
String data = "";
int angle = 0;
int distance = 0;
PFont font, titleFont1, titleFont2;
PImage kvLogo;
void setup() {
size(900, 600);
myPort = new Serial(this, "COM4", 9600); // Change COM port if needed
[Link]('\n');
font = createFont("Consolas", 18);
titleFont1 = createFont("Arial Black", 24); // For school name
titleFont2 = createFont("Arial Black", 20); // For Arduino Radar System
kvLogo = loadImage("kv_logo.png"); // Place "kv_logo.png" in sketch folder
void draw() {
background(10, 20, 10); // Dark radar background
// --- Kendriya Vidyalaya Logo ---
if (kvLogo != null) {
image(kvLogo, width - 110, 10, 90, 60); // Logo top-right corner
}
// --- Title Line 1: School Name ---
textFont(titleFont1);
textAlign(CENTER);
// Golden glowing text
fill(255, 180, 0, 120);
text("PM SHRI Kendriya Vidyalaya CRPF Gandhinagar", width/2 + 2, 42);
fill(255, 215, 0);
text("PM SHRI Kendriya Vidyalaya CRPF Gandhinagar", width/2, 40);
// --- Title Line 2: Arduino Radar System ---
textFont(titleFont2);
fill(0, 255, 150);
text("Arduino Radar System", width/2, 70);
// --- Radar Drawing ---
translate(width/2, height * 0.85); // Lower radar so no overlap
strokeWeight(2);
noFill();
// Radar circles
stroke(0, 100, 0);
for (int i = 1; i <= 4; i++) {
ellipse(0, 0, i * 150, i * 150);
// Angle lines every 30 degrees
stroke(0, 100, 0);
for (int i = 0; i <= 180; i += 30) {
float x = cos(radians(i)) * 300;
float y = -sin(radians(i)) * 300;
line(0, 0, x, y);
// Sweeping radar line
float radarX = cos(radians(angle)) * 300;
float radarY = -sin(radians(angle)) * 300;
stroke(0, 255, 0);
strokeWeight(3);
line(0, 0, radarX, radarY);
// Trail effect
for (int i = 1; i < 50; i++) {
stroke(0, 255, 0, 150 - i * 3);
line(0, 0, cos(radians(angle - i)) * 300, -sin(radians(angle - i)) * 300);
// Detected object (red glow)
if (distance > 0 && distance < 200) {
float objX = cos(radians(angle)) * distance * 1.5;
float objY = -sin(radians(angle)) * distance * 1.5;
noStroke();
for (int i = 3; i >= 0; i--) {
fill(255, 0, 0, 80 - i * 25);
ellipse(objX, objY, 20 + i * 10, 20 + i * 10);
fill(255, 0, 0);
ellipse(objX, objY, 10, 10);
}
// --- Display angle & distance neatly ---
fill(0, 255, 0);
textFont(font);
textSize(16);
textAlign(LEFT);
text("Angle: " + angle + "°", 40, 100);
text("Distance: " + distance + " cm", 240, 100);
void serialEvent(Serial myPort) {
data = [Link]('\n');
if (data != null) {
data = trim(data);
String[] parts = split(data, ',');
if ([Link] == 2) {
angle = int(parts[0]);
distance = int(parts[1]);
arduino code
#include <Servo.h>
Servo myServo;
int trigPin = 10;
int echoPin = 11;
long duration;
int distance;
void setup() {
[Link](9600);
[Link](12);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
for (int i = 0; i <= 180; i++) {
[Link](i);
delay(20);
distance = getDistance();
[Link](i);
[Link](",");
[Link](distance);
}
for (int i = 180; i >= 0; i--) {
[Link](i);
delay(20);
distance = getDistance();
[Link](i);
[Link](",");
[Link](distance);
}
}
int getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
return duration * 0.034 / 2; // convert to cm
}