LAB LAB / Mbed 2 deprecated PWM_LCD

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 TextLCD lcd(p5, p6, p7, p8, p9, p10); // rs, e, d4-d7
00005  
00006 AnalogIn P1(p15);
00007 PwmOut led(LED1);
00008 PwmOut FM(p21);
00009 
00010 float Px;
00011 int PWM;
00012 
00013 int main() {
00014     
00015     led.period_ms (150);
00016          
00017     while(1) {
00018     
00019         Px = P1.read();
00020                        
00021             if(Px < 0.1){
00022             Px = 0.1;
00023             }
00024             if(Px > 0.9){
00025             Px = 0.9;
00026             }
00027         
00028         PWM = Px*100;
00029         led = Px;
00030         FM = Px; 
00031         Px = Px * 3.3;     
00032         lcd.printf("S_FMBM = %2d PWM\n",PWM);
00033         lcd.printf("V15 = %2.2f V\n",Px);
00034     }
00035 }
00036  
00037