Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- bool first = true;
- char text1[17] = "Salut,";
- char text2[17] = "Alexandru!";
- char text3[17] = "";
- char text4[17] = "";
- void setup()
- {
- lcd.begin (16,2);
- }
- void loop()
- {
- if(first) {
- convert(text1, 0);
- convert(text2, 1);
- lcd.setCursor(0, 0);
- lcd.write(text1);
- lcd.setCursor(0, 1);
- lcd.write(text2);
- first = false;
- delay(100);
- }
- for(int i = 0; i < 16; i++) {
- if(!i) {
- text3[i] = text1[15];
- continue;
- }
- text3[i] = text1[i-1];
- }
- for(int i = 15; i >= 0; i--) {
- if(i == 15) {
- text4[i] = text2[0];
- continue;
- }
- text4[i] = text2[i+1];
- }
- strcpy(text1, text3);
- strcpy(text2, text4);
- lcd.setCursor(0, 0);
- lcd.write(text1);
- lcd.setCursor(0, 1);
- lcd.write(text2);
- delay(100);
- }
- void convert(char text[], int position) {
- char fill[17] = "";
- int length = strlen(text);
- for(int i = 0; i < 16 - length; i++) {
- strcat(fill," ");
- }
- if(position) {
- strcat(fill, text);
- strcpy(text, fill);
- return;
- }
- strcat(text, fill);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement