บทความ

กำลังแสดงโพสต์จาก เมษายน, 2018

ใบงานที่ 8 Ultrasonic Object Radar System

รูปภาพ
ผู้จัดทำ นางสาวจีรพร  ศรีบุญ  006 นางสาวพิมพ์พิชชา  แสงแจ่ม  037 อุปกรณ์ที่ใช้ 1.บอร์ด Arduino 2.โฟโต้บอร์ด 3.HC-SR04 4.Servo Motor 5.สายแพผู้-ผู้ 6.สายอัปโหลด รูปวงจร Download คลิก คำอธิบาย              เป็นวงจรเรดาร์ตรวจจับวัตถุ โดยใช้ HC-SR04 ที่เป็นเซนเซอร์ และใช้ Servo Motor หมุนหาวัตถุ ถ้า HC-SR04 หมุนไปเจอวัตถุ เรดาร์จะเป็นสีแดง แต่ถ้าไม่เจอวัตถุเรดาร์ก็จะเป็นสีเขียว Code Code Arduino // Includes the Servo library #include <Servo.h>.  // Defines Tirg and Echo pins of the Ultrasonic Sensor const int trigPin = 10; const int echoPin = 11; // Variables for the duration and the distance long duration; int distance; Servo myServo; // Creates a servo object for controlling the servo motor void setup() {   pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output   pinMode(echoPin, INPUT); // Sets the echoPin as an Input   Se...

ใบงานที่ 7 Measure Distance with Arduino and Ultrasonic Sensor

รูปภาพ
ผู้จัดทำ นางสาวจีรพร  ศรีบุญ 6031280006 นางสาวพิมพ์พิชชา  แสงแจ่ม  6031280037 อุปกรณ์ที่ใช้ 1.บอร์ด Arduino 2.Servo Motor (SG90) 3.สายแพผู้-ผู้ 4.HC-SR04 5.สายอัปโหลด 6.โฟโต้บอร์ด รูปวงจร Download คลิก คำอธิบาย เป็นวงจรที่วัดระยะทางที่แสดงผลโดยใช้ Servo Motor โดยใช้เป็นเข็มชี้ตัวเลข และ Monitor จะแสดงผลเป็นระยะทางในหน่วยของ นิ้วและเซนติเมตร และ Monitor แสดงมุมของ servo (Angle) Code #include <Servo.h>  //Load Servo Library int trigPin=13; //Sensor Trip pin connected to Arduino pin 13 int echoPin=11;  //Sensor Echo pin connected to Arduino pin 11 int servoControlPin=6; //Servo control line is connected to pin 6 float pingTime;  //time for ping to travel from sensor to target and return float targetDistance; //Distance to Target in inches float speedOfSound=776.5; //Speed of sound in miles per hour when temp is 77 degrees. float servoAngle; //Variable for the value we want to...