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.
Revision 1:649584ec899f, committed 2017-07-05
- Comitter:
- j3
- Date:
- Wed Jul 05 23:37:13 2017 +0000
- Parent:
- 0:bcb65a6f0e8a
- Commit message:
- fix
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jul 05 22:49:24 2017 +0000
+++ b/main.cpp Wed Jul 05 23:37:13 2017 +0000
@@ -46,7 +46,7 @@
float volts = 0.0F;
float period = 0.0F;
- pwmOut.period_us(period);
+ pwmOut.period(period);
printf("\033[H"); //home
printf("\033[0J"); //erase from cursor to end of screen
@@ -61,18 +61,17 @@
//Get ADC value in volts
volts = ((6.0F * rawADCdata) / 1023.0F);
- //convert to percentage for pwm
- period = (volts / 3.3F);
- if(period > 1.0F)
- {
- period = 1.0F;
- }
- pwmOut.period_us(period);
+ //convert to period in seconds for pwm
+ period = (1.0F / ((300.0F * volts) + 10.0F));
+
+ //Update sqwv period
+ pwmOut.period(period);
+ pwmOut.write(0.5F);
//Display data
printf("Raw Data = 0x%04x\r\n", rawADCdata);
printf("Volts = %3.2f\r\n", volts);
- printf("Period = %3.2f\r\n", period);
+ printf("Period = %5.4f\r\n", period);
printf("\033[H"); //home
wait(0.1F);