BASIC4MCU | 질문게시판 | Rf433 송수신기 도움좀 주세요!!!!ㅠㅠ제발 부탁드립니다
페이지 정보
작성자 A반장 작성일2018-09-28 21:09 조회11,323회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3242
본문
수신기에서 메세지를 받으면 진동모터가 울리게끔 하고 싶은데 어떻게 해냐 될까요?
스케치를 올려 봅니다
통신은 아주 잘되고 동전진동센서만 작동이 안되네요
수신기 스케치에서 조건을 좀 수정해야할거 같은데 제발 도와주세요 ㅠㅠ
수신기 스케치
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
const int RX_DIO_Pin = 11; // default 11
void setup()
{
Serial.begin(9600);
Serial.println("Ready to receive:");
vw_set_rx_pin(RX_DIO_Pin); // Initialize RX pin
vw_setup(2000); // Transfer speed : 2000 bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
if (vw_get_message(message, &messageLength)) // Non-blocking
{
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++)
{
Serial.write(message[i]);
}
Serial.println();
}
}
송신기 스케치
#include <VirtualWire.h>
const int TX_DIO_Pin = 12; // default 12
void setup()
{
vw_set_tx_pin(TX_DIO_Pin); // Initialize TX pin
vw_setup(2000); // Transfer speed : 2000 bits per sec
}
void loop()
{
send("Bbangpan!");
delay(1000);
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
댓글 0
조회수 11,323등록된 댓글이 없습니다.