Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
DigitalOut Class Reference
Anschließend wird ein Programm gezeigt, das alle Komponenten der Klassenreferenz der DigitalOut beinhaltet und mit den Kommentaren vergliechen werden kann:
DigitalOutClassReference.c
#include "mbed.h"
DigitalOut led1(LED1); // Create a DigitalOut connected to the specified pin.
DigitalOut led2(LED2);
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.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;
}