QRCode.ino 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * QRCode
  3. *
  4. * A quick example of generating a QR code.
  5. *
  6. * This prints the QR code to the serial monitor as solid blocks. Each module
  7. * is two characters wide, since the monospace font used in the serial monitor
  8. * is approximately twice as tall as wide.
  9. *
  10. */
  11. #include "qrcode.h"
  12. void setup() {
  13. Serial.begin(115200);
  14. // Start time
  15. uint32_t dt = millis();
  16. // Create the QR code
  17. QRCode qrcode;
  18. uint8_t qrcodeData[qrcode_getBufferSize(3)];
  19. qrcode_initText(&qrcode, qrcodeData, 3, 0, "HELLO WORLD");
  20. // Delta time
  21. dt = millis() - dt;
  22. Serial.print("QR Code Generation Time: ");
  23. Serial.print(dt);
  24. Serial.print("\n");
  25. // Top quiet zone
  26. Serial.print("\n\n\n\n");
  27. for (uint8_t y = 0; y < qrcode.size; y++) {
  28. // Left quiet zone
  29. Serial.print(" ");
  30. // Each horizontal module
  31. for (uint8_t x = 0; x < qrcode.size; x++) {
  32. // Print each module (UTF-8 \u2588 is a solid block)
  33. Serial.print(qrcode_getModule(&qrcode, x, y) ? "\u2588\u2588": " ");
  34. }
  35. Serial.print("\n");
  36. }
  37. // Bottom quiet zone
  38. Serial.print("\n\n\n\n");
  39. }
  40. void loop() {
  41. }