This week, I dug deeper into how switches work and continued playing with my
Photon, a tiny wireless board that is programmed with an Arduino-based language.
|
This is a headerless Photon, but the one I use to
prototype with has header pins soldered to it. |
The following is a simple sketch for a LilyPad Arduino. It has two blinking functions; one blinks faster if a switch is toggled from off to on (high to low). Although I have experience with switches in my work, the concept of a pull-up resistor was something new to ponder. According to the
baldengineer, "When using any kind of 'open' inputs with an Arduino such as switches, push buttons, reed relays, and some sensors, a pull-up resistor is needed for reliable operation. These resistors hold the I/O pin at a known value until the switch forces the I/O pin to a different known value. On each board there are Arduino Internal Pull-Up resistors built-in, they just need to be turned on in the sketch, usually in setup()." My original code didn't specify that I wanted the switch to be an INPUT_PULLUP, rather than just an INPUT, and it didn't work. When I changed the code, it did!
I also continued working on a personal passion project, which is trying to learn more about the Photon and the Internet of Things. Like the LilyPad Arduino, the Photon also has built in pull-up resistors. I haven't used them yet, but I thought I'd mention it.
My goal for the week was to get a servo up and running and connected to Twitter, which I was eventually able to do. Here is the
blog post that I wrote about this. I've been documenting my work with the Photon on my personal blog for about a month, because I'm hoping to use one in a project I'm building.
Also, since this is a coding class, I spent some time thinking about and experimenting with the code that I used, even if I didn't write it myself. Here is a
link to the open source code, along with my annotations.
No comments:
Post a Comment