[[FrontPage]] objectPage http://www.yama-lab.org/dp-1/index.php?HexTestEx1 or http://www.yama-lab2.org/dp-1/index.php?HexTestEx2 device yamaRasPiDp9_1 or yamaRasPiDp9_2 start after no write for 10 min. command: set readInterval=15000 command: set execInterval=0 command: program i2cServo program: ' program: ' init i2c program: ex("pi4j", "i2c use 1") program: ' program: ' init lux sensor program: ex("pi4j", "i2c write1 0x29,0x80,0x03") 'power up the tsl2561 lux sensor program: ex("pi4j", "i2c write1 0x29,0x81,0x00") program: ex("pi4j", "i2c write1 0x29,0x86,0x00") 'scale program: ex("pi4j", "i2c write1 0x29,0x80,0x00") 'power down program: ex("pi4j", "i2c write1 0x29,0x80,0x03") ' power up again program: delay(50) program: ' program: 'get the lux value program: v1=ex("pi4j", "i2c read1 0x29,0x8c") program: v2=ex("pi4j", "i2c read1 0x29,0x8d") program: v=s2i(v2)*256+s2i(v1) program: ' program: ' init servo program: ex("pi4j", "i2c write1 0x40,0x00,0x00") 'init servo, clear mode-1 program: sms=ex("pi4j", "i2c read1 0x40,0x00") 'read current mode-1 program: sm=s2i(sms) program: nsm=(0x007f & sm)|0x0010 program: ex("pi4j", "i2c write1 0x40,0x00,"+nsm) 'set the sleep mode on, restart disabled 40> 00+ 10+ program: ex("pi4j", "i2c write1 0x40,0xfe,0x70") 'set the pwm frequency prescale register 40> fe+ 70+ program: ex("pi4j", "i2c write1 0x40,0x00,"+sm) 'recover the mode-1 register, .... wake up. 40> 00+ 00+ program: delay(10) program: smi=sm | 0x00a1 program: ex("pi4j", "i2c write1 0x40,0x00,"+smi) ' set the mode-1 register to incremental mode. 40> 00+ a1+ program: delay(50) program: ' program: 'move servo by the lux value program: if v>10 then 'move ch0 to center program: { program: ex("pi4j", "i2c write4 0x40,0x06,0x96,0x00") program: } program: else program: { program: ex("pi4j", "i2c write4 0x40,0x06,0x258,0x00") program: } program: ex("pi4j", "i2c close.") program: ex("service","clear sendBuffer") program: ex("service","putSendBuffer device=light, Date="+ex("service","getCurrentDate.")+", v="+v); program: ex("service","sendResults.") command: end i2cServo command: run i2cServo result: device=light, Date=2016/11/23/ 0:54:11, v=0 currentDevice="yamaRasPiDp1_1",Date=2016/11/23/ 0:54:11 device=light, Date=2016/11/23/ 0:54:26, v=0 currentDevice="yamaRasPiDp1_1",Date=2016/11/23/ 0:54:26