top of page
Writer's pictureassa4664

Object Lab: Serial Communications

For this lab we started working with serial communication which allows computers to talk to each other.


Side note: for some reason I thought we had to do these step by step like the previous lab, and I ended up doing more than I had to. However, doing it that way did help me figure out a lot so that's good I guess.


Part One: Arduino to P5.js

In this part I had to establish communication that took inputs from the arduino and produced an output in P5.


I kept my circuit pretty clear of stuff, only setting up the variable resistors. I kept the LEDs off since I didn't need them at this time.


Here is my schematic:



Here is my circuit:



Code for arduino (pretty basic):


Once I had the arduino side set up and working I went to do the P5 side. I used the template provided by my professor and drew an ellipse. Using the potentiometer and variable resistor I coded it to change color and the dimensions of the ellipse.


Video of it doing that:




To give it a little more, I wanted to make the circle move. I felt like this gave the visual a little more fluidity. To make it move I used code I found from the resources on P5. It was pretty basic, I changed the random value range and I also added a piece that would reset x and not just the y dimension since I noticed that the circle would eventually disappear off the screen entirely.


I filmed a screen cast of what it looked like.


Part Two: P5 to Arduino

For this part we had to send outputs to the arduino. I made two different circles. One was yellow and the other was red. If you pressed on each one it would turn on the different lights by their respective color.




Video of that working:




Here is the code for Parts One and Two:



The Game:

I unfortunately did not complete the game. I wanted to make a butterfly catcher game, if you missed three you would "die" so to speak. Each missed butterfly would flash yellow, and the death one would flash a red LED.


I was only able to get the set up for it though.

I watched a lot of the Coder Train guys videos to figure out arrays and classes. I had some trouble getting fills to work the way I wanted to, but the biggest thing I struggled with was interaction. I wasn't able to get my objects to recognize when they were interacting with one another since I generate a lot of bubbles, I just didn't understand how to get it to recognize if it was interacting with any one.


The schematic I had set up so far was the one I used in Part One. I never got to the lives set up. My circuit looks pretty much the same since I was primarily focused with getting the code to work.


Here is a video of what I had set up:




Here is my P5.js code:


Here is my arduino code:



5 views0 comments

Recent Posts

See All

Week Ten

Comments


bottom of page