PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

43 lines
1.1KB

  1. // transmitter.pde
  2. //
  3. // Simple example of how to use VirtualWire to transmit messages
  4. // Implements a simplex (one-way) transmitter with an TX-C1 module
  5. //
  6. // See VirtualWire.h for detailed API docs
  7. // Author: Mike McCauley (mikem@airspayce.com)
  8. // Copyright (C) 2008 Mike McCauley
  9. // $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
  10. #include <VirtualWire.h>
  11. const int led_pin = 11;
  12. const int transmit_pin = 12;
  13. const int receive_pin = 2;
  14. const int transmit_en_pin = 3;
  15. void setup()
  16. {
  17. // Initialise the IO and ISR
  18. vw_set_tx_pin(transmit_pin);
  19. vw_set_rx_pin(receive_pin);
  20. vw_set_ptt_pin(transmit_en_pin);
  21. vw_set_ptt_inverted(true); // Required for DR3100
  22. vw_setup(2000); // Bits per sec
  23. pinMode(led_pin, OUTPUT);
  24. }
  25. byte count = 1;
  26. void loop()
  27. {
  28. char msg[7] = {'h','e','l','l','o',' ','#'};
  29. msg[6] = count;
  30. digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  31. vw_send((uint8_t *)msg, 7);
  32. vw_wait_tx(); // Wait until the whole message is gone
  33. digitalWrite(led_pin, LOW);
  34. delay(1000);
  35. count = count + 1;
  36. }