TP1
Dependencies: mbed
Diff: m3pi.cpp
- Revision:
- 10:4276eb0b8d4c
- Parent:
- 0:89e0c9ac4a1a
--- a/m3pi.cpp Wed Dec 09 10:25:27 2020 +0000 +++ b/m3pi.cpp Wed Dec 09 11:31:07 2020 +0000 @@ -203,6 +203,18 @@ return(_ser.getc()); } +void m3pi::play (char* music, int length) { + // The default 3pi serial slave program + // will not accept music strings longer than 100. + if (length > 100) + length = 100; + _ser.putc(DO_PLAY); + _ser.putc(length); + for (int i = 0 ; i < length ; i++) { + _ser.putc(music[i]); + } +} +