Tuesday 4 September 2012

Simple Stick User Guide - List of Contents

Simple Stick User Guide - Interfacing a LCD with Simple Stick

Simple Stick User Guide - Interfacing a LCD with Simple Stick

 The LCD interface on the Simple Stick lets you plug in a standard 16 pin LCD and drive it in 4-bit mode. Owing to the size of the Simple Stick and the fact that it has been designed to work on USB power, this LCD interface comes with a few trade offs
  • The Contrast Pin of the LCD is connected to a fixed resistor, so you will not be able to vary the contrast [Scroll to the bottom of this page to see how to overcome this ;) ]
  • The Backlight Power Supply uses a 470E resistor (to save current draw from USB) and as a result the back light will be very dim. [Scroll to the bottom of this page to see how to overcome this ;) ]
  • The Interface uses a fixed I/O for R/W mode select
  • The Interface is hard wired for 4-bit mode
  • The Interface works only with LCDs with the following Pin Mapping (commonly available!)

Character LCD - A Quick Overview
Here's an interesting Write up to get you understanding the working of LCDs
http://joshuagalloway.com/lcd.html

To try an LCD place it on the Simple Stick and run the Hello World Example under File->Examples->LiquidCrystal->Hello World, with the following changes

replace this line
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
with
LiquidCrystal lcd(3, 2, 0, 1, 4, 12, 6);



Heres a demo video of this code in action



Heres the code
Simple_LCD.ino
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(3, 2, 0, 1, 4, 12, 6);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

Hacks to Overcome the LCD Shortfalls

Back light - To increase the intensity of the backlight, you can solder a resistor of lesser value between the 'BL-' pin and the GND pin on your LCD [Video Coming Soon!]

Contrast - You can achieve full contrast by directly grounding the Contrast Pin. Keeping this in mind, if you decrease the resistance value like in the above manner, you can increase the contrast.  Remember this time, you need to put in the resistor between the 'Contrast' pin and the GND pin on your LCD.  [Video Coming Soon!] Decreasing the contrast is not possible without de-soldering the fixed resistor.



Simple Stick User Guide - Working with the IR LED

Simple Stick User Guide - Working with the IR LED

The IR LED on board the Simple Stick lets you generate Remote Control Signals using your Simple Stick. Given the Simple Stick's stick format, this opens up a number of interesting possibilities... " say, you are working on your laptop in a coffee shop.. and you find the program on the television to be boring.. voila! there comes the Simple Stick, program it and zap the channels on the TV ;) " thats the kind of possibilities... (thats just a crazy example! we take no responsibility for the consequences you might end up in as a result of this!) you can take it upto building a 2-way communication system between 2 laptops using Simple Stick!

The IR led is connected to PIN 9 of the Simple Stick which is a PWM pin.

You can use the IRRemote Library [part of the simplestick_demo_code.rar] and program the IR LED to generate remote control signals.

To check, open the IrSendDemo example from under File -> Examples -> IRRemote

Now there are only 2 lines code required,
First creating an IRsend object and then using the IRsendobject.send function

IRsend irsend; // This line creates an IRsend object

irsend.sendSony(0xa90, 12); // This line sends the Power On/Off code of Sony 12bit remote controls


for sending signal using other protocols (NEC, RC5, etc..) the following functions are available

sendNEC(unsigned long data, int nbits)
sendSony(unsigned long data, int nbits)
sendRC5(unsigned long data, int nbits)
sendRC6(unsigned long data, int nbits)
sendPanasonic(unsigned int address, unsigned long data)
sendJVC(unsigned long data, int nbits, int repeat)
sendRaw(unsigned int buf[], int len, int hz)

The IRsend object will automatically use pin 9 on the Simple Stick.
Heres a simple program that sends the sony Power On signal when the push button is being pressed.

IR_Send.ino

#include <IRremote.h>

IRsend irsend;

void setup()
{
  pinMode(11,INPUT_PULLUP);

}

void loop() {
  if (digitalRead(11)==0) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV power code
      delay(40);
    }
    while(digitalRead(11)==0);
    delay(100);
  }
}