# Using Arduino – Basics (*Work in Progress...*) [toc] ___ ## Getting in touch Arduino is an electronic platform of free software and hardware created to allow the creation and prototyping of interactive projects accessible to anyone. <img style="display:block;margin:48px auto;padding:1px;border:1px #eee;width:60%;" src="https://ettron.com/wp-content/uploads/2021/07/different-types-of-Arduino-boards.jpg"/> In a simplified way, the microcontroller present on the Arduino board is programmed in a development environment (IDE - *Integrated Development Environment*) with the Arduino programming language. In a complementary way, the Arduino board has several pins, sensors and electronic devices that allow them to create different projects and be used by artists, hobbyists or anyone. In addition to the Arduino board itself, the platform supports expanding its functionality through shields that can be added to projects, such as: Ethernet module, Relays, Motors, LCDs, wave generators, digital buttons, joysticks, GPS module, LED array, among others: <img style="display:block;margin:48px auto;padding:1px;border:1px #eee;width:60%;" src="https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2016/01/List-Arduino-Shields-Thumbnail.jpg?resize=702%2C457&quality=100&strip=all&ssl=1"/> Although basic knowledge of electronics is a good help in project development, it is not mandatory. Thus, for its interactive and accessible nature, learning Arduino can be easy, fun and lead to interesting projects. To learn more about the project, visit: [Arduino Project](https://www.arduino.cc/) ___ ## Downloading Arduino To be able to work on Arduino electronic projects, it is recommended that you have a physical board with you. Then, download the platform software to the appropriate settings for your computer: [Download Arduino Software](https://www.arduino.cc/en/software) When the installation is finished, unzip the folder and save it in the desired location on your computer. ___ ## Initial Configuration For this short tutorial, we will use Arduino Uno board. It will also be necessary to make use of the USB AB cable. :::warning :warning: Note! For other boards in the Arduino board family line it is necessary to look for the appropriate tutorial. ::: <img style="display:block;margin:48px auto;padding:1px;border:1px #eee;width:50%;" src="https://images.tcdn.com.br/img/img_prod/650361/placa_uno_smd_r3_cabo_compativel_com_arduino_1577_1_20200601122819.jpg"/> In an isolated way, the Arduino board is powered through the USB connection, so it is not necessary to connect it to extra power sources. Now, lets install the necessary drivers for Arduino Uno with Windows operational system with the follow steps below: - Connect the board to the computer and wait for the driver to install. - If the installer does not launch automatically, navigate to the **Windows Device Manager** (Start > Control Panel > Hardware > Device Manager) and find the Aduino UNO (COMxx) listing. - Right click and choose **Update driver**. - At the next screen, choose "Browse my computer for driver software", and click **Next**. - Click the **Browse...** button. Another dialog appears: navigate to the folder with the Arduino software that you just downloaded. Select the drivers folder an click **OK**, then click **Next**. - It will appear a notification that the board has not passed Windows Logo testing. Click on the button **Continue Anyway**. - After a few moments, a window will tell you the wizard has finished installing software for Arduino Uno. Press the **Close** button. ___ ## Software Great! Let's start to use the Arduino software! - Go to the unzipped Arduino folder where you saved it and double-click the **.exe** file and wait until the end of loading. - Open the Arduino program. - Go to **Tools** > **Board**, and select your board, in this case **Arduino Uno**. - Still in Tools, click **Tools** > **Serial Port**, and select the same port used in the configuration of the previous item *Initial Configuration*. The Arduino environment is ready to run your first program! The work and development homepage is called Sketch and will look like this: ![](https://i.imgur.com/HqSz3sV.png =500x) In this environment programs are written. The sketches are then written to the Arduino IDE and saved in **.ino** format. In the upper left corner you can see the main Sketches, which means: ![](https://i.imgur.com/lTx0kuD.png) **Verify**. Checks possible errors in the code. ![](https://i.imgur.com/l9H6GxX.png) **Upload**. It compiles the code and then sends it to the Arduino board. ![](https://i.imgur.com/gyBBnP1.png) **New**. Create a new Sketch. ![](https://i.imgur.com/znEaJFv.png) **Open**. Displays a listing of all existing scketches. ![](https://i.imgur.com/kY4Lwnh.png) **Save**. Saves the Sketch. ![](https://i.imgur.com/UajDiyA.png) **Serial Monitor**. Open the serial monitor. In the lower horizontal bars it is possible to receive notifications about the progress and status of the compilation and upload, as well as error or success information about the program: ![](https://i.imgur.com/5gX2S8D.png =400x) ### Serial Monitor The serial monitor is a sketch that displays the serial data that is sent to the computer by the Arduino board. If you want to manually send data to the board, type the desired text in the upper writing bar available and click "send", or just press Enter. During data transmission, data can be sent at different speed rates, which can be adjusted either in Sketch directly and with Serial Monitor. In the Sketch, use the **Serial.begin** function to define the data speed. Still, with Serial Monitor, go to the lower right bar and select one of the speeds options. Remember that the same speed must be set in both Sketch and Serial Monitor. ### Libraries For most of the functionality that can be performed with Arduino, many are covered by the use of libraries, which provide extra resources for use in sketches. Many libraries are already installed with the Arduino IDE. To check and add the existing libraries to the program go to **Sketch** > **Include Library**: ![](https://i.imgur.com/mVMeQ34.png =500x600) In this section, we can see some libraries already installed. To add others, click on Manage Libraries and install them as desired. Futhermore, you can also manually add some available library typing at the beginning of the line program. Example: ``` #include <ArduinoJson.h> ``` Furthermore, you can create your own libraries. For more detailed and in-depth information about libraries, visit: [Library Examples](https://docs.arduino.cc/library-examples/) [Libraries Documentation](https://www.arduino.cc/reference/en/libraries/?_gl=1*45pnk4*_ga*MjAxMDg4Njc0Ni4xNjQ3MTk1Mzk4*_ga_NEXN8H46L5*MTY2NDQxODI3OC44LjEuMTY2NDQxODM2Ni4wLjAuMA..) ___ ## Programming Arduino ### Basic Structures ### Variables ### Operators ### Control structures ### Digital and analog functions ### Good Practices ### First Program – Lighting a LED! Now, let's run a simple example program already built into the Arduino IDE. Go to **File** > **Examples** > **Basics** and select **Blink**. ![](https://i.imgur.com/RbkyMTr.png) This program aims to turn it on and off repeatedly, and after you have done all the settings as in the steps above, verify your program and upload it to the board. Next, we will see one of the LEDs built into the board turn on and off alternately :tada: ___ ## Practical Exercises – Collecting Environmental Data ### Light Detection ### Sound Detection ### Temperature Measurement ### Distance Measurement ### Accelerometer ___ ## Data Processing – Simple Example ### Converting serial output to JSON ___ ## References and Materials - Arduino Official Domain: [Arduino - Home](https://www.arduino.cc/) - To learn even more about Arduino and project making, visit: [Arduino Learning](https://docs.arduino.cc/learn/) - For more information on how to use Arduino Online, go to: [Arduino Web Editor](https://docs.arduino.cc/learn/starting-guide/the-arduino-web-editor)