MySQL for the Internet of Things

(Steven Felgate) #1

ChApTEr 2 ■ hArdwArE for IoT SoluTIonS


■Note If you use a Mac, it doesn’t matter which port you choose—either the one that starts with tty or the


one that starts with cu will work.


Now that you have your Arduino IDE installed, you can connect your Arduino and set the board and
serial port. You see the LEDs on the Arduino illuminate. This is because the Arduino is getting power from
the USB. Thus, you don’t need to provide an external power supply when the Arduino is connected to your
computer. Next, let’s dive into a simple project so you can see the Arduino IDE and learn how basic sketches
are built, compiled, and uploaded.


Project: Hardware “Hello, World!”


The ubiquitous “Hello, World!” project for the Arduino is the blinking light. The project uses an LED,
a breadboard, and some jumper wires. The Arduino turns on and off through the course of the loop()
iteration. That’s a fine project for getting started, but it doesn’t relate to how sensors could be used.
Thus, in this section, you expand on the blinking light project by adding a sensor. In this case, you
still keep things simple by using what is arguably the most basic of sensors: a pushbutton. The goal is to
illuminate the LED whenever the button is pushed.


Wiring the Circuit


Let’s begin by assembling an Arduino. Be sure to disconnect (power down) the Arduino first. You can use
any Arduino variant that has I/O pins. Place one LED and one pushbutton in the breadboard. Wire the
5V pin to the breadboard power rail and the ground pin to the ground rail, and place the pushbutton in the
center of the breadboard. Place the LED to one side of the breadboard, as shown in Figure 2-16.


Figure 2-15. Choosing the serial port

Free download pdf