1 Lab en
1 Lab en
Aim of the laboratory: to study the principle of operation and control of digital inputs of
microcontroller.
Task:
1. Create and configure an Arduino application project.
2. Connect the circuit shown in Figure 1.
3. Create application code to control the LED flash.
4. Connect the circuit diagram shown in Figure 2.
5. Generate application code to read button value.
6. Combine the combined scheme of Figures 1 and 2.
7. Write program code enabling LED to operate with button.
Equipment:
1. Arduino microcontroller.
2. Red LED light.
3. 1 and 10 k resistors.
4. Button.
5. Wires.
Workflow:
1. The Arduino microcontroller programming program runs in the computer's operating environment.
The USB cable connects the Arduino board to the computer. The top bar selects the Arduino
microcontroller and the COM port where the Arduino board is found. This COM port may be different
for each computer. After configuration, the Arduino board is disconnected from the computer.
2. Connect the wiring circuit shown in Figure 1. A digital input is used to control the LED light (may not
be D13 as shown in the circuit). The wiring circuit is described with the data of all electronics
components included in the wiring circuit (resistor, LED), as well as the most important data of the
microcontroller (digital control input LED is selected).
Figure 1 Principal electrical circuit of the LED light connection to the microcontroller.
3. Before writing the LED light control program code, the program setup () is configured in the program
code part. Input LED control digital input using pinMode (PIN, OUTPUT) function. Here, the PIN
indicates the selected digital port.
Next, using the delay () and digitalWrite (1par, 2par) functions, the program code that controls
the LED flash is generated. The delay () function in parentheses indicates the time in milliseconds. The
1par and 2par inside the digitalWrite () function represent the first and second function parameters. The
first parameter must indicate the selected digital port and the second parameter the HIGH or LOW
voltage level, depending on whether the LED is on or off.
4. Connect the wiring circuit shown in Figure 2. Please select digital port for button. Schematic
description of all electronic component parameters as well as connection data (input voltage, earthing) is
performed.
5. Using the serial.print () function, code is generated to read the value of a button. The parentheses of
this function indicate the parameter (port) whose value is to be output to the Serial monitor sub-window
of the Arduino application. The top bar then finds and activates the Serial monitor window and checks
the operation of the written program. If the numeric button is not read correctly, the program code is
adjusted until the desired result is achieved.
Figure 2 Principal electrical circuit of button connection to microcontroller.
6. Connect the combined circuit (Fig 1 and 2). It must consist of an LED light, a button and two
resistors. Optional digital ports for LED light and button. Performs a detailed description of the created
schema. List all the electronic components used, their data and the connection.
7. Write program code to control LED light on / off which is using the touch button.
Defense questions:
1. Digital Signals.
2. Digital-to-analog converter.
3. How to configurate diogital ports?
4. Principle of operation of LED light.
5. Pull-up and pull-down resistor.
6. Function of „if“ working principle.
7. Types of digital sensors.
Lab report:
1. The aim and tasks of the work.
2. 1, 2 wiring circuit and their descriptions.
3. Program code and description.
4. Control algorithm and its interpretation.
5. Results obtained during the work.
6. Conclusion.