Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.1 KiB

  1. /*
  2. Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. version 2 as published by the Free Software Foundation.
  6. */
  7. /**
  8. * Channel scanner
  9. *
  10. * Example to detect interference on the various channels available.
  11. * This is a good diagnostic tool to check whether you're picking a
  12. * good channel for your application.
  13. *
  14. * Inspired by cpixip.
  15. * See http://arduino.cc/forum/index.php/topic,54795.0.html
  16. */
  17. #include <SPI.h>
  18. #include "nRF24L01.h"
  19. #include "RF24.h"
  20. #include "printf.h"
  21. //
  22. // Hardware configuration
  23. //
  24. // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
  25. RF24 radio(7,8);
  26. //
  27. // Channel info
  28. //
  29. const uint8_t num_channels = 126;
  30. uint8_t values[num_channels];
  31. //
  32. // Setup
  33. //
  34. void setup(void)
  35. {
  36. //
  37. // Print preamble
  38. //
  39. Serial.begin(115200);
  40. printf_begin();
  41. Serial.println(F("\n\rRF24/examples/scanner/"));
  42. //
  43. // Setup and configure rf radio
  44. //
  45. radio.begin();
  46. radio.setAutoAck(false);
  47. // Get into standby mode
  48. radio.startListening();
  49. radio.stopListening();
  50. radio.printDetails();
  51. // Print out header, high then low digit
  52. int i = 0;
  53. while ( i < num_channels )
  54. {
  55. printf("%x",i>>4);
  56. ++i;
  57. }
  58. Serial.println();
  59. i = 0;
  60. while ( i < num_channels )
  61. {
  62. printf("%x",i&0xf);
  63. ++i;
  64. }
  65. Serial.println();
  66. }
  67. //
  68. // Loop
  69. //
  70. const int num_reps = 100;
  71. void loop(void)
  72. {
  73. // Clear measurement values
  74. memset(values,0,sizeof(values));
  75. // Scan all channels num_reps times
  76. int rep_counter = num_reps;
  77. while (rep_counter--)
  78. {
  79. int i = num_channels;
  80. while (i--)
  81. {
  82. // Select this channel
  83. radio.setChannel(i);
  84. // Listen for a little
  85. radio.startListening();
  86. delayMicroseconds(128);
  87. radio.stopListening();
  88. // Did we get a carrier?
  89. if ( radio.testCarrier() ){
  90. ++values[i];
  91. }
  92. }
  93. }
  94. // Print out channel measurements, clamped to a single hex digit
  95. int i = 0;
  96. while ( i < num_channels )
  97. {
  98. printf("%x",min(0xf,values[i]));
  99. ++i;
  100. }
  101. Serial.println();
  102. }
  103. // vim:ai:cin:sts=2 sw=2 ft=cpp