このプログラムはEightDotMatrixLedライブラリのサンプルプログラムです。 このサンプルプログラムは8個のLEDを4組点滅制御しています。 This program is a sample program EightDotMatrixLed library. This sample program to control the LED blinks four sets of eight. 動画回路での点灯制御の説明 1番上の赤色LED(com0):点灯・消灯を1秒かけてスムーズに行います 2番目の緑色LED(com1):点灯はスムーズ。消灯は直ぐに行います。 3番目の赤色LED(com2):点灯・消灯は1番目と同じ。輝度の上限を右から左に段階的に大きくしています。 4番目の赤色LED(com3):輝度データ(gray data)を直接制御しています。 =動画 video = {{http://www.youtube.com/watch?v=aRjSfpSjA30}} =回路図 schematic = {{/media/uploads/suupen/111204exampleschematic.jpg}}
Dependencies: mbed EightDotMatrixLed
main.cpp
00001 //============================================ 00002 // eightDotMatrixLed Library Example 00003 // 00004 // This program is used to control the LED 32. 00005 // 00006 // 00007 // <schematic> 00008 // --|>|-- 00009 // A K 00010 // seg A(p5) -----R(200[ohm])--- LED ----- com0(p13) 00011 // | 00012 // -- R(200[ohm])--- LED ----- com1(p14) 00013 // | 00014 // -- R(200[ohm])--- LED ----- com2(p28) 00015 // | 00016 // -- R(200[ohm])--- LED ----- com3(p27) 00017 // 00018 // 00019 // same : segB(p6), segC(p7), segD(p8), segE(p9), segF(p10), segG(p11), segH(p12) 00020 // 00021 // <Description of LED control> 00022 // com0 Led off to on ,on to off smooth (lighting = 0 to 100 [%] 00023 // com1 Led off to on smooth, on to off hard 00024 // com2 Led off to on, on to off smooth (lighting = 0 to gray data) 00025 // com3 gray data movement 00026 // 00027 //============================================= 00028 00029 #include "mbed.h" 00030 00031 #include "EightDotMatrixLed.h" 00032 00033 // common type (0:anode common 1:cathode common) 00034 // | 00035 // | segA segB segC segD segE segF segG segh com1 com2 com3 com4 (com5 to com8 = disable) 00036 // | | | | | | | | | | | | | 00037 EightDotMatrixLed segmentled(1, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p28, p27); 00038 00039 // com0 Led off to on ,on to off smooth (lighting = 0 to 100 [%] 00040 // com1 Led off to on smooth, on to off hard 00041 // com2 Led off to on, on to off smooth (lighting = 0 to gray data) 00042 // com3 gray data movement 00043 00044 00045 uint8_t D_dotGrayData[4][8] = { 00046 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // com0 disable 00047 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // com1 disable 00048 {0, 14, 29, 43, 57, 71, 86, 100}, // com2 enable (0 to 100 [%]) 00049 {0, 14, 29, 43, 57, 71, 86, 100}, // com3 enable (0 to 100 [%]) 00050 }; 00051 uint8_t D_dotDigitalData[4][8] = { 00052 {0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // com0 0:off, 1:on 00053 {0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // com1 0:disalbe 1:on 00054 {0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // com2 0:off, 1:on 00055 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} // com3 disable 00056 }; 00057 00058 Timer timer; // data change timer 00059 00060 int main() { 00061 uint8_t seg; 00062 uint8_t wk0, wk1, wk2, wk3; 00063 00064 timer.start(); 00065 00066 while(1) { 00067 // After 500[ms] to start the process 00068 if(timer.read_ms() >= 500){ 00069 timer.reset(); 00070 00071 // com0 Led off to on ,on to off smooth (lighting = 0 to 100 [%] 00072 wk0 = D_dotDigitalData[0][7]; 00073 for(seg = 7; seg > 0; seg--){ 00074 D_dotDigitalData[0][seg] = D_dotDigitalData[0][seg - 1]; 00075 } 00076 D_dotDigitalData[0][0] = wk0; 00077 00078 // com1 Led off to on smooth, on to off hard 00079 wk1 = D_dotDigitalData[1][7]; 00080 for(seg = 7; seg > 0; seg--){ 00081 D_dotDigitalData[1][seg] = D_dotDigitalData[1][seg - 1]; 00082 } 00083 D_dotDigitalData[1][0] = wk1; 00084 00085 // com2 Led off to on, on to off smooth (lighting = 0 to gray data) 00086 wk2 = D_dotDigitalData[2][7]; 00087 for(seg = 7; seg > 0; seg--){ 00088 D_dotDigitalData[2][seg] = D_dotDigitalData[2][seg - 1]; 00089 } 00090 D_dotDigitalData[2][0] = wk2; 00091 00092 // com3 gray data movement 00093 wk3 = D_dotGrayData[3][7]; 00094 for(seg = 7; seg > 0; seg--){ 00095 D_dotGrayData[3][seg] = D_dotGrayData[3][seg - 1]; 00096 } 00097 D_dotGrayData[3][0] = wk3; 00098 } 00099 00100 // This function, please repeat the process in less than 1ms. 00101 segmentled.EightDotMatrixLed_main((uint8_t*)D_dotGrayData, (uint8_t*)D_dotDigitalData); 00102 00103 } 00104 }
Generated on Sun Jul 17 2022 00:12:35 by 1.7.2