Digital Electronics Lecture Assignment #1

Tinkercard:

[Link to Tinkercard account: https://www.tinkercad.com/things/cFP7X98ORUE%5D

5 Changes to Circuit:

  1. Change the delay time for the LED’s

    In making changes to this circuit, I decided to start with a simple alteration. I changed the delay time on the green and blue LEDs from 500 milliseconds to 1000 milliseconds, or a full second. This ultimately means that the blue and green LEDs will blink more slowly. I completed this by changing the functions “delay(500)” to
    “delay(1000).”

  2. Add an additional LED

    The second idea I had for altering this circuit was to add an additional LED that would light up with the yellow LED when the button is not pushed. I first added another LED into the simulation, and connected the cathode to ground with black wire, and the anode to the Arduino Uno using white wire, to match the white LED.  Next, I turned my attention to coding. I plugged the LED into the fifth pin, so I wrote “int whiteLedPin = 5;” so that the code would recognize it. I then wrote “pinMode(whiteLedPin, OUTPUT);” under setup. From here, I turned off the white LED by writing “digitalWrite(whiteLedPin, LOW);” under “if(digitalRead(buttonPin) = HIGH)”. I wanted it to turn on only when the button was not pressed, along with the yellow LED, so I wrote “digitalWrite(whiteLedPin, HIGH);” under “else”.

  3. Change the pin numbers for the green and blue LED’s

    I have no experience with coding at all, so I thought it would be a good idea for me to practice using different pin numbers, and altering them in the code. I moved the green LED to pin number 6 and the blue LED to pin number 7. I then changed the code so that it would correspond with the new pin numbers, by writing “int greenLedPin = 6; int blueLedPin = 7;” instead of “int greenLedPin = 4; int blueLedPin = 5;”. As I adjusted the inputs, I also tried to angle the wire so that it would appear more organized by creating bends in the wire.

  4. Make the green LED and blue LED blink asynchronously

    My next idea was to code the blue LED and green LED to blink asynchronously, meaning that they would no longer blink together. To achieve this, I simply changed the blue LED to at first be off (or LOW) before the delay, and then turn on (or HIGH) after the delay. So instead of “digitalWrite(blueLedPin, HIGH);”, it now reads “digitalWrite(blueLedPin, LOW);” before the delay, and reads “digitalWrite(blueLedPin, HIGH);” following the delay.

  5. Add two more LEDs that line up with the blue and green LEDs.

    I liked the back-and-forth asynchronous lighting of the LEDs when the button is pushed, so naturally, I decided to add some more LEDs and code them to blink as well! I followed a process identical to the second change by inputting two more LEDs, red and orange, into pins eight and nine, respectively. I decided to choose a pink wire for the red LED, so that it would not appear as though it was going to power. From here, I utilized the same setup process, in establishing the pin numbers, and outputs for the LEDs. Once this was set up, I focused on getting these LEDs to blink. I wanted them to blink together slightly after the green LED, and stop blinking after the blue LED. After adjusting the delay times and arranging the order of each of the functions, I arrived on a result most similar to my initial idea, where the green and blue blink briefly before turning on the red and orange LEDs, respectively. I also ensured that the red and orange were off when the button was not pushed, by setting them to “LOW” under “else.”

Functions I Could Not Figure Out:

I struggled coding some of my other ideas, and I would often receive coding errors when attempting them in the simulation. For example, I had issues with replacing the button with a slide-switch. I initially thought that I could simply delete the button and insert the switch in its place, making nominal alterations to the code. However, after attempting this, flipping the switch did not alter the state of the circuit. I think that this process and the code is likely a little more complicated.

I also struggled with coding the yellow LED to blink. I followed a similar procedure to the one shown in the video, but I often received error messages. I’m not sure if there is a difference between coding this function for “if” or coding for “else,” but I could not quite get it to work. As I said previously, I have no experience with coding, so it is entirely possible that I am missing something very simple. Overall, I had fun trying out some different ideas!

Leave a comment

Design a site like this with WordPress.com
Get started