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: B2_Lekt1_BusOut_Digitalio.cpp
- Revision:
- 0:b4e3ba4a7bd3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/B2_Lekt1_BusOut_Digitalio.cpp Sun Jan 12 21:58:09 2020 +0000
@@ -0,0 +1,41 @@
+/*
+https://os.mbed.com/users/fpucher/code/TINF/wiki/BusOut-Programm
+ 2.Kodieren Sie den Joystick-Wert auf die jeweilige Pinnummer und geben diese
+ auf die Leds binär aus (up = p15, alle Leds leuchten, usw. p16 wird zu 0001).
+*/
+#include "mbed.h"
+
+BusOut leds(D0,D3,D6,D9,D11,D12,A1,A5);
+
+AnalogIn x(A3);
+AnalogIn y(A4);
+DigitalIn sw(D10,PullUp);
+
+int main()
+{
+
+ while(1)
+ {
+ if(sw.read()==0)
+ {
+ leds=0x0A;
+ }
+ if(x.read()<=0.1) //rechts
+ {
+ leds=0x03;
+ }
+ if(x.read()>=0.9) //links
+ {
+ leds=0x30;
+ }
+ if(y.read()<=0.1) //up
+ {
+ leds=0x04;
+ }
+
+ if(y.read()>=0.9) //down
+ {
+ leds=0x40;
+ }
+ }
+}
\ No newline at end of file