Moottorin ohjaaminen H-sillan avulla Motor control using H-bridge
main.cpp
- Committer:
- tyynetyyne
- Date:
- 2018-08-18
- Revision:
- 0:61da65a6f0b3
File content as of revision 0:61da65a6f0b3:
#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); } }