Close
0%
0%

Radar ultrasonico arduino

utilizando o sensor de Ultrasónico, servo motor
plataforma Arduino mega , Uno ,Nano .

Similar projects worth following
Using Arduino Ce Processing supply 5 v and computer screen, we come to a submarine aircraft tanks of technology.
or pays or contributes Razao social Jose Pedro Rodrigues do Amaral Ribeiro
IBAN BR190036 0305 0392 1000 1101 343C 1
Agencia 3921
Operaçao 001
Conta DV 001110134-3
Codigo SWIF CEFXBRSP

/*

Autor :Jose Pedro R. A. Ribeiro

Data :27/05/2016

Arduino versão 1.6.7

*/

#include <Servo.h> //

Servo leftRightServo; //

int leftRightPos = 0; //

int index = 0; //

long total = 0; //

int average = 0; //

long duration = 0; //

int distance = 0;

// CONFIGURACIÓN:

int echoPin = 53; //

int trigPin = 51; //

int servoPin = 12; //

int servoMin = 700; //

int servoMax = 2400; //

const int numReadings = 2; //

void setup() {

leftRightServo.attach(servoPin,700,2400); //

Serial.begin(9600); //

pinMode(trigPin, OUTPUT); //

pinMode(echoPin, INPUT); //

digitalWrite(trigPin, LOW); //

}

void loop() {

for(leftRightPos = 0; leftRightPos < 180; leftRightPos++) { //

leftRightServo.write(leftRightPos);

for (index = 0; index<numReadings; index++) { //

//

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH, 17400); //

if (!duration){ //

duration = 17400; //

}

distance = duration/58; //

total = total + distance; //

delay(50); //

}

average = total/numReadings; //

total = 0; //

//

Serial.print("X"); //

Serial.print(leftRightPos); //

Serial.print("V"); //

Serial.println(average); //

}

for(leftRightPos = 180; leftRightPos > 0; leftRightPos--) { //

leftRightServo.write(leftRightPos);

for (index = 0; index<numReadings; index++) {

// Pulso de 10us para inicial el modulo

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH, 17400);

if (!duration){

duration = 17400;

}

distance = duration/58;

total = total + distance;

delay(50);

}

average = total/numReadings;

total = 0;

Serial.print("X");

Serial.print(leftRightPos);

Serial.print("V");

Serial.println(average);

}

/*

Autor: Jose Pedro R. A. Ribeiro

Radar Ultrasonico

Processing 3.1.1

Data 27/05/2016 .

*/

import processing.serial.*; //

Serial myPort; //

float x, y; //

int radius = 350; //

int w = 300; //

int degree = 0; //

int value = 0; //

int motion = 0; //

int[] newValue = new int[181]; //

int[] oldValue = new int[181]; //

PFont myFont; //

int radarDist = 0; //

int firstRun = 0; //

int lf = 10; //

void setup(){

size(750, 450); //

background (0); //

myFont = createFont("verdana", 12); //

textFont(myFont); //

println(Serial.list()); //

myPort = new Serial(this,"com7", 9600); //

myPort.bufferUntil(lf); //

}

/* draw the screen */

void draw(){

fill(0); //

noStroke(); //

ellipse(radius, radius, 750, 750); //

rectMode(CENTER); //

rect(350,402,800,100); //

if (degree >= 179) { //

motion = 1; //

}

if (degree <= 1) { //

motion = 0; //

}

/* setup the radar sweep */

/*

We use trigonmetry to create points around a circle.

So the radius plus the cosine of the servo position converted to radians

Since radians 0 start at 90 degrees we add 180 to make it start from the left

Adding +1 (i) each time through the loops to move 1 degree matching the one degree of servo movement

cos is for the x left to right value and sin calculates the y value

since its a circle we plot our lines and vertices around the start point for everything will always be the center.

*/

strokeWeight(7); // set the thickness of the lines

if (motion == 0) { // if going left to right

for (int i = 0; i <= 20; i++) { // draw 20 lines with fading colour each 1 degree further round than the last

stroke(0, (10*i), 0); // set the stroke colour (Red, Green, Blue) base it on the the value of i

line(radius, radius, radius + cos(radians(degree+(180+i)))*w, radius + sin(radians(degree+(180+i)))*w); // line(start x, start y, end x, end y)

}

} else { // if going right to left

for (int i = 20; i >= 0; i--) { // draw 20 lines with fading colour

stroke(0,200-(10*i), 0); // using standard RGB values, each between 0 and 255

line(radius, radius, radius + cos(radians(degree+(180+i)))*w, radius + sin(radians(degree+(180+i)))*w);

}

}

/* Setup the shapes made from the sensor values */

noStroke(); // no outline

/* first sweep */

fill(0,50,0); // set the fill colour of the shape (Red, Green, Blue)

beginShape(); // start drawing shape

for (int i = 0; i < 180; i++)...

Read more »

SG90Servo.pdf

SG90 DETALHES

Adobe Portable Document Format - 125.09 kB - 05/28/2016 at 02:06

Preview
Download

  • 1 × SENSOR ULTRASONICO 5V 4 SAIDAS
  • 1 × PLACA ARDUINO UNO,MEGA,NANO
  • 1 × SERVO SG90
  • 1 × SUPORTE SERVO
  • 1 × FONTE DC 5V

View all 6 components

  • Segunda Versao Super tecnologica

    Jose Pedro R. A. Ribeiro05/29/2016 at 01:13 0 comments

    //Autor Jose Pedro R. A. Ribeiro josepedrofederal@yahoo.com.br 28/05/2016 Processing 3.1.1

    import processing.serial.*;

    Serial myPort;

    int time, i, currentServoAngle, k, m, ANGLE, DISTANCE;

    float ANGLE_RAD;

    float x, y;

    float[] x_mem=new float[200];

    float[] y_mem=new float[200];

    float[] x_width =new float[200];

    float[] y_width =new float[200];

    int CHECK_ANG_INT;

    int CHECK_SON_int;

    int OBJECT_WIDTH = 4;

    PFont Font1;

    void setup() {

    size(800, 400);

    Font1 = createFont("Times New Roman Bold", 16);

    println(Serial.list());

    smooth();

    myPort = new Serial(this, "COM8", 115200);

    translate(400, 400);

    }

    void draw_background()

    {

    background(0, 30, 30);

    fill(0, 102, 51);

    textFont(Font1);

    text("Arduino Radar processing 3.1.1", 10, 30);

    fill(0, 51, 0);

    arc(400, 400, 800, 800, PI, 2*PI, CHORD);

    noFill();

    stroke(0, 251, 32) ;

    arc(400, 400, 700, 700, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 600, 600, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 500, 500, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 400, 400, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 300, 300, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 200, 200, PI, 2*PI, CHORD);

    noFill();

    arc(400, 400, 100, 100, PI, 2*PI, CHORD);

    line(400, 400, 400, 0);

    line(400, 400, 25, 250);

    line(400, 400, 775, 250);

    line(400, 400, 115, 115);

    line(400, 400, 685, 115);

    line(400, 400, 235, 35);

    line(400, 400, 565, 35);

    }

    void draw() {

    draw_background();

    String INPUT_ANGLE = myPort.readStringUntil('*');

    String INPUT_DIST = myPort.readStringUntil('^');

    if (INPUT_ANGLE != null) {

    INPUT_ANGLE = INPUT_ANGLE.replaceFirst("\\*", "");

    ANGLE=int(INPUT_ANGLE);

    ANGLE_RAD=radians(ANGLE);

    currentServoAngle=ANGLE;

    }

    if (INPUT_DIST != null) {

    INPUT_DIST = INPUT_DIST.replaceFirst("\\^", "");

    DISTANCE=int(INPUT_DIST);

    DISTANCE=DISTANCE*5;

    }

    if (1 == 1)

    {

    if (DISTANCE>=300) {

    // Large distance object need not be plotted

    DISTANCE= 0;

    }

    println(DISTANCE);

    println(currentServoAngle);

    i=i+10;

    x=DISTANCE*cos(ANGLE_RAD);

    text(400+x, 10, 60);

    y=DISTANCE*sin(ANGLE_RAD);

    text(400-y, 10, 80);

    x_mem[currentServoAngle]=400+x;

    y_mem[currentServoAngle]=400-y;

    if (DISTANCE < 300 )

    {

    x_width[currentServoAngle] = 400 + ((DISTANCE + OBJECT_WIDTH)*cos(ANGLE_RAD));

    y_width[currentServoAngle] = 400 - ((DISTANCE + OBJECT_WIDTH)*sin(ANGLE_RAD));

    } else {

    x_width[currentServoAngle] = x_mem[currentServoAngle];

    y_width[currentServoAngle] = y_mem[currentServoAngle];

    }

    // if (DISTANCE<400)

    for (k=0; k<180; k++)

    {

    stroke(127, 255, 0);

    fill(127, 255, 0);

    ellipse(400, 400, 4, 4);

    ellipse(x_mem[k], y_mem[k], 4, 4);

    ellipse(x_width[k], y_width[k], 4, 4);

    //line(x_width[k], y_width[k], x_mem[k], y_mem[k]);

    }

    if (i>800) {

    i=0;

    }

    noFill();

    stroke(255, 0, 51) ;

    arc(400, 400, i, i, PI, 2*PI, CHORD);

    arc(400, 400, i-1, i-1, PI, 2*PI, CHORD);

    arc(400, 400, i-2, i-2, PI, 2*PI, CHORD);

    arc(400, 400, i-3, i-3, PI, 2*PI, CHORD);

    arc(400, 400, i-4, i-4, PI, 2*PI, CHORD);

    }

    }

    //lembre se veja qual porta serial que esta no ide arduino defina placa e porta .no caso porta serial "COM8".Coloque a sua no programa linha 19

  • sensor ultrasônico HC-SRO4

    Jose Pedro R. A. Ribeiro05/28/2016 at 19:43 0 comments

    O sensor ultrasônico HC-SR04 funciona como um detector de objetos e permite medir distancias mínimas de 2 centímetros podendo chegar a distancias máximas de até 4 metros com uma precisão de 3 milímetros. Estes sensores emitem um sinal ultrassônico (40 kHz) que ao atingir um objeto, retorna ao sensor. O sinal de retorno é captado, permitindo-se calcular a distância do objeto ao sensor, medindo o tempo de ida e volta do sinal emitido.

    Usando a seguinte fórmula, é possível calcular a distância, sendo que v (velocidade do som) é ~350m/s.

    d[m] = ( v[m/s] * t[s] ) / 2

    Para a contagem do tempo, foi utilizado o Timer1, configurado de modo que incremente a cada 1us.

View all 2 project logs

Enjoy this project?

Share

Discussions

Jose Pedro R. A. Ribeiro wrote 05/28/2016 at 12:40 point

As pessoas pode tambem  aprender português 

termos técnicos são de fácil compreensão.

vou refletir sobre sugestão .

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates