The Studio of Eric Valosin

Tuesday, March 4, 2014

How Computers Meditate: A New Project

For() Loop Meditation

In programming, a "for loop" is a way of performing an operation on a series of items. For example, looking at every individual pixel of an image, one after another, and doing something to each of them. It goes something like this:

for(x=0; x<100; x++) {
    pixels[x] = color(255);

Transliterated to english: 

for every integer (starting with 0; and going up to 100; incrementing 1 after each time) {
    look at the corresponding pixel assigned to [that integer] and set = it's color (to white);

To look through a whole image, you'd have to include the y dimension as well as the x, but you get the idea: You look at a pixel, do something to it, move on to the next pixel and repeat until you reach the end. The more I thought about this, the more I felt like the computer program was almost meditating, completing a mantra, repeated for every pixel it looped through... a for() loop is a computer meditating!

Now then, for a temporary non-sequitor: 

I took a trip to the Rubin Museum, where they had an exhibit of Tibetan Prayer Beads, and began studying the theory behind them - why 108 beads, how they're used, what materials amplify prayers to what degree, etc. I'll share a bit of their enlightenment with you:

...and suddenly it hit me! It occured to me that the "meditation" of the for loop is essentially a rosary prayer! As you move from bead to bead you complete the same prayer for each bead until you reach the end.


for(bead=0; bead<108; bead++){

Pushbutton Prayer Beads

I wondered if there could be a way to meditate on an image, pixel by pixel, by using "prayer beads" made of pushbuttons. Every bead's button advances you to the next pixel. Perhaps the room even fills with light the color of that pixel when you press the button. Even more, maybe that pixel then gets assigned a random size and location on a wall and gets projected into a random collage, reconfiguring the image (starting to tap into the mystical, apophatic deconstruction of the image - knowing it less as you know it more...). Maybe the image in question is even derived from a live snapshot of the viewer himself...

My naive pre-prototype (and much pre-studying) sketches and notes:

Pushbutton Prototypes

For the end result, since I will want the signal to run through the chain of buttons to whatever button in the series happens to trigger the change, I'm guessing I'll probably want NC pushbuttons (Normally Closed; pressing them breaks the circuit) instead of the standard NO (Normally Open; pressing them completes the circuit). Otherwise the circuit will always be broken by all the buttons except the one in play. Don't have any of those right now though, so I decided to get started with some very basic pushbutton prototypes.

1) I started off with the prebaked arduino pushbutton tutorial. Two pushbuttons are set to input pins (2 and 3 in this case) that tell an LED (set to the standard output pin 13) to turn on if one button is pressed but not if both are pressed.

2) Using a microcontroller for this seemed like overkill, but it afforded me the opportunity to learn about pull-up resistors and other stuff that will come in handy when its no longer overkill later. But I wanted to see if I could back up a bit and do the simpler task: prove my understanding of the circuitry by bypassing the microcontroller. So I made a simple pushbutton circuit (hooked up to a battery instead) that would turn the LED on if the button was pressed. No fancy logic statements for the coordination of two buttons, but it worked, so I felt reassured about moving on!

technically I really don't know if the resistor used is the appropriate strength. I didn't do the math (nor claim to really understand how to... Ohms law is still a hypothesis in my mind...) but I know LEDs can handle a range of voltage so I wasn't too worried about blowing it out.

And of course my wife just informed me this was all stuff she learned in high school science (I blame a new system in middle school that placed me in the wrong math track for the rest of my academic career)! Well, better I catch up now then! (For the record, I know this stuff is elementary and did learn it quite early on. I think it's the practical application I missed out on)

3) Now to see if I can write a sketch to control the color of an RGB LED and cycle through the colors based on the push of a button. First, a sketch equivalent to the first one controlling the red LED, but where each RGB value could be manually input.

4) Finally, modifying that sketch so that the RGB values are indexed as options of a switch case function, and each button press cycles through those options. Here I selected 3 random color combinations to cycle through.

Added a switch case with 3 possible RGB values, and then a Button State Change function that switches between case options whenever the button is first pressed.

Hopefully these are the beginning steps to then populating that list of possible colors from the pixels of an image, and then stringing enough lights together for a big effect, and enough buttons together for prayer beads! To be continued

No comments:

Post a Comment