I was happy that I struggled so much with servos last week, because this week I knew going in that the servo wasn't going to go more than 180 degrees. With that in mind, I started thinking about how to physically open and close the blinds using the servo. I didn't use the photoresistor this time because (a) I'd already used it on past projects and felt comfortable with it, and (b) my kit actually didn't come with one, and I had only had access to one because of a kit I'd checked out from our library... which I'd already returned.
That said, I decided just to stick with the push button and focus on the servo and the physical aspects of getting the blinds to move. My house has the blinds like these where you can twist the rod to tilt the blinds or pull the string to make them go up and down.
I didn't think I could get the mechanics of the "up and down" part because for down you have to pull the cord off to the side and that seemed really complicated so I decided to go with the twisting part. I tested it and found that the rod needed to rotate seven times in order to go from open to closed. That was definitely going to be an issue with having a servo that could only go 180 degrees, but I thought maybe not insurmountable if I just used gear ratios.
Business as usual: Tinkercad
As per my standard operating procedure, I set up my model on Tinkercad, and got things working:
and it should've been this code:
So that was an hour of my life I wasn't getting back! I now had working code and everything was going to be perfect. I had it set up so that each time I pushed the button the servo either ran 180 degrees clockwise or 180 degrees counterclockwise (opening or closing the window).
Next Problem: Nothing Uploads
Now being ready to upload the code to my breadboard I ran into a terrifying problem: the code would not upload to the breadboard. Just wouldn't do it. It compiled, everything was great, but then it just would not copy over to the Arduino.
Clearly I'm just dumb and didn't connect things well. Take out USB. Reconnect USB. Try again. No.
Clearly I just need to close the Arduino IDE and open it again. Nope.
Clearly I need to the close the Arduino IDE, take out the USB, reconnect, the USB, then open the IDE again. Keep trying, sweetie.
Okay clearly I need to do all that, plus restart my computer. No dice.
Okay must just be this code. Let's try uploading code from last week because we know that works. But no, it doesn't! Terror grips my soul.
Now we hit the forums.
I was able to confirm my Arduino board wasn't "fried" (thank all that is holy), but then resetting it still didn't actually help. The next step on the forum was terrifying:Okay so that was fun.
Good news is, it worked! Now the code uploaded and I could breathe again. Everything's good from here on out, right? Right?????
Pretend this isn't a problem: backwards button reading
For some reason, even though I hadn't changed anything else related to the button wiring in my code or on my breadboard, the button state was reading high even when it wasn't pressed (and reading low when it was pressed).
I tried using ChatGPT, by giving it my code and asking what might be going on:
It gave me quite a few ideas for troubleshooting:
I attempted all the suggestions, including this one:
Change pinMode(buttonPin, INPUT); to pinMode(buttonPin, INPUT_PULLUP);
That still didn't work, so I changed the code to look for LOW instead of HIGH and just moved on.











