วันพุธที่ 14 มีนาคม พ.ศ. 2561

ส่งงานครั้งที่ 6

Arduino Relay Control



const int buttonPin = 12;
const int transistorPin = 7;

int buttonState = 0;

void setup()
{

 pinMode(buttonPin, INPUT);
 pinMode (transistorPin, OUTPUT);

}

void loop()
{

 buttonState = digitalRead(buttonPin);

 if (buttonState == LOW)
  {

   digitalWrite (transistorPin, HIGH);
 
  }

 else
  {
 
   digitalWrite (transistorPin, LOW);

  }

}
ผลการค้นหารูปภาพสำหรับ code arduino control 12v relay

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

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

Mini Project

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