Skip to content

Commit 82ed6fd

Browse files
committed
Fix default address, read.
1 parent 3090e42 commit 82ed6fd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

adafruit_mcp4725.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
# Internal constants:
38-
_MCP4725_DEFAULT_ADDRESS = const(0b01100000)
38+
_MCP4725_DEFAULT_ADDRESS = const(0b01100010)
3939
_MCP4725_WRITE_FAST_MODE = const(0b00000000)
4040

4141

@@ -92,7 +92,7 @@ def _read(self):
9292
dac_high = self._BUFFER[1]
9393
dac_low = self._BUFFER[2] >> 4
9494
# Reconstruct 12-bit value and return it.
95-
return ((dac_high << 8) | dac_low) & 0xFFF
95+
return ((dac_high << 4) | dac_low) & 0xFFF
9696
finally:
9797
# Ensure bus is always unlocked.
9898
self._i2c.unlock()

examples/simpletest.py

+2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
# Main loop will go up and down through the range of DAC values forever.
3434
while True:
3535
# Go up the 12-bit raw range.
36+
print('Going up 0-3.3V...')
3637
for i in range(4095):
3738
dac.raw_value = i
3839
# Go back down the 12-bit raw range.
40+
print('Going down 3.3-0V...')
3941
for i in range(4095, -1, -1):
4042
dac.raw_value = i

0 commit comments

Comments
 (0)