hi

Dependencies:   microbit

Committer:
bvnoake
Date:
Sun Mar 03 09:19:54 2019 +0000
Revision:
0:efa5691654d7
Child:
1:52a1fd1e7193
Challenge2; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bvnoake 0:efa5691654d7 1 #include "MicroBit.h"
bvnoake 0:efa5691654d7 2 //#include "binTree.h"
bvnoake 0:efa5691654d7 3
bvnoake 0:efa5691654d7 4 MicroBit uBit;
bvnoake 0:efa5691654d7 5
bvnoake 0:efa5691654d7 6 uint64_t reading;
bvnoake 0:efa5691654d7 7 bool running = false;
bvnoake 0:efa5691654d7 8 int value = 0;
bvnoake 0:efa5691654d7 9 bool BP = false;
bvnoake 0:efa5691654d7 10
bvnoake 0:efa5691654d7 11 int read1;
bvnoake 0:efa5691654d7 12
bvnoake 0:efa5691654d7 13
bvnoake 0:efa5691654d7 14 int main()
bvnoake 0:efa5691654d7 15 {
bvnoake 0:efa5691654d7 16
bvnoake 0:efa5691654d7 17 uBit.init();
bvnoake 0:efa5691654d7 18 while(1)
bvnoake 0:efa5691654d7 19 {
bvnoake 0:efa5691654d7 20 MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_DIGITAL);
bvnoake 0:efa5691654d7 21
bvnoake 0:efa5691654d7 22 value = P0.getDigitalValue();
bvnoake 0:efa5691654d7 23
bvnoake 0:efa5691654d7 24 reading = system_timer_current_time();
bvnoake 0:efa5691654d7 25 read1 = uBit.systemTime();
bvnoake 0:efa5691654d7 26 while(P0.getDigitalValue() == 1)
bvnoake 0:efa5691654d7 27 {
bvnoake 0:efa5691654d7 28 BP = true;
bvnoake 0:efa5691654d7 29 }
bvnoake 0:efa5691654d7 30 read1 = uBit.systemTime() - read1;
bvnoake 0:efa5691654d7 31 while (value == 1)
bvnoake 0:efa5691654d7 32 {
bvnoake 0:efa5691654d7 33 // uBit.display.scroll("read");
bvnoake 0:efa5691654d7 34 // read = system_timer_current_time() - reading;
bvnoake 0:efa5691654d7 35 if (1 > 0 && 1 < 500)
bvnoake 0:efa5691654d7 36 {
bvnoake 0:efa5691654d7 37 //shows a dot on the screen
bvnoake 0:efa5691654d7 38 uBit.display.scroll("dot");
bvnoake 0:efa5691654d7 39 }
bvnoake 0:efa5691654d7 40 //if button is held down for a brief amount of time
bvnoake 0:efa5691654d7 41 else if (1 > 500 )
bvnoake 0:efa5691654d7 42 {
bvnoake 0:efa5691654d7 43 //shows a dash on screen
bvnoake 0:efa5691654d7 44 uBit.display.scroll("dash");
bvnoake 0:efa5691654d7 45 }
bvnoake 0:efa5691654d7 46 //if button held down for a longer time
bvnoake 0:efa5691654d7 47 /*else if (timepressed > 1500)
bvnoake 0:efa5691654d7 48 {
bvnoake 0:efa5691654d7 49 //displays stop along the screen
bvnoake 0:efa5691654d7 50 uBit.display.scroll("STOP");
bvnoake 0:efa5691654d7 51 //sets mcode as false so buttons stop running
bvnoake 0:efa5691654d7 52 mcode = false;
bvnoake 0:efa5691654d7 53 }
bvnoake 0:efa5691654d7 54 */
bvnoake 0:efa5691654d7 55 value = 0;
bvnoake 0:efa5691654d7 56 }
bvnoake 0:efa5691654d7 57
bvnoake 0:efa5691654d7 58
bvnoake 0:efa5691654d7 59
bvnoake 0:efa5691654d7 60
bvnoake 0:efa5691654d7 61
bvnoake 0:efa5691654d7 62 }
bvnoake 0:efa5691654d7 63 release_fiber();
bvnoake 0:efa5691654d7 64
bvnoake 0:efa5691654d7 65
bvnoake 0:efa5691654d7 66 }
bvnoake 0:efa5691654d7 67
bvnoake 0:efa5691654d7 68