diff --git a/pca9685.go b/pca9685.go index abc2e8f..60f513f 100644 --- a/pca9685.go +++ b/pca9685.go @@ -182,10 +182,10 @@ func (p *PCA9685) setPwm(pwm int, on uint16, off uint16) { onB := byte(on) offB := byte(off) - p.i2cBus.WriteReg(LED0_ON_L+byte(4)*byte(pwm), []byte{onB & WORD}) - p.i2cBus.WriteReg(LED0_ON_H+byte(4)*byte(pwm), []byte{onB >> 8}) - p.i2cBus.WriteReg(LED0_OFF_L+byte(4)*byte(pwm), []byte{offB & WORD}) - p.i2cBus.WriteReg(LED0_OFF_H+byte(4)*byte(pwm), []byte{offB >> 8}) + p.i2cBus.WriteReg(LED0_ON_L+byte(4)*byte(pwm), []byte{onB & 0xF0}) + p.i2cBus.WriteReg(LED0_ON_H+byte(4)*byte(pwm), []byte{onB & 0x0F}) + p.i2cBus.WriteReg(LED0_OFF_L+byte(4)*byte(pwm), []byte{offB & 0xF0}) + p.i2cBus.WriteReg(LED0_OFF_H+byte(4)*byte(pwm), []byte{offB & 0x0F}) } func (pwm *Pwm) setPercentage(percentage float32) error {