7 years, 5 months ago.

LED明るさ制御

下記のプログラムで、「パターン25~27」の点灯を暗くしたい(明るさを変えたい)のですが どの様に制御させればよいか分からず困っており、質問させて頂きました。 ご教授頂けると幸いです。

  1. include "mbed.h"

Ticker flipper; BusOut Col(dp3,dp6,dp7,dp8,dp9,dp10,dp11,dp12); BusOut Row(dp15,dp16,dp17,dp18,dp19,dp20,dp21,dp22);

void flip() { uint8_t pt[][8] = { {0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, パターン1 {0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00}, パターン2 {0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00}, パターン3 {0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00}, パターン4 {0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00}, パターン5 {0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00}, パターン6 {0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00}, パターン7 {0x40,0x00,0x00,0x40,0x40,0x40,0x00,0x00}, パターン8 {0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x00}, パターン9 {0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40}, パターン10 {0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40}, パターン11 {0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,}, パターン12 {0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,}, パターン13 {0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,}, パターン14 {0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x40,}, パターン15 {0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,}, パターン16 {0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,}, パターン17 {0x00,0x08,0x08,0x08,0x00,0x00,0x00,0x00,}, パターン18 {0x00,0x00,0x08,0x08,0x08,0x00,0x00,0x00,}, パターン19 {0x08,0x00,0x00,0x08,0x08,0x08,0x00,0x00,}, パターン20 {0x00,0x08,0x00,0x00,0x08,0x08,0x08,0x00,}, パターン21 {0x00,0x00,0x08,0x00,0x00,0x08,0x08,0x08,}, パターン22 {0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x08,}, パターン23 {0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,}, パターン24 {0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,}, パターン25 {0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,}, パターン26 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,}, パターン27 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}, パターン28 blank {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}, パターン29 blank {0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}, パターン30 };

static int col = 0; static int puttern = 0; static int change = 0;

Row = 0; Col = pt[puttern][col]; Row = 1 << col;

col++; col %=8;

change; if(change <= 0) {

パターンを切り替える puttern++; puttern %= sizeof(pt) / sizeof(*pt);

次に切り替えるまでの処理回数をセットする change = 100; } }

int main() { flipper.attach(&flip,0.001);

while(1) { } }

1 Answer

7 years, 5 months ago.

全フレーム同じデータを出さないで、(ちらつかない程度に)交互にON/OFFを切り替えれば良いと思います。

Accepted Answer