Advertisement
microrobotics

433 MHZ RF Transmitter HTX-1

Apr 3rd, 2023
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Here is an example code for a 433 MHz RF Transmitter module HTX-1 that can be used with an Arduino board:
  3.  
  4. This code uses the VirtualWire library to send a simple message "Hello, World!" over the 433 MHz RF Transmitter module HTX-1. The vw_set_tx_pin() function is used to specify the digital pin that is connected to the transmitter module. The vw_setup() function is used to set the transmission rate in bits per second. In the loop() function, the vw_send() function is used to send the message, and the vw_wait_tx() function is used to wait until the message is sent before sending the next message. The delay() function is used to wait for 1 second between sending messages.
  5.  
  6. To use this code, connect the data pin of the HTX-1 module to the digital pin specified in the transmit_pin variable (in this case, pin 10). Connect the power supply and ground of the HTX-1 module to the 5V and ground pins of the Arduino board, respectively.
  7.  
  8. Note that the HTX-1 module is a low-cost and low-range RF transmitter module that can be used for simple wireless communication applications. If you require longer range or more advanced features, you may need to use a different module or a different wireless communication protocol.
  9. */
  10.  
  11. #include <VirtualWire.h>
  12.  
  13. const int transmit_pin = 10;
  14. const int transmit_rate = 2000; // in bits per second
  15.  
  16. void setup() {
  17.   vw_set_tx_pin(transmit_pin);
  18.   vw_setup(transmit_rate);
  19. }
  20.  
  21. void loop() {
  22.   const char *msg = "Hello, World!";
  23.   vw_send((uint8_t *)msg, strlen(msg));
  24.   vw_wait_tx(); // Wait until the message is sent
  25.   delay(1000);  // Wait for 1 second before sending the next message
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement