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.
Diff: E5_Lekt1_HexLeds_Digitalio.cpp
- Revision:
- 0:b4e3ba4a7bd3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/E5_Lekt1_HexLeds_Digitalio.cpp Sun Jan 12 21:58:09 2020 +0000
@@ -0,0 +1,62 @@
+/*
+5. [HexLeds] Erzeuge das folgende HexLeds Programm für vier Leds und folgenden Funktionen:
+
+main() {
+ hexleds.eingabe() // einlesen eines Integer-Wertes von der Tastatur mit scanf("%d", &ein);
+ hexleds.ausgabe() // ausgeben des Integer-Wertes der von der Tastatur eingegeben wurde
+ hexleds.hexOut() // Ausgabe des Wertes in Hex-Darstellung an den 4 Leds
+ hexleds.printStatus() // Anzeigen ob Leds ein oder aus
+*/
+#include "mbed.h"
+
+//BusOut leds(D0,D3,D6,D9,D11,D12,A1,A5);
+BusOut leds(D0,D3,D6,D9);
+
+int hexleds_eingabe(int eingabe);
+int hexleds_ausgabe(int ausgabe);
+int hexleds_hexout(int hexout);
+int hexleds_printstatus(int value);
+
+int main()
+{
+ int value=0;
+ while(1)
+ {
+ value=hexleds_eingabe(value);
+ hexleds_ausgabe(value);
+ hexleds_hexout(value);
+ hexleds_printstatus(value);
+ }
+}
+
+
+int hexleds_printstatus(int kontrolle)
+{
+ if(leds=kontrolle)
+ {
+ printf("alles leuchtet\n");
+ }
+ else
+ {
+ printf("alles falsch\n");
+ }
+ return kontrolle;
+}
+
+int hexleds_hexout(int hexout)
+{
+ leds=hexout;
+ return hexout;
+}
+
+int hexleds_ausgabe(int ausgabe)
+{
+ printf("Wert: %d\n",ausgabe);
+ return ausgabe;
+}
+
+int hexleds_eingabe(int eingabe)
+{
+ eingabe=0xE;
+ return eingabe;
+}
\ No newline at end of file