Modelul cu caractere rosii pe fundal negru este produs si distribuit de cei de la SparkFun Electronics (vezi Serial Enabled 16x2 LCD - Red on Black 5V) si a fost achizitionat din Romania de la Robofun (vezi LCD 16X2 PENTRU SERIAL - ROSU PE NEGRU, 5V).
Pentru a-l testa, am folosit placa Arduino construita de Nelu:
Primele teste le-am facut dupa ce m-am inspirat din articolele Serial LCD Kit Quickstart Guide si Serial Enabled LCD Kit Datasheet realizand si un filmulet numit testare LCD1602 serial de la SparkFun.
Sketch-ul testat de mine, cu succes, si prezentat in filmulet este:
// https://www.sparkfun.com/tutorials/289
// adapted by niq_ro from http://nicuflorica.blogspot.com/
#include <SoftwareSerial.h>
SoftwareSerial lcd(2, 3); // This is required, to start an instance of an LCD (RX at pin D3)
void setup()
{
lcd.begin(9600); // Start the LCD at 9600 baud
}
void loop()
{
// Clear the display
lcd.write(0xFE); // send the special command
lcd.write(0x01); // send the clear screen command
// move the cursor at first line and firs colon
lcd.write(0xFE); // send the special command
lcd.write(0x80); // send the set cursor command
// print a fisrt text
lcd.print("www.tehnic.go.ro");
delay (2000);
// print second text
lcd.print(" made by niq_ro");
delay (2000);
}
Pinul Rx este conectat la D3 de la Arduino.
Ulterior, am folosit liblioteca serLCD prezentata si la Arduino pe site, in articolul serLCD - Sparkfun serLCD Library, care se poate descarca de la https://github.com/scogswell/ArduinoSerLCD.
Filmuletul testare LCD1602 serial de la SparkFun (2) prezinta exemplul din librarie, in care pinul Rx al afisajului este conectat la D2 de la placa Arduino:
Am depistat un articol numit Serial LCD Module publicat pe ElectronicsForYou si foloseste un Atmega8 cu oscilator intern la 8MHz, iar partea de firmware se gaseste la https://github.com/pranjal-joshi/serialLCD-library-Arduino-and-Raspberry-Pi.
La "inceputurile" mele cu Arduino, am prezentat un sketch in care se deplaseaza doar un rand pe afisajul LCD16x2 (vezi Arduino si un afisaj LCD clasic (16 caractere si 2 randuri), asa ca am adaptat si pentru cel serial, dupa cum se vdede in filmuletul numit LCD1602 serial - text deplasabil doar un rand
Noul sketch este:
La "inceputurile" mele cu Arduino, am prezentat un sketch in care se deplaseaza doar un rand pe afisajul LCD16x2 (vezi Arduino si un afisaj LCD clasic (16 caractere si 2 randuri), asa ca am adaptat si pentru cel serial, dupa cum se vdede in filmuletul numit LCD1602 serial - text deplasabil doar un rand
// http://playground.arduino.cc/Code/SerLCD
// https://github.com/scogswell/ArduinoSerLCD
// original sketch in 01.2013 by niq_ro from http://nicuflorica.blogspot.com/
// adapted for serial LCD module by niq_ro in 05.2014, Craiova
#include <SoftwareSerial.h>
#include <SerLCD.h>
// This Arduino sketch using SerLCD library's Steven Cogswell
// In this sketch the Rx pin of the SerLCD is connected to
// Arduino digital pin 2 (Tx) We set the SoftwareSerial
// Rx to 0 because the SerLCD has no facility to transmit
// back.
//
SoftwareSerial NSS(0,2);
SerLCD theLCD(NSS);
int timp = 500; // delay between scenes
void setup()
{
// Remember to start the NewSoftSerial port before doing things with the SerLCD
NSS.begin(9600);
Serial.begin(9600);
// This will attempt to initialize the display to blank with the backlight on
theLCD.begin();
}
// Silly looking demo that just loops through features of SerLCD
//
void loop()
{
// Some text at positions
theLCD.clear();
theLCD.setBacklight(140);
theLCD.setPosition(1,0);
theLCD.print("www.tehnic.go.ro");
delay(2000);
theLCD.setBacklight(157);
theLCD.setPosition(2,1);
theLCD.print("made by niq_ro");
delay(2000);
theLCD.clear();
theLCD.setBacklight(157);
delay(timp);
theLCD.setPosition(1,15);
theLCD.print("w");
delay(timp);
theLCD.setPosition(1,14);
theLCD.print("ww");
delay(timp);
theLCD.setPosition(1,13);
theLCD.print("www");
delay(timp);
theLCD.setPosition(1,12);
theLCD.print("www.");
delay(timp);
theLCD.setPosition(1,11);
theLCD.print("www.t");
delay(timp);
theLCD.setPosition(1,10);
theLCD.print("www.te");
delay(timp);
theLCD.setPosition(1,9);
theLCD.print("www.teh");
delay(timp);
theLCD.setPosition(1,8);
theLCD.print("www.tehn");
delay(timp);
theLCD.setPosition(1,7);
theLCD.print("www.tehni");
delay(timp);
theLCD.setPosition(1,6);
theLCD.print("www.tehnic");
delay(timp);
theLCD.setPosition(1,5);
theLCD.print("www.tehnic.");
delay(timp);
theLCD.setPosition(1,4);
theLCD.print("www.tehnic.g");
delay(timp);
theLCD.setPosition(1,3);
theLCD.print("www.tehnic.go");
delay(timp);
theLCD.setPosition(1,2);
theLCD.print("www.tehnic.go.");
delay(timp);
theLCD.setPosition(1,1);
theLCD.print("www.tehnic.go.r");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("www.tehnic.go.ro");
delay(timp);
//-------------------------
theLCD.setPosition(1,0);
theLCD.print("www.tehnic.go.ro");
delay(timp);
theLCD.setPosition(2,15);
theLCD.print("m");
delay(timp);
theLCD.setPosition(2,14);
theLCD.print("ma");
delay(timp);
theLCD.setPosition(2,13);
theLCD.print("mad");
delay(timp);
theLCD.setPosition(2,12);
theLCD.print("made");
delay(timp);
theLCD.setPosition(2,11);
theLCD.print("made ");
delay(timp);
theLCD.setPosition(2,10);
theLCD.print("made b");
delay(timp);
theLCD.setPosition(2,9);
theLCD.print("made by");
delay(timp);
theLCD.setPosition(2,8);
theLCD.print("made by ");
delay(timp);
theLCD.setPosition(2,7);
theLCD.print("made by n");
delay(timp);
theLCD.setPosition(2,6);
theLCD.print("made by ni");
delay(timp);
theLCD.setPosition(2,5);
theLCD.print("made by niq");
delay(timp);
theLCD.setPosition(2,4);
theLCD.print("made by niq_");
delay(timp);
theLCD.setPosition(2,3);
theLCD.print("made by niq_r");
delay(timp);
theLCD.setPosition(2,2);
theLCD.print("made by niq_ro");
delay(timp);
theLCD.setPosition(2,1);
theLCD.print("made by niq_ro ");
delay(timp);
theLCD.setPosition(2,1);
theLCD.print("made by ");
delay(timp);
theLCD.setPosition(2,1);
theLCD.print("made by niq_ro");
delay(timp);
theLCD.setPosition(2,1);
theLCD.print("made by ");
delay(timp);
theLCD.setPosition(2,1);
theLCD.print("made by niq_ro");
delay(3000);
// -------------------------------
theLCD.setPosition(2,0);
theLCD.print("made by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("ade by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("de by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("e by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print(" by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("by niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("y niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print(" niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("niq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("iq_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("q_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("_ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("ro ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print("o ");
delay(timp);
theLCD.setPosition(2,0);
theLCD.print(" ");
delay(timp);
// --------------------
theLCD.setPosition(1,0);
theLCD.print("ww.tehnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("w.tehnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print(".tehnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("tehnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("ehnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("hnic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("nic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("ic.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("c.go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print(".go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("go.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("o.ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print(".ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("ro ");
delay(timp);
theLCD.setPosition(1,0);
theLCD.print("o ");
delay(1000);
}
PS: Am primit de la Liviu Roman o varianta "curata" de sketch.. pe care am mai pus si eu cate o imbunatatire... de imagine :)
obtinand filmuletul LCD1602 serial - text deplasabil doar un rand (2)
// original sketch by Liviu Roman
// adapted sketch for Arduino by Nicu Florica (aka niq_ro)
#include <SoftwareSerial.h>
#include <SerLCD.h>
SoftwareSerial NSS(0,2);
SerLCD theLCD(NSS);
String randulUnu = "www.tehnic.go.ro";
String randulDoi = "made by niq_ro";
int lengthRandulUnu = randulUnu.length();
int lengthRandulDoi = randulDoi.length();
int timp = 500;
int start;
int finish;
void setup()
{
NSS.begin(9600);
Serial.begin(9600);
theLCD.begin();
}
void loop()
{
theLCD.clear();
theLCD.setBacklight(157);
start = 0;
finish = 1;
for (int i=15; i >= 0; i--){
theLCD.setPosition(1,i);
theLCD.print(randulUnu.substring(start,finish));
++finish;
delay(timp);
}
delay(1000);
start = 0;
finish = 1;
for (int i=15; i >=0; i--){
theLCD.setPosition(2,i);
theLCD.print(randulDoi.substring(start,finish));
if (i<2) theLCD.print(" ");
++finish;
delay(timp);
}
delay(1000);
for (int i=0; i <= lengthRandulDoi; i++){
theLCD.setPosition(2,0);
theLCD.print(randulDoi.substring(i,lengthRandulDoi));
theLCD.print(" ");
delay(timp);
}
delay(1000);
for (int i=0; i <= lengthRandulUnu; i++){
theLCD.setPosition(1,0);
theLCD.print(randulUnu.substring(i,lengthRandulUnu));
theLCD.print(" ");
delay(timp);
}
delay(1000);
}
7.5.2014
Am facut un filmult de o calitate mai buna, care se numeste LCD1602 serial - text deplasabil doar un rand (3)
Nu am testat, dar ar trebui să meargă și varianta asta (http://codeshare.io/z0Ys8) Am simplificat puțin mai mult codul, dar desigur că se poate și mai mult făcând o funcție. Chiar te rog să testezi și să-mi spui dacă funcționează. O zi bună.
RăspundețiȘtergeream incarcat sketch-ul de la tine, dar la compilare zice ca: 'string' is not a name a type... scris cu S mare e ok, pana ajunge la substring, pe care nu-l cunoaste....
RăspundețiȘtergereCorect. Am greșit sintaxa funcției. Verifică acum te rog http://codeshare.io/z0Ys8
Ștergeream modificat un pic pe cel initial... adaugand odoar mici corectii, de stergere dupa...
Ștergeremerge... substring(randulDoi,i,lengthRandulDoi) trebuie schimbat cu randulDoi.substring(i,lengthRandulDoi))... o sa pun curand si codul si un filmulet...
RăspundețiȘtergere