Assignment 1: Analog and Digital Input and Output

The first assignment is a way for you to show that you understand the basics of digital and analog input and output and how to write a basic Arduino sketch.  It’s also an introduction to coming up with an idea, planning it, implementing it, then documenting your project.  There’s no content requirement, we’re saving that for later classes after everyone is good with the fundamentals of physical computing.

First, come up with an idea and a plan. “Use three switches to turn on three different LEDs and a photoresistor to change the intensity of a fourth LED.”  Based on that idea, create a circuit diagram, draw it on paper or use Fritzing.  Now build the circuit, write the code, and make it happen!

The requirements for this assignment are to take digital and analog input and create outputs for LEDs or the digital vibrators we handed out today in class.  You’re free to use other outputs or make your own switches, there’s also the collection of components in A10.

Document your entire process, from your first idea, the circuits that didn’t work, the changes you made, and what was the final result.   In your documentation, ask yourself what you learned, what went wrong, what you’d do differently if you did it a second time.

To submit your project, post a reply with the documentation.  Attach a zip file to that post containing your Arduino sketch, a photo of your finished breadboard circuit, and anything else you think is relevant.  I’m working on how we can post video to the blog, but for now you could post it to your AFS account and link to that from your submission.

Due 23:59, Monday.  Let me know ASAP if you have a conflict and will be submitting late, if you talked to me after class please send me email as a reminder.

31 thoughts on “Assignment 1: Analog and Digital Input and Output”

  1. My first idea was to incorporate the haptic feedback device in my project. I knew I was going to make the haptic be interactive with some switches so I needed to figure out what multiple switches could do to a haptic feedback. I decided I would have an Arduino read how many switches are on, light up corresponding LEDs and have the haptic feedback buzz that many times.

    This was very feasible and I didn’t have any issues wiring this idea on the breadboard. I had three digital pins on the Arduino read the inputs from three switches into variables called switchPin1, switchPin2, and switchPin3. I stored the values of the switches in variables called switchRead1, switchRead2, and switchRead3. Then I created a counter variable that resets to 0 after every loop. Using IF statements, I increased the counter amount by one for every switch that was turned on. Once my counter variable summed every switch, a FOR loop would send an analog signal to the haptic feedback the number of times equal to the counter variable. Then it would reset and read the switches again and buzz that many times. I used a variable called HapOut that did an analogWrite on a Digital pin that could do a PWM to control the voltage entering the haptic feedback device.

    The only issue I had was writing the correct FOR loop based on the counter amount and the correct IF statements. To solve my problem, I wrote in separate sketch just the FOR loop to get the haptic buzzing properly. Another small issue I had was with the IF statements. I did not have two “=” signs when comparing the switchRead variables to a HIGH output. I only used one “=” and that just assigned a HIGH output value to my counter.

    ZIP File : https://drive.google.com/file/d/0B7wS6X9v0HxmN01qRjhLZjFnQ0U/view?usp=sharing
    Video of Project: https://youtu.be/SvQLeOGoA-s

  2. My idea was to create a sort of progress bar with an LED bar strip. The progress bar indicates how dark the surrounding environment is. For example, if the there is no light, ideally all 10 LEDs on the bar would be on. Similarly, if there was a lot of light, the very few LEDs would be on. In this case, the surrounding light would be the analog input, and the LED bar containing 10 LEDs would be the output. Additionally, in order to satisfy the digital input requirement of the project, there would also be a switch that either turns all the LEDs on or off. Sounds simple enough, but there was a lot of programming involved, and even more wiring (10 LEDs) involved. However, being an ECE major, I felt it was a project worth undertaking.

    I found Arduino code to control 10 LEDs individually from https://www.arduino.cc/en/Tutorial/BarGraph which I partially adapted to suit my purposes. I used the switch and LDR as was discussed in class. Additionally, I wrote code that took the value from the LDR, and normalized it to a value between and inclusive of 0 and 10, using the map function (https://www.arduino.cc/en/Reference/Map) . It then used this value to run a loop and turn the corresponding number of consecutive LEDS on, and the rest off.

    There were two main challenges I faced, both on the hardware side. I initially thought to have the switch and LDR connected in the same circuit loop, but this meant that value recorded from the LDR was not 0 when the switch was off. I found this kind of circuit too complex to deal with, so I just made two circuit loops connected to the Arduino individually: one for the switch, and another for the LDR. Secondly, the LDR was slightly laggy, and the values it ranged between were slightly inconsistent. Also, I discovered a weird kind self-affecting haptic loop, that caused brightness to increase when more LEDs were on, thus affecting the input to the LDR.

    After a bit of testing and trying different ranges for the LDR, I was able to make the circuit work to a reasonable extent. Given a second attempt to do the project, I would definitely consider a design using fewer wires and more organization, as my circuit ended up looking a little messy! Additionally, I would consider using a better LDR/resistor combination as the ranges proved a little tedious and difficult to handle.

    ZIP File: https://drive.google.com/file/d/0BxDLW7cgDfWoaExhS2dvQVQ3VGs/view?usp=sharing
    Video of project: https://www.youtube.com/watch?v=rz41h2AHdNc&feature=youtu.be

  3. I had the idea to try and make a quick whack-o-mole game with 3 LEDs and 3 Photodiodes. I would keep track of how many times the player hit the mole on time with a score, and I would have the LEDs phase out if the player waited too long.

    My only issue when working on this circuit was that I forgot that not all the digital inputs on the Arduino were capable of PWM – thus only one of my LEDs was dimmable. In terms of software, the player can hold their finger over the photodiode to ensure they hit it when it pops up – I need to think of a better solution to prevent this.

    On a second time I may want to add proper force-detection sensors and a better interface for the game, currently the bare sensors aren’t very sturdy and the setup doesn’t look as visually appealing as it could – I may want to add on some kind of decoration to the LEDs, maybe they could represent the eyes of some kind of creature.

    Video: https://drive.google.com/a/andrew.cmu.edu/file/d/0BxEy1_Wr9TRpNHNIN2lKa2hDRlk/view?usp=sharing

    ZIP:
    https://drive.google.com/a/andrew.cmu.edu/file/d/0BxEy1_Wr9TRpT0JJd0Z5Ti1ENms/view?usp=sharing

  4. My starting idea for this assignment was to create a circuit with a primary switch that controls an LED (digital on/off), link the LED to a second switch, and if that’s on have the LED controlled by a photo-resistor (so that if it’s dark, the light goes on). If both the primary and secondary switches are off, the LED will not turn on, regardless of light conditions. (Random aside: this idea was partly inspired by the porch light where I live, and by me constantly forgetting to turn it on/off).

    In my first test of the circuit, I had the LED attached directly to the 5V output. This lit up the LED, but didn’t let me turn it off when I tried to use my secondary switch. Switching the LED to ground and having the resistors connect to V fixed this problem. I also ran into a few problems with the way I nested for-loops, but after debugging and reordering curly brackets {}, the code ran smoothly. Another issue I ran into before the circuit worked semi-smoothly was with the photo-resistor – I had to play around with adding a second resistor to it to get a better range of feedback (I eventually settled for a 510 ohm resistor). My final issue was another code-related one: I forgot to include a step that returns the LED to off when the photo-resistor stops detecting a dark-enough environment. After adding a few lines to my script, the circuit ran smoothly.

    If I did this circuit a second time, I would have the LEDs separated from the switches, and have their state(s) being controlled solely by the Arduino, instead of by a combination of the switches and the Arduino (the switches would be used solely to interact with the Arduino). This would make the board a lot easier to expand/ add facets to.

    Zip file: https://drive.google.com/file/d/0BxOEW2LimG2Oc2hEb1hUb3c0bW8/view?usp=sharing

    **youtube clip of circuit to be added as a comment tonight as soon as I can go back to the Phys Comp lab to record it

  5. I decided to make an electronic die using a couple of LEDs and an accelerometer. Essentially, the accelerometer has three analog outputs, and the arduino samples them from time to time, and when the average change over the last 3 samples is over a certain value, it rolls. The rolling consists of flashing random numbers on the LEDs for a bit, then it stops on a random one.
    The biggest issue that I ran into was that the specific accelerometer I used, while easy to setup, outputs really garbage-y data, which is the reason I ended up just using the overall change.

    Picture – https://drive.google.com/a/andrew.cmu.edu/file/d/0B6bFUuOZ0DHJeHd1Y0ZITm9fR2s/view?usp=sharing
    Code – https://drive.google.com/a/andrew.cmu.edu/file/d/0B6bFUuOZ0DHJUE9FWnlIQ1hsSmM/view?usp=sharing

  6. For this assignment, I made a circuit so that if a switch is turned on, an LED would blink SOS in morse, while its brightness is correlated to the photo resistor’s input. Overall, this was a good project to refresh my pretty beginner skills with circuits and programming with the Arduino.

    Most of my process and information is documented in my process page (in the zip), but as a synopsis:
    The biggest issues I had during this project were hardware focused. The coding was relatively simple and clean, and yet I was still getting frustrated because my output wasn’t what I was expecting. Most of the problems had to do with the pins being in the wrong output or input (like not putting them in a PWM~ pin) as well as finding the right resources/functions for programming the photoresists readings to the led.

    My original idea was a bit more ambitious, I wanted to light the LED based on an on and off the rhythm of the switch. Based on if I clicked or didn’t click within an interval of time, I hoped to create an array that could be compared to the global key I’d set. Unfortunately, I underestimated my time and skills to get this far and decided to scale down.

    If I did this circuit again, I would check my programming more often in order to avoid collapsed problems on top of one another-expediting the debugging process.

    Zip File: https://cmu.box.com/s/ce8q22fzl6mjfbvf2ai9horaxeqbh75r

  7. First idea: have a DC motor powered fan and 3 LEDs respond to a temperature sensor

    I found two different circuit designs that I thought were doable- one that used a temperature sensor, and one that powered a fan. I wanted to combine the two, as well as incorporate the LEDs to give a sense of which range the current temperature was in. In the highest temperature range, the fan would turn on.

    To get started with this, I first built and tested each circuit separately, and then tried to combine the two. However, when trying to test the iterations of the combined circuits/code, I realized that it was difficult to reliably control the temperature sensor. So, I decided to switch to using a photoresistor since the amount of light is easier to manipulate.

    Modified idea: have a DC motor powered fan and 3 LEDs respond to a light sensor

    It was a little easier to work with the photoresistor since we already went over the code in class, and it required less calculations. Now, the hard part was getting rid of using the relay and push button that came with the DC motor powered fan circuit. I switched those two parts for a transistor and a diode based on online tutorials, but I was still having difficulty getting the fan to work, as well as one of my LEDs.
    Then, I realized in my sketch that I had assigned the analogWrite function to HIGH instead of 255. This solved the problem of the fan not working, since previously it had not been getting enough power. However, one of my LEDs was still not working, so I independently tested the particular LED and switched to a lower resistor. It worked fine, so then I switched to a different pin, which solved the issue (so I guess one of the pins on my Arduino doesn’t work).

    What I learned: how to power a DC motor with an Arduino, how to use a transistor and diode, the importance of the difference between analog and digital, the importance of manipulation of sensors for testing, how to use Fritzing

    What went wrong: one of the Arduino’s pins didn’t work

    If I had to do it a second time: don’t waste time wondering what went wrong by trying the same thing over and over again, test parts independently when troubleshooting

    Zip File: https://drive.google.com/a/andrew.cmu.edu/file/d/0B0yMpI_ZOcoYc1NoYWJfRDR2Wm8/view?usp=sharing

  8. My initial idea was to use some sort of input to generate a response on an LED array. I found one of the 8×8 Matrices over on the shelf and thought that would be a great thing to work with. This posed two problems, firstly I had no idea how to interface with it (this I quickly solved with some googling and cutting up some existing code I found). And the second problem I discovered when I went to test that code, was that it wouldn’t fit on my breadboard with enough room left over to wire it up. No luck finding larger ones either.
    So I resorted to creating my own array, which I think was ultimately a good choice. Instead of copy a fair amount of code off of the internet, I created both the physical circuit and the code completely from scratch.
    I settled on a simple array of LEDs that would respond to a proximity sensor, lighting more of the array as the object got closer to the sensor. Interestingly, I learned that these infrared sensors have a minimum range, and when you get closer than about ~10 cm everything goes really weird. I also learned about the nature of the analogue input pins on the Arduino, I struggled to get them to respond as I wanted them to.
    One other challenge I face, that I still can’t explain, was that the first two outputs (pins 1 & 0) were constantly outputting a signal. I was unable to override them in my code, and ended up just having to switch the wires to another pin.
    If I did it a second time, and had more time on my hands, I would experiment with a larger array of LEDs, and perhaps even a second sensor to influence the display even further.

    Zip file containing video: https://drive.google.com/open?id=0B_rqoxuDYou6SllTYzhVc2tjWVU

  9. My idea for Assignment 1 was to create a circuit that would use potentiometers to control the R, G, B channels of an RGB LED (as well as have an on/off switch). The end goal was to be able to just turn the knobs and have the color of the LED change accordingly.

    I started by first building the potentiometer part of the circuit, using Arduino documentations about potentiometers (https://www.arduino.cc/en/Tutorial/AnalogInput). One thing that tripped me up a little bit was whether potentiometers had any polarity; I was pretty sure they didn’t, but I took some time to research just to make sure. Afterwards, I then did a simple power test to figure out which pins of the RGB LED were which and then wired the LED and on/off switch to complete the circuit.

    The next part of this project naturally involved writing some Arduino code, which caused significantly more issues than the actual circuit construction. I first wanted to verify that my potentiometers were wired correctly, so I did a Serial print test of the values to 1) ensure the potentiometers were indeed working 2) check the range of values, so I would know what factor I had to scale them down to put into the 0-255 values necessary for the LED. This test helped me discover that, in my Arduino sketch, I had reversed the Blue and Green LED pins, which I was quickly able to fix. I also identified that I was getting max Values from the potentiometer at about 1000, so I decided that my scaling factor would be 4. I then wrote the whole code for the system to work. However, the LED was not responding, which was quite disconcerting. After some debugging, I discovered it was because of two reasons: 1) in my code I had written “if (switchPin == HIGH)” instead of “if (digitalWrite(switchPin) == HIGH” 2) I had also wired my on/off switch incorrectly.

    Through this project, I got more experience using the Analog pins of the Arduino, which I had never really used that much before this class, as well as some more experience debugging circuits. One mistake that I would fix if I were to redo this project was that I did not do a good job of making the project in simple steps (I had assembled the circuit basically all together and wrote the code in one shot). I realize that if I had been a bit more modular, especially in testing the on/off switch part of my circuit, then I could have caught my circuit and code issues a bit faster.

    Google Drive Folder of Arduino Sketch & Circuit Diagram: https://drive.google.com/drive/folders/0B6_H_AUOVi–b1ljTG85UExnSU0?usp=sharing
    Youtube Video of Working Project: https://youtu.be/WIfXQ5ronLw

  10. My project is a shoe that lights up and counts your steps.
    There are two modes to the shoe: counting and flashing

    The counting mode records the number of steps you have taken and displays that number in binary through six leds, topping out at a whopping 63 steps!
    The flashing mode just flashes the lights in a cool way whenever you take a step, using the same 6 leds.

    The modes are controlled via a two-state sliding switch. The steps are recorded through a pressure sensor embedded in the shoe.

    The next steps (no pun intended) would be to embed the rest of the electronics into the shoe. I decided not to do this because mounting an arduino onto the shoe seemed a bit ridiculous, and I thought what I had served as a nice proof of concept. Additionally, I couldn’t find any AA batteries in the physical computing lab and although I’m willing to destroy a pair of shoes for the project, I wasn’t willing to buy batteries for it ¯\_(ツ)_/¯.

    Youtube link: https://youtu.be/cNHTVsrnLaI (apologies for the poor quality video)
    Zip File: https://goo.gl/Ue1SNA (apologies for the poor quality code)

  11. The goal was to make a circuit with a switch, a button, a potentiometer, and an LED. The switch controls the function of the button, and the potentiometer controls the brightness of the LED. When the switch is in position one, the user can press the button to turn the LED on. When the switch is in position two, the LED stays on, except when the user presses the button. The potentiometer is connected to an analog input pin, and the measurement for the pin is converted to LED pulse width modulation values.

    To build the goal, I started by diagramming everything on paper: goal, schematic, and program logic.

    When building the device, I noted errors and corrected the schematic.
    There were two main issues with the device: one programming logic, and one circuit. Initially when programming, if/then statements were used to control the button function from the switch. The statements began to be super long, and they did not work. The button would not affect the LED. I used print statements to find which path the logic was following. I then looked at the Arduino documentation and discovered the ‘&&‘ logical operator. I used that to trigger the LED with button presses. The circuit was messed up because of electric buildup in the switch/button. To fix that I added a ground to each of the switches.

    video: https://www.youtube.com/watch?v=uup3xFP17AY&feature=youtu.be
    zip: https://drive.google.com/open?id=0B6FN8R0MrzCKcU5wOFhnSnJRR0E

  12. I was clueless for the longest time as to what I wanted to do with this project. I kept switching from one idea to another finding faults with each one I picked. Something that was common in many of my initial ideas was using a motor to resonate against something. My first idea was to use cones made of different materials and have the motor vibrate through them. I wanted to compare the tones created with the different cones. However after briefly testing this, I wasn’t happy with the outcome. While talking to a friend about this, I was reminded of a musical instrument that I know as the jal tarang (https://www.youtube.com/watch?v=TwzYjNR7uiA). It involves filling ceramic bowls of different sizes with different levels of water and striking the bowls with a stick. On trying this though, I found that the motor wasn’t able create the noises very well but it did create interesting wave patterns in the water. I decided to focus my project on these patterns.

    The components used in this project are a potentiometer, a vibration motor (larger than the one supplied in class), a motor driver, a blue LED, resistors, wires, solder, a cup of water, and red ink. The motor vibrate against the cup of water to create waveforms. I decided to use a pulsing motor because it created more interesting patterns. To highlight the patterns I put a drop of ink in the water and saw the ink move with the pulsing patterns.

    When I first attached the motor and observed the patterns I saw that the motor I was using was too small to create pronounced patterns. I moved to using a larger motor but found that it wasn’t working very well. With Jake’s (the TA) advice, I put in a motor driver to help the motor draw the current that it needs. I wanted to use the potentiometer to control the amount time period of the pulse. Initially I had it as a continuous relation to the analog output of the potentiometer but found that changing the pulse time period continuously with changing the potentiometer didn’t let the motor function properly. I then changed to changing the pulse in steps with it able to take specific values. The next addition to the project was a blue LED that blinks at the same rate as the pulse of the motor. This acts as a visual representation of the frequency of the pulse and allows the user to make connections between the frequency and the patterns created in the water.

    If I did this project again, I would want to do this a larger bowl with potentially stronger motors. I would also want to have multiple motors interacting with each other in and out of phase with each other. I think this would create patterns that are more interesting than having a single motor. That would also make it more interactive by potentially allowing 6 people to control the phase of six different motors.

    I learned that sometimes I should pick an idea and start testing it before discarding it as not good enough. I found inspiration for the new project from a poor attempt of a previous idea.

    Link to video: https://youtu.be/t_fjO7IzFBA
    Link to drive: https://goo.gl/Ak3N8A

  13. I started my project by getting the LED to work with the analog input of the light sensor. Wanting to add some complexity to this, I added the switch. In my code, I created 4 unique cases based on these two inputs. Combinations of photosensor on/off and switch on/off. Then I plugged in two LEDs. Using the delay function, I made it so that the LEDs would flicker, if the button was pressed while the shadow was cast on the sensor. Then if the shadow was not cast but the button was pressed, I added the cell phone vibrator to vibrate. But if the shadow was cast, the vibrator would stop, and the lights would flicker. When the shadow is cast but the button is not pressed, the LEDs light up without flickering.

    The multiple cases allowed for more room in the code to have different cases for how the outputs would respond to the inputs. I think using the same logic with different sensors or outputs, along with other components of the physical world, this could be applied to many different projects.

    Link: https://drive.google.com/open?id=0B60n0Wdv4KcISFpyd1VobEozZGc

  14. Ripple Effect

    My original idea for this assignment was to make some sort of interactive light display. It started out simple, just using a series of switches to trigger different lighting patterns, however, this seemed to basic and predictable. My idea started to truly take shape when I started playing around with timing of the LEDs fading in and out. My final design is based off the concept of a ripple effect.
    I decided to make a system where the person interacting with my project could wave their hand over the photo-resistor and the LEDs would light up in a wave like pattern that directly corresponds to the speed of the hand. I was able to achieve this by using the analog output from the photo-resistor to help determine the speed at which the shadow passes over it. I then used this amount of time to determine the delay length for the fade effect of the LEDs. Finally, to accomplish the ripple or wave effect, I set up four rows of LEDs and offset their fade in and fade out by multiples of 15 to make the difference in timing significant enough to recognize.
    The issues that I ran into included the inconsistent feedback when I waved my hand over the sensor. Most of the time the resistance difference was not substantial enough to track and very difficult to replicate. In the end, I had to hardcode the values at which the Arduino knew to start counting to help determine the delay time. I also noticed that the delay time was difficult to pinpoint as well. If left alone, the time it took for the LEDs to fade in and out was way too long, but dividing by too large of a number resulted in almost no difference when given different speeds. Lastly, I noticed that the green LEDs were much more resistant to the fading pattern than the other LEDs leading to an odd and irregular pattern over all. I combated this with a smaller ohm resistor which helped but did not completely fix the problem.
    If I were to try this again, I would have implemented a gage for the maximum and an appropriate corresponding minimum analog value from the photo-resistor so that the system could be adaptable to various environments. I would have also liked to implement a way to offset the different LEDs so that it corresponds directly to the speed as well.

    Video: https://www.youtube.com/watch?v=afzRKiFv__g

    ZipFile: https://drive.google.com/open?id=0B62ArY8nFitqWXFYanpLZUJRRFE

  15. My initial idea was that I wanted to replicate the confusion and difficulty associated with twister, but with your fingers. There is a point in the game were it is no longer possible to do what you have to do because you simply do not have enough limbs. I wanted to create a circuit that forced the user and a partner of their choosing to collaborate in order to successfully turn off the LED.

    My breadboard is fitted with 5 push buttons and a single photo resistor and an LED. The goal was to turn the LED off. By using a digital interaction where in all 5 buttons must be pushed down however that still does not allow the LED to turn off, but an analog input from the photo resister of brightness reading 820 or higher will then be able to turn it off. The trick is once you’ve pushed all the buttons down you unfortunately do not have any hands to complete such interaction thus a friend must hold there flash light while you are stuck there holding down a bunch of buttons.

    I coded it so when the input value of each pinmode A-E equals 0 that will give the photo resistor has the chance to read the lighting environment. I used a code provided by Arduino (http://www.arduino.cc/en/Tutorial/AnalogReadSerial) for the serial read in order to locate the best value for the photo resistor and plugged in the according values.

    I did not run into many issues since I did a fairly easy circuit. This is the first time I have ever coded as well as making anything with a breadboard so I wanted to use this as a learning opportunity vs. a challenge (that’s for later).

    Zip file- https://drive.google.com/drive/folders/0B_JEXda9ZXwvWnNHYzF5Tm81VVk?usp=sharing
    Link to video- https://youtu.be/DgAncIweBzE

  16. My initial idea was to have the intensity of three LEDs respond to different inputs at the same time. I decided to use both the photoresistor and potentiometer as inputs for two of the LEDs, and a bit of code to control the third. After sketching it out simply, wiring it on the breadboard went smoothly. I set up the LED and the photoresistor, then added the second LED and the potentiometer, then the third LED. The board got a bit messy but after I separated the LEDs and the sensor-resistors, it became cleaner.
    My general setup: I had two analog input pins read information from the photoresistor and potentiometer, and three digital pins that can do PWM power the three LEDs. I wrote code in portions – first for the LED controlled by the photoresistor, then the LED controlled by the potentiometer. I had the Arduino control the third LED to slowly turn on and off. This all went smoothly; the only changes I made were playing around with resistors until the change due the photoresistor was more evident, and also playing with delay constants so the third LED was the speed I wanted.

    Zip file, which includes the video: https://drive.google.com/open?id=0Bw2BkLX-TTddNVFyZzB2bHdWNDQ

  17. My initial idea was to create a motion detector. I wanted to use the LCD and translate that information so it would be able to detect changes light as motion. The speed of the changing light information could cause a specific LED to light up. However, the LCD was not sensitive enough so I decided to transition this idea. Instead of a light sensor, a potentiometer would provide the information to change the LEDs.

    My video, process, including issues and details are in the google drive.

    Google Drive containing zip and process: https://drive.google.com/drive/u/3/folders/0BxP5AAHGNXBAOG1HdmU1Y2V6bjg

  18. So three LEDs were separately set up to react to three different switches. I observed that sometimes the blue LED attached to the level switch may sometimes turn off when the switch is closed, and remain on when it isn’t. This is rather counter intuitive, and I have yet to understand why this happens.
    For the momentary switch attached to the yellow LED, I realized that the button must be oriented with the slightly longer side parallel to the rows.
    The red slide switch works as predicted.

    Now for the tricky part: using the
    Okay, I wanted to use the potentiometer as a variable resistor to change the brightness of one of the LEDs, and used the AnalogReadSerial Example that comes with the Arduino software to connect the potentiometer to A0.
    I used B1K initially, and uploading the code resulted in a blank serial monitor.

    Then I tried a B10K, where uploading resulted in nothing showing up in the serial monitor at all. For the sake of completing this project on time and learning more, I will come back to this at a later time.
    I connected the photoresistor to the Arduino because we want to use the light values (so the photoresistor is the input), and map these values onto LED brightness levels. Since there is a spectrum of brightness levels, we will need an Analog output, so a PWM pin is used to connect the Arduino to the LED.

    The process of data/path of electricity is more or less:
    Power -> photoresistor -> analogInput pin ->pull down resistor that’s grounded -> through Arduino -> PWM pin -> resistor -> LED -> ground.
    This way, each resistor has power and is grounded, and also sending information to the Arduino.
    The following schematic was used for guidance: https://learn.adafruit.com/assets/460

    So what can I do with a photoresistor to interact with the LED? The code to make the LED brighter with less light is provided on the page.
    I changed it to try and make the LED brightness change more dramatically. When I cover my finger over the photoresistor, I want the LED to be almost dark (off). I can map the value the photoresistor receives in normal fluorescent light (classroom light) to be a baseline?

    Interesting, I moved to work on the 4th LED at home, where the light levels are dramatically lower, the light is relatively brighter but the level of brightness that changes from covering the photoresistor is smaller.
    I’ll need a pin for the photoresistor to send its data to the Arduino, and since it’s analog data (I think that means that there’s a continuum of integer values from 1023 to 0), I’m using the Analog Pin (A0). ), We are inputting the photoresistor’s analog data rather than digital data, or 1, 0 , corresponding to an on/off, as the light levels are not exactly either on or off but vary, which we are capturing as the intermediate values.
    Question:
    Serial.print(“Analog reading = “);
    Serial.println(photocellReading); // the raw analog reading
    What is the difference between these two lines? We are just trying to analog read the pin values from the photoresistor.

    Instead of mapping the values, maybe I can divide the readings from the photoresistor by a smaller values than 1023/255 = 4, assuming equal mapping of readings onto the LED brightness values.
    We want there to be greater values encompassed (greater step intervals) from the readings to LED brightness values. I also want the LED to get darker when I cover the photoresistor, so I removed the line:
    photocellReading = 1023 – photocellReading;
    and changed the map values line to the following:
    LEDbrightness = (photocellReading/n);
    Where I tried 100, 10, 50, but quickly realized that I was no accessing a whole range of LED brightness values. I will have to map the analog values onto the LED brightness values, but will use a smaller range of either LED brightness or photoresistor values.

    When the photoresistor values were restricted from 0-700, the light basically stayed always on, suggested that if Serial.println worked for the photocell readings, it would be around 600-1023.

    At this point, I realized the speed that my serial read was at 9600 and my serial monitor was in a very wrong speed. Fixing it yielded appropriate readings from 240-270 in the dimly lit room, which dropped to 80s and 100s when completely covered. I tested a bunch of theories, and also adjusted the range of mapping for LED values, and of course, that didn’t work. How do I access the bottom range (lower levels of brightness) of the LED values? All of my readings range from 80-200, but I can not get the photoresistor to read lower than 80. That is the main issue.

    Zip file: https://drive.google.com/open?id=0B6vucT1cFrpgOTFkOUNDRUtvcTQ

  19. My first idea was to involve haptic feedback in some way as well as switches, leds that faded on their own, and photocells that changed the rate at which the leds faded. The hope was to have a switch that turned half the leds on, then using the photocell, attempting to fade the other half of the leds at the same rate as the automatically fading ones. When these rates were equal, there would be a vibration
    As I was unsure of how to do this and failed on multiple attempts for reasons involving lack of skill and understanding, I settled for a switch to turn 2 leds on and then a photocell to dim and brighten them accordingly. Circuits that didn’t work involved one in which multiple leds were in series because there didn’t seem to be enough current, or one of the leds may have been faulty. Nonetheless, the ending circuit included a photocell connected to a switch which was then connected to two leds in parallel. The code worked after correcting syntax errors, however I do not think it is the correct code. Bits and pieces of it were taken from https://www.arduino.cc/en/Tutorial/Fading and https://www.arduino.cc/en/Tutorial/Button .
    Overall, the finished project worked, although it was both simple made inefficiently, and not entirely useful. I still learned a lot and have been pushed to learn much more. If I were to do this a second time, I’d hopefully find a way to make my original idea and pick up the skills necessary to do so.
    video and zipped folder containing assignment:
    https://drive.google.com/file/d/0B9GI47zyEowxNTBjeDI0NkppRWc/view?usp=sharing

  20. Google Drive with video, documentation, etc…
    https://drive.google.com/open?id=0BxAGrufmmWthb0tBSXh1bk1jX2c

    Initial Idea:
    Create an interactive led light show controlled by a potentiometer and a few switches. Brightness would be controlled by the potentiometer and the lightshow chosen would be controlled by switches.

    What didn’t work:
    1. With the number of lights that I wanted to implement with a dimming and brightening features, there weren’t enough AWS supported pins on the Arduino to do that. Most of my initial confusion and frustration came from not realizing that not all pins supported AWS.
    2. The next gimmicky challenge that I came across was the implementation of a potentiometer as I wasn’t really 100% sure how to integrate one into the circuit. I eventually figured it out after some trial and error and in the process reworked my circuits and finalized my idea for the project.

    Changes I made:
    1. The original circuits that I made were more or less test circuits to make sure that I knew how to use the different components such as potentiometers, switches, and LEDs.
    2. The next big change happened when I finalized my idea to creating a visual display for the setting on the potentiometer. I essentially added many more LEDs as well as moving the potentiometer to a better spot.
    3. The last change that was made was just wire management as well as a little tidying up in the final phase of the project. This change included using uniform color wires, choosing wires of similar lengths, making the LEDs more uniform and aligned.

    Final Product:
    The final product consists of a potentiometer connected to and read by an Arduino, which in turn lights up a series of LEDs, the number of which is controlled by the resistance of the potentiometer. The resistance can be changed by turning the nob on the potentiometer and the lights move from a white LED, indicating power, to green, then yellow, and finally red, indicating the amount of voltage currently in the circuit. Finally I also implemented a switch that can turn off the entire circuit in case anything went wrong/caught on fire/short circuited.

    What I learned:
    1. Basic understanding of Arduino programming, building, and debugging.
    2. Fundamentals of breadboarding.
    3. Debugging/troubleshooting breadboard circuits

    What went wrong:
    1. The biggest issue that I had in the beginning was the confusion regarding the individual pin support for AWS on the Arduino. I didn’t realize that not allof the support that feature and therefore spent a lot of time debugging essentially nothing.
    2. Spent a good amount of time learning the Arduino language as well as the basics of wiring up an Arduino, probably more than I should have.

    What I’ll do next time:
    1. The first thing that needs to be changed is the sketch for the project. I feel like much of it was simple repetition and could have been done in 1/10th of the lines I took to write.
    2. Wiring. I initially wire by project pretty haphazardly and paid the price in the end when everything for extremely messy. Had to re-wire. Next time: use colors!
    3. Planning. Plan things out before actually doing the project as not to waste time doing menial tasks.

  21. For this assignment, I plugged in 3 LEDS, red, yellow and blue, where each of its brightness is controlled by a photoresistor, a potentiometer, and as thermo-sensor, respectively.

    The red LED, controlled by the photoresistor, would light up once there is more shadow casting upon the resistor, and vice versa.
    The second analog switch, the potentiometer, not only the brightness of the yellow LED, but also turns on/off the both red and blue LEDs, depending on whether the potentiometer values hit between 0 and 1.
    Lastly, I’ve played with a thermo-sensor that controls the brightness of the blue LED.

    Video, Circuit Diagram and Arduino Code linked in below:
    https://drive.google.com/open?id=0B70fyRiHk85qVnRkUnpObTR4c1U

  22. My project is called BreathWithYourPlant. Its goal is to help us take care of our plants better and be more connected with them. It has three LEDs, red, yellow, and blue, that correspond to sunlight, food and water. So the LEDs light up when the plant needs more sunlight/food/water. The green LED is the most interesting one: it has a breathing pattern that synchronizes with the plant’s. When the plant is under more sunlight, it breathes faster (LED lights up and dims at faster speed), and vice versa. This function makes the plants more “actively living”.

    In terms of building this project, I had a little trouble with the pseudo-analog input because I forgot that only the digital inputs with the “~” sign allows the LED to have a smooth output of transitioning between different levels of brightness. During the building process, it was also hard to keep track of the location of buttons, wires and resistors.

    Here is the link to the video demo and arduino code:
    https://drive.google.com/drive/folders/0B0lS0mmjvCWPSFB0S2IzaEE0V2s?usp=sharing

      1. My project is a series of LEDs that blink in sequence, so that there is a single “blink” traveling along the line of LEDs. I integrated a knob that changes the speed at which the blink travels along the line.
        Since this video I’ve added a switch that changes the direction of the blink. One thing I’d like to change is that the blink does not immediately change speeds or direction; it continues the loop along the whole line first. I’m going to try further to get it to change within the loop.

  23. My project was an LED cat that responds to being “pet” by “purring” and “waking up.” I used two LEDs, a vibration motor and a lever switch to achieve this. Every time you “stroke” the lever switch, the cat purrs (the vibration motor turns on) and then the LED eyes get brighter. You can stroke it up to 5 times before the cat resets. I had the most trouble getting accurate readings from the lever switch and getting the gradient to work on the LEDs. I ended setting the lever switch to PULLUP and setting it active low.

    Arduino sketch and video:
    https://drive.google.com/drive/folders/0B3_nRvY5FHyHcW5CeHdVZGRRUDQ?usp=sharing

  24. My idea was to create a simple six button braille symbol.

    As a user you can enter your braille patterns and retrieve it on the serial monitor. The green led lights up if you enter a recognized pattern of an English alphabet and the red one lights up otherwise.

    Challenges I faced:

    I was short on time as I had already passed the submission deadline due to other tasking commitments. I, therefore, had to complete my project in class – which was a fun challenge!

    The code was initially bulky, which I did a good job on making more readable and accessible for someone evaluating.

    The circuitry was more tasking that expected. Push buttons aren’t the best thing to wire up, especially with jumper cables and resistors interfering with each other.

    What I want to do next:

    If I get time, I’ll attach an HC05 bluetooth module to this. Once done, I can spin up a quick app that can connect to this assemblage and make learning braille for both blind students and others a complete tech solution.

    link to zip file: https://drive.google.com/file/d/0B5Odh0nyHUsJTnl6VzFXTlVHbmM/view?usp=sharing

Leave a Reply