Advertisement
RestrainedEdge

Untitled

Dec 15th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <SimulatorProgram.h>
  2. #include <LiquidCrystalsSim.h>
  3.  
  4. int B1 = 7;
  5. int B2 = 8;
  6. int B3 = 9;
  7. int B4 = 10;
  8. int B5 = 15;
  9. int B6 = 16;
  10. int B7 = 17;
  11. int B8 = 18;
  12.  
  13. int offset;
  14. String data;
  15. int delayMS = 100;
  16. int startMS;
  17. bool isRunning = false;
  18. String firstLine;
  19. String secondLine;
  20.  
  21. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  22.  
  23. void setup() {
  24. Serial.begin(9600);
  25. inString.reserve(10);
  26.  
  27. lcd.begin(16, 2);
  28. lcd.setCursor(3, 0);
  29. lcd.print("SPAUSKITE");
  30. lcd.setCursor(2, 1);
  31. lcd.print("BUTTON8(D18)");
  32. lcd.noBlink();
  33. }
  34.  
  35. void loop() {
  36. int startButtonState = digitalRead(B8);
  37. if(!isRunning && startButtonState == HIGH) {
  38. isRunning = true;
  39. startMS = millis();
  40. offset = 0;
  41. //Generate Text
  42. }
  43. if(isRunning) {
  44. if(offset * delayMS + startMS < millis()) {
  45. offset++;
  46.  
  47. String first = extractFromString(firstLine, offset, 16);
  48. String second = extractFromString(secondLine, offset, 16);
  49. }
  50. if(secondLine.length() < offset) {
  51. isRunning = false;
  52. }
  53. }
  54. }
  55. String extractFromString(String base, int offset, int lcdWidth) {
  56. String result = "";
  57. for(int i = 0; i < lcdWidth; i++) {
  58. if(i + offset < base.length()) {
  59. result += base.substring(i + offset, i + offset +1);
  60. }
  61. else {
  62. result += " ";
  63. }
  64. }
  65. return result;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement