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.
main.cpp
- Committer:
- martwerl
- Date:
- 2018-11-15
- Revision:
- 0:a082d4766316
File content as of revision 0:a082d4766316:
#include "mbed.h"
//Lauflicht, das sich bei jedem Button-Click um 1 weiterbewegt
//Das ist die Polling Lösung
// LSB MSB
// 2^0 2^1 2^2 2^11
BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); // Ausgabe für eine Bit Gruppe
// D20 D19 D18 D17 D16 D15 D14 D13 D4 D3 D2 D1
// SW1 SW2 SW3 SW4
// Bit0 Bit1 Bit2 Bit3
//BusIn btn(P0_10,P0_15,P0_23,P1_16); //Ausgabe für eine Bitgruppe
DigitalIn sw4(P1_16); //Taster
int PrevSW4 = 0;//Schalterzustand, wie er bei der letzten Abfrage war
void OneRunLightStep(); //einen Schritt eines Lauflichts ausführen
int CheckButton();
int main()
{
lb = 1;
while(1) {
if(CheckButton() )
OneRunLightStep();
}
}
int CheckButton()
{
int ret = 0;
if(sw4 == 1 && PrevSW4 == 0)//Taster gedrückt und alter Schalterzustand 0
ret = 1;
else
ret = 0;
PrevSW4 = sw4; //alten Schalterzustand merken
return ret;//wenn 1 retouniert wird, wird Funktion OneRunLightStep() aufgerufen
}
void OneRunLightStep()
{
if(lb == 0)//wenns finster ist...
lb = 1;//einschalten
else
lb = lb << 1;//...um 1 nach links schieben
}