Play Video

21-ULTRASONIC/ULTRASOUND DISTANCE SENSOR/METER

Ultrasonic භාවිතයෙන් දුර මැනීම පිලිබඳව හා Ultrasound තාක්ශනය පිලිබඳව මේ වීඩියෝ එකේ කතා කරනවා.

Task 1 - Basic use of an Ultrasonic sensor

Circuit and Code

Arduino Code එක පහතින් ලබාගන්න.

/*
  by Dileepa Jayawardena
  ii.lk
    Ultrasonic sensor Pins:
        VCC: +5VDC
        Trig : Trigger (INPUT) - Pin11
        Echo: Echo (OUTPUT) - Pin 12
        GND: GND
*/

int trigPin = 11;    //Trig - green Jumper
int echoPin = 12;    //Echo - yellow Jumper
long duration, cm, inches;

void setup() {
  //Serial Port begin
  Serial.begin (9600);
  //Define inputs and outputs
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
}

void loop()
{


  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.

  duration = pulseIn(echoPin, HIGH);

  // convert the time into a distance
  cm = (duration / 2) / 29.1;
  inches = (duration / 2) / 74;

  Serial.print(duration);
  Serial.print(",");

  Serial.print(cm);
  Serial.print("cm,");

  Serial.print(inches);
  Serial.print("inches");
  Serial.println();

}

Task 2 - Ultrasonic Headband

❒ Components

*Arduino Pro mini IC Base
*Arduino Ultrasonic Sensor
*1000mah 3.7V battery (LiPo)
*Buzzer
*Switch
*Wires to connect components

Circuit and Code

Arduino Code එක පහතින් ලබාගන්න.

/*
  by Dileepa Jayawardena
  ii.lk
Ultrasonic sensor Pins:
        VCC: +5VDC
        Trig : Trigger (INPUT) - Pin11
        Echo: Echo (OUTPUT) - Pin 12
        GND: GND
*/
int buzzer = 5;

int trigPin = 11;    //Trig - green Jumper
int echoPin = 12;    //Echo - yellow Jumper
long duration, cm, inches;

void setup() {
  //Serial Port begin
  Serial.begin (9600);
  //Define inputs and outputs
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);

  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
}

void loop()
{


  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.

  duration = pulseIn(echoPin, HIGH);

  // convert the time into a distance
  cm = (duration / 2) / 29.1;
  inches = (duration / 2) / 74;

  Serial.print(cm);
  Serial.print("cm, ");

  Serial.print(inches);
  Serial.print("inches");
  Serial.println();






  if (cm < 30) {
    tone(buzzer, (30 - cm) * 300, 100);
  }
  // delay(50);
}

01 – ARDUINO INTRODUCTION

Play Video 01 – Arduino Introduction මෙම වීඩියෝ මාලාව ලංකාවේ ලක්ශ සංක්්‍ාත පිරිසක් නරභා ඇති වීඩියෝ මාලාවකි. Arduino මූලික දැනීම සම්පූර්ණ කරගැනීමට එම වීඩියෝ මාලාවෙන් හැකි වේ. එසේම නව...

02 – Arduino Boards Review

Play Video 02 – Arduino Boards Review විවිද වර්ගයේ ආර්ඩුයිනෝ බෝඩ් වර්ග වෙලඳපොලේ දකින්නට ලැබෙනවා. අපගේ නිර්මාණ වලට ගැලපෙන සේ අපට අවැසි බෝඩ් තෝරෑ ගැනීමට හැකි වන සේ ඒවාගේ...

03 – Start Programming / Digital Write / Blink LED

Play Video 03 – Start Programming / Digital Write / Blink LED ආර්ඩුයිනෝ ප්‍රොග්‍රැමින්ග් හා පරිපථ නිර්මාණය සඳහා මූලික පියවර තැබීමට මේ වීඩියෝවෙන් බලාපොරොත්තු වෙනවා. ❒ Download Arduino IDE...

0
Would love your thoughts, please comment.x
()
x