วันอาทิตย์ที่ 25 มีนาคม พ.ศ. 2561

ส่งงารครั้งที่14

Clap Switch using Arduino


const int analogInPin = A0;  // กำหรดตัวแปร analogInPin ที่ขา A0
int sensorValue = 0;   

void setup() 
{
 DDRD = 0xFF;  //ชี้ตำเเหน่งของ DDRD ที่ตำเเหน่ง 0xFF
}

void loop() 
{
 sensorValue = analogRead(analogInPin);    
 if(sensorValue>60)
 {
  PORTD ^=(1<<7); //หากมีการสลับระหว่าง LED บนและปิดบน pin7
  delay(250);
  }
}


Clap Switch using Arduino Circuit Diagram

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

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

Mini Project

 Control Lamp 220v  With LDR const int lamp = 12; const int ldrPin=A0; #include <Wire.h> #include <LiquidCrystal_I2C.h&g...