Advertisement
Guest User

rf transmitter

a guest
Oct 13th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.26 KB | Source Code | 0 0
  1. /////////////   transmitter v2.0  /////////
  2. #include <SPI.h>
  3. #include <RH_ASK.h>   //rf library
  4.  
  5.  
  6. const byte adressPin1 = 7;
  7. const byte adressPin2 = 8;
  8. int adress1, adress2;
  9.  
  10.  
  11. //RH_ASK rf_driver(2000,10); //syntax for changing digital pin and baud rate
  12. RH_ASK rf_driver; //default tx pin D12
  13.  
  14. //uint8_t buff[11]; //array for storing message for
  15. char *message1 = "Activation";
  16. char *message2 = "Moonwalker";
  17. char message3 = "Enterprise";
  18. char message4 = "Resolution";
  19. char *msg; //rf message
  20.  
  21. void setup() {
  22.   Serial.begin(9600);
  23.  
  24.   rf_driver.init();
  25.  
  26.   pinMode(LED_BUILTIN, OUTPUT);
  27.   pinMode(adressPin1, INPUT);
  28.   pinMode(adressPin2, INPUT);
  29.  
  30.   adress1 = digitalRead(adressPin1);
  31.   adress2 = digitalRead(adressPin2);
  32.  
  33.   ////testing///
  34.   adress1 = LOW;
  35.   adress2 = LOW;
  36.   //////////////
  37.  
  38.   if(adress1 == LOW && adress2 == LOW)
  39.     *msg = *message1;
  40.  
  41.   if(adress1 == LOW && adress2 == HIGH)
  42.     msg = *message2;
  43.  
  44.   //if(adress1 == HIGH && adress2 == LOW)
  45.     //msg = message3;
  46.  
  47.   //if(adress1 == HIGH && adress2 == HIGH)
  48.     //msg = message4;
  49.  
  50.  
  51. }
  52.  
  53. void loop() {
  54.  
  55.   digitalWrite(LED_BUILTIN, HIGH);
  56.   rf_driver.send((uint8_t*)msg, strlen(msg));
  57.   rf_driver.waitPacketSent();
  58.   digitalWrite(LED_BUILTIN, LOW);
  59.   delay(500);
  60.  
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement