any ideas PLEASE on how to add 2-3 random targets on the screen using radars ecuation ?( just for the code only, not for the entire project with components and stuff)
Hello and thank you a lot! What I mean is a short simulation of a radar screen that will show or not show some targets(distance, radar cross section or even received power from target) depending on the parameters introduced by the user.(also parameters of the radar range equation, antenna gain, wavelength, transmitted power, etc) So in the end there will be displayed only the targets that fulfill the formulas requirements. What do you think? Thank you a lot ! ❤️
Yeah, I've been researching that too, aiming to create an advanced radar system. If you have any valuable information on this topic, please share. It would help me a lot. Btw thanks for the comment!
So, there are two codes - one for Arduino Uno and the other for graphical representation. To upload the code to the Arduino board, you'll need Arduino IDE. And for the graphical representation, you'll need Processing software
Hey, i built the radar right and so was the code but the board just doesnt turn on (it turns on a very low power led that indicates it is turned on but barely) and it doesnt do anything
Bro my servo motor is not rotating but vibrating and it's showing red in radar when there is no object also pls tell fast only few days for the tec fair
Ma'am, I want to attach it to a boat to detect ships or objects above and below the water. My question is, will it detect the water as well? If yes, how can I stop it from detecting the water?
Hi my friend. Thank you for the video! I want to make an Arduino radar project. Most of the radar projects using Arduino define the object with only one dimension. Whether the object is thin or thick, it draws the entire length on the radar monitor. Is it possible to make a multi-point radar project using Arduino? That is, I will be able to see the size of the object. For example, if there is a box in front of it, I will see it in width and length.
Yeah, most Arduino radar setups, like mine, only measure distance at one point, so they can't show the full size or shape of an object. To get that multi-point radar effect, you'd need more sensors or use something like LIDAR, which scans across the object and gives you more detailed info. It’s definitely possible but would require more complex hardware
interesting that you choose to mute the actual recorded audio. This isn't radar. This is sonar, and I am willing to bet that you can hear an audible beeping form the speakers.
yes, replace this line of code For a range of 2 meters: distance = duration * 0.034 / 2; For a range of 1 meter: distance = duration * 0.017; // Since we want the direct one-way distance,
Fantastic! I would suggest providing a link to the visualization software (rather than providing a 0.5 second image of the software title). Other than that, great work!
You don’t have to link anything basically there are two codes - one for Arduino Uno and the other for graphical representation. To upload the code to the Arduino board, you'll need Arduino IDE. And for the graphical representation, you'll need Processing software
@@SciCraftame with metal detectors but they use Eddie currents to pick up metals in those and some have actual sonar as well ....when i think of Radar i think of m.a.s.h. lol....
would there be a way to do this without using the servo motor? like i get it won't be able to rotate and have a wider span, but can it do the same thing without needing to rotate?
Yeah, why not? Everything is possible, but it will need a different code. Just subscribe to my channel, and I might upload it there. If it's ready, I can personally give you the code
This happens when you try to send an Arduino code to a board. In this case, it is because Processing must be running therefore its using the port. So if you get this message, remember to stop the Processing code before you send the code in Arduino.
To resolve the issue, I'll need pictures of the setup and the error. You can easily reach me at scicraft90@gmail.com or connect with me on Instagram using the handle instagram.com/scicraft9. we can work together to solve this problem.
Actually, this problem also happened to me while making this project. After trying everything possible, I came to realize that my ultrasonic sensor was faulty. After replacing it with a new sensor, then everything is working fine
This happens when you try to send an Arduino code to a board. In this case, it is because Processing must be running therefore its using the port. So if you get this message, remember to stop the Processing code before you send the code in Arduino. Hope it helps.
@@SciCraft i don't know if you will see this but im wondering what you mean with a voltage issue? in what way? does the servo get to little voltage or what do you mean with voltage issue?
Make sure your power supply is strong enough to handle the servo motor. The SG-90 servo usually needs about 500mA to 1A at 5V to work properly. If your power supply isn’t up to the task, it might slow down the servo. Also, check the jumper wires sometimes, a loose or poorly connected wire can cause issues. Make sure all connections are secure and properly seated.
@@AwesomeArnav-ex5li I need to see some video of the issue so I can understand exactly what's happening. You can share the videos with me through my Gmail at scicraft90@gmail.com
It’s a sonar because the ultrasonic sensor uses sound waves to measure distance and locate the object and Radar uses radio waves to detect and locate objects but sorry to mention it as radar because most people think it is radar and search this project as how to make radar using Arduino so that's why
@@CrimsonRoseBDO bayağı bir uğraştım ama radar görüntüsü var servo hareket ediyor fakat yesil ve kırmızı göstergeler yok onlarda kodda integerler fakat hata alıyorum hala.
i hope u still read this comment,i did everything the same way and i got it to work and it working fine but very very slow and the radar would stop working like after 10 sec can u help me pls T-T
It sounds like the issue might be related to the timing or power supply. First, check if the power is consistent and sufficient for the radar and servo. Also, try reducing the delay in the code between radar readings, as a high delay might be causing the slowdown and stopping after 10 seconds. Let me know if that helps!
Well it may 'technically' be a SONAR, but.... I think focusing on that fails to recognise the really good video. It takes ages to produce quality videos. Who gives a shizzle whether it's radio waves or sound waves (Yo' momma??).... exactly! The process is the same anyway! If you'd said "Build your own SONAR" then some daft Next Tuesday would comment "But we don't all live in submarines". Great video, keep the faith!!!
🥺💬 I think SciLab release code with examples of many application, I used to work with MatLab, SciLab, and scientific program there is more application from location-based. Radar is not applicable for detecting objects only but the information you can align the shape of the object and tell about how objects are related on reflection information and is it possible with assumption. Radar can help the investigation to evidence for investigation or attachment more than catch the flying bird only.
Just watch the video, or visit my website where you'll find a link in the description. On my website, you can access the project page and follow the steps to complete it.
@@SciCraft No, most people search for radar, and you trick them into thinking it's radar by not including the recorded sound and by misnaming the video as "Build Your Own DIY Radar System Using Arduino: A Step-by-Step Guide!" No where do you say it's sonar. The only hint we get of it is in the parts list "ultrasonic sensor".
Processing code: import processing.serial.*; // imports library for serial communication import java.awt.event.KeyEvent; // imports library for reading the data from the serial port import java.io.IOException; Serial myPort; // defines Object Serial // defubes variables String angle=""; String distance=""; String data=""; String noObject; float pixsDistance; int iAngle, iDistance; int index1=0; int index2=0; PFont orcFont; void setup() { size (1200, 700); // ***CHANGE THIS TO YOUR SCREEN RESOLUTION*** smooth(); myPort = new Serial(this,"COM5", 9600); // starts the serial communication myPort.bufferUntil('.'); // reads the data from the serial port up to the character '.'. So actually it reads this: angle,distance. } void draw() { fill(98,245,31); // simulating motion blur and slow fade of the moving line noStroke(); fill(0,4); rect(0, 0, width, height-height*0.065); fill(98,245,31); // green color // calls the functions for drawing the radar drawRadar(); drawLine(); drawObject(); drawText(); } void serialEvent (Serial myPort) { // starts reading data from the Serial Port // reads the data from the Serial Port up to the character '.' and puts it into the String variable "data". data = myPort.readStringUntil('.'); data = data.substring(0,data.length()-1); index1 = data.indexOf(","); // find the character ',' and puts it into the variable "index1" angle= data.substring(0, index1); // read the data from position "0" to position of the variable index1 or thats the value of the angle the Arduino Board sent into the Serial Port distance= data.substring(index1+1, data.length()); // read the data from position "index1" to the end of the data pr thats the value of the distance // converts the String variables into Integer iAngle = int(angle); iDistance = int(distance); } void drawRadar() { pushMatrix(); translate(width/2,height-height*0.074); // moves the starting coordinats to new location noFill(); strokeWeight(2); stroke(98,245,31); // draws the arc lines arc(0,0,(width-width*0.0625),(width-width*0.0625),PI,TWO_PI); arc(0,0,(width-width*0.27),(width-width*0.27),PI,TWO_PI); arc(0,0,(width-width*0.479),(width-width*0.479),PI,TWO_PI); arc(0,0,(width-width*0.687),(width-width*0.687),PI,TWO_PI); // draws the angle lines line(-width/2,0,width/2,0); line(0,0,(-width/2)*cos(radians(30)),(-width/2)*sin(radians(30))); line(0,0,(-width/2)*cos(radians(60)),(-width/2)*sin(radians(60))); line(0,0,(-width/2)*cos(radians(90)),(-width/2)*sin(radians(90))); line(0,0,(-width/2)*cos(radians(120)),(-width/2)*sin(radians(120))); line(0,0,(-width/2)*cos(radians(150)),(-width/2)*sin(radians(150))); line((-width/2)*cos(radians(30)),0,width/2,0); popMatrix(); } void drawObject() { pushMatrix(); translate(width/2,height-height*0.074); // moves the starting coordinats to new location strokeWeight(9); stroke(255,10,10); // red color pixsDistance = iDistance*((height-height*0.1666)*0.025); // covers the distance from the sensor from cm to pixels // limiting the range to 40 cms if(iDistance40) { noObject = "Out of Range"; } else { noObject = "In Range"; } fill(0,0,0); noStroke(); rect(0, height-height*0.0648, width, height); fill(98,245,31); textSize(25); text("10cm",width-width*0.3854,height-height*0.0833); text("20cm",width-width*0.281,height-height*0.0833); text("30cm",width-width*0.177,height-height*0.0833); text("40cm",width-width*0.0729,height-height*0.0833); textSize(40); text("SciCraft ", width-width*0.875, height-height*0.0277); text("Angle: " + iAngle +" °", width-width*0.48, height-height*0.0277); text("Distance: ", width-width*0.26, height-height*0.0277); if(iDistance
Thanks for sharing! Really appreciate.🥰
Thank you so much for the Super Thanks! Your support truly touches my heart and boosts my confidence to keep creating great content
tried it and worked completly fine
What should I do as the connection are loose
Broo what kind of library should be use bro ?
any ideas PLEASE on how to add 2-3 random targets on the screen using radars ecuation ?( just for the code only, not for the entire project with components and stuff)
can you explain that to me a little?
Hello and thank you a lot! What I mean is a short simulation of a radar screen that will show or not show some targets(distance, radar cross section or even received power from target) depending on the parameters introduced by the user.(also parameters of the radar range equation, antenna gain, wavelength, transmitted power, etc) So in the end there will be displayed only the targets that fulfill the formulas requirements. What do you think? Thank you a lot ! ❤️
Can you email me this with a straightforward and clear explanation? My Gmail is scicraft90@gmail.com
Does it also work with an arduino nano?
Yep, it will work
@@SciCraft thanks
Does the radar need to be connected to a pc?
How to make a 360° one ?
Select the appropriate servo and do changes in radar code.
what is the processing software? what is it's name?
Its name is Processing.
Hi, it was an interesting project.
I just had one question, if I wanted to shine a laser light on an obstacle when the radar detects it
How will the code changes?
Hello, how can I make the radar stop spinning without having to disconnect it from my PC port?
instagram.com/scicraft9/ - This is my instagram ID , DM me
use chatgpt
My sensor is moving slowly. What seems to be the problem?
My olso
Id be interested to see something like this upscaled for more advanced radar such as doppler. Navigational doppler radar would be neat.
Yeah, I've been researching that too, aiming to create an advanced radar system. If you have any valuable information on this topic, please share. It would help me a lot. Btw thanks for the comment!
How can i use the data from the ultrasonic and make it in use not just displaying it
How do you want to use it??
Which program needs for code?
So, there are two codes - one for Arduino Uno and the other for graphical representation. To upload the code to the Arduino board, you'll need Arduino IDE. And for the graphical representation, you'll need Processing software
Hey, i built the radar right and so was the code but the board just doesnt turn on (it turns on a very low power led that indicates it is turned on but barely) and it doesnt do anything
instagram.com/scicraft9/ - This is my instagram ID , DM me!
Im sorry, i figured it out. Turns out the port on my pc didns supply enough power.@@SciCraft
Hi! what type of connector are you using for the servo motor?
Can you please clarify what you are trying to say?
@@SciCraft like what type of connector are you using to connect the servo motor to the arduino? 2:33
Female-Female jumper wires
@@SciCraft Ok. Thanks!
so how do i make it do things such as turn on a light when an object is detected or play a sound or start a countdown ?
To achieve that, you simply need to modify the code
i think you should clean your breadboard once in awhile
How to add a screen to display that radar
Actually, I'm working on this radar with a separate display, and I will upload soon. Make sure to subscribe to the channel.
Bro my servo motor is not rotating but vibrating and it's showing red in radar when there is no object also pls tell fast only few days for the tec fair
Pls 🥺 help
@@naitiksoni907 Please contact me at my Gmail: scicraft90@gmail.com. We will solve your problem together
how do i make my servo go as fast as your's was cause mine is moving a bit slow
You can reach me at scicraft90@gmail.com or connect with me on Instagram using the handle instagram.com/scicraft9/
Ma'am, I want to attach it to a boat to detect ships or objects above and below the water. My question is, will it detect the water as well? If yes, how can I stop it from detecting the water?
my radar is showing everything red but there is no object can you help me please
instagram.com/scicraft9/ - This is my instagram ID , DM me
I have a problem with the green signal thing it doesn’t move and I tried everything 😢 what shall I do
instagram.com/scicraft9/ - This is my instagram ID , DM me!
Did you find a solution ?
Nice video shot, thank you for sharing it, keep it up :)
Hi my friend. Thank you for the video! I want to make an Arduino radar project. Most of the radar projects using Arduino define the object with only one dimension. Whether the object is thin or thick, it draws the entire length on the radar monitor. Is it possible to make a multi-point radar project using Arduino? That is, I will be able to see the size of the object. For example, if there is a box in front of it, I will see it in width and length.
Yeah, most Arduino radar setups, like mine, only measure distance at one point, so they can't show the full size or shape of an object. To get that multi-point radar effect, you'd need more sensors or use something like LIDAR, which scans across the object and gives you more detailed info. It’s definitely possible but would require more complex hardware
interesting that you choose to mute the actual recorded audio. This isn't radar. This is sonar, and I am willing to bet that you can hear an audible beeping form the speakers.
Yes bro this is a sonar, I had also mentioned in the video
Im new to Arduino , Is there a way to change the Serial.print to output to USB port??
I think is solved, wrong USB port call
Hi how to check the port? I Cannot upload the code to Arduino..as port isnt visible..
May I ask what did you use to make the UI on the computer?
hey, can u tell me how to change the distance range to 2 meters or 1 meter
yes, replace this line of code
For a range of 2 meters:
distance = duration * 0.034 / 2;
For a range of 1 meter:
distance = duration * 0.017; // Since we want the direct one-way distance,
@@SciCraft thanks
also please send me your discord or instagram i have a doubt i will send picture
@@bhbkjujinmjnh instagram.com/scicraft9/
Fantastic! I would suggest providing a link to the visualization software (rather than providing a 0.5 second image of the software title). Other than that, great work!
In the description
please help how to link the arduino IDE and the processing enviroment
You don’t have to link anything basically there are two codes - one for Arduino Uno and the other for graphical representation. To upload the code to the Arduino board, you'll need Arduino IDE. And for the graphical representation, you'll need Processing software
Sonar. Radar uses radio, not sound.
Yes,you are right bro
But most people of the think it is a radar
T.v. antennas used to tell me when someone was walking up to my door lol...
@@SciCraftame with metal detectors but they use Eddie currents to pick up metals in those and some have actual sonar as well ....when i think of Radar i think of m.a.s.h. lol....
@@SciCraftnot if you use the word sonar they wouldn't.
Hey man, i used the code you made, the ultrasonic sensor is moving slowly. Do I need a power source?
can i use this underwater?
I don’t think the current setup would work underwater
greatest of all timeeeeeeeeeeee
Thanks bro❤️
Bro my motor is not rotating what is the problem
can we classify the objects here if we can please share the updated code
Love the smoky bread-board and quite slow.. add an ASCI and more radar sensors (receivers)
100% working bro 10 times worked no problems
Great 👍
I'm not geeting the visual output what is the solution to that?
would there be a way to do this without using the servo motor? like i get it won't be able to rotate and have a wider span, but can it do the same thing without needing to rotate?
Yeah, why not? Everything is possible, but it will need a different code. Just subscribe to my channel, and I might upload it there. If it's ready, I can personally give you the code
@@SciCraft ok! thank you! because this will be very useful for making a prototype of something im making for a school competition.
my radar isnt moving... im not sure whats wrong
How to download that processing software
you have to download processing 3.0 software
I am doing in Mac Book and my port is /dev/c..... what should I do
instagram.com/scicraft9/
Dm me
I constantly get port busy or port not found what should I do?
This happens when you try to send an Arduino code to a board. In this case, it is because Processing must be running therefore its using the port. So if you get this message, remember to stop the Processing code before you send the code in Arduino.
How can I change duration
Which duration?
i got this code in arduino ide: Failed uploading: uploading error: exit status 1
To resolve the issue, I'll need pictures of the setup and the error. You can easily reach me at scicraft90@gmail.com or connect with me on Instagram using the handle instagram.com/scicraft9. we can work together to solve this problem.
My radar is showing all red even when there is no object in front of it.
Actually, this problem also happened to me while making this project. After trying everything possible, I came to realize that my ultrasonic sensor was faulty. After replacing it with a new sensor, then everything is working fine
i dont know why but when it detect something it spin faster
Thank you! It worked!
Glad it helped!
Hello, I encountered an error on line 47, how can I fix it?
what is the error?
hi i am geting a error (avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.) what to do pls tell
Can you please send me the circuit diagram for this.
instagram.com/scicraft9/
Dm me
hello can we do same project using stm32, if yes can u give code for it
instagram.com/scicraft9/ - This is my instagram ID , DM me!
🥺 i really need help how to add sensors gas? is it possible please helppp me
instagram.com/scicraft9/ - This is my instagram ID , DM me!
how far it can detect?
Upto 40cm
can't it move the reach away anymore?
@@SciCraft
ı am getting errror in this part
iAngle = int(angle);
iDistance = int(distance);
The function parseİnt(String) does not exist.
how can ı fix it
I changed the faulty part as follows and set the language to English.
iAngle = parseInt(angle);
iDistance = parseInt(distance);
sir it is not working for me !! it is not showing any errors in code but while uploading it is showing error
What is the error?
@@SciCraft Sorry to bother you sir it is perfectly working now and thank you your time and response.
I'm glad it worked!
I keep getting the port busy message what to do?
This happens when you try to send an Arduino code to a board. In this case, it is because Processing must be running therefore its using the port. So if you get this message, remember to stop the Processing code before you send the code in Arduino.
Hope it helps.
PLEASE HELP ME MY SERVOP IS NOT TURNING PROPERLY MY EXIBITION IS ON 9TH PLEASEE TELL HOW TO SOLVE THIS
Is correctly installed?
Please send me images or a video of your current setup to my Gmail at scicraft90@gmail.com
I want best processing app link plss...... 🙆
Isn't this actually a sonar?
How to add serial port
instagram.com/scicraft9/ - This is my instagram ID , DM me
why is mine moving really slow
It's a voltage issue
@@SciCraft i don't know if you will see this but im wondering what you mean with a voltage issue? in what way? does the servo get to little voltage or what do you mean with voltage issue?
Make sure your power supply is strong enough to handle the servo motor. The SG-90 servo usually needs about 500mA to 1A at 5V to work properly. If your power supply isn’t up to the task, it might slow down the servo. Also, check the jumper wires sometimes, a loose or poorly connected wire can cause issues. Make sure all connections are secure and properly seated.
@@SciCraft thanks, i will try to fix it👍
my processing software is not working it pls help
What is the exact issue?
@@SciCraft every time i start any code it starts and after 2 mins it says not responding and it closes
@@AwesomeArnav-ex5li I need to see some video of the issue so I can understand exactly what's happening. You can share the videos with me through my Gmail at scicraft90@gmail.com
@@SciCraft the radar project you showed that is working but its not giving the out put on he processing application
did u find anything tomorrow is my competition pls help
radar or sonar ?
It’s a sonar because the ultrasonic sensor uses sound waves to measure distance and locate the object and Radar uses radio waves to detect and locate objects but sorry to mention it as radar because most people think it is radar and search this project as how to make radar using Arduino so that's why
100% Woorking ❤
amazing only amazing thank you
Thank you so much 😊
The parseInt(String) function does not exist.
Gives a fault
In the code ?
instagram.com/scicraft9?igshid=MzRlODBiNWFlZA== dm me on instagram
@@SciCraft 47 and 48 processing
@@taylancelik8372 Same problem here. Did you solve the problem. Sorunu çözebildiniz mi hocam.
@@CrimsonRoseBDO bayağı bir uğraştım ama radar görüntüsü var servo hareket ediyor fakat yesil ve kırmızı göstergeler yok onlarda kodda integerler fakat hata alıyorum hala.
How can I contact you?
This is my email - scicraft90@gmail.com
i hope u still read this comment,i did everything the same way and i got it to work and it working fine but very very slow and the radar would stop working like after 10 sec can u help me pls T-T
It sounds like the issue might be related to the timing or power supply. First, check if the power is consistent and sufficient for the radar and servo. Also, try reducing the delay in the code between radar readings, as a high delay might be causing the slowdown and stopping after 10 seconds. Let me know if that helps!
isn't that a sonar sensor not a radar sensor
No sonar it's use for underwater only
its good project, but the circuit diagram and video is different,,
The circuit diagram is the same, but the way of connecting things might be different
Mine is not working you lied😢
Can u send the code please ❤
Codes:-
IDE:-drive.google.com/file/d/177iKPwRGpDglTV7PG5hAgFL8iY_Jm6EP/view?usp=share_link
Processing:- drive.google.com/file/d/1jQ9G55sKmw-xedU3e3QEJNCIltC_npbP/view?usp=drive_link
is the jumper wires a male-male or female-female?
I had used all types of jumpers.
Well it may 'technically' be a SONAR, but.... I think focusing on that fails to recognise the really good video. It takes ages to produce quality videos. Who gives a shizzle whether it's radio waves or sound waves (Yo' momma??).... exactly! The process is the same anyway! If you'd said "Build your own SONAR" then some daft Next Tuesday would comment "But we don't all live in submarines".
Great video, keep the faith!!!
Thank a lot man for your understanding. I truly appreciate it.
everthing works expet the servo motor it doesnt even flinch
it is getting HOT WHAT I DO?????
Is your Arduino board overheating?
@@SciCraft yeeeees!
@@SciCraft what i și wrong and
@@SciCraft is
And processing 4 i downloaded and my PC tells "app not found"
bang kenapa pas di running kok not responding ya
Okay, you can Gmail me:- scicraft90@gmail.com or here is my Instagram ID:- instagram.com/scicraft9/, contact me.
Thanks 🤞🏽
Welcome❤️
Is there a way to stop the servo sensor from spinning once it detects an object?
Yes, it is possible instagram.com/scicraft9/ - This is my Instagram ID, DM me
life saverrrrrr
Thanks :)
Welcome!!❤️☺️
🥺💬 I think SciLab release code with examples of many application, I used to work with MatLab, SciLab, and scientific program there is more application from location-based. Radar is not applicable for detecting objects only but the information you can align the shape of the object and tell about how objects are related on reflection information and is it possible with assumption. Radar can help the investigation to evidence for investigation or attachment more than catch the flying bird only.
thank you so much bro for sharing such a important infomation ❤
How you did this voice
In Microsoft clipchamp video editor
Not working ..😊
Whats the problem?
Can you send me processing code in the comment
instagram.com/scicraft9/
Dm me
IS good see life of inside
This sensor is not rader sensor
how to install processor
can you tell me
Go to this link processing.org/ and download it
thank youuuuuuuuuuuuuuuuuu
Always Welcomeeeeee❤️☺️
thank you i like men
Thank you too
Can u tell me how to make it faster without sending me your insta link
Just watch the video, or visit my website where you'll find a link in the description. On my website, you can access the project page and follow the steps to complete it.
goatttttttt
hello brother I followed your step but my radar is not rotating plz help
instagram.com/scicraft9/ - This is my instagram ID , DM me
Same bro
😍😍
This is not radar…
For this is a sonar but most of people think this is a radar and search for this
@@SciCraft right, which makes this misleading AF…
@@SciCraft No, most people search for radar, and you trick them into thinking it's radar by not including the recorded sound and by misnaming the video as "Build Your Own DIY Radar System Using Arduino: A Step-by-Step Guide!" No where do you say it's sonar. The only hint we get of it is in the parts list "ultrasonic sensor".
You Fail! 😂😂. People are so ready to battle. Great video. I made this my first project. Turned out perfect. Thanks You!
:) hi
Hello 👋
mantap buat steammi sama pak priyo
Processing code:
import processing.serial.*; // imports library for serial communication
import java.awt.event.KeyEvent; // imports library for reading the data from the serial port
import java.io.IOException;
Serial myPort; // defines Object Serial
// defubes variables
String angle="";
String distance="";
String data="";
String noObject;
float pixsDistance;
int iAngle, iDistance;
int index1=0;
int index2=0;
PFont orcFont;
void setup() {
size (1200, 700); // ***CHANGE THIS TO YOUR SCREEN RESOLUTION***
smooth();
myPort = new Serial(this,"COM5", 9600); // starts the serial communication
myPort.bufferUntil('.'); // reads the data from the serial port up to the character '.'. So actually it reads this: angle,distance.
}
void draw() {
fill(98,245,31);
// simulating motion blur and slow fade of the moving line
noStroke();
fill(0,4);
rect(0, 0, width, height-height*0.065);
fill(98,245,31); // green color
// calls the functions for drawing the radar
drawRadar();
drawLine();
drawObject();
drawText();
}
void serialEvent (Serial myPort) { // starts reading data from the Serial Port
// reads the data from the Serial Port up to the character '.' and puts it into the String variable "data".
data = myPort.readStringUntil('.');
data = data.substring(0,data.length()-1);
index1 = data.indexOf(","); // find the character ',' and puts it into the variable "index1"
angle= data.substring(0, index1); // read the data from position "0" to position of the variable index1 or thats the value of the angle the Arduino Board sent into the Serial Port
distance= data.substring(index1+1, data.length()); // read the data from position "index1" to the end of the data pr thats the value of the distance
// converts the String variables into Integer
iAngle = int(angle);
iDistance = int(distance);
}
void drawRadar() {
pushMatrix();
translate(width/2,height-height*0.074); // moves the starting coordinats to new location
noFill();
strokeWeight(2);
stroke(98,245,31);
// draws the arc lines
arc(0,0,(width-width*0.0625),(width-width*0.0625),PI,TWO_PI);
arc(0,0,(width-width*0.27),(width-width*0.27),PI,TWO_PI);
arc(0,0,(width-width*0.479),(width-width*0.479),PI,TWO_PI);
arc(0,0,(width-width*0.687),(width-width*0.687),PI,TWO_PI);
// draws the angle lines
line(-width/2,0,width/2,0);
line(0,0,(-width/2)*cos(radians(30)),(-width/2)*sin(radians(30)));
line(0,0,(-width/2)*cos(radians(60)),(-width/2)*sin(radians(60)));
line(0,0,(-width/2)*cos(radians(90)),(-width/2)*sin(radians(90)));
line(0,0,(-width/2)*cos(radians(120)),(-width/2)*sin(radians(120)));
line(0,0,(-width/2)*cos(radians(150)),(-width/2)*sin(radians(150)));
line((-width/2)*cos(radians(30)),0,width/2,0);
popMatrix();
}
void drawObject() {
pushMatrix();
translate(width/2,height-height*0.074); // moves the starting coordinats to new location
strokeWeight(9);
stroke(255,10,10); // red color
pixsDistance = iDistance*((height-height*0.1666)*0.025); // covers the distance from the sensor from cm to pixels
// limiting the range to 40 cms
if(iDistance40) {
noObject = "Out of Range";
}
else {
noObject = "In Range";
}
fill(0,0,0);
noStroke();
rect(0, height-height*0.0648, width, height);
fill(98,245,31);
textSize(25);
text("10cm",width-width*0.3854,height-height*0.0833);
text("20cm",width-width*0.281,height-height*0.0833);
text("30cm",width-width*0.177,height-height*0.0833);
text("40cm",width-width*0.0729,height-height*0.0833);
textSize(40);
text("SciCraft ", width-width*0.875, height-height*0.0277);
text("Angle: " + iAngle +" °", width-width*0.48, height-height*0.0277);
text("Distance: ", width-width*0.26, height-height*0.0277);
if(iDistance