Besa Mavriqi
/
Mbed_Dig_Out_Class_Reffernce
Mbed
Embed:
(wiki syntax)
Show/hide line numbers
Mbed_Dig_Out_Class_Reffernce.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut led1(LED1); // Create a DigitalOut connected to the specified pin. 00004 DigitalOut led2(LED2, 0); // Create a DigitalOut connected to the specified pin and initialize with 0 00005 DigitalOut led3(LED3); 00006 DigitalOut led4(LED4); 00007 00008 int value = 1; 00009 00010 int main(void) { 00011 led1.write(1); // Set the output, specified as 0 or 1 (int) 00012 led2 = 1; // DigitalOut & operator= (int value) - A shorthand for write() 00013 led3 = value; // DigitalOut & operator= (int value) - A shorthand for write() 00014 led4 = led3; // DigitalOut & operator= (DigitalOut &rhs) - A shorthand for write() using the assignment operator which copies the state from the DigitalOut argument. 00015 00016 if(led2.is_connected ()) { // Return the output setting, represented as 0 or 1 00017 if(led2.read() ) // Return the output setting, represented as 0 or 1 (int) 00018 printf("%d %d\n", led1.read(), led2.read()); 00019 } 00020 if(led2) // operator int () - A shorthand for read() 00021 printf("%d %d\n", led3.read(), led4.read()); 00022 00023 return 0; 00024 }
Generated on Thu Jul 14 2022 10:59:56 by 1.7.2