Arduino - SOFTWARE DESIGN
Arduino - SOFTWARE DESIGN
Abstract
Node MCU provides many different types of microcontrollers, all
of which can be programmed to interface with various types of external
sensors, output devices, as well as other microcontrollers and it has
inbuilt WiFi connectivity. By using the analog and digital I/O pins, users
can use an Arduino for a wide array of applications to do many
different jobs and functions. By using the basic tools provided by the
manufacturer, it is simple to begin programming your microcontroller to
function however it is needed.
Keywords:
Arduino IDE, Node MCU, programming, sensors, variables, data types,
variables, commands.
Introduction
At this point, we must also tell the computer which port we will be
communicating with the board. On a Mac this will be under Tools ->
Serial Port -> /dev/tty.usbmedem. On a Windows this will be Tools ->
Serial Port ->COMx, with the x referring to a number 3 or higher.
Once this is all set up, we can now write a program and send it to
the Node MCU for it to run.
Once you have declared all of your variables, you can begin the next
section, which is the setup function. This is a function that will run only
once at the beginning of the program, and will initialize or set up anything
that you need to. For example, if we want to set up the program to be
able to output data to a serial screen, we must include the following
command:
void loop()
{
Serial.begin(9600);
}
This command will begin the serial communication with the
microcontroller and operate at 9600 baud, which simply means the
number of pulses per second. This is one of the most common things to
include in the setup function, simply because it will allow us to debug code
more efficiently, because we can output values to the screen on our
computer to see what kind of data we are getting.
Now that we have the setup function completed, we can move onto the
main part of the program, which is the loop function. This loop function is
created by typing the following:
void loop()
{
}
We are then able to include anything we want the microcontroller to do
repeatedly inside the curly braces. This is where we will read data from
sensors, process the data accordingly, and send it to any output we want.
To create a simple program to read the values from temperature sensors,
do calculations, and output them to the screen, we can do the following
things.
First we read the values the sensors are giving us using the following
commands
Once you have verified that your code has been properly written, you can
upload it to the microcontroller. Make sure that you have connected your
board to your USB port on your computer. You can then click the arrow next to
the verify button. Your computer will now upload the code to the
microcontroller, and assuming you have correctly wired your temperature
sensors to the correct input pins to give the board the data, you should be
able to see the calculated temperatures in the serial monitor window. To bring
up this window, simply click the magnifying glass in the upper right hand
corner of the coding window in the same row as the verify button.