| 1 |
''' |
| 2 |
For Malus Law experiment |
| 3 |
Connect stepper motor to PB0, PB1, PB2, PB3 (A+,B+,A-,B-) |
| 4 |
Connect TSL2561 sensor to I2C |
| 5 |
LASER Beam -> Polarizer -> Analyzer mounted on stepper motor -> TSL2561 |
| 6 |
''' |
| 7 |
|
| 8 |
from matplotlib import pyplot as plt |
| 9 |
TSL2561_init() |
| 10 |
TSL2561_gain(1) |
| 11 |
TSL2561_timing(0) |
| 12 |
setReg('DDRB',15) |
| 13 |
steps=[3,6,12,9] |
| 14 |
points = 0 |
| 15 |
Y=[] |
| 16 |
for a in range(50): |
| 17 |
for b in steps: |
| 18 |
setReg('PORTB',b) |
| 19 |
plt.pause(0.1) |
| 20 |
lux = TSL2561_all() |
| 21 |
if lux is not None: |
| 22 |
print(points,lux) |
| 23 |
plt.scatter(points,lux[0]) |
| 24 |
points+=1 |
| 25 |
|
| 26 |
|