Categories
Atlas Object

ATLAS Object: Sensor Box

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

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.

The schematic

My final analog circuit

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.

Morse Code

Morse Code Chart From Wikipedia

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

The morse code transmitter mobile app I made.

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.

Adding lights

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

The code

Operation

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

The inside of my sensor 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.

The RGB side of the box.
The photosensor/status light side of the box.

Finishing up

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!

Setting the alarm.
Disabling the triggered alarm
Changing the lights from green to blue.

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.

Leave a Reply

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