Haikus with Donald Trump.

Screen Shot 2015-10-14 at 2.07.44 AM

I have a confession to make: I couldn’t figure out how to get this project up and running with a potentiometer in time for class on Wednesday. Keep in mind that the process was littered with tiny successes and failures and here’s just a bit of what I learned.

The assignment this week was to review the labs we did in class and figure out a creative way to get the Arduino to communicate with p5.js using serial communication. For instance, we could push a button and display text, twist a potentiometer and create an animation, touch a pressure sensor and play music, etc.

I’ve been talking a lot lately with friends at ITP about generative text and computational poetry. I loved the idea of creating some kind of random haiku generator based on the transcripts of Donald Trump’s speeches.

I figured out pretty quickly that I would need to learn a lot more about Python in order to write a program that would analyze large bodies of text. I did learn, though, that Python has a function that allows you to count the number of syllables in each word, which will come in handy when I actually decide to build that version of the project.

So I decided to hack the project anyway. I searched online and realized that a few other people have been paying attention to Donald Trump’s campaign speeches and written down examples of unintentional haikus he’d said in public.

I pulled 15 haikus from a Washington Post article and loaded them into a spreadsheet. I divided each line of the haiku into a different column in the spreadsheet and called each column individually as an array, p. That way, whenever you clicked your mouse it would randomly cycle through the haikus. I was able to display a haiku by asking for line1[p], line2[p], and line3[p] whenever the mouse was clicked.

Success! I created a version of the haiku generator in p5 before adding the physical input we’d learned about in the labs. Check out the Donald Trump haiku generator here.

Screen Shot 2015-10-14 at 2.10.04 AM

Next, I added in some code to enable the serial communication between the Arduino (already loaded with some simple commands) and the computer’s serial port.

Screen Shot 2015-10-14 at 2.12.48 AM

I mapped the pot values from 0-1023 to 0-15, since there were only 15 haikus to cycle through.

Then I added in the lines of code we had reviewed in our labs. There was a lot of stuff going on to enable serial communication and map the correct values but I felt like I understood what each line of code was doing. I used the function print(newData) and was able to see the values change from 0-15 as I twisted the pot!

Except there was one problem: I couldn’t figure out how to write a command that told the computer that the newData values being received from the serial port should be equal to the variable p I mentioned above.

I tried writing a new function getHaiku(newData) that would display each haiku based on the pot number but it didn’t work. I felt like I tried everything, from creating new variables to setting p = newData, but I could not figure out how to get the pot value to control the animation.

Here’s my full code in case anyone has an idea of what I’m doing wrong:


Leave a Reply

Your email address will not be published. Required fields are marked *