![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
FRDM-KL25Z with Arduino LCD KeyPad Shield (SKU: DFR0009).
FRDM-KL25Z with Arduino LCD KeyPad Shield (SKU: DFR0009).
/*** * --------------------------------------------- * Arduino LCD KeyPad Shield (SKU: DFR0009) * --------------------------------------------- * - Button : a0 -> PTB0 * right : < 0x0100 * up : < 0x5400 * down : < 0xa500 * left : < 0xfd00 * select : ??? * --------------------------------------------- * - DB4 : d4 -> PTA4 * - DB5 : d5 -> PTA5 * - DB6 : d6 -> PTC8 * - DB7 : d7 -> PTC9 * - RS : d8 -> PTA13 * - Enable : d9 -> PTD5 * - Backlight Control : d10 -> PTD0 * --------------------------------------------- * - http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009) * - http://www.dfrobot.com/index.php?route=product/product&keyword=DFR0009&category_id=0&description=1&model=1&product_id=51 * - http://www.amazon.co.jp/dp/B00ACCN148 * - http://akizukidenshi.com/catalog/g/gM-07029/ ***/
main.cpp@1:c04ae2fc1a27, 2014-03-14 (annotated)
- Committer:
- MRSa
- Date:
- Fri Mar 14 14:17:00 2014 +0000
- Revision:
- 1:c04ae2fc1a27
- Parent:
- 0:ca0a38f28cbe
- Child:
- 2:796f7d90beac
add backlight control.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MRSa | 0:ca0a38f28cbe | 1 | #include "mbed.h" |
MRSa | 0:ca0a38f28cbe | 2 | #include "TextLCD.h" |
MRSa | 0:ca0a38f28cbe | 3 | |
MRSa | 0:ca0a38f28cbe | 4 | DigitalOut myled(LED1); |
MRSa | 0:ca0a38f28cbe | 5 | |
MRSa | 0:ca0a38f28cbe | 6 | #ifdef TARGET_KL25Z |
MRSa | 0:ca0a38f28cbe | 7 | // LCD (RS, E, D4, D5, D6, D7) |
MRSa | 0:ca0a38f28cbe | 8 | TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9); // LCD Shield for Arduino (DFR00009) |
MRSa | 0:ca0a38f28cbe | 9 | AnalogIn button(PTB0); // board button |
MRSa | 1:c04ae2fc1a27 | 10 | PwmOut backlight(PTD0); |
MRSa | 0:ca0a38f28cbe | 11 | #endif |
MRSa | 0:ca0a38f28cbe | 12 | |
MRSa | 0:ca0a38f28cbe | 13 | /*** |
MRSa | 0:ca0a38f28cbe | 14 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 15 | * Arduino LCD KeyPad Shield (SKU: DFR0009) |
MRSa | 0:ca0a38f28cbe | 16 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 17 | * - Button : a0 -> PTB0 |
MRSa | 0:ca0a38f28cbe | 18 | * right : < 0.15 |
MRSa | 0:ca0a38f28cbe | 19 | * up : < 0.35 |
MRSa | 0:ca0a38f28cbe | 20 | * down : < 0.65 |
MRSa | 0:ca0a38f28cbe | 21 | * left : < 0.99 |
MRSa | 0:ca0a38f28cbe | 22 | * select : ??? |
MRSa | 0:ca0a38f28cbe | 23 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 24 | * - DB4 : d4 -> pta4 |
MRSa | 0:ca0a38f28cbe | 25 | * - DB5 : d5 -> pta5 |
MRSa | 0:ca0a38f28cbe | 26 | * - DB6 : d6 -> ptc8 |
MRSa | 0:ca0a38f28cbe | 27 | * - DB7 : d7 -> ptc9 |
MRSa | 0:ca0a38f28cbe | 28 | * - RS : d8 -> pta13 |
MRSa | 0:ca0a38f28cbe | 29 | * - Enable : d9 -> ptd5 |
MRSa | 0:ca0a38f28cbe | 30 | * - Backlit Control : d10 -> ptd0 |
MRSa | 0:ca0a38f28cbe | 31 | * --------------------------------------------- |
MRSa | 0:ca0a38f28cbe | 32 | * - http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009) |
MRSa | 0:ca0a38f28cbe | 33 | * - http://www.dfrobot.com/index.php?route=product/product&keyword=DFR0009&category_id=0&description=1&model=1&product_id=51 |
MRSa | 0:ca0a38f28cbe | 34 | * - http://www.amazon.co.jp/dp/B00ACCN148 |
MRSa | 0:ca0a38f28cbe | 35 | * - http://akizukidenshi.com/catalog/g/gM-07029/ |
MRSa | 0:ca0a38f28cbe | 36 | ***/ |
MRSa | 0:ca0a38f28cbe | 37 | |
MRSa | 0:ca0a38f28cbe | 38 | int main() |
MRSa | 0:ca0a38f28cbe | 39 | { |
MRSa | 0:ca0a38f28cbe | 40 | int count = 0; |
MRSa | 0:ca0a38f28cbe | 41 | #ifdef TARGET_KL25Z |
MRSa | 1:c04ae2fc1a27 | 42 | backlight = 1; // ON: 1, OFF: 0 |
MRSa | 0:ca0a38f28cbe | 43 | lcd.cls(); |
MRSa | 0:ca0a38f28cbe | 44 | lcd.printf("HELLO"); |
MRSa | 0:ca0a38f28cbe | 45 | #endif |
MRSa | 0:ca0a38f28cbe | 46 | while (1) |
MRSa | 0:ca0a38f28cbe | 47 | { |
MRSa | 0:ca0a38f28cbe | 48 | wait(0.3); |
MRSa | 0:ca0a38f28cbe | 49 | myled = (myled == 1) ? 0 : 1; |
MRSa | 0:ca0a38f28cbe | 50 | count = count + 1; |
MRSa | 0:ca0a38f28cbe | 51 | |
MRSa | 0:ca0a38f28cbe | 52 | #ifdef TARGET_KL25Z |
MRSa | 0:ca0a38f28cbe | 53 | // READ BUTTON VALUE |
MRSa | 0:ca0a38f28cbe | 54 | unsigned long value = button.read_u16(); |
MRSa | 0:ca0a38f28cbe | 55 | |
MRSa | 0:ca0a38f28cbe | 56 | // LCD OUTPUT |
MRSa | 0:ca0a38f28cbe | 57 | lcd.cls(); |
MRSa | 0:ca0a38f28cbe | 58 | lcd.locate(0,0); |
MRSa | 0:ca0a38f28cbe | 59 | lcd.printf("%d", count); // loop counter |
MRSa | 0:ca0a38f28cbe | 60 | |
MRSa | 0:ca0a38f28cbe | 61 | lcd.locate(0,1); |
MRSa | 0:ca0a38f28cbe | 62 | lcd.printf("BUTTON : %04x", value); // button value |
MRSa | 0:ca0a38f28cbe | 63 | #endif |
MRSa | 0:ca0a38f28cbe | 64 | } |
MRSa | 0:ca0a38f28cbe | 65 | } |