Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include "MicroBit.h"
  2.  
  3. MicroBit uBit;
  4. MicroBitButton buttonA(MICROBIT_PIN_BUTTON_A, MICROBIT_ID_BUTTON_A);
  5.  
  6. //Construction of a struct for the binary tree used
  7. //accepting a node that either translates to a dash
  8. //or a dot
  9. struct tree
  10. {
  11.   char key_value;
  12.   node *dash;
  13.   node *dot;
  14. };
  15.  
  16. tree* treeChar(char key_value)
  17. {
  18.   tree* tree = new struct tree;
  19.   tree->DOT = NULL;
  20.   tree->DOT = NULL;
  21.   tree->data = key_value;
  22.   return tree;
  23. }
  24.  
  25. //Function to receive data and translate said data
  26. //into characters from morse code
  27. void recieve(MicroBitEvent)
  28. {
  29.   //Tree is created and the node is set to the root
  30.   //of the binary tree
  31.   tree* treeRoot = treeChar('');
  32.   tree* treeNode = treeRoot;
  33. }
  34.  
  35. int main() {
  36.    // Initialise the micro:bit runtime.
  37.     uBit.init();
  38.  
  39.     bool pressed = false;
  40.  
  41.       // loop while button A pressed
  42.     while (buttonA.isPressed())
  43.     {
  44.       pressed = true;
  45.     }
  46.  
  47.     release_fiber();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement