BrickUp API Service for Docker version.

Speaker.h 715B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // library for seeed Graphic programming project
  2. // loovee @ 2015-9-24
  3. // under MIT license
  4. #ifndef __GROVE_SPEAKER_G_H__
  5. #define __GROVE_SPEAKER_G_H__
  6. #include <Arduino.h>
  7. #define NOTE_1 320
  8. #define NOTE_2 360
  9. #define NOTE_3 400
  10. #define NOTE_4 425
  11. #define NOTE_5 480
  12. #define NOTE_6 532
  13. #define NOTE_7 600
  14. #define NOTE_8 651
  15. #define NO_NOTE 0
  16. class grove_speaker_g{
  17. public:
  18. void SpeakerWrite(int PinName,int Note)
  19. {
  20. if(Note > 8)Note = 0;
  21. int __note[8] = {NOTE_1, NOTE_2, NOTE_3, NOTE_4, NOTE_5, NOTE_6, NOTE_7, NOTE_8};
  22. if(Note == 0)noTone(PinName);
  23. else
  24. {
  25. tone(PinName, __note[Note-1], 0);
  26. }
  27. }
  28. };
  29. #endif