' Ohjelma lukee analogiatulosta 1 jännitteen ja tulostaa sen 8-bittisen arvon LCD-näytölle ' Toimii kaikkien OOPicien kanssa, sopivia LCD-näyttöjä www.esutech.com ' LCD-näytön ohjaus ja kytkentä kuten http://www.oopic.com/lcd.htm ' ' Esim. Potentiometrin kytkentä analogiatuloon ' ' |------- I/O line 1 ' V ' +5V ___/\/\/\/\____ GND ' 'This program sets up a Virtual Circuit to handle all of the data strobe function. 'Once all the setup have been done, all that is needed to write text to the LCD is 'to execute a command like; ' LCD.String = "TextToWrite" '-or- ' LCD.String = Str$(12345) ' Nämä ovat LCD-näytön käsittelyssä käytettäviä objekteja Dim D As New oDio4 'Initializes a new object called D as a nibble I/O Dim E As New oDio1 'Initializes a new object called E as a single bit I/O Dim RS As New oDio1 'Initializes a new object called RS as a single bit I/O Dim LCD As New oDataStrobe 'Initializes a new object called LCD as a Data Strobe Dim x As New oByte ' Tätä käytetään viiveen silmukkalaskurissa Dim Analogiatulo As New oA2D ' Tätä käytetään analogiatulon objektina Sub main() 'Pääohjelman alku Call IOSetup 'IOSetup-aliohjelman kutsu Call LCDSetup 'LCDSetup-aliohjelman kutsu do call ClearLCD ' Tyhjennetään näyttö call LocateRow1 ' Siirrytään riville 1 LCD.String = "www.esutech.com" ' Kirjoitetaan teksti LCD-näytölle for x = 1 to 50:next x ' Pieni viive call LocateRow2 ' Siirrytään riville 2 LCD.String = Str$(Analogiatulo.Value) ' Kirjoitetaan analogiatulon arvo LCD-näytölle for x = 1 to 50:next x ' Pieni viive loop End Sub 'Pääohjelman loppu Sub LocateRow1() 'Siirretään kohdistin riville 1, sarakkeeseen 1 RS = 0 'Sets Register Select to Control Register LCD.Value = 128: 'Sets the address of the cursor RS = 1 'Sets Register Select to Data Register End Sub Sub LocateRow2() 'Siirretään kohdistin riville 2, sarakkeeseen 1 RS = 0 'Sets Register Select to Control Register LCD.Value = 192: 'Sets the address of the cursor RS = 1 'Sets Register Select to Data Register End Sub Sub ClearLCD() 'Tyhjennetään LCD-näyttö RS = 0 'Sets Register Select to Control Register LCD.Value = 1: 'Sets the address of the cursor RS = 1 'Sets Register Select to Data Register End Sub Sub IOSetup() 'Tämä rutiini määrittää käytettävät I/O linjat, jotka on kytketty LCD-näyttöön ja 'analogiatuloon ja konfiguroi Virtuaalipiirin lähettämään kirjoituspulssin. D.Iogroup = 3 'I/O group used for nibble out to LCD D.Nibble = 1 'Which nibble to use Upper or Lower D.Direction = 0 'Direction of data flow in or out E.IOLine = 27 'Which I/O line to use for Display enable and strobe E.Direction = 0 'Direction of data flow in or out E = 0 'Initialize E to 0 RS.IOLine = 26 'Which I/O line to use for Register Select RS.Direction = 0 'Direction of data flow in or out RS = 0 'Initialize RS to 0 LCD.Output.Link(D) 'Connect the datastrobe's data to the LCD's data I/O line LCD.Strobe.Link(E) 'Connect the datastrobe's datastrobe to the LCD's E I/O line LCD.Operate = cvTrue 'Turn the Datastrobe object on. Analogiatulo.IOLine = 1 'Mitä I/O-linjaa käytettää analogiatulona Analogiatulo.Operate = cvTrue 'A/D-muunnos päälle End Sub Sub LCDSetup() ' Tämä rutiini resetoi ja alustaa LCD-näytön ja ' asettaa sen 4 bitin tiedonsiirtotilaan ' oletuksena olevasta 8 bitin tilasta RS = 0 'Sets Register Select to Control Register LCD.Mode = cv8Bit: 'Select 8-bit mode LCD.Value = 3: ' Power on sequence LCD.Value = 3: ' Power on sequence LCD.Value = 3: ' Power on sequence LCD.Value = 2: ' Sets data length to 4 bits LCD.Mode = cv4Bit: ' Select 4-bit mode LCD.Value = 40: ' Set # of display lines & font LCD.Value = 8: ' Set display off LCD.Value = 12: ' sets display on LCD.Value = 6: ' Set entry mode RS = 1 'Sets Register Select to Data Register End Sub