Besa Mavriqi
/
Mbed_Dig_Out_Class_Reffernce
Mbed
Diff: Mbed_Dig_Out_Class_Reffernce.cpp
- Revision:
- 0:645b1d3bcc9d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mbed_Dig_Out_Class_Reffernce.cpp Tue Jan 14 23:09:29 2020 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +DigitalOut led1(LED1); // Create a DigitalOut connected to the specified pin. +DigitalOut led2(LED2, 0); // Create a DigitalOut connected to the specified pin and initialize with 0 +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +int value = 1; + +int main(void) { + led1.write(1); // Set the output, specified as 0 or 1 (int) + led2 = 1; // DigitalOut & operator= (int value) - A shorthand for write() + led3 = value; // DigitalOut & operator= (int value) - A shorthand for write() + led4 = led3; // DigitalOut & operator= (DigitalOut &rhs) - A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument. + + if(led2.is_connected ()) { // Return the output setting, represented as 0 or 1 + if(led2.read() ) // Return the output setting, represented as 0 or 1 (int) + printf("%d %d\n", led1.read(), led2.read()); + } + if(led2) // operator int () - A shorthand for read() + printf("%d %d\n", led3.read(), led4.read()); + + return 0; +} \ No newline at end of file