Test of ADC Pin to battery level on Coragem device
main.cpp
- Committer:
- idna
- Date:
- 2017-02-07
- Revision:
- 2:26e1d1bf3d08
- Parent:
- 0:54f4263790ee
File content as of revision 2:26e1d1bf3d08:
#include "mbed.h" //DigitalOut led1(LED1); DigitalOut led1(P0_13);// nRF52840 io DigitalOut led2(P0_14); DigitalOut led3(P0_15); DigitalOut led4(P0_16); InterruptIn button1(P0_11);//(USER_BUTTON nRf52840); InterruptIn button2(P0_12); InterruptIn button3(P0_24); InterruptIn button4(P0_25); int button3_flag=0; void button1_pressed() { led1 = 0; } void button1_released() { led1 = led2 =led3 =led4 = 1;// LED OFF //led1 = 0; } void button2_pressed() { led2 = 0; } void button2_released() { led1 = led2 =led3 =led4 = 1; //led1 = 0; } void button3_pressed() { button3_flag = 1; } void button3_released() { led1 = led2 =led3 =led4 = 1; //led1 = 0; button3_flag=0; } void button4_pressed() { led4 = 0; } void button4_released() { led1 = led2 =led3 =led4 = 1; //led1 = 0; } int main() { led1 = led2 =led3 =led4 = 0; button1.fall(&button1_pressed); button1.rise(&button1_released); button2.fall(&button2_pressed); button2.rise(&button2_released); button3.fall(&button3_pressed); button3.rise(&button3_released); button4.fall(&button4_pressed); button4.rise(&button4_released); while (true) { if(button3_flag == 1) { led3 = 0; wait(0.1); led3 = 1; wait(0.1); } else { led1 = !led1; wait(0.5); led2 = !led2; wait(0.5); led3 = !led3; wait(0.5); led4 = !led4; wait(0.5); } } }