Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. #include "I2Cdev.h"
  2. #include "MPU6050.h"
  3.  
  4.  
  5. #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  6. #include "Wire.h"
  7. #endif
  8.  
  9.  
  10. MPU6050 accelgyro;
  11.  
  12.  
  13. int16_t ax, ay, az;
  14. int16_t gx, gy, gz;
  15.  
  16. const int buzzer = 3; //buzzer to arduino pin 9
  17.  
  18.  
  19.  
  20. #define OUTPUT_READABLE_ACCELGYRO
  21.  
  22.  
  23.  
  24.  
  25. #define LED_PIN 13
  26. bool blinkState = false;
  27.  
  28.  
  29.  
  30. //hey jew boy this is where im defining all the values
  31.  
  32.  
  33. short count = 0;
  34. bool debounce = false;
  35. int ticker = 0;
  36. byte jewishzach = 0;
  37.  
  38. void setup() {
  39.  
  40. #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  41. Wire.begin();
  42. #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  43. Fastwire::setup(400, true);
  44. #endif
  45.  
  46.  
  47. Serial.begin(38400);
  48.  
  49.  
  50. pinMode(LED_PIN, OUTPUT);
  51.  
  52. pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  53.  
  54. }
  55.  
  56. void loop() {
  57. delay(10);
  58. accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  59. ticker++;
  60.  
  61.  
  62. if (ay > 20000 && debounce == false) {
  63.  
  64. count++;
  65. debounce = true;
  66. ticker = ticker + 200;
  67. tone(buzzer, 2000); // Send 0.5KHz sound signal...
  68. delay(200);
  69. noTone(buzzer); // Stop sound...
  70. debounce = false;
  71. Serial.println(count);
  72. }
  73.  
  74. if (ticker >= 3000) {
  75. ticker = 0;
  76. if (count < 58) {
  77.  
  78.  
  79. for(jewishzach=1; jewishzach<13; jewishzach++){
  80. tone(buzzer, 1000); // Send 1KHz sound signal...
  81. delay(375); // zach is a queer...
  82. noTone(buzzer); // Stop sound...
  83. delay(375); // ...jewish also...
  84. }
  85. count = 0;
  86. }
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. #ifdef OUTPUT_READABLE_ACCELGYRO
  95. #endif
  96.  
  97. #ifdef OUTPUT_BINARY_ACCELGYRO
  98. Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
  99. Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
  100. Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
  101. Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));
  102. Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));
  103. Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
  104. #endif
  105.  
  106. blinkState = !blinkState;
  107. digitalWrite(LED_PIN, blinkState);
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement