2013/12/15

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...



2013/11/13

Solved: Cordova Error: Please install Android target 17 (the Android 4.2 SDK)

Many of you might encounter the error message while adding Android OS support into your Cordova project:

[Error: Please install Android target 17 (the Android 4.2 SDK)]



After trying all Android SDK Tools, but I still getting the error message.
Then I try to install the Android 4.2.2 (API 17). Well, it worked!!




The error message is a little bit misleading! It's the API missing not Android Target!
Here is the screenshot that I successfully added the "Android Target 17".


Done.