Demonstration

   

Parts:

  • BX-24 Microproccessor
  • LCD - Optrex # DMC24201
  • 10K Potentiometer
  • Pressure Sensitive Switch (optional)


Hookup:

   

  • BX pin #23 to Ground
  • BX pin #21 to +5V
  • LCDOutput
    pin #functionpin #function
    1Power +5V
    2GroundGround
    3Contrastto Potentiometer
    4Register Select13BX-24
    5Read/Write14BX-24
    6Enable15BX-24
    14Data #15
    13Data #26BX-24
    12Data #37BX-24
    11Data #48BX-24
    10Data #59BX-24
    9Data #610BX-24
    8Data #711BX-24
    7Data #812BX-24
    15Backlight
    (blue wire)
    (ideally, should be run
    off additional power supply)

BX-24 programming:

This program sends data out to the shift register and 'counts' in binary: 0000_0001, 0000_0010, 0000_0011, etc.

Option Explicit
'A basicX function driver module for powering a 40x2 LCD display
'controls init and basic writing functions

'This driver assumes that the 8bit input pins of the LCD are
'connected to the BX special register PORTC which consists
'of pins 5 - 12 inclusive, and can be addressed directly.
'The MSB of the lcd input starts with pin 5, the LSB of the
'lcd input ends with pin 12

'Register Select Pin
const lcd_rs as byte = 13
'Read/Write pin
const lcd_rw as byte = 14
'Enable pin
const lcd_en as byte = 15

dim myString as string

dim force_sensor as integer

Public Sub Main()

         call delay(0.5) 'standard startup delay

         call init_lcd() 'initialize the lcd
   do
	force_sensor = getADC(16)
	debug.print "force_sensor = " ; cstr(force_sensor)
	if (force_sensor < 500) then	
         myString = "push more!"
         call printf(myString)

	else
         myString = "ouch!"
         call printf(myString)
	end if

         call delay(2.0)
         call clearScreen()
   loop
End Sub

''''''''''''''''''''''''''''''''''''''''
'LCD DRIVER CODE                       '
''''''''''''''''''''''''''''''''''''''''
public sub printf(ByRef printData as string)
         call startText()
         dim character as string * 1
         dim counter as byte
         dim printpass as byte

         for counter = 1 to cbyte(len(printData))
                 character = mid(printData, counter, 1)
                 printpass = asc(character)
                 Register.portC = printpass
                 call sendData()
         next

end sub

public sub clearScreen()
         call startFunction()
         Register.portC = bx0000_0001
         call sendData()
         call startText()
end sub

public sub init_lcd()
         'sends the proper setup signals to initialize the lcd
         register.ddrc = bx1111_1111

         'Setup the cursor and home location
         call startFunction()
         Register.portC = bx0000_1111    'set the cursor style
         call sendData()
         Register.portC = bx0011_1000    'set display to 2line, 5x7 character, 8bit data
         call sendData()
         Register.portC = bx0000_0001    'clear screen
         call sendData()
end sub

public sub startFunction()
         'sets up the lcd values to send a function variable
         call lcdEN(1)                           'bring enable high
         call lcdRW(0)                           'set the read write register to write
         call lcdRS(0)                           'set the register to function
end sub

public sub startText()
         call lcdEN(1)                           'bring enable high
         call lcdRW(0)                           'bring read write register to write
         call lcdRS(1)                           'set the register to text

end sub

public sub lcdRS(byVal state as byte)
         call putpin(lcd_rs, state)
end sub

public sub lcdRW(byVal state as byte)
         call putpin(lcd_rw, state)
end sub

public sub lcdEN(byVal state as byte)
         call putpin(lcd_en, state)
end sub

public sub sendData()
         call putpin(lcd_en, 0)                  'pulse the enable to tell the lcd to grab data
         call putpin(lcd_en, 1)
end sub

References

  1. How Stuff Works:
    http://electronics.howstuffworks.com/lcd.htm
  2. Product information — LCD, Optrex # DMC24201:
    http://www.allelectronics.com/cgi-bin/category.cgi?category=365&item=LCD-74&type=store
  3. LCD Display Driver - Patrick Dwyer:
    http://www.digilutionary.net/pcomp/LCD/lcd.shtml
  4. LCD screen - Takuro Lippitt :
    http://stage.itp.nyu.edu/~tml231/physcomp/netobj/LCD.html
  5. LCD - Dennis Crowley:
    http://stage.itp.tsoa.nyu.edu/%7Edc788/fall2002/physcomp/lcd_techresearch.html

LCDs · Introduction to Physical Computing · Prof. Tom Igoe