Module Thu Phát Sóng Rf

TPhường.HCM: Miễn tổn phí vận tải giao dịch tự 300kTỉnh thành khác: Miễn phí đi lại đơn hàng tự 500k


Sở thu phạt RF 433MHZ là một trong những module giá bèo, sử dụng sóng radio nhằm truyền biểu hiện thân bộ vạc (transmitter module) với bộ thu (receiver module).


BỘ THU

BỘ PHÁT

Hình thực tế:

*

*

*

*

————————-CODE THAM KHẢO————————–

Thỏng viện VirtualWire.h

Phát:

/*Để triển khai truyền thừa nhận giữa 2 module đề nghị msinh sống độc lập gấp đôi Arduino IDE, tức là đề xuất kích vào biểu tượng Arduino 2 lần * Để truyền biểu thị đi đề xuất mở đúng Serial MOnitor đúng port của module truyền * Để thừa nhận tín hiệu gửi cho bắt buộc msinh hoạt đúng Serila Monitor đúng port của module thừa nhận * Chân data kết nối cùng với chân số 8 của Arduino */#include VirtualWire.h> // knhì báo thỏng viện VirtualWirevoid setup() Serial.begin(9600);// giao tiếp Serial cùng với baudrate 9600 Serial.println("Ready........."); vw_set_ptt_inverted(true);// yêu cầu cho RF liên kết modules vw_setup(1024);// thiết lập vận tốc truyền bộc lộ vw_set_tx_pin(8);// thiết lập chân digital nhằm vạc tín hiệu------------------------------------------------------------------void loop() char text<20> = "";// knhì báo string dạng array byte i = 0; while (Serial.available() == 0) // nothing while (Serial.available() > 0) char ch = Serial.read(); text = ch; i++; delay(5); Serial.print("sent: "); Serial.println(text); vw_send((byte *)text, sizeof(text));// gửi bộc lộ đi vw_wait_tx(); delay(100);

Thu:

/*Để tiến hành truyền dấn thân 2 module đề nghị msinh hoạt chủ quyền 2 lần Arduino IDE, tức là đề nghị kích vào hình tượng Arduino gấp đôi * Để truyền dấu hiệu đi nên mnghỉ ngơi đúng Serial MOnitor đúng port của module truyền * Để dìm biểu thị gửi cho đề nghị msinh hoạt đúng Serila Monitor đúng port của module dấn * Chân data liên kết cùng với chân 8 của arduino */#include VirtualWire.h> // knhị báo thỏng viện VirtualWirebyte msg;// thay đổi lưu lại tài liệu thừa nhận đượcbyte msgLen = VW_MAX_MESSAGE_LEN;void setup() Serial.begin(9600); Serial.println("READY.........."); vw_setup(1024); // setup tốc độ truyền biểu thị vw_set_rx_pin(8);// thiết lập chân digital để dìm tín hiệu----------------------------------------------------------------------------------------- vw_rx_start();// bước đầu nhấn tín hiệuvoid loop() if (vw_get_message(msg, &msgLen)) // nếu gồm biểu hiện được truyền mang lại Serial.print("got: "); for (int i = 0; i msgLen; i++) Serial.write(msg);// in cam kết từ bỏ ra màn hình Serial.println();

Leave a Reply

Your email address will not be published. Required fields are marked *