We will be using S4A to program the board. Therefore, we need to first set up our Arduino adequately.
Download the S4A software by reaching S4A and then clicking on “Downloads” > Choose the correct version based upon your operating system.
Afterwards, download the S4A firmware by reaching this link > Right-click > Save as > Remove the .txt part of the name > Save as type: Change from “Text Document” to “All Files” > Save.
You will also need to use Arduino IDE to code and upload the firmware onto your Arduino Leonardo board.
Download the software by visiting Arduino IDE > Scroll down until you see the “Download the Arduino IDE” section and choose the version based upon your operating system (e.g. If you have Windows 7, choose “Windows Installer” / if you have Windows 10, choose “Windows app”) > On the next page choose “Just download” and run the installation files.
Launch Arduino IDE and open the S4A firmware by going to File > Open or by pressing Ctrl+O and then browsing to the location you previously saved the firmware to.
Connect the Arduino to your computer.
Select Arduino Leonardo from Tools menu > Board.
Select the correct port from the Tools menu > Port.
Upload the S4A firmware into it by using the right arrow (→) button at the top right corner of the window, by choosing Sketch > Upload or by pressing Ctrl+U on the keyboard.
If the S4A firmware was successfully uploaded into the Arduino board, the “searching board…” message should disappear in a few seconds.
You will need to connect the ambient light sensor and the LED patches to the Arduino board. The ambient light sensor patch has 3 cables deriving from it, whereas the LED patch has two cables.
The positive side of the ambient light sensor goes to 5V.
The negative side goes to GND. You can use either of the 3 GND pins available on the board.
If you are not sure which one of the ambient light sensor legs is positive, just attempt to connect either to pin 5V and the other one to GND. If that doesn’t work, try the reverse.
Finally connect the remaining cable of the ambient light sensor patch to A0.
The negative side of the LED goes to GND and the positive one to a digital pin (ex. 13).
In the end it should look like this:
We want to program the Arduino board so that the ambient light sensor interacts with the LED.
Take notice of how the value of A0 changes based on fluctuations in the amount of light.
In our example, A5 (i.e. Analog pin 5, which is where we connected the ambient light sensor), displays a value around 30 when no artificial light is pointed at it.
Whereas if we point a smartphone torch at the ambient light sensor, the value drops down to around 10.
Once you’ve understood how the ambient light sensor reacts to changes in the amount of light, you are ready to program the Arduino so that, whenever the ambient light sensor records a value higher than 15 (in our example), the LED patch will turn on, otherwise the LED patch will stay off.
This tutorial has been developed as part of the #iTech project, co-financed by the Erasmus + Programme of the European Union.
Project number: 2017-1-FR02-KA205-012764
EU disclaimer: The content of this publication does not reflect the official opinion of the European Union. Responsibility for the information and views expressed in the therein lies entirely with the author(s).
For more details, contact firstname.lastname@example.org