แนะนำงานสั่งงาน Relay 4 channel



 อุปกรณ์ ที่ใช้ 

1.Arduino Nano ATmega328P พร้อมสาย usb ต่อคอมพิวเตอร์ 

2.Relay 4 Ch หรือ 1 CH  

3. สายจัมพ์

4. BreadBoard มีหรือไม่มีก็ได้  



Relay Module 5V 4 Channel Isolation Control 250V/10A 

แบบ Active LOW พร้อมไฟ LED แสดงผลการทำงาน

4-Channel Relay breakout

Power supply range from 5V~7.5V

Onboard Photocoupler isolation

Equiped with high-current relay, AC250V 10A ; DC30V 10A.

Relay Output Indicator LED

TTL logic interface can be directly connected to microcontroller 

(Arduino, 8051, AVR, PIC, DSP, ARM, ARM, MSP430,etc )


DataSheets

https://www.handsontec.com/dataspecs/4Ch-relay.pdf


โปรแกรม ภาษา ซี

// the setup function runs once when you press reset or power the board

// relay Nano pin  4,6,7,8

void setup() {

// initialize digital pin LED_BUILTIN as an output.

  pinMode(LED_BUILTIN, OUTPUT);

//ตั้งค่า พินเลข 4,6,7,8 เป็นเอาท์พุต

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

//เปิดจ่ายไฟ ค่าพินเลข 8,9,10,11  เพื่อปิดการทำงานของ Relay

digitalWrite(4, HIGH);

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

}


// the loop function runs over and over again forever

void loop() {

  digitalWrite(4, LOW);  // turn on LED on (LOW  is the voltage level = Active Low)

  delay(1000);                     

  digitalWrite(4, HIGH); // turn the LED off by making the voltage HIGH

  delay(1000);                     

}

///////////////////////////////////////////////////

Contact:
https://www.facebook.com/chaiyutpong

ความคิดเห็น