Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SimulatorProgram.h>
- #include <LiquidCrystalsSim.h>
- int B1 = 7;
- int B2 = 8;
- int B3 = 9;
- int B4 = 10;
- int B5 = 15;
- int B6 = 16;
- int B7 = 17;
- int B8 = 18;
- int offset;
- String data;
- int delayMS = 100;
- int startMS;
- bool isRunning = false;
- String firstLine;
- String secondLine;
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup() {
- Serial.begin(9600);
- inString.reserve(10);
- lcd.begin(16, 2);
- lcd.setCursor(3, 0);
- lcd.print("SPAUSKITE");
- lcd.setCursor(2, 1);
- lcd.print("BUTTON8(D18)");
- lcd.noBlink();
- }
- void loop() {
- int startButtonState = digitalRead(B8);
- if(!isRunning && startButtonState == HIGH) {
- isRunning = true;
- startMS = millis();
- offset = 0;
- //Generate Text
- }
- if(isRunning) {
- if(offset * delayMS + startMS < millis()) {
- offset++;
- String first = extractFromString(firstLine, offset, 16);
- String second = extractFromString(secondLine, offset, 16);
- }
- if(secondLine.length() < offset) {
- isRunning = false;
- }
- }
- }
- String extractFromString(String base, int offset, int lcdWidth) {
- String result = "";
- for(int i = 0; i < lcdWidth; i++) {
- if(i + offset < base.length()) {
- result += base.substring(i + offset, i + offset +1);
- }
- else {
- result += " ";
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement