Refact json response and fixed piezo tone

This commit is contained in:
2024-03-10 13:56:38 +07:00
parent 76e9ae14e5
commit e064e198a3
6 changed files with 198 additions and 31 deletions

24
test/serial/piezo.ts Normal file
View File

@@ -0,0 +1,24 @@
import { Board, Piezo } from "johnny-five";
const board = new Board({
port: '/dev/ttyUSB0',
repl: false
});
board.on('ready', () => {
const piezo = new Piezo(11);
let ins = 0;
board.loop(500, async () => {
piezo.play({
song: "C4",
beats: 1/2,
tempo: 100
})
await new Promise(resolve => setTimeout(resolve, 100));
piezo.note("C4", 100);
await new Promise(resolve => setTimeout(resolve, 100));
piezo.tone(262 * 7.3, 100);
})
})