Moottorin ohjaaminen H-sillan avulla Motor control using H-bridge
Diff: main.cpp
- Revision:
- 0:61da65a6f0b3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Aug 18 14:11:53 2018 +0000 @@ -0,0 +1,26 @@ +#include "MicroBit.h" + +MicroBit uBit; + +int main(){ + uBit.init(); + while (1){ + uBit.io.P1.setDigitalValue(1); + uBit.io.P0.setDigitalValue(0); + for(int i=0; i<=1023; i=i+20){ + uBit.io.P2.setAnalogValue(i); + uBit.sleep(200); + } + uBit.io.P1.setDigitalValue(0); + uBit.sleep(500); + uBit.io.P0.setDigitalValue(1); + for(int i=1023; i>=0; i=i-20){ + uBit.io.P2.setAnalogValue(i); + uBit.sleep(200); + } + uBit.io.P0.setDigitalValue(0); + uBit.sleep(500); + } +} + +