12/04/2568

Theme 4 วงจรพัฒนาโครงงานการจำลอง Servo motor ควบคุมด้วยการกดติ ปล่อยดับ

 

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้  คำสั่งเขียน 

#include <Servo.h>
Servo myservo;
const int buttonPin = 2;
int button1 = 0;
int click = 0;
int modeServo = 0;
void setup(){
pinMode (buttonPin, INPUT);
myservo.attach(9);
}
void loop(){
button1 = digitalRead(buttonPin);
if (button1 == LOW) {
click = 0;
myservo.write(0);
}
else if(button1 == HIGH){
click++;
if (click == 1) {
modeServo++; } }
if (modeServo == 1){
myservo.write(90);
}
delay(50);

📣ความรู้ไปประยุกต์ใช้อุปกรณ์อิเล็กทรอนิกส์เพื่อสร้างสรรค์เป็นโครงงานตามที่โจทย์กำหนดได้ วงจร 





ไม่มีความคิดเห็น:

แสดงความคิดเห็น

ครูเต้ง เทคโนฯ