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.
A5_Lekt1_Knightrider_Digitalio.cpp
- Committer:
- robertbuc
- Date:
- 2020-01-12
- Revision:
- 1:f67201cad9f7
- Parent:
- 0:b4e3ba4a7bd3
File content as of revision 1:f67201cad9f7:
/*
5. [Knightrider] Erstelle mit Hilfe der DigitalOut ein Programm zur Erzeugung
des LED-Sweep-Effekt „Knightrider“ mit den integrierten vier blauen LEDs.
*/
#include "mbed.h"
BusOut leds(D0,D3,D6,D9,D11,D12,A1,A5);
void knightrider();
int main()
{
while(1)
{
knightrider();
}
}
void knightrider()
{
leds=1;
wait_ms(300);
for(int i=0;i<3;i++) //4 lichter einschalten
{
leds=leds<<1|1;
wait_ms(300);
}
for(int i=0;i<8;i++) //4 lichter verschieben
{
leds=leds<<1;
wait_ms(300);
}
//retour
leds=128;
wait_ms(300);
for(int i=0;i<3;i++) //4 lichter einschalten
{
leds=leds>>1|128;
wait_ms(300);
}
for(int i=0;i<8;i++) //4 lichter verschieben
{
leds=leds>>1;
wait_ms(300);
}
}