Going Outside Simulator â˘
I didnât really know what to do for this project, since the Arduino bits and pieces I had were sort of random and I canât make phone apps without a Mac...in comes Processing which we were learning how to use in another class this semester.
For this project, I used Processingâs Serial library in Java to allow my arduino to control a canvas and audio. Hereâs what Processing was doing in response to the above video:
https://www.screencast.com/t/jA1Dg2WfPfz
The potentiometer alters the hue of the background color and the tint applied to the other images on the screen (clouds and trees - I drew these myself). The colormode of the Processing sketch was set to HSB to allow the potentiometer to alter the color shade and the CDS cell to alter the brightness.
The CDS cell alters the brightness of the color set by the potentiometer. When I started I wasnât thinking and put the CDS in front of the Neopixel which then kept making it strobe due to the lights on the Neopixel changing. It was moved behind the Neopixel for the final iteration.
The mic amp uses the volume level of the enviromemt to set the sound of the audio file being played by Processingâs sound library (sound free use from here:Â https://freesound.org/people/lextrack/sounds/272417/)Â Â The values of the potentiometer, CDS cell, and mic amp are mapped to values 0-255 in the Arduino code. While I ended up not being able to use serial.write, the 0-255 is still more convenient for using in Processing. In Processing itself, the mic amps values had to be mapped to 0.0-1.0 for the Sound libraryâs amp() function. Originally I was going to have the potentiometer cycle through different photo filters on Processing, but for some reason Processing lacks the ability to remove filters after applying them so I switched to changing the hue. 90% of the problems with this project were due to Processing being weird.Â
Processing will send the Arduino an int (0, 1, or 2) when one of the canvas variables changes meaningfully. The CDS cell and mic especially tend to have 1-2 differences in the numbers it sent, so I tried to catch then when they had differences of greater than 3-5 for the three inputs. The 0 represents the mic has changed volume, the 1 means the hue has changed via the potentiometer, and the 2 means the brightness has changed via the CDS cell. These ints were then sent back to the Arduino, where they light up the Neopixel green (mic), blue (potentiometer), or yellow (CDS) to give feedback on what is being changed. This was especially helpful because I canât open the serial monitor to ensure whatâs being sent back while the Processing sketch is running.
Coding stuff:
Processingâs loop runs every 60 seconds, which is slower than the Arduino sending information. This caused backlog and made it so the canvas was responding with a large delay. Delaying the Arduino sending data and using port.clear(); in Processing made it so the lag was eliminated and it responded in real-time without backlog
The mic ampâs effect on the audio is very subtle - my screen recording has terrible audio quality but it is noticeable if you pull the mic out and then plug it back in - my roomâs noise had the Processing audio set to around half volume (it defaults to full volume with no input)Â
Sending three different variables from the Arduino didnât really work super well and needed multiple fixesÂ
I sent the variables all in a string seperated by â,â using Serial.println() and then threw an extra line break in there
In Processing, I had the port be read until it detected a line break - this ensured it only got three variables at a time instead of an endless stream of dataÂ
The string was then split at the commas, saved to an array, and cast to integers and floats when needed. The [0] index of the array was the mic, [1] was the potentiometer, and [2] was the CDS cell
Bonus: I had to duct tape my phone to a tripod to get the simultaneous videos (when I picked the Arduino up I was blowing into the mic)














