Rfduino with 2004 I2C Display

Test out 20 x 4 LCD with my RFduino

Since RFduino pin definitions are different than that of other Arduinos, it took me really long time to figure out these pins after search, search, and search the webs...

The driver/library and coding samples came with RFduino/Arduino do not work. Must ask the vendor to provide the driver/library to make it working properly.

RFduino default pins for SPI interface:
SCL on GPIO 5 SDA on GPIO 6

There are four pins on this LCD module:
1. VCC (Power 5V)
2. GND (Ground)
3. SCL (Clock pin)
4. SDA (Data pin)

One pin on the back of the LCD module. Remove it to turn off LCD all time.
Close the pin you will be able to turn on/off the LCD with command:

lcd.backlight() : turn on
lcd.noBacklight()  : turn off

Some other LCD commands:

lcd.init() : initialise the LCD
lcd.setCoursor(x, y) : place cursor
lcd.print("Hello World"); print string


//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <wire.h>
#include <liquidcrystal_i2c.h="">

#define SCL_CLOCK_PIN 3
#define SDA_DATA_PIN 2


LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void showNumber(){
  
  int min1 = 1;
  int max1 = 3;
  int i = 0;
      lcd.setCursor(0,2);
      lcd.print("Random:");
  
  for(i=0;i<=50;i++){
    lcd.setCursor(8,2);

    //lcd.print(random(min1, max1));

    if(random(min1, max1)==1){
      lcd.print("playing");
    }else{
      lcd.print("learning");
    }
    delay(100);
    lcd.setCursor(8,2);
    lcd.print("           ");
    
    delay(100);
  }
  
}

void setup()
{
  //You may setup your own clock pin(SCL), data pin(SDA) 2013-12-14
  //Wire.beginOnPins(SCL_CLOCK_PIN, SDA_DATA_PIN);
  
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print(" Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Ryan is learning");
   lcd.setCursor(2,3);
  lcd.print("Javascript!!");
  delay(2000);
}


void loop()
{
    lcd.init();
      lcd.setCursor(1,0);
  lcd.print("Ryan is learning");
  delay(1000);
        lcd.setCursor(0,1);
        lcd.print(" or ");
  delay(1000);
  lcd.setCursor(0,2);
  lcd.print("Ryan is playing?");
  delay(1000);
   lcd.setCursor(0,3);
   lcd.print("!@#$%ˆ*()_+");
   delay(1000);
   
  showNumber();
}


It's working now...



Comments

Popular posts from this blog

Arduino - DFPlayer Mini MP3 Module

Android control color RGB LED using HC-05 Bluetooth with Arduino (Part I)

Arduino #27 AsyncWifimanager ElegantOTA ESP32 (WiFi Password Mgnt. + WiFi Firmware Update)