Besa Mavriqi
/
Mbed_Dig_Out_Class_Reffernce
Mbed
Mbed_Dig_Out_Class_Reffernce.cpp
- Committer:
- besam
- Date:
- 2020-01-14
- Revision:
- 0:645b1d3bcc9d
File content as of revision 0:645b1d3bcc9d:
#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; }