I just need to move this project to Mbed Studio since online compiler is not working at the moment
Dependencies: mbed F042K6_USBDevice
Diff: main.cpp
- Revision:
- 0:795d2bf38fe9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat May 16 11:17:10 2020 +0000 @@ -0,0 +1,49 @@ +// https://developer.mbed.org/handbook/USBSerial +// + driver https://os.mbed.com/media/uploads/samux/serial.zip + +#include "mbed.h" +#include "USBSerial.h" + +DigitalOut pulse(PA_7); +DigitalOut direction(PA_6); + +unsigned int pulDelay = 1; +unsigned int cnt = 0; +int dir = 0; +int prev_dir = 1; + + +int main() { + + SYSCFG->CFGR1 |=0x10; //Pins PA11/12 instead of pins PA9/10 (umo��uje pou��t USB) + USBSerial serial; + + serial.printf("MBED virtual serial port!\r\n"); + wait_ms(500); + + + + while(1){ + direction.write(0); + while(cnt<=10000){ + pulse.write(1); + wait_ms(pulDelay); + pulse.write(0); + wait_ms(pulDelay); + cnt ++; + } + wait_ms(5000); + cnt = 0; + direction.write(1); + while(cnt<=10000){ + pulse.write(1); + wait_ms(pulDelay); + pulse.write(0); + wait_ms(pulDelay); + cnt ++; + } + wait_ms(5000); + cnt = 0; + + } +} \ No newline at end of file