Arduino Uno 45 projects for beginners and experts

Page 5

Chapter 4 • The first steps (LED, switch, serial connection))

Chapter 4 • The first steps (LED, switch, serial connection) We will start with a series of projects that make use of LEDs and switches. The first projects are simple, but as we go along the complexity slowly increases. If you don’t want to build the projects, we recommend you read them anyway because we will be discussing and explaining several C++ commands. 4.1 Flashing LED

We will redo the program from the tutorial, but this time we will connect an LED of our own, calculate the current limiting resistor and write the program ourselves. We won’t make use of the LED on the Arduino, but solder one on to the development shield. Or rather two LEDs, one extra for the following project. In order to use an LED we must connect it in series with a resistor. This resistor will limit the current through the LED, hence the name “current limiting resistor”. Without this resistor the LED will be destroyed as will the Arduino port that the LED is connected to.

Figure 12. Section of the datasheet of the LED. The first thing we need to do is look at the datasheet of the LED. The important variable is the current consumption, which in the case of an LED is called “forward current”. The maximum value according to the datasheet is 20 mA, the recommended value is 16-18 mA. The resistor must make sure this value is not exceeded. Apart from the LED, the Arduino must be protected as well. The maximum current that the Arduino can supply through a pin is 40 mA. This value is only applicable when just one pin is using the current. When multiple pins are in use the maximum value drops, and it can be quite complicated to calculate what the maximum is for a given situation. A rule of thumb for the Arduino Uno is that 14 mA is a safe value regardless of the number of pins in use. This is somewhat under the recommended value for our LED but the amount of light it emits at this current is still more than enough. The next important LED property is the voltage drop over the LED. In the datasheet this is

● 23

45 Arduino Projects UK 160209.indd 23

18-02-16 15:16


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.