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.
3_Lekt_Analog_io
Wiki-Seite
Gehe auf die Lehrerbox/PE/TINF und kopiere den Inhalt der Datei program-wiki.txt auf IHRE EIGENE Wiki-Seite und ändere bzw. erweitere die entsprechenden Programme bzw. Textteile.
Diese Programme wurden im Mbed-Simulator geschrieben und getestet.
Lektion: Joystick
Programmbeschreibung:
Änderungen:
Datum:
A1_Lekt3_Joystick_Analogio.cpp
#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=0x0f;
}
if(x.read()<=0.1) //rechts
{
leds=0x01;
}
if(x.read()>=0.9) //links
{
leds=0x02;
}
if(y.read()<=0.1) //up
{
leds=0x04;
}
if(y.read()>=0.9) //down
{
leds=0x08;
}
}
}
Lektion: Poti
Programmbeschreibung:
Änderungen:
Datum:
A2_Lekt3_Poti_Analogio.cpp
#include "mbed.h"
Serial pc(USBTX,USBRX);
AnalogIn poti(A3);
int main()
{
//Datenformat bei Sender und Empfänger gleich einstellen
//8-Datenbits, kein paritätsbit, 1 stoppbit
pc.format(8,Serial::None,1);
pc.baud(115200);
int val;
while(1)
{
//6-Bit nach rechts schieben um die wirklichen 10-bit zu erhalten_0bis1023
//wegen mbed
val=poti.read_u16()>>6;
printf("%d\n",val);
wait_ms(500);
}
}
void test1()
{
int cnt=0; //counter
while(1)
{
printf("Hallo %d\n",cnt);
cnt++;
wait_ms(500);
}
}