Skip to main content

Remote Flying Fish Project Part 2: DIY Series - Arduino Testing

Based on chapter 1, we now have a fish balloon, a tank of helium gas, several motors and motor drivers.

DO NOT inflate the balloon yet...

image121_bc32ab03bc578b033b480b2da1ecdf81f941bdcb.jpg

Just leave it like this...

Arduino testing

**If you are familiar with using Arduino, you may skip this chapter.**

Before testing, let’s get to know some of the background to Arduino.

Introduction

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs, like the lights on a sensor and turn it into output in order to activate a motor, turn on an LED or publish something online. To do so, Arduino programming language and Arduino Software (IDE) will be required.

Types of Arduino

In the Arduino family, there are many different models of boards and modules with different supporting features, for example, Arduino UNO, NANO, MICRO, MEGA. In this project, every model can also perform similar results, it only needs to select the module in your Arduino IDE. We will discuss it in the following part.

image151_df8e5561f9cdc02e9bff75699dd2a955d2b8d7d5.png

Selection of Arduino board

image35_b8dc487dc151c83a9ed6f728cbc3512a88ee4089.png

For the design of the product, you are recommended to use Arduino Nano. The pin configuration is as shown below.

image132_4dcbf2e32f91af21c3b3048bb1711ef47ad0e2eb.png

Arduino Nano in total provides 22pins for data I/O (input/output), which are D0-D13 and A0-A7. For some pins, like D0, D1, D11, and D12, they serve for other purposes as well. If you do not know what they will do, you should not prioritize their usability.

Nevertheless, Nano is not the lightest or the smallest board in the Arduino series. You have other options regarding the design of the product and you are free to use other boards during development and testing.

Installing the Arduino IDE

You need to install the Arduino Integrated Development Environment (IDE) on the computer. Although your computer might contain the Arduino IDE already, it is recommended to install the Arduino again to reduce the probability of errors during the whole development process. Get your computer ready by working on the following progress.

  1. Go to the official Arduino download page ( https://www.arduino.cc/en/Main/Software )

     

  2. Select the install packet depends on the operating system of your computer.

    %25E6%2593%25B7%25E5%258F%25963_b56af119347d6a0c6af5ec2d536f7994206b4234.png

     

  3. A ZIP file will be downloaded to your computer. Unzip it and drag the folder inside to the desktop. Open the folder and open the application “arduino.exe”. Now Arduino IDE is available on your computer.

Setting up the Arduino IDE

  1. Connect the Arduino Nano to the computer using a Nano USB cable. (The version of USB cable depends on the module of Arduino board you are using. Wait until the initialization of the board finishes.

     

  2. Check the COM Port number of the Arduino Nano in your computer as follows:

     

    start_menu_6258bbbfa1ff283a15a938852bcc64ff27361408.png

    (i) Click “Control Panel” at the Start Menu and click “Hardware and Sound”

    (ii) A window will show up, choose “Device Manager” (under Devices and Printers).

     

    (iii) If a pop-up message shows up, click ok.

    (iv) A “Device Management” window will show up.

    %25E6%2593%25B7%25E5%258F%25961_9cce83d6dd5975f89605b70b3103eec4e476eb14.png

    (v) Double click on “Ports (COM & LPT)”, check the parenthesis next to Arduino Nano. In this case, it is COM3.

    %25E6%2593%25B7%25E5%258F%259611_b1bc5a991a905756e0df97c3c90608dc792180ab.png

     

  3. Start the Arduino IDE, check the settings:

    (i) Board: Arduino Nano

    (ii) Processor: ATmega328

    (ii) Port: Choose the Port Number obtained in Step 2

    (iii)Programmer: AVRISP mkII

    2019-08-11_%282%29_ff895a5272b19eaf2f9a2845804a6618d2762d66.png

Turning On the On-board Light

This part teaches you more about the interaction between programming instructions, Arduino board, and peripherals, for example, LED.

  1. Click on the “File” > “Examples” > “01. Blink. '' A new window showing a sketch named “Blink” should pop out as below. Just to note that in Arduino IDE, the source code is called a “sketch”.

    2019-08-01_%288%29_c4f1b12f48f4980a5764898148e7d4f5819f6399.png

     

  2. The pop-out sketch “Blink” should be the same as shown below. Study the comment inside “/* ... */” CAREFULLY. One should note that comment is widely used in programming since it provides useful information to people who read the program afterwards. In Arduino, we put the comment inside /* */ or after //. Lines inside /* */ or after // will not be executed by the program.

    2019-08-01_%289%29_9a1714bd655301cc2a9582cf44042648e92981a5.png

     

  3. Verify the sketch “Blink” by clicking the “✔” on the top right-hand corner. If there is no problem, Arduino will show a message as below.

    image163_8bcdbc86c5ae58ba02fe3efd06396d1b1cfe3e5c.png

     

  4. If there are any problems, Arduino will show an error message as below here. If an error message is shown, please try to debug the program by following the message.

    image104_a4dc4f875361ae59ce13f8c41405a942e2b3f789.png

  5. If compilation completes without errors, click the “→” to upload the sketch to the Arduino board. The Arduino board will be initialized and be installed with the sketch “Blink” after you upload the sketch.
  6. Wait until the word “Done uploading” shows on the status bar. image95_f2c2ce035b21dc497fd7fd5f72805800a87e737f.png
  7. Now observe the Arduino board, you should see the on-board LED marked “L” blinking.

    %25E6%2593%25B7%25E5%258F%259671_726f99a629a38f8921b8cae6f242cc7931a5fedd.png

  8. We can follow the sketch “Blink” to understand why the on-board LED blinks.

    image182_0a6d613cb5d2eac3aa2b860f74527cb9f16f258e.png

    The program above shows how to set the LED “L” to be the output. There are other settings from Pin 0 to 13 which will be shown in the future part. You HAVE TO set the correct pin as an output so the signal can successfully go out from that pin.

    The program below shows a loop which means the program keeps going through the contents inside until there is any break (this program does not contain break). The instruction “digitalWrite” means giving a signal (HIGH or LOW) to the pin (LED_BUILTIN here). HIGH means applying power while LOW means no power is applied, and “delay” means holding everything. “1000” inside the bracket of “delay” means 1000 milliseconds (ms), which indicates 1000 x 10-3 second, i.e. 1 second.

    image26_ae07c4581cbfef99702da7f8745530f4b0544364.png

  9. You can try to change the number 1000 to other amounts, for example, 400 or 2500. The command “delay” then holds 0.4 seconds and 2.5 seconds respectively. Upload the sketch to the Arduino board after you change the number.
  10. DO NOT change any settings. You need to use the blink as the template for completing the next part.

In the next chapter, we will cover, Motor Testing :)

You can download the pdf version of this chapter in the Download section below.

 Parts in this series

lokit has not written a bio yet…