ใบงานที่ 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...