Värivalojen ohjauspaneli Controlling of RGB-led with push buttons
Diff: main.cpp
- Revision:
- 0:404701693bdc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 25 10:36:21 2018 +0000 @@ -0,0 +1,46 @@ + +#include "MicroBit.h" + +MicroBit uBit; +int A = 0; +int B = 0; +int C = 0; + +int main(){ + uBit.init(); + while (1){ + A = uBit.io.P1.getDigitalValue(); + B = uBit.io.P5.getDigitalValue(); + C = uBit.io.P0.getDigitalValue(); + + if ((A == 1 && B == 1) && C == 1) { + uBit.io.P2.setDigitalValue(1); + uBit.sleep(1000); + uBit.io.P2.setDigitalValue(0); + uBit.io.P11.setDigitalValue(1); + uBit.sleep(1000); + uBit.io.P11.setDigitalValue(0); + uBit.io.P8.setDigitalValue(1); + uBit.sleep(1000); + uBit.io.P8.setDigitalValue(0); + } else { + if(A == 1){ + uBit.io.P2.setDigitalValue(1); + } else { + uBit.io.P2.setDigitalValue(0); + } + if(B == 1){ + uBit.io.P11.setDigitalValue(1); + } else { + uBit.io.P11.setDigitalValue(0); + } + if(C == 1){ + uBit.io.P8.setDigitalValue(1); + } else { + uBit.io.P8.setDigitalValue(0); + } + } + } +} + +