Let’s make a simple but fun integration. You can make a more complex integration if you need. I don’t need…
Why this integration is cool? Because is with a external hardware (LDR). We change a program based on a value of a LDR (an resistor that value depends on the light).
Is not a very simple hardware schema. This figure shows the hardware:
Processing is a cool tool that allow you make beatiful programs. You can get it in https://processing.org/ . There is a download link in the menu in the right.
Arduino you can get in https://www.arduino.cc/
You will need the Arduino to read the LDR value and Processing to use this value. We load an image and use it as background. And draw a circle based on the mouse position.
The Arduino code is:
Arduino basics: setup() run once and loop run in loop() after setup(). We connected LDR to port analog 5 (A5) of the Arduino and print the value read in the serial.
The Processing code is: