Wednesday, October 23, 2024

Covering My Bases: The Circuit and Coding Playing Challenges

Not that anyone is asking for this, but I'm documenting my discoveries for myself so I don't lose track of them!  Also this is a good review to make sure I know what I'm doing!

Circuit Play

  1. What happens if you turn the LED around (reverse the wiring)?
    It still flashes on the Arduino board, but the LED doesn’t anymore.

  2. What happens if you remove the positive lead from the breadboard? Does the circuit still work?
    Yes, it still works, not sure why!

  3. What happens if you place the resistor to the positive side of the LED and simply used a wire to run back from the LED to ground? When you do this, you will need to change up the wiring a little so check this closely to make sure you have not shorted out the circuit.
    I’m not sure what this means, but if it means can you put the resistor on the other side of the LED, the answer is yes!

  4. What happens if you move the wire from port 13 to port 12 on the Arduino?
    The light stops flashing because it’s not connected to the port that’s alternating anymore.

Code Play

  1. If you moved the wire from port 13 to port 12 on the Arduino, what do you need to change in the code?
    If you move the wire from port 13 to 12 without changing the code, it won’t work.  You need to change these lines.

digitalWrite(12,HIGH)

digitalWrite(12,LOW)

Now the light will flash again, but not nearly as brightly (which I’m not entirely sure why).  But I'll find out later!!! -- you also have to change it in the setup() function!

  1. What happens if you change the two delay code lines from delay(1000) to delay(2000)? Take out a stop watch or timer of some sort and time the rate of blinking for each of these settings. How many times does the LED blink in a minute for each of these settings? What have you learned about the value that is placed between the parenthesis after delay()? What value (parameter) would you place in delay() if you wanted the LED to blink at a rate of once every 3 seconds? How about every half second?
    The delay(1000) gives 30 blinks in one minute.
    The delay(2000) gives 15 blinks in one minute.
    The delay parameter is in 1 one-thousandth of a second, so if I wanted a blink every 3 seconds, I would need to use delay(3000), and if I wanted it for every half-second, I would need to use delay(500).

  2. What happens if you place // before the words void setup()?
    Trying to comment out the setup will not allow the code to compile.

  3. What happens if you place // before the words void loop()?
    Trying to comment out the primary loop will not allow the code to compile.

  4. What happens if you remove the last curly brace “}” in the program?
    Dropping any {}s will get you a compilation error.

  5. What happens if you place a // before pinMode(13,HIGH) in setup()?
    If you mean in the loop, then the pin will never turn on.  We don’t actually turn on the pinMode to HIGH in setup.  If you mean OUTPUT in the setup(), then the light ends up really low – this answers my previous question, because when I changed the pin to 12 from 13, I didn’t change it in the setup() – yay!

  6. What happens if you changed HIGH to high on the pinMode(13,HIGH) line?
    The code is case sensitive, so it won’t compile.

  7. What happens if you change the word pinMode to pinmode in pinMode(13,HIGH)?
    The code is case sensitive, so it won’t compile.

 

No comments:

Post a Comment

Nooooo, don't make me reflect on my learning!

 ... I just want to stick wires in breadboards and make froggies dance!!! Okay, but seriously, that stupid dancing frog was clearly my most ...