int sensorPin = A0; // thieret lập chân đọc quang trở
int ledPin = 9; // chọn chân cho LED
int quangtro = A0;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int giatriQuangtro = analogRead(quangtro);//Đọc giá trị quang trở
Serial.println(giatriQuangtro); // Xuất giá trị ra Serial Monitor
delay(500);
int sensorValue = analogRead(sensorPin); // Đọc giá trị của cảm biến
if(sensorValue < 300)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
delay(300);
}