ต้องการจะเชื่อม nrf24l01(เป็นตัวส่งสัญญาณ) กับ MQ-2(ตัวรับควัน) เเต่ไม่รู้จะเรื่มหรือเชื่อมกันยังไงดีจึงมาขอคำแนะนำและคำปรึกษา
ขอบคุณค่ะ
ข้างล่างเป็นเป็นโค้ดของตัวรับควัน(เพียวๆค่ะ)
/*
MQ2 -> Arduino
Vcc -> 5V
Gnd -> Gnd
AD -> A0
*/
void setup() {
Serial.begin(9600);
}
void loop() {
float vol;
int sensorValue = analogRead(A0);
vol=(float)sensorValue/1024*5.0;
Serial.println(vol,1);
delay(100);
}
ส่วนอันนี้เป็นของตัวส่งสัญญาณค่ะ
#include <SPI.h>
#include <nRF24L01p.h>
nrf24l01p transmitter(7,8); // CSN,CE
void setup() {
delay(150) ;
serial.begin(115200) ;
SPI.begin();
SPI.setBitOrder (MSBFIRST);
transmitter.chanal (90);
transmitter.IXadress (" ALL ")
transmitter.init();
string message;
void loop(){
transmitter.txPL (" PPAP ")
transmitter.sent (Fast);
delay(1000);
}
}
สอบถามเรื่องการเขียนโปรแกรมภาษาซีหน่อยค่ะ (ช่วยแนะนำทีค่ะ)
ขอบคุณค่ะ
ข้างล่างเป็นเป็นโค้ดของตัวรับควัน(เพียวๆค่ะ)
/*
MQ2 -> Arduino
Vcc -> 5V
Gnd -> Gnd
AD -> A0
*/
void setup() {
Serial.begin(9600);
}
void loop() {
float vol;
int sensorValue = analogRead(A0);
vol=(float)sensorValue/1024*5.0;
Serial.println(vol,1);
delay(100);
}
ส่วนอันนี้เป็นของตัวส่งสัญญาณค่ะ
#include <SPI.h>
#include <nRF24L01p.h>
nrf24l01p transmitter(7,8); // CSN,CE
void setup() {
delay(150) ;
serial.begin(115200) ;
SPI.begin();
SPI.setBitOrder (MSBFIRST);
transmitter.chanal (90);
transmitter.IXadress (" ALL ")
transmitter.init();
string message;
void loop(){
transmitter.txPL (" PPAP ")
transmitter.sent (Fast);
delay(1000);
}
}