micro:bit kolme lediä liikennevaloina (punainen=P2, keltainen=P1, vihreä=P0) three leds as traffic lights (red=P2, yellow=P1, green=P0)

Dependencies:   microbit

Committer:
tyynetyyne
Date:
Thu May 24 08:22:07 2018 +0000
Revision:
0:1be186a0b596
traffic lights

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tyynetyyne 0:1be186a0b596 1 #include "MicroBit.h"
tyynetyyne 0:1be186a0b596 2
tyynetyyne 0:1be186a0b596 3 MicroBit uBit;
tyynetyyne 0:1be186a0b596 4
tyynetyyne 0:1be186a0b596 5 int main()
tyynetyyne 0:1be186a0b596 6 {
tyynetyyne 0:1be186a0b596 7 uBit.init();
tyynetyyne 0:1be186a0b596 8 while (1){
tyynetyyne 0:1be186a0b596 9 uBit.io.P2.setDigitalValue(1);
tyynetyyne 0:1be186a0b596 10 uBit.sleep(4000);
tyynetyyne 0:1be186a0b596 11 uBit.io.P1.setDigitalValue(1);
tyynetyyne 0:1be186a0b596 12 uBit.sleep(2000);
tyynetyyne 0:1be186a0b596 13 uBit.io.P2.setDigitalValue(0);
tyynetyyne 0:1be186a0b596 14 uBit.io.P1.setDigitalValue(0);
tyynetyyne 0:1be186a0b596 15 uBit.io.P0.setDigitalValue(1);
tyynetyyne 0:1be186a0b596 16 uBit.sleep(4000);
tyynetyyne 0:1be186a0b596 17 uBit.io.P0.setDigitalValue(0);
tyynetyyne 0:1be186a0b596 18 }
tyynetyyne 0:1be186a0b596 19 }