Processing App’s Code For Ultrasonic Sesnor Using Arduino



import processing.serial.*;
Serial myPort;
String data=”” ;
PFont myFont;
void setup()
{
size(1366,900); // size of processing window
background(0);// setting background color to black
myPort = new Serial(this, “COM3”, 9600);
myPort.bufferUntil(‘\n’);
}
void draw()
{
background(0);
textAlign(CENTER);
fill(255);
text(data,820,400);
textSize(100);
fill(#4B5DCE);
text(” Distance : cm”,450,400);
noFill();
stroke(#4B5DCE);
}
void serialEvent(Serial myPort)
{

data=myPort.readStringUntil(‘\n’);
}

IF YOU ARE GETTING A STRAY ERROR THEN COPY OR DOWNLOAD THE CODE FROM HERE




Leave a Reply

Your email address will not be published. Required fields are marked *