Category Archives: Mstr Atoms and Bits

Photophobic Switch- Eleni Giannopoulos

I made a fairly useless switch that’s a little bit of a self portrait. When it’s exposed to light the LED turns red and blinks “SOS” in morse code repeatedly until the lights are turned off, or it is covered up, and when its dark enough it blinks “O OK.” This is pretty how I function when the sun comes up in the morning and my body is like SOS until I wait for night to come again so I can say O OK and go back to sleep.

I did this using the photoresistor. I hooked it up in a separate little circuit on the breadboard and asked it to sense the amount of light in the room, in my code. Then I hooked the RBG LED and said that if the levels were over 200 (which I guess is bright by my room standards) the R pin would go off and blink SOS. Then, if the levels were under 200, which is dark, the G pin would go off and blink O OK. I did the morse code just by appropriately timed delays.

 

It’s hands free because you can wait for dark, or put your mouth over it or something. I guess it’s not a perfect “light” sensor because you can fool it by covering it up with something but then again you can fool me by covering me up with a blanket in the morning, I’ll go right back to sleep.

 

 

Toilet Seat Reminder

Since I only got my Arduino kit on Friday I needed to do a bit of catching up, so I repeated the lesson from class to make the bulb flash and change timing. I Then decided to build on the same basic code in order to make a practical application. I decided to use the piezo buzzer from my arduino kit to create an indicator of whether or not the toilet seat was up. The idea being that when the seat was up it would buzz, and when it was down it would stay silent. This way it would remind the user to always put the seat down.

To achieve this I simply modified the variables of the example code a bit, switching HIGH and LOW so that when connected it would be “off” and when disconnected it would turn “On”. I also removed the resister connecting the buzzer to the circuit, as I found it got ever so slightly louder, and the buzzer can accept a large range of voltages.

Once I uploaded the sketch to the arduino I powered it using a 9V battery so that I wouldn’t have to bring my laptop into the bathroom.

Toilet Buzzer in action!

Circuit Connected

It worked fairly well, the only problem is the wires I have aren’t very long, so I would be unable to actually open the toilet seat all the way with the current setup.

Password Switch

For the second assignment I decided to extend the first switch by adding another touch sensor and also a password sequence. If the correct password is entered, then the light turns on or off. Since it was really cold when I was working on this, I cut up an empty soda can instead of going out to buy aluminum foil:

I then attached the three rectangles to my circuit:

So to get the password working, I needed to change my code a bit. To do this I set up a password array that stores the sequence of sensors you need to press to activate the LED. I also store an integer that represents the index of the current correct sensor to press, called current. Current starts at 0, so the sensor at the 0th index is correct sensor to press. When it is pressed, current is incremented to 1, so the sensor at the 1st index is the correct sensor to press. For simplicity, the password is just 0, 1, then 2, which matches up with current.

At first, I wanted to make the code a bit more flexible, like allowing me to change the password to different lengths and such, but arrays in Arduino (C++) are different from what I am used to so I held off on that. I looked it up and found out that to get the length of an array, you need to call sizeof(array) and then divide that by the size of the elements in the array. So since ints are 2 bytes each, to get the number of elements in an int array, you need to calculate: sizeof(array) / 2. So making the code more flexible is an optimization I can do at a later point.

Here is the code:

 

Gas Leak Detector II

I added some function to the switch I made last week.

The code looks like this.

When the sensor is not detecting gas, the blue LED blinks every one second. When the sensor detects gas leak (when the value of the analog in is greater than 250), red and yellow LEDs flash to let you know there is a gas leak.

My apartment doesn’t have a good ventilation. I tested the machine with alcohol instead of gas to be safe since the sensor detects alcohol too.

Here is the test video.

Led sequence with light sensor

I was using the light sensor (phototransistor) for this project too.  When the sensor reads a light that is brighter than its previous surroundings, the LEDs start lighting up in sequence. This is an Arduino, who is happy about the light, and can’t wait for the winter to end. Sorry Mr Stark. It also warns the user to using proper protection against the sun.

Animated GIF  - Find & Share on GIPHY

Assignment 2

For this assignment I decided to use the photo-resistor, because its a switch that you can turn on and off again, and you can play with how long the light stays on for. I started by building the Color Changing Light from the book and then making it simpler so I could write my own code. I decided to use two LEDs and design it sort of like a timer. The green light turns on when there is enough light, and then after 10 seconds it blinks a little and if you don’t turn it off then, then it switches off and the red LED turns on. Then if you cover it both go off again. It can be repeatable too. I decided to write the code so that the LED didn’t fade on and off like it usually does with the photo-resistor because I wanted a more responsive switch. I did this by watching the output of the photo-resistor and picking a number for when the LED would light up. I made the time interval pretty short just so it would be quicker to film. The LEDs also turn off whenever there isn’t enough light, not just when it finishes it’s cycle. For the code it was all if statements, but I probably could have used a while loop instead.

Just Atoms and Bits

 

This assignment gave me a lot of difficulties. I’m learning both coding and circuits for the first time and really don’t have a firm grasp on either of them. We were supposed to add some sort of time or another interactive element to a circuit you don’t flip with your hands. While trying to come up with an idea, I really wanted to either work with the temperature or the light sensor. A friend told me they didn’t think the temperature sensor was very reliable, so I picked light.

I decided to try to use the book we were given to complete the assignment. I chose one that used the RGB LED, but made a modification to the circuit they presented, which I hoped would allow me to just use one LED for the circuit. Looking back, it may have worked, I may have been using the wrong resistor. Unfortunately, I forgot to take a picture because I was frustrated with my creation and just wanted something to work.

first failed attempt (or maybe 2nd?)

I tried to find something on the internet that was more simple than the project in the book. I followed a guide from sparkfun.com. Using the schematic they provided, I still wasn’t even able to get the light to shine. Sending a picture to a friend, they suggested some adjustments which allowed me to make the LED glow. After uploading the code I found on the website, it didn’t seem to react to the sensor. Strangely, it seemed to get a little dimmer when it was very dark over the sensor, but the difference was barely recognisable.

Here is the light shining

Here is a picture taken with the flash on my phone turned on, giving the appearance of responsiveness to light

Body Position Indicator

Building on my Orientation Switch from last week, I added a green LED to my circuit to provide a visual indicator for both the flat and upright positions instead of having a single LED turning on or off to indicate the position. I configured my switch so that the red LED would turn on when the circuit is lying flat and the green LED would turn on when the circuit is positioned upright.

To achieve this, I used the tilt switch input as a variable for my conditional statement. If the switch was on (circuit in flat position), the red LED would turn on and the green LED would turn off, and vice versa.

 

View post on imgur.com

Position flat: Red LED on, Green LED off

View post on imgur.com

Position upright: Green LED on, Red LED off

View post on imgur.com

I attached the circuit to my chest so that the red LED would be on when I am lying down and the green LED would be on when I am upright. This can function as a rudimentary sleep/wake indicator based on body position alone. And this time, I’m not using my hands!

RGB led with potentiometers

For this project I decided to control using potentiometers or dials.

Although my circuit seems complicated because there are so many wires, it is actually quite simple. I first debugged two separate circuits and then combined them to make the final project

.

I started with the RGB LED, for which I needed to figure out which prongs went where. (And I started out with the legs of my LED going to the wrong places, but to figure this out I had to have another intermediary step. I used three LEDs: red, green, and blue to figure out what exactly was happening. Once I cleared that up, I placed my RGB LED with the small legs to digital pins and the long leg going to ground.

 


Then I tried a few positions before getting the potentiometer into the right configuration. (nothing like the smell of a short) :/  So the leg on the right goes to power, middle to an analog pin, and the left to ground.
Added some resistors everywhere just in case, and:

Conclusion:I think I may have shorted the red of my RGB LED at the beginning or at some earlier date I don’t recall because the power is going through, but I never see red or purple light with it on even at a lower resistance.

P.S.- my github folder link is: https://github.com/dl2514/creativeComputing

Love-O-Meter

I decided to go with a setup that was in the book called “Love-O-Meter”.  I wanted to do something with temperature and since this is my first time ever using an Arduino or even coding for that matter it was helpful to have a guide through it. I had some trouble with getting it to read off correctly but realized it was because I was not uploading it.