lab2

Dependencies:   mbed

Committer:
HPWang
Date:
Wed Mar 09 02:40:13 2016 +0000
Revision:
0:7b2e8e9735ec
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HPWang 0:7b2e8e9735ec 1 #include "mbed.h"
HPWang 0:7b2e8e9735ec 2
HPWang 0:7b2e8e9735ec 3 PwmOut mypwm(PWM_OUT);
HPWang 0:7b2e8e9735ec 4
HPWang 0:7b2e8e9735ec 5 float nagle_ref = 0.0;
HPWang 0:7b2e8e9735ec 6 float nagle_read = 0.0;
HPWang 0:7b2e8e9735ec 7 float nagle_check;
HPWang 0:7b2e8e9735ec 8 float err = 0.0;
HPWang 0:7b2e8e9735ec 9 float ierr = 0.0;
HPWang 0:7b2e8e9735ec 10 float PI_out = 0.0;
HPWang 0:7b2e8e9735ec 11 float pwm1_duty = 0.5;
HPWang 0:7b2e8e9735ec 12
HPWang 0:7b2e8e9735ec 13 ㄎㄛ
HPWang 0:7b2e8e9735ec 14
HPWang 0:7b2e8e9735ec 15 int main() {
HPWang 0:7b2e8e9735ec 16
HPWang 0:7b2e8e9735ec 17 mypwm.period_ms(10);
HPWang 0:7b2e8e9735ec 18 mypwm.pulsewidth_ms(1);
HPWang 0:7b2e8e9735ec 19
HPWang 0:7b2e8e9735ec 20 printf("pwm set to %.2f %%\n", mypwm.read() * 100);
HPWang 0:7b2e8e9735ec 21
HPWang 0:7b2e8e9735ec 22 while(1) {
HPWang 0:7b2e8e9735ec 23 myled = !myled;
HPWang 0:7b2e8e9735ec 24 wait(1);
HPWang 0:7b2e8e9735ec 25 }
HPWang 0:7b2e8e9735ec 26 }