a led demo code

Dependents:   Nucleo_F411RE_OS_Robot_Tank

Committer:
adaphoto
Date:
Tue Jun 19 12:24:06 2018 +0000
Revision:
2:94318e6e89ff
Parent:
1:6cb3a93ae325
??????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
adaphoto 0:651a5dcc2df6 1 #ifndef LED_H_ADA
adaphoto 0:651a5dcc2df6 2 #define LED_H_ADA
adaphoto 0:651a5dcc2df6 3
adaphoto 1:6cb3a93ae325 4 /*
adaphoto 1:6cb3a93ae325 5 Example of use:
adaphoto 1:6cb3a93ae325 6 * @code
adaphoto 1:6cb3a93ae325 7 *LED user_led(LED1);
adaphoto 1:6cb3a93ae325 8 *int main()
adaphoto 1:6cb3a93ae325 9 *{
adaphoto 1:6cb3a93ae325 10 *
adaphoto 1:6cb3a93ae325 11 * while (true)
adaphoto 1:6cb3a93ae325 12 * {
adaphoto 1:6cb3a93ae325 13 * user_led.LED_On();
adaphoto 1:6cb3a93ae325 14 * wait(0.05);
adaphoto 1:6cb3a93ae325 15 * user_led.LED_Off();
adaphoto 1:6cb3a93ae325 16 * wait(0.05);
adaphoto 1:6cb3a93ae325 17 * }
adaphoto 1:6cb3a93ae325 18 *}
adaphoto 1:6cb3a93ae325 19 * @code
adaphoto 1:6cb3a93ae325 20 */
adaphoto 1:6cb3a93ae325 21
adaphoto 0:651a5dcc2df6 22 class LED
adaphoto 0:651a5dcc2df6 23 {
adaphoto 0:651a5dcc2df6 24 public:
adaphoto 0:651a5dcc2df6 25 LED(PinName ledpin);
adaphoto 0:651a5dcc2df6 26
adaphoto 2:94318e6e89ff 27 // LED亮起控制函数,IO口输出高电平
adaphoto 0:651a5dcc2df6 28 void LED_On();
adaphoto 0:651a5dcc2df6 29
adaphoto 2:94318e6e89ff 30 // LED关闭控制函数,IO口输出低电平
adaphoto 0:651a5dcc2df6 31 void LED_Off();
adaphoto 0:651a5dcc2df6 32
adaphoto 2:94318e6e89ff 33 // LED闪烁控制函数,每次调用该函数,则IO口翻转一次状态
adaphoto 0:651a5dcc2df6 34 void LED_Troggle();
adaphoto 0:651a5dcc2df6 35
adaphoto 0:651a5dcc2df6 36 private:
adaphoto 0:651a5dcc2df6 37 DigitalOut led;
adaphoto 2:94318e6e89ff 38
adaphoto 2:94318e6e89ff 39 // 初始化函数
adaphoto 0:651a5dcc2df6 40 void init();
adaphoto 0:651a5dcc2df6 41 };
adaphoto 0:651a5dcc2df6 42
adaphoto 0:651a5dcc2df6 43 #endif