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.
main.cpp@0:40e67238a337, 2010-08-29 (annotated)
- Committer:
- takeuchi
- Date:
- Sun Aug 29 12:03:20 2010 +0000
- Revision:
- 0:40e67238a337
- Child:
- 1:a8aceb43c7bf
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| takeuchi | 0:40e67238a337 | 1 | // PWM1 |
| takeuchi | 0:40e67238a337 | 2 | #include "mbed.h" |
| takeuchi | 0:40e67238a337 | 3 | #include "TextLCD.h" |
| takeuchi | 0:40e67238a337 | 4 | |
| takeuchi | 0:40e67238a337 | 5 | #define ON 1 |
| takeuchi | 0:40e67238a337 | 6 | #define OFF 0 |
| takeuchi | 0:40e67238a337 | 7 | |
| takeuchi | 0:40e67238a337 | 8 | DigitalOut mled1(LED1); |
| takeuchi | 0:40e67238a337 | 9 | DigitalOut mled2(LED2); |
| takeuchi | 0:40e67238a337 | 10 | DigitalOut mled3(LED3); |
| takeuchi | 0:40e67238a337 | 11 | DigitalOut mled4(LED4); |
| takeuchi | 0:40e67238a337 | 12 | AnalogIn vin_adc(p20); |
| takeuchi | 0:40e67238a337 | 13 | AnalogIn vr_adc(p19); |
| takeuchi | 0:40e67238a337 | 14 | PwmOut railout_pwm(p21); |
| takeuchi | 0:40e67238a337 | 15 | |
| takeuchi | 0:40e67238a337 | 16 | TextLCD lcd(p24, p25, p26, p27, p28, p29, p30,16,2); // rs, rw, e, d0, d1, d2, d3 |
| takeuchi | 0:40e67238a337 | 17 | float adc_volt; |
| takeuchi | 0:40e67238a337 | 18 | |
| takeuchi | 0:40e67238a337 | 19 | int main() { |
| takeuchi | 0:40e67238a337 | 20 | float vr_data; |
| takeuchi | 0:40e67238a337 | 21 | while(1){ |
| takeuchi | 0:40e67238a337 | 22 | vr_data=vr_adc.read(); |
| takeuchi | 0:40e67238a337 | 23 | lcd.cls(); |
| takeuchi | 0:40e67238a337 | 24 | lcd.locate(0,0); |
| takeuchi | 0:40e67238a337 | 25 | lcd.printf("Vin:%2.1fV",vin_adc.read()*15); |
| takeuchi | 0:40e67238a337 | 26 | lcd.locate(0,1); |
| takeuchi | 0:40e67238a337 | 27 | lcd.printf("Dt:%2.0f%%",vr_data*100); |
| takeuchi | 0:40e67238a337 | 28 | railout_pwm.write(vr_data); |
| takeuchi | 0:40e67238a337 | 29 | mled1=ON; |
| takeuchi | 0:40e67238a337 | 30 | wait(vr_data); |
| takeuchi | 0:40e67238a337 | 31 | mled1=OFF; |
| takeuchi | 0:40e67238a337 | 32 | wait(vr_data); |
| takeuchi | 0:40e67238a337 | 33 | }//while |
| takeuchi | 0:40e67238a337 | 34 | }//main |