ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

ขอสอบถามเกี่ยวกับตัวโค้ตหน่อยนะครับ

หนึ่ง
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int ledPin = 13;
int pirPin = 10;
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
int counter = 0;
int currentState = 0;
int previousState = 0;

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(pirPin, INPUT); // declare sensor as input
lcd.begin(16, 2);
lcd.setCursor(4, 0);
lcd.print("counter");
}
void loop(){
val = digitalRead(pirPin); // read PIR sensor input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
currentState = 1;
// We only want to print on the output change, not state
pirState = HIGH;
delay(1000);
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
currentState = 0;
// We only want to print on the output change, not state
pirState = LOW;
}
}
if(currentState != previousState){
if(currentState == 1){
counter = counter + 1;
lcd.setCursor(4,1);
lcd.print(counter);
delay(200);
}
}
}

ผมลองเขียนโค้ตตัวนี้ให้เป็นตัวนับจำนวนเซ็นเซอร์นะครับแทนที่จะนำเวลาผ่าน rip senser แต่มันดันนับไม่หยุดนับไปเรื่อยๆเลย ส่วนตัว rip ก็ไมทำงานเพระาอะไรหรอครับ

 

QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

มีคอร์สสอน Arduino แบบละเอียดที่หน้าเว็บ ด้านบนซ้ายครับ

แสดงความคิดเห็นที่ 1-1 จากทั้งหมด 1 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม