Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TSI TextLCD-modificada mbed
main.cpp@0:c5c53d980f96, 2013-12-05 (annotated)
- Committer:
- salondonog
- Date:
- Thu Dec 05 21:08:22 2013 +0000
- Revision:
- 0:c5c53d980f96
- Child:
- 1:8d8ab2b89420
PWM, controlado por touch FL25Z
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| salondonog | 0:c5c53d980f96 | 1 | #include "mbed.h" |
| salondonog | 0:c5c53d980f96 | 2 | #include "TSISensor.h" |
| salondonog | 0:c5c53d980f96 | 3 | #include "TextLCD.h" |
| salondonog | 0:c5c53d980f96 | 4 | |
| salondonog | 0:c5c53d980f96 | 5 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); |
| salondonog | 0:c5c53d980f96 | 6 | float dutty=0.5; //Ancho del pwm |
| salondonog | 0:c5c53d980f96 | 7 | float T=100; //Periodo del pwm |
| salondonog | 0:c5c53d980f96 | 8 | |
| salondonog | 0:c5c53d980f96 | 9 | int main(void) { |
| salondonog | 0:c5c53d980f96 | 10 | |
| salondonog | 0:c5c53d980f96 | 11 | PwmOut pwm(LED2); |
| salondonog | 0:c5c53d980f96 | 12 | TSISensor tsi; |
| salondonog | 0:c5c53d980f96 | 13 | pwm.pulsewidth(dutty); |
| salondonog | 0:c5c53d980f96 | 14 | pwm.period_ms(T); |
| salondonog | 0:c5c53d980f96 | 15 | |
| salondonog | 0:c5c53d980f96 | 16 | while (true) { |
| salondonog | 0:c5c53d980f96 | 17 | if(tsi.readPercentage()!=0){ |
| salondonog | 0:c5c53d980f96 | 18 | pwm = 1.0 - tsi.readPercentage(); |
| salondonog | 0:c5c53d980f96 | 19 | lcd.cls(); |
| salondonog | 0:c5c53d980f96 | 20 | lcd.printf("PWM=%g",tsi.readPercentage()); |
| salondonog | 0:c5c53d980f96 | 21 | } |
| salondonog | 0:c5c53d980f96 | 22 | wait(0.1); |
| salondonog | 0:c5c53d980f96 | 23 | } |
| salondonog | 0:c5c53d980f96 | 24 | } |