This demonstration shows how to use the PmodALS. You will also see how to plot a graph using matplotlib.
The PmodALS and a light source is required. E.g. cell phone flashlight.
The ambient light sensor is initialized and set to log a reading every 1 second. The sensor can be covered to reduce the light reading, and a light source can be used to increase the light reading
In [1]:
from pynq import Overlay
Overlay("base.bit").download()
In [2]:
from pynq.iop import Pmod_ALS
from pynq.iop import PMODB
# ALS sensor is on PMODB
my_als = Pmod_ALS(PMODB)
my_als.read()
Out[2]:
In [3]:
my_als.start_log()
In [4]:
my_als.stop_log()
log = my_als.get_log()
In [5]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(range(len(log)), log, 'ro')
plt.title('ALS Sensor log')
plt.axis([0, len(log), min(log), max(log)])
plt.show()
In [ ]: