Bruno St-Georges
/
Question7
q7
Revision 0:646b2dba28ca, committed 2019-10-22
- Comitter:
- brunostgr
- Date:
- Tue Oct 22 13:39:46 2019 +0000
- Commit message:
- q7
Changed in this revision
Question7.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 646b2dba28ca Question7.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Question7.cpp Tue Oct 22 13:39:46 2019 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" + +PwmOut pwm(PC_7); // Broche PWM +Serial pc(USBTX, USBRX); // Port USB + +// Programme principal +int main() { + + // Declaration des variables + float th, th1, th2; + + pwm.period_ms(1); // Periode 1 ms pour frequence 1kHz + pwm.pulsewidth_us(1000); // Duty cycle 100% par defaut + pc.printf("Entrez une valeur de PWM a deux chiffres"); + + while(1) { + th1 = pc.getc(); // Chiffre des dizaines + th2 = pc.getc(); // Chiffre des unites + th = ((10 * (th1 - 0x30)) + (th2 - 0x30))*10; // Conversion en us + pwm.pulsewidth_us(th); // Assignation du nouveau duty cycle + } +}
diff -r 000000000000 -r 646b2dba28ca mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 22 13:39:46 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file