$regfile = "2313def.dat" $crystal = 4000000 Config Sda = Portd.5 Config Scl = Portd.4 Config I2cdelay = 10 Config Pind.6 = Output Const Jcl1562bwrite = &H70 Const Jcl1562bread = &H71 'mask out all but the lower six dac bits Const Jcl1562bcompon = &B11000000 'make this pin high to use it as input Const Jclmask = &B00000001 Dim Dacval As Byte Dim Dacwrite As Byte Dim Jclinput As Byte Cls Do Reset Portd.6 For Dacval = 0 To 63 Step 1 Dacwrite = Dacval Or Jcl1562bcompon I2cstart I2cwbyte Jcl1562bwrite I2cwbyte Jclmask I2cwbyte Dacwrite I2cstop I2cstart I2cwbyte Jcl1562bread I2crbyte Jclinput , Nack I2cstop Jclinput = Jclinput And Jclmask If Jclinput = Jclmask Then Exit For End If Next Dacval Locate 1 , 1 Lcd Dacval ; " " Loop End