Data Sheet
32/40
Part No. : LTR-559ALS-01
BNS-OD-FC002/A4
Optical Sensor
LTR-559ALS-01
11. Pseudo Codes Examples
Control Registers
// The Control Registers define the operating modes and gain settings of the ALS and PS of LTR-559.
// Default settings are 0x00 for both registers (both in Standby mode).
Slave_Addr = 0x23 // Slave address of LTR-559 device
// Enable ALS
Register_Addr = 0x80 // ALS_CONTR register
Command = 0x01 // For Gain X1
// For Gain X2, Command = 0x05
// For Gain X4, Command = 0x09
// For Gain X8, Command = 0x0D
// For Gain X48, Command = 0x19
// For Gain X96, Command = 0x1D
WriteByte(Slave_Addr, Register_Addr, Command)
// Enable PS
Register_Addr = 0x81 // PS_CONTR register
Command = 0x03
WriteByte(Slave_Addr, Register_Addr, Command)
PS LED Registers
// The PS LED Registers define the LED pulse modulation frequency, duty cycle and peak current.
// Default setting is 0x7F (60kHz, 100%, 100mA).
Slave_Addr = 0x23 // Slave address of LTR-559 device
// Set LED Pulse Freq 30kHz (duty cycle 100%, peak curr 100mA)
Register_Addr = 0x82 // PS_LED register
Command = 0x1F // Pulse Freq = 30kHz, (duty cyc 100%, peak curr 100mA)
// For Pulse Freq = 40kHz, (100%, 100mA), Command = 0x3F
// For Pulse Freq = 50kHz, (100%, 100mA), Command = 0x5F
// For Pulse Freq = 60kHz, (100%, 100mA), Command = 0x7F
// For Pulse Freq = 70kHz, (100%, 100mA), Command = 0x9F
// For Pulse Freq = 80kHz, (100%, 100mA), Command = 0xBF
// For Pulse Freq = 90kHz, (100%, 100mA), Command = 0xDF
// For Pulse Freq = 100kHz, (100%, 100mA), Command = 0xFF
WriteByte(Slave_Addr, Register_Addr, Command)
// Set LED Duty Cycle 25% (pulse freq 60kHz, peak curr 100mA)
Register_Addr = 0x82 // PS_LED register
Command = 0x67 // Duty Cycle = 25%, (pulse freq 60kHz, peak curr 100mA)
// For Duty Cycle = 50%, (60kHz, 100mA), Command = 0x6F
// For Duty Cycle = 75%, (60kHz, 100mA), Command = 0x77
// For Duty Cycle = 100%, (60kHz, 100mA), Command = 0x7F
WriteByte(Slave_Addr, Register_Addr, Command)