Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
For this lab, we were tasked with developing a game using P5JS that responded to two different inputs from the Arduino. I decided not to use my sensor box since my sensor box was falling a part due to poor construction. I decided to make a prototype of something similar to my final project idea.
Programming with P5.js
Building the circuit
Next, I had to build the actual circuit. I thought it would be cool to use an ultrasonic sensor to make the bar move when the user brings their hand close to the sensor. I had the bar move to the left when no object is detected and to the right when an object is detected. Since I needed a second input, I made a potentiometer be able to change the color of the ball.
Diagram of circuit:
Video of working circuit
Potentiometer color changing ball
What I would do differently.
For my final project I am making motion pong. The game will be controlled with motion sensors. I will need to figure out how to smooth the sensor value better as in this implementation of the ultrasonic sensor, the bar was a little bit shaky. I would also use a library with physics rather than writing complicated code to deal with collisions simply based on the x and y location of the ball and other objects.
Let it snow.
For this lab, we were tasked with creating a circuit that had analog inputs and outputs followed by a sensor box that had at least two different inputs and two different outputs.
Creating the analog circuit
For this task, we had to use the analog input pins on the Arduino board to read values from multiple analog sensors. In my example, I used a photoresistor and a potentiometer as the analog inputs. For the outputs, I used two different LED’s connected to the PWM pins to simulate an analog output. The brightness of the LED’s change depending on the rotation of the potentiometer and the value of the light sensor.
My final analog circuit
The sensor box
The next step in the lab was to build an interactive sensor box. This box needed two analog inputs and two outputs. For my box, I originally was thinking about a unique way to transmit information to my box like the current time. Since my Arduino doesn’t have bluetooth or wifi capabilities, I came up with the idea of using morse code to send information with my phone’s flash light to the Arduino.
Just like a binary 1 or a 0, more code is composed of short or long pulses of light or sound. During this stage of development, I wasn’t quite sure what exactly I wanted to build other than a device that could read morse code. So I decided to write code so that the Arduino could translate morse code into any letter or number so I could have the flexibility to do whatever.
Lots of if else statements and a mobile app
Using a photo sensor, I programmed the Arduino to be able to detect if an iPhone flashlight was flashing at the sensor. I made a value threshold that the sensor would measure to set the device into “program mode”. In “program mode” the Arduino would listen for values from the photosensor and determine whether a flash of light was long or short “S” or “L” by recording the time a flash started and stopped. In addition to the standard short and long flashes, I programed the Arduino to look for an extra long flash and an even longer flash to mark the end of a letter and to exit program mode respectively. The Arduino would record the sequence of short and long bursts until a the longer flash signaled the end of the letter. The program would then go through a very long if-else statement to determine what letter the recorded long and short flashes corresponded to.
In order to transmit the morse code, I designed a simple iOS app using Swift and SwiftUI that allows a user to type a message and transmit that message in morse code using the phone’s flashlight.
Once I got the morse code system working, the project still was only working within the console and did not have any lights or feedback on the Arduino itself. I decided to add the following: a yellow LED to show that program mode was activated, and a LED strip that I could set the color of using morse code.
While I could theoretically transmit any RGB value using morse code, due to time constraints, I only programmed the Arduino to recognize commands for the colors: white, red, blue, and green. Once I got that working, I had to figure out what to do about my second analog output.
The silent motion detection alarm
With the RGB strip and the program LED, I had my two outputs completed but I only had the single light sensor as the input. I decided to add a motion alarm feature to the device with the idea that it could only be set and disabled using more code. I added an ultrasonic sensor to the analog input pins and wrote code to detect how far an object is away from the sensor. I added a morse code command “set” that would enable the sensor and cause the lights to blink if an object came within range of the sensor. The blinking would only stop if the command “disable” was sent to the box using the morse app.
Ideally, I would want to add an audible alarm for this feature but I did not have the time.
Sensor box Schematic
Upon turning on the sensor box the RGB strip lights up white. You can then transmit any of the following commands by typing them in the morse code transmitter app and pressing transmit:
“blue”: Changes the RGB strip to blue.
“red”: Changes the RGB strip to red.
“white”: Changes the RGB strip to white.
“green”: Changes the RGB strip to green.
“set”: Turns on the red LED and activates the ultrasonic sensor. If an object comes within range of the ultrasonic sensor, the lights flash.
“disable”: Disables the flashing lights.
When the box is receiving commands, the yellow program led light up.
Building the Box
Personally, this was the most difficult part of the project. For the “box” part of the sensor box we had to create an enclosure for our device so no wires could be seen. Most of my experience with technology is with software and crafting physical things is still a new skill for me. I had a cross country meet in California so I was a little crunched with time I could spend fabricating. I originally thought about using LEGOs to build an enclosure, but I did not want to spend $50 at target. I settled on using cardboard from the BTU lab instead. I cut the cardboard into 4 different pieces and glued/taped them into a box enclosure. I cut holes in the box for the alarm status LED, the “Program Mode” LED, the photo resistor, the ultrasonic sensor (it looks like eyes), and the RGB strip. I decided not to seal the top of the box so I could easily modify connections. As for connecting my components, I soldered the status LED’s and the photosensor to separate breakout boards (one for the LEDs and one for the photocell). I was able to string the RGB strip through the hole I made so it was visible on the outside of the box. I then used a piece of paper to cover the strip.
After assembling everything together, I was finally able to film a demo of everything working. Here are a few videos of the different features below!
Fixing for the future.
I had a lot of fun with this project despite being a bit rushed on the fabrication piece. I plan to use my morse code system I made for future projects as that opens up many possibilities for data transfer to the Arduino. I am going to learn more about how to fabricate using 3D printing and laser cutting.
For the Among Us Locker world.
Sparks were flying in this one.
For our second lab in ATLAS Object, we practiced programing our Arduino boards to control more complicated circuits.
Part 1: Two LED circuit, twice as lit as before!
For part one of this lab we were tasked to make an LED circuit with two LED’s and two switches to give two unique outputs.
Before I began making the circuit, I first drew a circuit diagram schematic. Since we were using the Arduino’s input and output pins, there were multiple sections to this circuit.
The next step was to find the proper resistors for the LED’s. I decided to use one green and one blue LED. I calculated the resistance value using the supply voltage, forward voltage, and the forward current.
After finishing the resistor calculations, I drew the circuit diagram. I also included two 1K pulldown resistors for the digital inputs.
Next it was time to actually build the circuit. I built the circuit as it was drawn in the diagram.
But nothing happened when I pressed the switches. My hardware engineering may have been done but now it was time to make the software in the Arduino IDE. I wrote a program that would tell the output pins connected to each LED to turn on if a corresponding input pin measured a high value and off if it reads low. This “high value” would be read if a switch was turned on completing the circuit from the 3V3 pin to the input pin. After a few trial and error attempts, I got the LEDs to turn on when their respective switch was pressed. I was feeling a little “tinkerish” so I decided to add an additional feature to the program. Rather than just turning both LEDs when both switches were pressed simultaneously, I programmed the Arduino to respond to both buttons being pressed with a cool LED sequence. This sequence repeats indefinitely until a button is pressed.
Part 2: The Strip
For the second part of our lab, we were tasked with programing an LED strip to respond to our switch presses. I decided to keep the LEDs on my board and add the strip to the existing circuit. I luckily had previously purchased a Raspberry Pi Nano kit that had a pre-soldered LED strip ready to go. All I needed to do was connect a few wires and write the program to operate the strip.
Writing the program was a learning experience. I had to learn how to use 3rd party libraries in order to operate the LED strip. I used the Adafruit NeoPixel library which worked very well with my generic light strip.
Since I kept my LEDs from the previous part in my circuit, adding in code to get outputs for the LED strip was easy. I made the LED strip turn blue when the switch to the blue LED was pressed and green when the green LED was pressed. To mix things up a bit, I programed my LED sequence that occurs when pressing both buttons to make the strip flash green and blue rapidly.
The code below definitely could have been made much shorter using while/for loops/recursive functions, but I was more concerned with getting my program working rather than making it easy to read and edit. I will definitely do a better job of this in the future.
Part 3: Soldering
Soldering the breakout boards was the final part of the lab. I had a little bit of difficulty with soldering since I was not present for the last day of the lab. I was eventually able to get some help during after hours. The first step was to find the appropriate resistor for the two LEDs in series. Next I soldered a red LED, blue LED, a resistor, and two wires to the breakout board. Since I was able to use my existing circuit, connecting the wires to the correct pins was easy and required no coding.
Below is the video demonstrating the circuit working.
Brightening up the morning
We kicked off our Friday in lab with building circuits! For this lap we were tasked with building a both parallel and series circuits to light up two LEDs.
Building the series circuit
For this first circuit, I used an AC to DC adapter that connect to the bread-board, a voltage regulator, and a resistor with two LEDs. I also needed to add a push button switch.
Choosing the resistor value wasn’t extremely hard. I just used Ohm’s law to find the needed current for the particular color of LED.
After figuring out the resistor value, I got to actually building the circuit. I did not have too many issues making this circuit work other than the fact that I am still getting used to how small all of the components are. After a couple times trying to get wires to stay in their bread-board ports, I got it working.
Making the Parallel Circuit
For the parallel circuit, I used the same components as the series circuits albeit with some extra wires, and an extra resistor. Unlike a series circuit, a parallel circuit will not drop voltage around the whole circuit with just a single resistor (and LED load). Because of this, the extra resistor was needed.
Having suffered through Physics 2 last year, I was able to remember how to build a parallel circuit. However, like my experience building the series circuit, I struggled to work with the small pieces. I found that the wires would easily slip out of the bread-board. Fortunately, I was able to get it working with only a few times cursing at my bread-board. The LED’s glowed brighter than the series circuit.