'/**************************************/;
'/* Program Demo For ET-ROBOT RD2 V1.0 */;
'/* Controller  : P89C51RD2(Philips)   */;
'/* Run X-TAL   : 18.432 Mhz           */;
'/*             : X2 Mode(6 Cycle Run) */;
'/* Complier    : BASCOM-51(V2.0.11.0) */;
'/* Write By    : Eakachai Makarn      */;
'/* File Update : December-2003        */;
'/* Example Demo R-Light Display on LCD*/;
'/**************************************/;
'
$regfile = "89c51rd.dat"                                      'P89C51RD2(Philips)
$ramstart = 0
$ramsize = 256
$crystal = 36864000                                           '18.432MHz (X2 Mode)

Config Lcdpin = Pin , Db4 = P2.0 , Db5 = P2.1 , Db6 = P2.2 , Db7 = P2.3 , E = P2.4 , Rs = P2.5
Config Lcd = 16 * 2
Cursor Off                                                    'Not Display Cursor LCD

Config Timer0 = Timer , Gate = Internal , Mode = 1            'GETRC() functions needs timer 0
Config Getrc = 20                                             '20mS wait for charging the capacitor
Dim Light As Word                                             'Variable For Used With Function

Cls                                                           'Clear Display
Lcd "**DEMO R-LIGHT**"                                        'Display LCD Line1
Locate 2 , 1                                                  'Line2 Position 1
Lcd "Light Value =   "

Do
  Light = Getrc(p1.1)                                         'get RC value
  Locate 2 , 14                                               'Line2 Position 14
  Lcd Light                                                   'Display Result
  Wait 1                                                      'wait a moment
Loop


