Digital Input/Output – Analog Input

This week we dove into digital input/output and analog input. For most of the assignments, I decided to cut and strip my wire instead of using jumper cables. I found that the jumper cables were too long and made the board turn into a nest of wires. It also looks much nicer!

For the first lab, I connected two LEDs to a switch.  This lab didn’t give me much trouble. 

Two LEDs connected to a switch on a breadboard.
Sketch of two LEDS connected to a switch

Next, I removed one LED and wired a potentiometer into my breadboard. After putting the new code on the Arduino, everything worked perfectly. 


Potentiometer connected to breadboard lighting up a LED
Potentiometer connected to breadboard lighting up a LED

Everything started so well until I moved to the sensors. After wiring the breadboard, I ran the serial monitor in the Arduino software. I was surprised to see a very low reading when I pushed really hard on the pressure sensor or completely blocked the light on the phototransistor. I wire and re-wired the board, tried new sensors, and saw no change. To get the LED to light-up properly, I mapped the sensors and changed their settings based on my low readings. The mapping worked, but I wanted to figure out what was going wrong. In a group office hour, the residents told me to check my resistor. They were correct. I was using a 10 Ω resistor when I should be using a 220. After swapping out the resistor, my sensors worked as expected. I had to remap them with the new readings. I read the color-coding wrong when picking my resistor, a simple error that provided hours of confusion. 

Data being displayed on a computer screen

Light sensor used to light a LED Pressure sensor used to light a LED Pressure sensor used to light a LED Light sensor used to light a LED

For the final build, I decided to use two pressure sensors and two LEDs. This wiring got fun! And with my new appreciation of testing and measuring my resistors, I was able to get this circuit up and running quickly. I reached out to Danny regarding the blinking of my LED’s when I wasn’t activating the sensor, and he suggested using the constraint command to limit the circuit. I tried coding this, but I couldn’t get it to run. This is my main question for next week’s class. I can see how this extra power could play havoc on a circuit in the future. 

Two pressure sensors lighting up two LEDS on a breadboard. A sketch of Two pressure sensors lighting up two LEDS on a breadboard.

 

Clock Failure – Character Success

At the start of the week, I had the idea to make a clock. I was concerned that I was biting off more than I could chew but excited to take on the challenge.

First, I laid out my sketch to have 60-second blocks, 60-minute blocks, and 24-hour blocks. I would call the second, minute, and hour functions to light up the blocks. Using a variable for RGB colors would blick in the current time setting when it advanced, one random color would be left behind. My first problem was the clock wasn’t running. I soon realized that I needed to code some sort of statement to move the rectangle. With the help of Philip Cadoux, I learned IF statements. A sample of that code is below:

Code sample for a P5JS sketch showing an if statement

The clock advanced based on the clock on my computer with a couple of problems. It always reset and didn’t show the proper time. I made a jumbled timer. Lost, I sought out some office hours. I had a great conversation, but we couldn’t come up with a proper solution. After spending a couple more hours on the project, I became frustrated and decided to put this project on hold until I learn more about IF statements and loops. I will come back and complete this sketch!

In the meantime, you can see the current sketch here.

I still wanted to create something this week that uses everything that I’ve learned so far. With a new sketch and idea, I got to work drawing an interactive version of a doodle I’ve drawn for years.  This is Frank, the Gowanus Canal monster. *Gowanus Canal is a highly polluted body of water in Brooklyn that I lived near for years.

Doodle of a monster underwater

When you play the program, the bubbles rise from the bottom but using -frameCount. Frank’s eyes bounce back and forth that I achieved but using a random variable—finally, the color mix of the water changes based on mouseX and mouseY movements. I used two background settings, one blue and one green, to make the mixing effect. 

Below is the code: 

P5JS sketch

P5JS sketch

P5JS sketch

This sketch isn’t as elaborate as my original clock idea, but it brings me a lot of joy. I tackled some new techniques like mouse movement, variables, and frameCount in a more light-hearted approach. The friends, I sent this to also got a good laugh out of it. Sometimes simple is better, but I will finish that clock!

To see Frank in full glory, head over here. 

Virtual Sound Walk – First Steps In Unity

This week Shannon Hu, David Leyva, and I  collaborated on a virtual sound walk using Unity. The goal was to build a wilderness themed maze using assets from the Unity Store and sound triggers. As the player progresses through the maze, they would encounter various noises triggered by invisible collision frames. Our sounds would be made up of recorded and found clips that we edited in Audition. 

First, we tackled building the maze from a hand-drawn sketch. Line drawing of a maze.

Top down view of a tree maze made in Unity.

We found an asset package that included Redwood tree models that we used as the walls. From this point on, our problems with Unity began. 

  • Character Falling: We found that our character kept falling into the abyss when we hit play. After adjusting for gravity and weight of the character with no visible change, we removed the plane and used a cube as the floor. The cube idea seemed to work, but we’re not entirely sure why. 
  • Stuck Character: Visually, it appeared that we had enough room for the character to navigate the maze, but that wasn’t the case. Every few steps, our character would get tied up on a tree. I need to investigate if there is a way to map out the area that a character can and cannot walk. 
  • Sound Triggers: In our original world, the sounds played on a loop rather than triggered by the character. We later found out that we did not apply the trigger script on the trees. 

The world quickly got confusing to work with, so we deleted most of the assets and started over. 

For this second piece, we removed the idea of a maze and scattered trees simulating an old-growth forest of Redwoods. With the triggers adequately placed, the character can experience birds chirping, a wolf howling, bears growling, and a few other surprises. We also were able to import rabbits and birds that a player can find. 

In the end, we would like to add more wildlife and possibly create some creatures. We would also like to make the forest denser without altogether impeding the character from moving. 

Top down view of a unity forest scene. 

Below is a working version of the world uploaded to simmer.io. 

From this exercise, I believe that I started to grasp the basic fundamentals of Unity and look forward to creating more worlds!