(Help) bác nào học adruino giúp em với

devailon nhưng mà con uno trước lôi chip ra nghịch hỏng cmnr, dạo này chip khan hàng quá chưa thay đc
 
Tham khảo code trên mạng rồi tự làm. Tự suy nghĩ làm thì nó mới nhớ lâu đc :cautious:

Gửi từ Xiaomi Redmi Note 8 bằng vozFApp
 
Đơn giản nhưng thôi ếu giúp đâu.:whistle:
https://shopee...vn/product/83038628/1732622588?smtt=0.100537477-1624460969.9
Set 1 timer tầm 1p lấy mẫu 1 lần độ sáng.1 flag để lưu tối hay sáng
https://www.cytrontech....vn/amp-p-low-cost-pir-sensor-module-hc-sr501?gclid=CjwKCAjwt8uGBhBAEiwAayu_9Xs9a4tMV-kcF_yGbm4_YGBsYvy2EGxAl3oK0yrFXF_9QqUsYJ9xzhoCuwgQAvD_BwE
1 cảm biến chuyển động để ra ngắt ngoài.Vứt chương trình kêu vào ngắt luôn cũng được.
Trên mạch có sẵn biến trở để set ngưỡng

Sent from Xiaomi M2102J20SG using vozFApp
 
C:
int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
int light = 500; // Mức biến trở ngưỡng sáng/tối
int quangtro = A1;// Quang trở
int cuongdosang = 0; // Cường độ sáng
int coibeep = 7; // chan coi beep
int chuyendong = 8; // input PIR
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(coibeep, OUTPUT);
  pinMode(chuyendong, INPUT);
}

void loop() {
  // read the value from the sensor:
  light = analogRead(sensorPin);
   cuongdosang = analogRead(quangtro);
  // Khi trời tối
  if (cuongdosang < light) {
    // turn the ledPin off:
    digitalWrite(ledPin, LOW);
    // Có chuyển động còi chớp và đèn chớp
    while (digitalRead(chuyendong) == HIGH) {
      digitalWrite(coibeep, HIGH);
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(coibeep, LOW);
      digitalWrite(ledPin, LOW);
      delay(1000);
    }
    digitalWrite(coibeep, LOW); // Tắt còi

  }
  else if (cuongdosang > light) {
    // turn the ledPin on
    digitalWrite(ledPin, HIGH);
    while (digitalRead(chuyendong) == HIGH) {
      digitalWrite(coibeep, HIGH);
      delay(1000);
      digitalWrite(coibeep, LOW);
      delay(1000);
    }
    digitalWrite(coibeep, LOW);

  }
}
Viết bừa cái code, còn mạch tự vẽ đi nhé
 
Last edited:
Đơn giản nhưng thôi ếu giúp đâu.:whistle:
https://shopee...vn/product/83038628/1732622588?smtt=0.100537477-1624460969.9
Set 1 timer tầm 1p lấy mẫu 1 lần độ sáng.1 flag để lưu tối hay sáng
https://www.cytrontech....vn/amp-p-low-cost-pir-sensor-module-hc-sr501?gclid=CjwKCAjwt8uGBhBAEiwAayu_9Xs9a4tMV-kcF_yGbm4_YGBsYvy2EGxAl3oK0yrFXF_9QqUsYJ9xzhoCuwgQAvD_BwE
1 cảm biến chuyển động để ra ngắt ngoài.Vứt chương trình kêu vào ngắt luôn cũng được.
Trên mạch có sẵn biến trở để set ngưỡng

Sent from Xiaomi M2102J20SG using vozFApp
Tinkercad mà bác.
C:
int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
int light = 500; // Mức biến trở ngưỡng sáng/tối
int coibeep = 7; // chan coi beep
int chuyendong = 8; // input PIR
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(coibeep, OUTPUT);
  pinMode(chuyendong, INPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // Khi trời tối
  if (sensorValue < light) {
    // turn the ledPin off:
    digitalWrite(ledPin, LOW);
    // Có chuyển động còi chớp và đèn chớp
    while (digitalRead(chuyendong) == HIGH) {
      digitalWrite(coibeep, HIGH);
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(coibeep, LOW);
      digitalWrite(ledPin, LOW);
    }
    digitalWrite(coibeep, LOW); // Tắt còi

  }
  else if (sensorValue > light) {
    // turn the ledPin on
    digitalWrite(ledPin, HIGH);
    while (digitalRead(chuyendong) == HIGH) {
      digitalWrite(coibeep, HIGH);
      delay(1000);
      digitalWrite(coibeep, LOW);
    }
    digitalWrite(coibeep, LOW);

  }
}
Viết bừa cái code, còn mạch tự vẽ đi nhé
Giúp em cho trót với bác, vẽ mạch là cái gì em có biết đâu ạ. :(
 
Nếu plc thì mình giúp đc chưa arduino biết cách làm chuw lâu rồi k dùng k nhớ code

Gửi từ Nphone bằng vozFApp
 
2 xị nhé, giờ 1 tín cũng 2-300k rồi, môn này phải 4 tín
UDqbcUT.png
 
Back
Top