Nagito Sukegawa
/
Test_Brushless_Driver
2020 Off season development Test of brushless motor driver
main.cpp@0:710164f391d3, 2020-03-12 (annotated)
- Committer:
- st17099ng
- Date:
- Thu Mar 12 15:20:04 2020 +0000
- Revision:
- 0:710164f391d3
Initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
st17099ng | 0:710164f391d3 | 1 | #include "mbed.h" |
st17099ng | 0:710164f391d3 | 2 | |
st17099ng | 0:710164f391d3 | 3 | DigitalOut myled(LED1);//LED1,p26 |
st17099ng | 0:710164f391d3 | 4 | PwmOut led1(D7); |
st17099ng | 0:710164f391d3 | 5 | //Serial pc(D8,D2,115200); |
st17099ng | 0:710164f391d3 | 6 | Serial pc(USBTX,USBRX,115200); |
st17099ng | 0:710164f391d3 | 7 | |
st17099ng | 0:710164f391d3 | 8 | int main() |
st17099ng | 0:710164f391d3 | 9 | { |
st17099ng | 0:710164f391d3 | 10 | led1.period_ms(20); |
st17099ng | 0:710164f391d3 | 11 | led1.pulsewidth_us(2000); |
st17099ng | 0:710164f391d3 | 12 | wait_ms(1); |
st17099ng | 0:710164f391d3 | 13 | led1.pulsewidth_us(1000); |
st17099ng | 0:710164f391d3 | 14 | wait_ms(1); |
st17099ng | 0:710164f391d3 | 15 | myled = 1; |
st17099ng | 0:710164f391d3 | 16 | wait(3); |
st17099ng | 0:710164f391d3 | 17 | while(1) { |
st17099ng | 0:710164f391d3 | 18 | myled=0; |
st17099ng | 0:710164f391d3 | 19 | for(int i = 1000; i < 2000; i+=10) { |
st17099ng | 0:710164f391d3 | 20 | led1.pulsewidth_us(i); |
st17099ng | 0:710164f391d3 | 21 | wait_ms(30); |
st17099ng | 0:710164f391d3 | 22 | } |
st17099ng | 0:710164f391d3 | 23 | for(int i = 2000; i > 1000; i-=10) { |
st17099ng | 0:710164f391d3 | 24 | led1.pulsewidth_us(i); |
st17099ng | 0:710164f391d3 | 25 | wait_ms(30); |
st17099ng | 0:710164f391d3 | 26 | } |
st17099ng | 0:710164f391d3 | 27 | // NVIC_SystemReset(); |
st17099ng | 0:710164f391d3 | 28 | } |
st17099ng | 0:710164f391d3 | 29 | } |