📜 ⬆️ ⬇️

When you want snow ...

Hello!

In spite of all my 34 years old, a big child lives in me, sometimes a little bit sentimental and all so romantic. Well, like any child, I still like to create something, the main thing is that it is not difficult, quickly reproducible and gives a result that is visible to the eye.


(KDPV)

This child lives in St. Petersburg, a city in which the weather is usually European. Those. in the middle of December you see this picture outside the window:
')


The truth is, while I was gathering thoughts in the pre-New Year rush, everything changed a little bit ...



But, despite this, I can't help but share the idea of ​​where else you can shove arduins purchased on ebay and aimlessly wallowing. Moreover, our country is big and there is not enough snow for everything :)
In general, I sat, missed the lack of snow outside the window, and my hands itched to cook something. From here, the idea was born to assemble from the shit and sticks of Arduino Nano, a 16x2 LCD screen and an I2C adapter to it just such a fun:



I will not give the connection diagrams drawn in Fritzing - who is familiar with arduina and so will understand everything, and who will not - duck is useful in Google and Yandex. But I will naturally share the sketch. For him, please do not kick, because my education is completely humanitarian.

Sketch
#include <Wire.h> #include <LiquidCrystal_I2C.h> //   LCD  I2C LiquidCrystal_I2C lcd(0x27,16,2); //   0x27,  16,  2 int s1; //   №1 int s2; int s3; int s4; int s5; int s6; int s7; int t; //   void setup() { lcd.init(); //   lcd.backlight(); //     lcd.clear(); //   Serial.begin(9600); t = 600; //    } void loop() { //----------    LCD---------- s1 = random(3); s2 = s1 + random(2,5); s3 = s2 + random(2,5); s4 = s3 + random(2,5); s5 = s4 + random(2,5); s6 = s5 + random(2,5); s7 = s6 + random(2,5); lcd.setCursor(0, 0); lcd.print(" "); //   lcd.setCursor(s1, 0); lcd.write('*'); lcd.setCursor(s2, 0); lcd.write('*'); lcd.setCursor(s3, 0); lcd.write('*'); lcd.setCursor(s4, 0); lcd.write('*'); lcd.setCursor(s5, 0); lcd.write('*'); lcd.setCursor(s6, 0); lcd.write('*'); lcd.setCursor(s7, 0); lcd.write('*'); Serial.print (s1); Serial.print (" "); Serial.print (s2); Serial.print (" "); Serial.print (s3); Serial.print (" "); Serial.print (s4); Serial.print (" "); Serial.print (s5); Serial.print (" "); Serial.print (s6); Serial.print (" "); Serial.print (s7); Serial.println (); delay (t); //----------    LCD---------- lcd.setCursor(0, 1); lcd.print(" "); //   lcd.setCursor(s1 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s2 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s3 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s4 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s5 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s6 + random (-1, 2), 1); lcd.write('*'); lcd.setCursor(s7 + random (-1, 2), 1); lcd.write('*'); delay (t); } 



Unfortunately, the screens in my presence are only two-line. :( On the four-line, I think it will look much more interesting (the code will need to be added a little). By the way, if you have any, post the video in the comments. Well, if anyone can make the code more beautiful, I will also be happy to see it in the comments; ).

Library for the screen we take from here , maybe, with your may not earn (tried on cats).
And finally, the video:



Thank you all for your attention and Happy New Year!

Source: https://habr.com/ru/post/364905/


All Articles