Värivalojen ohjauspaneli Controlling of RGB-led with push buttons
Revision 0:404701693bdc, committed 2018-07-25
- Comitter:
- tyynetyyne
- Date:
- Wed Jul 25 10:36:21 2018 +0000
- Commit message:
- Controlling RGB-led with push buttons (microbit);
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
microbit.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /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); + } + } + } +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/microbit.lib Wed Jul 25 10:36:21 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f