⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1wire.bas

📁 82 sample programs written in BASCOM-8051 for 8051 developement
💻 BAS
字号:
'--------------------------------------------------------------
'                    1WIRE.BAS
' demonstrates 1wreset, 1wwrite and 1wread()
' pull-up of 4K7 required to VCC from P.1
' DS2401 serial button connected to P1.1
'--------------------------------------------------------------
Config 1wire = P1.1                     'use this pin
Dim Ar(8) As Byte , A As Byte , I As Byte

1wreset                                 'reset the device
Print Err                               'print error 1 if error
1wwrite &H33                            'read ROM command
For I = 1 To 8
  Ar(i) = 1wread()                      'place into array
Next
For I = 1 To 8
   Printhex Ar(i);                      'print output
Next
Print                                                         'linefeed

'You can also use multiple pins
'alias the pin first
Tsensor Alias P1.2

'the optional argument specifies the pin to use
1wreset Tsensor                                               'reset

1wwrite &H33 Tsensor                                          'write value to Tsensor
1wwrite Ar(1) , 2 Tsensor                                     'write 2 bytes to Tsensor
A = 1wread(tsensor)                                           'return byte from Tsensor
Ar(1) = 1wread(2 , P1.2)                                      'read 2 bytes from Tsensor

End

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -