feat: call motor turn python from JS

This commit is contained in:
joshuashoemaker 2021-01-21 20:40:49 -06:00
parent d16297a325
commit 05e5e48c02

View File

@ -0,0 +1,22 @@
import { spawn } from 'child_process'
function sleep (ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const main = async () => {
console.log('start')
const rotateProcess = spawn('python', ['src/Server/moveStepper.py', '3', '5', '7', '11', 'clockwise', '0.01'])
console.log('running')
await sleep(5000)
rotateProcess.kill()
console.log('change direction')
const couterRotateProcess = spawn('python', ['src/Server/moveStepper.py', '3', '5', '7', '11', 'counterClockwise', '0.01'])
await sleep(5000)
couterRotateProcess.kill()
}
main()