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.

54 lines
1.4 KiB

4 years ago
  1. #include <PCD8544_SPI.h>
  2. #include <shiftRegButtonLib.h>
  3. #include <myInterrupts.h>
  4. #define CLR_BIT(p,n) ((p) &= ~((1) << (n)))
  5. #define SET_BIT(p,n) ((p) |= (1 << (n)))
  6. //Pinzuordnungen
  7. #define BL 10 //backlight, Hintergrundbeleuchtung LCD
  8. #define SD_CARD_CS 2 //D2 ist Chip Enable
  9. #define BAT_VOLTAGE A7 //Akkuspannung an A7
  10. #define _OE_LEVEL 7 //D7 fuer Output Enable Pegelwandler
  11. #define BRIGHTNESS OCR1B
  12. //globale Objekte anlegen
  13. volatile PCD8544_SPI_FB lcd;
  14. volatile myInterrupts Timer2;
  15. volatile myInterrupts pwmBL;
  16. volatile shiftRegButton tasten;
  17. //LCD
  18. uint8_t renderTime = 0;
  19. #define renderTimeout 100 //es wird alle 100ms gerendert
  20. String lcdLines[6]; //Strings welche alle 100ms ausgegeben werden
  21. //Kommandos
  22. #define nothing 9 //reset/nichts tun
  23. #define speedA 1 // set speed A + speed
  24. #define dirA 2 // set direction A + dir
  25. #define speedB 3 // set speed B + speed
  26. #define dirB 4 // set direction B + dir
  27. #define goDrive 5 //go + time to go
  28. #define stopDrive 6 //stop
  29. #define getTemp 7 //get temperature
  30. #define timeToDrive 8 //Zeitdauer des fahrens
  31. #define getDistance 10 //Abstand zu Objekten
  32. int16_t pwmA = 0;
  33. int16_t pwmB = 0;
  34. bool forwardA = true;
  35. bool forwardB = true;
  36. bool driveOn = false;
  37. uint16_t driveTimeout = 0;
  38. int16_t distance;
  39. int16_t temperature;
  40. //Funk
  41. #include <SPI.h>
  42. #include <nRF24L01.h>
  43. #include <RF24.h>
  44. RF24 radio(A2, A3); // CE, CSN
  45. const byte address[6] = "00001";
  46. uint8_t commands[32];