สวิตช์ควบคุมระยะไกล 10 ช่อง 2.4 GHz

ลองใช้เครื่องมือของเราเพื่อกำจัดปัญหา





ในโพสต์นี้เราจะสร้างสวิตช์ควบคุมระยะไกล 10 ช่องตามแถบ ISM (อุตสาหกรรมวิทยาศาสตร์และการแพทย์)

บทนำ

วง ISM ทำงานที่ 2.4 GHz ซึ่งสามารถใช้งานได้โดยไม่ต้องออกใบอนุญาตพร้อมกำลังขับที่เหมาะสม



โครงการที่เสนอคือสวิตช์ไร้สายเปิด / ปิดสำหรับวัตถุประสงค์ทั่วไปซึ่งสามารถใช้เพื่อเปิด / ปิดไฟพัดลมเครื่องใช้ภายในบ้านไปจนถึงระบบอัตโนมัติภายในบ้านหากมีความมั่นใจเพียงพอที่จะนำการปรับเปลี่ยนฮาร์ดแวร์หรือซอฟต์แวร์มาสู่โครงการนี้

โครงการแบ่งออกเป็นสองส่วนคือรีโมทและตัวรับสัญญาณ



รีโมทคอนโทรล:

รีโมทคอนโทรลประกอบด้วยปุ่มกด 10 ปุ่มสำหรับควบคุมรีเลย์ 10 ตัวที่เครื่องรับ รีโมททำงานโดยแบตเตอรี่ 9V ซึ่งทำให้พกพาได้

หัวใจของโครงการคือโมดูลตัวรับส่งสัญญาณ 2.4 GHz NRF24L01 ซึ่งทำให้การสื่อสารระหว่างสอง Arduinos เป็นไปได้

รีโมทมีไฟ LED แสดงการตอบรับ

ไฟ LED รับทราบจะสว่างขึ้นชั่วขณะทุกครั้งเมื่อเรากดปุ่มบนรีโมทและต่อเมื่อผู้รับได้รับสัญญาณที่ส่งจากนั้นเครื่องรับจะส่งสัญญาณตอบกลับกลับไปที่รีโมทเพื่อเรียกใช้ LED

กระบวนการนี้จะช่วยให้มั่นใจได้ว่าคำสั่งเปิด / ปิดของรีโมทคอนโทรลถึงปลายทางด้วยการยืนยันด้วยภาพ

สวิตช์เปิด / ปิดมีให้ในวงจรของรีโมทคอนโทรลเพื่อป้องกันการสูญเสียพลังงานส่วนเกินในขณะที่ไม่ได้ใช้งาน

แนะนำให้ใช้ Arduino Nano หรือ Arduino Pro-mini ในการสร้างรีโมทเนื่องจากอยู่ในรูปแบบที่เล็กกว่าซึ่งทำให้พกพาได้

แผนภูมิวงจรรวม:

เครื่องส่งสัญญาณรีโมทคอนโทรล 10 ช่อง 2.4 GHz

ด้านบนคือแผนภาพวงจรทั้งหมดสำหรับรีโมทคอนโทรล แผนภาพการเชื่อมต่อพินสำหรับ NRF24L01 ยังได้รับในแผนผังเดียวกัน

ปิดรีโมทเมื่อคุณทำเสร็จแล้ว

โปรดดาวน์โหลดไฟล์ไลบรารีที่นี่: github.com/nRF24/RF24.git

โปรแกรมสำหรับระยะไกล:

//-----Program Developed by R.Girish----//
#include
#include
RF24 radio(9,10)
const byte address[][6] = {'00001', '00002'}
const int ip1 = 2
const int ip2 = 3
const int ip3 = 4
const int ip4 = 5
const int ip5 = 6
const int ip6 = 7
const int ip7 = 8
const int ip8 = A0
const int ip9 = A1
const int ip10 = A2
const int buzzer = A3
char buzzchar[32] = ''
const char constbuzzer[32] = 'buzz'
const char button1[32] = 'activate_1'
const char button2[32] = 'activate_2'
const char button3[32] = 'activate_3'
const char button4[32] = 'activate_4'
const char button5[32] = 'activate_5'
const char button6[32] = 'activate_6'
const char button7[32] = 'activate_7'
const char button8[32] = 'activate_8'
const char button9[32] = 'activate_9'
const char button10[32] = 'activate_10'
void setup()
{
pinMode(ip1, INPUT)
pinMode(ip2, INPUT)
pinMode(ip3, INPUT)
pinMode(ip4, INPUT)
pinMode(ip5, INPUT)
pinMode(ip6, INPUT)
pinMode(ip7, INPUT)
pinMode(ip8, INPUT)
pinMode(ip9, INPUT)
pinMode(ip10, INPUT)
pinMode(buzzer, OUTPUT)
digitalWrite(ip1, HIGH)
digitalWrite(ip2, HIGH)
digitalWrite(ip3, HIGH)
digitalWrite(ip4, HIGH)
digitalWrite(ip5, HIGH)
digitalWrite(ip6, HIGH)
digitalWrite(ip7, HIGH)
digitalWrite(ip8, HIGH)
digitalWrite(ip9, HIGH)
digitalWrite(ip10, HIGH)
radio.begin()
radio.openWritingPipe(address[1])
radio.openReadingPipe(1, address[0])
radio.setChannel(100)
radio.setDataRate(RF24_250KBPS)
radio.setPALevel(RF24_PA_MAX)
radio.stopListening()
}
void loop()
{
if(digitalRead(ip1) == LOW)
{
radio.write(&button1, sizeof(button1))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip2) == LOW)
{
radio.write(&button2, sizeof(button2))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip3) == LOW)
{
radio.write(&button3, sizeof(button3))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip4) == LOW)
{
radio.write(&button4, sizeof(button4))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip5) == LOW)
{
radio.write(&button5, sizeof(button5))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip6) == LOW)
{
radio.write(&button6, sizeof(button6))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip7) == LOW)
{
radio.write(&button7, sizeof(button7))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip8) == LOW)
{
radio.write(&button8, sizeof(button8))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip9) == LOW)
{
radio.write(&button9, sizeof(button9))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
if(digitalRead(ip10) == LOW)
{
radio.write(&button10, sizeof(button10))
radio.startListening()
while(!radio.available())
radio.read(&buzzchar, sizeof(buzzchar))
if(strcmp(buzzchar,constbuzzer) == 0)
{
digitalWrite(buzzer, HIGH)
delay(500)
digitalWrite(buzzer,LOW)
}
radio.stopListening()
}
}
//-----Program Developed by R.Girish----//

นั่นสรุปวงจรรีโมทคอนโทรล

ผู้รับ:

วงจรตัวรับประกอบด้วย Arduino ซึ่งเป็นตัวเลือกที่คุณเลือกได้ตัวต้านทาน จำกัด กระแส 10 ตัวที่ 330 โอห์มทรานซิสเตอร์ 10 ตัวและรีเลย์ 10 ตัวสร้างขั้นตอนการส่งออก

ที่ขาเอาต์พุต 10 ขาของ Arduino แต่ละตัวเชื่อมต่อกับรีเลย์ 10 ตัวผ่านตัวต้านทานและทรานซิสเตอร์

โปรดตรวจสอบให้แน่ใจว่าแหล่งจ่ายไฟของคุณสามารถจ่ายกระแสไฟฟ้าได้อย่างน้อย 1A ซึ่งจำเป็นต่อการใช้งานรีเลย์หลายตัวในทันที

โมดูลตัวรับส่งสัญญาณ 2.4 GHz NRF24L01 ให้การสื่อสารระหว่างระยะไกล

แผนภูมิวงจรรวม:



2.4 GHz 10 ช่องรีโมทคอนโทรลตัวรับ

หากคุณสับสนกับแผนภาพการเดินสายไฟระหว่างโมดูล Arduino และ NRF24L01 เพียงแค่ดูที่ตารางข้างแผนผังมันก็เหมือนกันสำหรับวงจรรีโมทคอนโทรลเช่นกัน

ลำดับเอาต์พุตและพินเอาต์พุตมีดังนี้:

Arduino PIN - ลำดับเอาต์พุต

PIN 2 - เอาต์พุต 1
PIN 3 - เอาต์พุต 2
PIN 4 - เอาต์พุต 3
PIN 5 - เอาท์พุท 4
PIN 6 - เอาต์พุต 5
PIN 7 - เอาท์พุท 6
PIN 8 - เอาต์พุต 7
PIN A0 - เอาต์พุต 8
PIN A1 - เอาต์พุต 9
PIN A2 - เอาต์พุต 10

ขั้นตอนการส่งออก:

การเชื่อมต่อรีเลย์รีโมทคอนโทรล 10 ช่อง 2.4 GHz

เอาต์พุตถูกจัดแสดงโดยมีสองขั้นตอนเอาต์พุตเพื่อความเรียบง่ายของไดอะแกรม คุณต้องขยายเป็นสิบช่องหากคุณใช้ทั้ง 10 ช่อง

โปรแกรมสำหรับผู้รับ:

//-----Program Developed by R.Girish----//
#include
#include
RF24 radio(9,10)
const byte address[][6] = {'00001', '00002'}
const int op1 = 2
const int op2 = 3
const int op3 = 4
const int op4 = 5
const int op5 = 6
const int op6 = 7
const int op7 = 8
const int op8 = A0
const int op9 = A1
const int op10 = A2
const char buzzer[32] = 'buzz'
char buttonstate[32] = ''
const char button1[32] = 'activate_1'
const char button2[32] = 'activate_2'
const char button3[32] = 'activate_3'
const char button4[32] = 'activate_4'
const char button5[32] = 'activate_5'
const char button6[32] = 'activate_6'
const char button7[32] = 'activate_7'
const char button8[32] = 'activate_8'
const char button9[32] = 'activate_9'
const char button10[32] = 'activate_10'
boolean status1 = false
boolean status2 = false
boolean status3 = false
boolean status4 = false
boolean status5 = false
boolean status6 = false
boolean status7 = false
boolean status8 = false
boolean status9 = false
boolean status10 = false
void setup()
{
Serial.begin(9600)
pinMode(op1, OUTPUT)
pinMode(op2, OUTPUT)
pinMode(op3, OUTPUT)
pinMode(op4, OUTPUT)
pinMode(op5, OUTPUT)
pinMode(op6, OUTPUT)
pinMode(op7, OUTPUT)
pinMode(op8, OUTPUT)
pinMode(op9, OUTPUT)
pinMode(op10, OUTPUT)
radio.begin()
radio.openReadingPipe(1, address[1])
radio.openWritingPipe(address[0])
radio.setChannel(100)
radio.setDataRate(RF24_250KBPS)
radio.setPALevel(RF24_PA_MAX)
radio.startListening()
}
void loop()
{
while(!radio.available())
radio.read(&buttonstate, sizeof(buttonstate))
Serial.println(buttonstate)
if((strcmp(buttonstate,button1) == 0) && status1 == false)
{
digitalWrite(op1, HIGH)
status1 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button1) == 0) && status1 == true)
{
digitalWrite(op1, LOW)
status1 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button2) == 0) && status2 == false)
{
digitalWrite(op2, HIGH)
status2 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button2) == 0) && status2 == true)
{
digitalWrite(op2, LOW)
status2 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button3) == 0) && status3 == false)
{
digitalWrite(op3, HIGH)
status3 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button3) == 0) && status3 == true)
{
digitalWrite(op3, LOW)
status3 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button4) == 0) && status4 == false)
{
digitalWrite(op4, HIGH)
status4 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button4) == 0) && status4 == true)
{
digitalWrite(op4, LOW)
status4 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button5) == 0) && status5 == false)
{
digitalWrite(op5, HIGH)
status5 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button5) == 0) && status5 == true)
{
digitalWrite(op5, LOW)
status5 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button6) == 0) && status6 == false)
{
digitalWrite(op6, HIGH)
status6 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button6) == 0) && status6 == true)
{
digitalWrite(op6, LOW)
status6 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button7) == 0) && status7 == false)
{
digitalWrite(op7, HIGH)
status7 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button7) == 0) && status7 == true)
{
digitalWrite(op7, LOW)
status7 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button8) == 0) && status8 == false)
{
digitalWrite(op8, HIGH)
status8 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button8) == 0) && status8 == true)
{
digitalWrite(op8, LOW)
status8 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button9) == 0) && status9 == false)
{
digitalWrite(op9, HIGH)
status9 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button9) == 0) && status9 == true)
{
digitalWrite(op9, LOW)
status9 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button10) == 0) && status10 == false)
{
digitalWrite(op10, HIGH)
status10 = true
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
else if((strcmp(buttonstate,button10) == 0) && status10 == true)
{
digitalWrite(op10, LOW)
status10 = false
radio.stopListening()
for(int i = 0 i <10 i++)
{
radio.write(&buzzer, sizeof(buzzer))
delay(10)
}
radio.startListening()
}
}
//-----Program Developed by R.Girish----//

สรุปว่าผู้รับ

มีระยะทางทฤษฎี 100 เมตรในทางปฏิบัติอาจใช้งานได้ประมาณ 30 เมตรขึ้นไปอาจแตกต่างกันไปขึ้นอยู่กับอุปสรรคที่มั่นคงระหว่างรีโมทและเครื่องรับ

วิธีดำเนินโครงการนี้:

•เปิดเครื่องรับก่อนแล้วจึงรีโมท

•กดปุ่มใด ๆ ในรีโมททีละปุ่ม

•หากคุณกดปุ่มแรกเอาต์พุตที่เกี่ยวข้องจะถูกทริกเกอร์เช่นเอาต์พุต 1 จะเปิด หากคุณกดปุ่มเดียวกันบนรีโมทอีกครั้งระบบจะปิดเอาต์พุต 1 ที่เครื่องรับ

•ใช้กับปุ่มทั้งหมดและ 10 เอาต์พุต

•ปิดรีโมทหลังใช้งาน

หากคุณมีคำถามเพิ่มเติมเกี่ยวกับสวิตช์ควบคุมระยะไกล 2.4 GHz 10 แชนเนลที่กล่าวถึงข้างต้นโปรดแสดงความคิดเห็นในส่วนความคิดเห็น




คู่ของ: วงจรกำเนิดสัญญาณ Arduino PWM ถัดไป: วิธีเรียกใช้เซอร์โวมอเตอร์โดยใช้ IC 555