So this week's project is using a potentiometer to affect the rate of blinking for an LED. Basically, it's like using a dial to turn something up and down. I can appreciate that, because at least I understand why I might want to do this. Here is the initial electronic sketch. I think that's what this is. I copied it out of the book, but as I did it, it made more sense.
Here is what the sketch and the circuitry looked like initially.
A couple of things about the code: in the directions it said that it set the integer for ledPin to make it easier to follow and that made sense until I added another digital pin and it didn't work anymore. So what I took from that is if you're going to add stuff, it's going to get harder to follow the code. Which is fine, but I was also fine with it looking like the one from last week, which I figured out, it could, once I used some of that to make 2 LEDs work. Aside from that, it was easy enough to follow.
So for the next part, I added an additional digital pin, a red LED. To do that, I had to remove the integer ledPin=13 and change pinMode(ledPin, OUTPUT) to pinMode(13,OUTPUT). I also added pin 12 as an output. I tried to make ledPin=12 as well as 13 but it didn't like that so I went back and looked at the blink sketch that had 2 LEDs and worked off of that.
Then I wanted to make them blink at different rates, so I ended up changing the delay for pin 12 to 50 milliseconds instead of sensorValue. So pin 13 had a delay of the sensor value and pin 12 I played with until I came up with two different rates.
FYI: I used the Apple Clips App to edit the video and then uploaded it to Youtube.
You could make it fancier, but I just wanted some words.
As far as the code and circuit play went, I wasn't able to wrap my mind around 2 analog pins and one digital. The best I could come up with was that it was kind of like having 2 switches for the same lightbulb, one at the top of my stairs and one at the bottom. But that only made sense to me as a switch, so like using the button switch. I couldn't decide if you could do both. I wasn't really sure why you'd want two dials. I did change the digitalWrite to analogWrite and as I suspected, it broke it. So I changed it back.
One thing I learned was to take good notes. Going back and looking at what I did last week helped me figure out how to change the code for this week. I'm not sure exactly what I learned about electricity, but I feel like I know more somehow.