Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include "MicroBit.h"
  2.  
  3. MicroBit uBit;
  4.  
  5. int main(){
  6.     uBit.init();
  7.     MicroBitImage flower("0,255,30,255,0\n0,30,255,30,0\n,0,255,30,255,0\n,0,0,30,0,0\n0,0,30,0,0\n");
  8.     uBit.display.setDisplayMode(DISPLAY_MODE_GREYSCALE);
  9.    
  10.     int x=0;
  11.     bool goRight = true;
  12.     while (true){
  13.         uBit.display.image.paste(flower,x,0);
  14.         uBit.sleep(250);
  15.        
  16.         if (goRight){
  17.             x++;
  18.             if (x > 2){
  19.                 goRight = false;
  20.             }
  21.         }
  22.         else if (!goRight){
  23.             x--;
  24.             if (x < -2){
  25.                 goRight = true;
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement