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
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 PinName pin_CDS = PB_0; 00005 PinName pin_LEDR = PB_6; 00006 PinName pin_LEDG = PB_5; 00007 PinName pin_LEDB = PB_4; 00008 00009 AnalogIn adc_CDS(pin_CDS); 00010 00011 // rs, rw, e, d0-d3 00012 TextLCD lcd(PB_12, PB_13, PB_14, PB_15, PA_9, PA_10, PA_11); 00013 00014 PwmOut LEDR(pin_LEDR); 00015 PwmOut LEDG(pin_LEDG); 00016 PwmOut LEDB(pin_LEDB); 00017 00018 float LED_Ctrl(int value); 00019 00020 int main() { 00021 00022 int ADC_Data; 00023 float Brightness; 00024 LEDR = LED_Ctrl(0); 00025 LEDG = LED_Ctrl(0); 00026 LEDB = LED_Ctrl(0); 00027 00028 lcd.printf(" ADC Data : \n"); 00029 lcd.printf(""); 00030 while(1) { 00031 ADC_Data = adc_CDS.read()*4095; 00032 lcd.locate(12, 0); 00033 lcd.printf("%4d", ADC_Data); 00034 if(ADC_Data > 3000) 00035 ADC_Data = 3000; 00036 ADC_Data /= 30; 00037 Brightness = (100.0 - ADC_Data) / 100; 00038 LEDR = Brightness; 00039 LEDG = Brightness; 00040 LEDB = Brightness; 00041 wait(0.5); 00042 } 00043 } 00044 00045 // brightness Control 0 ~ 100(%) 00046 float LED_Ctrl(int value) 00047 { 00048 float brightness = value; 00049 brightness /= 100; 00050 return brightness; 00051 }
Generated on Fri Jul 15 2022 23:29:01 by
1.7.2