DigitalOut クラスを継承して,オープンドレインにも設定できるように拡張した DigitalOutEx クラスの使用例. Example of derived class DigitalOutEx for setting also open-drain inherited from DigitalOut class.
Dependencies: UIT_DigitalOutEx mbed
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2015-08-25
- Revision:
- 1:9aa6eadce404
- Parent:
- 0:390e8489dea4
- Child:
- 2:21f669fe4965
File content as of revision 1:9aa6eadce404:
//------------------------------------------------------------- // DigitalOutEx クラスの使用例(赤色 LED をオープンドレインで駆動する) // // LED のアノード側: 5 V // LED のカソード側: D8 // // 初期状態はオープンドレインに設定するが,count > 10 に // なったらプッシュプル出力に設定しなおす // // 2015/08/25, Copyright (c) 2015 MIKAMI, Naoki //------------------------------------------------------------- #include "DigitalOutEx.hpp" using namespace Mikami; // デフォルトはオープンドレインに設定される DigitalOutEx ledR_(D8); // PA_9, LED のカソード側をこの端子につなぐ //DigitalOutEx ledR_(D8, DigitalOutEx::PushPull); // PA_9 //DigitalOutEx ledR_(D6); // PB_10 //DigitalOutEx ledR_(A4, 1); // PC_1 //DigitalOutEx ledR_(PD_2); // NG int main() { int count = 0; while(true) { ledR_ = !ledR_; // 前の状態の逆にする wait(1); if (++count > 10) ledR_.SetPushPull(); // プッシュプル出力に設定 } }