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 :from pynq import Overlay Overlay("base.bit").download()
In :from pynq.iop import Pmod_ALS from pynq.iop import PMODB # ALS sensor is on PMODB my_als = Pmod_ALS(PMODB) my_als.read()
In :my_als.stop_log() log = my_als.get_log()
In :%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 [ ]: