fork(3) download
  1. // Count elements in array
  2. #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
  3.  
  4. /*
  5. Matrix Effect Demo
  6. November 19, 2017
  7. Copyright (C) 2017 Jesse Campbell
  8. All rights reserved.
  9. A demo showing a Matrix movie effect
  10.  
  11. This library is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU Lesser General Public
  13. License as published by the Free Software Foundation; either
  14. version 2.1 of the License, or (at your option) any later version.
  15. */
  16.  
  17. #include <Arduboy2.h>
  18.  
  19. // make an instance of arduboy used for many functions
  20. Arduboy2 arduboy;
  21.  
  22. char m[16][8]; // 16 chars across, 8 chars high
  23. int ySpeeds[16];
  24.  
  25. // This function runs once in your game.
  26. // use it for anything that needs to be set only once in your game.
  27. void setup() {
  28. // initiate arduboy instance
  29. arduboy.begin();
  30.  
  31. arduboy.setFrameRate(60);
  32.  
  33. randomSeed(analogRead(3));
  34.  
  35. // fill 2D array with random characters
  36. for(int i=0; i<COUNT_OF(m); i++){
  37. for(int j=0; j<COUNT_OF(m[i]); j++){
  38. m[i][j] = random(255);
  39. }
  40. }
  41.  
  42. // randomize the speed that columns move
  43. for(int i=0; i<COUNT_OF(ySpeeds); i++){
  44. ySpeeds[i] = random(8,200);
  45. }
  46. }
  47.  
  48. void loop() {
  49. // pause render until it's time for the next frame
  50. if (!(arduboy.nextFrame()))
  51. return;
  52.  
  53. // first we clear our screen to black
  54. arduboy.clear();
  55.  
  56. for(int i=0; i<COUNT_OF(m); i++){
  57. for(int j=0; j<COUNT_OF(m[i]); j++){
  58.  
  59. // move the cursor to the right position with good spacing between chars
  60. // draw the char partially off the screen for a smooth effect
  61. arduboy.setCursor(i*8, (j*8+64+millis()/ySpeeds[i])%(64+ySpeeds[i]%48)-8);
  62.  
  63. if(random(1000) > 985){
  64. m[i][j] = random(255); // randomly change the character once in a while
  65. }
  66. arduboy.print(m[i][j]); // print character in 2D array
  67. }
  68. }
  69.  
  70. // then we finally we tell the arduboy to display what we just wrote to the display
  71. arduboy.display();
  72. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:22: fatal error: Arduboy2.h: No such file or directory
 #include <Arduboy2.h>
                      ^
compilation terminated.
stdout
Standard output is empty