添加433MHZ转发

This commit is contained in:
2023-04-14 10:05:31 +08:00
parent 295f4e8a66
commit b0f46d869e
5 changed files with 355 additions and 185 deletions

View File

@@ -13,9 +13,14 @@ add_compile_options(-Wall
# Pull in our pico_stdlib which pulls in commonly used features
target_link_libraries(transmit pico_stdlib)
# enable usb output, disable uart output
pico_enable_stdio_usb(transmit 1)
pico_enable_stdio_uart(transmit 0)
pico_enable_stdio_uart(transmit ENABLED)
# create map/bin/hex file etc.
pico_add_extra_outputs(transmit)

View File

@@ -6,7 +6,6 @@
#define BUFFER_SIZ 1024
// 闪烁LED
static void light()
{
@@ -31,32 +30,29 @@ static int RAND()
char password[BUFFER_SIZ];
int i = 0;
FILE *fp;
memset(password, 0, BUFFER_SIZ);
srand(time(NULL));
while (i != PASSWD_LEN) {
password[i++] = pool[rand() % sizeof(pool)];
}
printf("%d\n", atoi(password));
//printf("%d\n", atoi(password));
return atoi(password);
}
int main(void) {
int main(void)
{
const uint RADIO_TRANSMIT_PIN = 16; // 433发射模块引脚
const uint BUTTON = 17; // 按钮发射
const uint RADIO_TRANSMIT_PIN = 16; // 433发射模块引脚
const uint BUTTON = 17; // 按钮发射
const uint PULSE_LENGTH = 169; // set this to PULSELENGTH RECIEVED
const uint REPEAT_TRANSMIT = 4; // set this to whatever works best for you. // 重复发送
const uint PROTOCOL = 1; // set this to PROTOCOL RECIEVED
const uint BIT_LENGTH = 24; // set this to BIT LENGTH RECIEVED
const uint PULSE_LENGTH = 169; // set this to PULSELENGTH RECIEVED
const uint REPEAT_TRANSMIT = 4; // set this to whatever works best for you. // 重复发送
const uint PROTOCOL = 1; // set this to PROTOCOL RECIEVED
const uint BIT_LENGTH = 24; // set this to BIT LENGTH RECIEVED
stdio_init_all();
gpio_init(RADIO_TRANSMIT_PIN);
@@ -67,35 +63,32 @@ int main(void) {
mySwitch.setRepeatTransmit(REPEAT_TRANSMIT);
int RANDOM = 30;
int LOOP_NUM = 2; // 循环发送次数
const int but = 55001;
int LOOP_NUM = 1; // 循环发送次数
while(1)
{
const int but = 55001;
stdio_uart_init_full(uart0, 115200, 6, 7);
while (1) {
//fprintf(uart0_handle, "Hello from uart0!\r\n");
//if (1 == gpio_get(BUTTON)) { // 按钮按下
for (int i=0; i<=LOOP_NUM; i++) {
RANDOM = RAND();
light(); // 灯闪烁
sleep_ms(RANDOM * 2 / 3); // 等待随机时间
mySwitch.send(but, BIT_LENGTH); // 第一次发射
sleep_ms(130);
for (int i = 0; i <= LOOP_NUM; i++) {
RANDOM = RAND();
light(); // 灯闪烁
//mySwitch.send(but+1, BIT_LENGTH); // 第二次发射
//sleep_ms(130);
}
sleep_ms(RANDOM * 2 / 3); // 等待随机时间
mySwitch.send(but, BIT_LENGTH); // 第一次发射
sleep_ms(130);
//mySwitch.send(but+1, BIT_LENGTH); // 第二次发射
//sleep_ms(130);
}
//}
sleep_ms(3000);
}
return 0;
}