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 DigitalOut myled(LED1); 00005 00006 #ifdef TARGET_KL25Z 00007 // LCD (RS, E, D4, D5, D6, D7) 00008 TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9); // LCD Shield for Arduino (DFR00009) 00009 AnalogIn button(PTB0); // board button 00010 PwmOut backlight(PTD0); 00011 #endif 00012 00013 /*** 00014 * --------------------------------------------- 00015 * Arduino LCD KeyPad Shield (SKU: DFR0009) 00016 * --------------------------------------------- 00017 * - Button : a0 -> PTB0 00018 * right : < 0.15 00019 * up : < 0.35 00020 * down : < 0.65 00021 * left : < 0.99 00022 * select : ??? 00023 * --------------------------------------------- 00024 * - DB4 : d4 -> pta4 00025 * - DB5 : d5 -> pta5 00026 * - DB6 : d6 -> ptc8 00027 * - DB7 : d7 -> ptc9 00028 * - RS : d8 -> pta13 00029 * - Enable : d9 -> ptd5 00030 * - Backlight Control : d10 -> ptd0 00031 * --------------------------------------------- 00032 * - http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009) 00033 * - http://www.dfrobot.com/index.php?route=product/product&keyword=DFR0009&category_id=0&description=1&model=1&product_id=51 00034 * - http://www.amazon.co.jp/dp/B00ACCN148 00035 * - http://akizukidenshi.com/catalog/g/gM-07029/ 00036 ***/ 00037 00038 int main() 00039 { 00040 int count = 0; 00041 #ifdef TARGET_KL25Z 00042 backlight = 1; // ON: 1, OFF: 0 00043 lcd.cls(); 00044 lcd.printf("HELLO"); 00045 wait(0.5); 00046 #endif 00047 while (1) 00048 { 00049 myled = (myled == 1) ? 0 : 1; 00050 count = count + 1; 00051 00052 #ifdef TARGET_KL25Z 00053 // READ BUTTON VALUE 00054 unsigned long value = button.read_u16(); 00055 00056 // LCD OUTPUT 00057 lcd.cls(); 00058 lcd.locate(0,0); 00059 lcd.printf("%d", count); // loop counter 00060 00061 lcd.locate(0,1); 00062 lcd.printf("BUTTON : %04x", value); // button value 00063 #endif 00064 wait(0.2); 00065 } 00066 }
Generated on Mon Jul 18 2022 00:10:12 by
1.7.2