Things used in this project

Hardware components:
Ard yun
Arduino Arduino Yun
×1
Ultrasonic Sensor
×1
Servo (generic)
×1
11026 02
Jumper wires (generic)
×10
Software apps and online services:
Ide web
Arduino Arduino IDE
H5g3etjnacmazg8oq17z
MATLAB

Schematics

YunConfig.fzz
Fritzing file for servo and Ultrasonic sensor connections
YunConfig.fzz

Code

matlab_code_to_run_on_pc.mMATLAB
MatLab code to be compiled and executed on PC
theta = 0:(pi/180):pi;
s = serial('COM10');
s.BaudRate=9600
fopen(s)
i = 0;

inc = 1;

while i<180
   A = fgets(s);
   num(i+1) = str2num(A);
   i = i+1;
end
fclose(s)

j = 1

while j<181
    tab(j,1) = (j-1)*inc
    tab(j,2) = num(j)
    tab(j,3) = num(j)*cosd((j-1)*inc)
    tab(j,4) = num(j)*sind((j-1)*inc)
    j = j+1
end
%figure
%polar(theta,num)

plot(tab(:,3),tab(:,4))
Arduino CodeArduino
Arduino Code to be uploaded to Arduino Yun
#include <Servo.h>
#include <NewPing.h>

#define TRIGGER_PIN  12 
#define ECHO_PIN     11  
#define MAX_DISTANCE 200 

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); 
Servo myservo;  

int pos = 0;   
int it = 10;

void setup() {
  myservo.attach(9); 
  Serial.begin(9600);
  delay(3000);
}

void loop() {
  int i = 0;
  int t = 0;
  int a = 0;

  for (i = 0; i < 180; i ++)
  {
    unsigned int uS = sonar.ping();
    myservo.write(i);
    delay(20);
    for (t = 0; t < it; t++)
    {
      uS = sonar.ping();
      a = uS/US_ROUNDTRIP_CM + a;
      delay(30);
    }
    
    a = a / (it-1);
    t = 0;

    Serial.println(a); 
    a = 0;
  }

}

Credits

Aaeaaqaaaaaaaawqaaaajdlhmmy3zgyylthimjatngrjyi05zdqwltbhnzhmzwyyztuxnq
Satyavrat Wagle

I have an active interest in IoT, Wireless Sensor Networks, Single Board Computing Implementations, Embedded Systems, and Robotics.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Guess the Number With Arduino KeyPad
Easy
  • 37
  • 3

Full instructions

A simple and funnies project with an Arduino UNO and the famous keypad shield. Arduino selects a random number, you guess the number.

Control a 7 Segment Display with a keypad!
Easy
  • 52
  • 2

Full instructions

In this project I'll show you a simple way to control a 7 Segment Display with a keypad!

Using 9 Axes Motion Shield with Arduino
Easy
  • 5
  • 1

Protip

The Arduino 9 Axes Motion Shield allows your Arduino to measure movement: orientation, acceleration and magnetic field.

Potentiometer with RGB LED
Easy
  • 30
  • 2

This uses potentiometers to control a RGB LED.

Launch Pad Count Down Sequence Display
Easy
  • 65
  • 2

Work in progress

A 7 Segment Display of a Countdown from 9 to 0 for a Launch Pad Control Panel.

Know the Temp of Your Home From Anywhere with Arduino Cloud!
Easy
  • 1,907
  • 9

Full instructions

Ever wanted to know the temperature of your home from somewhere? Here's an easy way to do it with Arduino Cloud and the Yun Shield!

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog