Eksperiment med I2C - og en DEMO heraf

I2C med ARDUINO UNO fungerer fint med et interface, indkøbt i kineserland for

From amount 8,03 DKK
To amount $1,15 USD
Exchange rate: 1 Danish Krone = 0,143335 U.S. Dollars

 

 

 

DANISH ENGLISH

For at få DEMOEN til at virke, skal man bruge dette "LIB" ( en .rar-file):  new-liquidcrystal.rar
Udpak filen og læg i ARDUINO's Library-biblotek.

DEMO-filen kan downloades her: sainlcdtest.rar, udpak filen, læg den i dit Sketch-katalog
Du skal muligvis tilføje "
LCD.H", som er placeret i LIB:  new-liquidcrystal.rar.
Dette gøres ved, i Arduino-IDE, under SKETCH, trykke på "Tilføj File..." - gå ned i ARDUINO/LIBRARY med stifinder, og find den.

To make the DEMO working, you must use this "LIB" ( .rar-file ) new-liquidcrystal.rar
Unpack it, and put it in the ARDUINO Library.

The DEMO-file can be downloaded here: sainlcdtest.rar, unpack the file and STORE it in your Sketch-library. You proberbly have to add "lcd.h" from another LIB: new-liquidcrystal.rar.

Open your ARDUINO-IDE, under SKETCH, push "ADD file" - go into ARDUINO/LIBRARY with your browser and find it.

/*
** Example Arduino sketch for SainSmart I2C LCD1602 adapter 
**    PCF8574 for HD44780 LCD Display
** Application Note: http://www.ti.com/lit/ml/scyb031/scyb031.pdf
** ---------------------------------------------------------------------------
** I2C Address pins 0, 1 & 2 are all permenantly tied high 
** so the address is fixed at 0x27
** A2 A1 A0
** ----------------------
** 0 0 0 = 20HEX Alle porte er lagt til stel i strapningerne
** 0 0 1 = 21HEX
** 0 1 0 = 22HEX
** 0 1 1 = 23HEX
** 1 0 0 = 24HEX
** 1 0 1 = 25HEX
** 1 1 0 = 26HEX
** 1 1 1 = 27HEX -> Alle porte er HIGH - ingen af dem er lagt til stel
** ----------------------
** 
** NOTE: Test on Arduino UNO Ver 3 whose I2C pins are A4==SDA, A5==SCL/
** ------------------------------------------------------------------------------------------
*/
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27                 // Define I2C Address where the PCF8574A is 0x27HEX

#define En_pin 2                      //Enable
#define Rw_pin 1                      //Read/Write
#define Rs_pin 0                      //Register Select
#define D4_pin 4                      //DisplayData 4
#define D5_pin 5                      //DisplayData 5
#define D6_pin 6                      //DisplayData 6
#define D7_pin 7                      //DisplayData 7
int n = 0;                            //tæller 

LiquidCrystal_I2C lcd (I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (16,2);
  lcd.home ();                         // go home
  lcd.setCursor ( 0, 0 );              // go to the FIRST line
  lcd.print(" CODING PIRATES ");
  lcd.setCursor ( 0, 1 );              // go to the SECOND line
  lcd.print(" Malpartida lib.");
  delay(5000);
  lcd.setCursor ( 0, 1 );              // go to the SECOND line
  lcd.print(" Test & Demo ");
  delay(5000);
  lcd.setCursor ( 0, 2 );              // go to the fourth line
  lcd.print("Iteration No: ");
}

void loop()
{
  lcd.setCursor (13,1);                // go col 13 of line 0
  lcd.print(n++); 
  delay(1000);
}