Option Explicit
Const SCL As Byte = 6 ' I2C clock - SCL
Const SDA As Byte = 5 ' I2C data - SDA
Const SD21 As Byte = &HC2 'SD21 I2C Address
'pata 1
const S01 as byte = 63
const S01P as byte = 84
const S01N as byte = 105
const S02 as byte = 64
const S02P as byte = 85
const S02N as byte = 106
const S03 as byte = 65
const S03P as byte = 86
const S03N as byte = 107
'pata 2
const S04 as byte = 66
const S04P as byte = 87
const S04N as byte = 108
const S05 as byte = 67
const S05P as byte = 88
const S05N as byte = 109
const S06 as byte = 68
const S06P as byte = 89
const S06N as byte = 110
'pata 3
const S07 as byte = 69
const S07P as byte = 90
const S07N as byte = 111
const S08 as byte = 70
const S08P as byte = 91
const S08N as byte = 112
const S09 as byte = 71
const S09P as byte = 92
const S09N as byte = 113
'pata 4
const S10 as byte = 72
const S10P as byte = 93
const S10N as byte = 114
const S11 as byte = 73
const S11P as byte = 94
const S11N as byte = 115
const S12 as byte = 74
const S12P as byte = 95
const S12N as byte = 116
'------------------------------------
'***********menu principal***********
'------------------------------------
Public Sub Main()
Call levantarse()
End Sub
'------------------------------------
'****************subs****************
'------------------------------------
sub levantarse()
posicion(S01,128,S02,256,S03,256)
posicion(S04,128,S05,256,S06,256)
posicion(S07,128,S08,256,S09,256)
posicion(S10,128,S11,256,S12,256)
call delay(2.0)
posicion(S01,128,S02,128,S03,128)
posicion(S04,128,S05,128,S06,128)
posicion(S07,128,S08,128,S09,128)
posicion(S10,128,S11,128,S12,128)
call delay(2.0)
End Sub
Sub posicion(ByVal SV1 As Byte, ByVal a As Byte, ByVal SV2 As Byte, ByVal b As byte, ByVal SV3 As Byte, ByVal c As Byte)
Call I2cByteWrite(SD21, SV1, a)
Call I2cByteWrite(SD21, SV2, b)
Call I2cByteWrite(SD21, SV3, c)
End Sub
'--------------------------------
'I2C Sub Routines by Gerald Coe
'--------------------------------
' writes I2cData to I2cReg at I2cAddr
Sub I2cByteWrite(ByVal I2cAddr As Byte, ByVal I2cReg As Byte, ByVal I2cData As Byte)
Call I2cStart()
Call I2cOutByte(I2cAddr) ' send device address
Call I2cOutByte(I2cReg) ' send register address
Call I2cOutByte(I2cData) ' send the data
Call I2cStop()
End Sub
Sub I2cOutByte(I2cData As Byte)
Call ShiftOut(SDA, SCL, 8, I2cData) ' shift data out
Call PutPin(SDA, bxInputTristate) ' turn SDA around
Call PutPin(SCL, bxOutputHigh) ' and clock in the ack' bit
Call PutPin(SCL, bxOutputLow)
End Sub
Sub I2cStart() ' I2C start bit sequence
Call PutPin(SDA, bxOutputHigh)
Call PutPin(SCL, bxOutputHigh)
Call PutPin(SDA, bxOutputLow)
Call PutPin(SCL, bxOutputLow)
End Sub
Sub I2cStop() ' I2C stop bit sequence
Call PutPin(SDA, bxOutputLow)
Call PutPin(SCL, bxOutputHigh)
Call PutPin(SDA, bxOutputHigh)
End Sub