Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. // THIS IS THE PAYLOAD CODE: https://pastebin.com/0psPbddR
  2.  
  3. // THIS IS THE STRUCTURE CODE: https://pastebin.com/4kFdj932
  4.  
  5. // THIS IS THE DESCENT CODE: https://pastebin.com/jwbtCfT4
  6.  
  7. //importing EYW
  8. #include <EYW.h>
  9.  
  10. //Section of payload variables
  11. EYW Camera::Camera cameraservo;
  12. bool timing = true;
  13. int
  14.  
  15. //Section for structure variables
  16. EYW::Altimeter altimeter;
  17. float currentHeight = 0;
  18. int structButtonPin = 2;
  19. int structLedPin = 4;
  20. int structSpeakerPin = 5;
  21. int frequency = 880;
  22. int duration = 1000;
  23.  
  24. //Section for descent variables
  25. EYW::RangeFinder descent;
  26. int descButtonPin = 2;
  27. int distanceFromGround = 0;
  28. int descLedPin = 4;
  29. int descSpeakerPin = 5;
  30. int descTriggerPin = 6;
  31. int descEchoPin = 7;
  32.  
  33. //Payload's timer system because EYW's is bad
  34. void Timer(int delayTime)
  35. {
  36. for (int i=0; i <= delayTime; i++)
  37. {
  38. timing = true;
  39. delay(1);
  40. }
  41. timing = false;
  42. }
  43.  
  44. void setup() {
  45. //Setting the serial montitor speed
  46. Serial.begin(9600);
  47. //Starting payload stuff
  48. cameraservo.begin();
  49. cameraservo.calibrate();
  50. cameraservo.alarm();
  51.  
  52. //Starting descent stuff
  53. descent.begin(descButtonPin, descLedPin, descSpeakerPin, descTriggerPin, descEchoPin);
  54. descent.calibrate(10);
  55. descent.alarm();
  56.  
  57.  
  58. //Starting structure stuff
  59. altimeter.begin(structButtonPin, structLedPin, structSpeakerPin);
  60. altimeter.calibrate(100);
  61. altimeter.alarm();
  62.  
  63. //Starting the payload's timer
  64. Timer(1000);
  65. }
  66.  
  67. void loop() {
  68. if (timing == false || cameraservo.buttonPressed() == true) {
  69. cameraservo.getPicture();
  70. Timer(5000);
  71. }
  72. currentHeight = altimeter.getHeightAvg(20);
  73. Serial.print("Current Height: ")
  74. Serial.println(currentHeight)
  75. if (currentHeight) {
  76. altimeter.alarm(6,2000,500);
  77. }
  78. distanceFromGround = descent.getDistance();
  79. Serial.print("CurrentDistance: ")
  80. Serial.println(distanceFromGround)
  81. if (distance<10) {
  82. descent.alarm(2,2000,100)
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement