//-------------------------------------------------------------------------------------------------------
// -------------------------------------------- RADAR ---------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// ------------------------------ SERIAL PRINT (ARDUINO TO PROCESSING) ----------------------------------
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//Program Variables
float xcoord, ycoord, xcoord2, ycoord2; //x and y coordinates
int angle;
int angle2;
//-------------------------------------------------------------------------------------------------------
// ---------------------------------------- RADAR SWEEPER -----------------------------------------------
//-------------------------------------------------------------------------------------------------------
float radius = 500; // Radius of radar sweep
float hyp = 500; // sweep arm length
float frequency = (1); //speed of sweep default = 1 (is it possible to lower the frequency?????)
int sweep = 0; // 0 = anti-clockwise 1 = clockwise
//-------------------------------------------------------------------------------------------------------
// FONT
PFont myFont;// uses a library to create font
//-------------------------------------------------------------------------------------------------------
// ------------------------------------- WINDOW SIZE & FONT ---------------------------------------------
//-------------------------------------------------------------------------------------------------------
// SETUP WINDOW AND FONT
void setup(){
size(1000, 500); // Window size
myFont = createFont("Verdana", 20); // System font
textFont(myFont);}
//-------------------------------------------------------------------------------------------------------
// ----------------------------------- WINDOWS BACKGROUND COLOUR ----------------------------------------
//-------------------------------------------------------------------------------------------------------
void draw(){
background (#00569B); // Window background colour
noStroke();
//-------------------------------------------------------------------------------------------------------
fill(255); // Length of vertical line
smooth();
//-------------------------------------------------------------------------------------------------------
// -------------------------------------- BEGINNING OF CIRCLES ------------------------------------------
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, radius2, radius2); // Position of circles
stroke(180); // How dark the line is
fill(250);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-100, (radius2)-100);
stroke(180);
fill(245);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-200, (radius2)-200);
stroke(180);
fill(240);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-300, (radius2)-300);
stroke(180);
fill(235);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-400, (radius2)-400);
stroke(180);
fill(230);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-500, (radius2)-500);
stroke(180);
fill(225);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-600, (radius2)-600);
stroke(180);
fill(220);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-700, (radius2)-700);
stroke(180);
fill(215);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-800, (radius2)-800);
stroke(180);
fill(210);
smooth();
//-------------------------------------------------------------------------------------------------------
ellipse(width/2, 500, (radius2)-900, (radius2)-900);
stroke(180);
//-------------------------------------------------------------------------------------------------------
line(width/2, 500, 500, 0);
stroke(180);
//-------------------------------------------------------------------------------------------------------
// ---------------------------------------- END OF CIRCLES ----------------------------------------------
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// ------------------------------------------- SWEEPER --------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// ROTATES LINE AROUND CIRCLE
xcoord = radius + cos(radians(angle))*hyp;
ycoord = radius + sin(radians(angle))*hyp;
stroke(#FF0011); // default = 1 (BLACK)
line(width/2, 500, xcoord, ycoord); // Set position of sweep point
//-------------------------------------------------------------------------------------------------------
// ------------------------------------------ CALCULATIONS ----------------------------------------------
//-------------------------------------------------------------------------------------------------------
// keep reinitializing to 0, to avoid flashing during redrawing
angle2 = 0;
if(sweep == 0)
{
angle -= frequency;
}
else if(sweep == 1) // 1 = repeats 0 = moves once
{
angle += frequency;
}
if(angle == 0)
{
sweep = 0;
}
else if(angle == -180) //At 180 degrees, the sweeper stops and goes back (default = -180)
{
sweep = 1; // 1 = repeats 0 = 0-360°+ (default = 1)
}
//-------------------------------------------------------------------------------------------------------
// --------------------------------------------- TEXT ---------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// TEXT ONLY
text("Radar Example", 20, 30); // Last co-ordinates are to set position of text
text("Sweep Angle = "+angle, 790, 30); // Co-ordinates for text
text("x = "+xcoord, 790, 55); // x axis position
text("y = "+ycoord, 790, 75); // y axis position
}
//-------------------------------------------------------------------------------------------------------