Programming - MacOS
This section explains the step-by-step process to program the Nano Board microcontroller and DS3231 Real Time Clock
Table of Contents - LCD Alarm Clock Instruction Guide
Programming Preface
The following instructions will guide you through the processes of preparing your MacOS computer with the correct Arduino IDE configuration (the computer program used to upload a program to your Nano Board (Part C)) and through programming the Nano Board (Part C) microcontroller and DS3231 Real Time Clock (Part D). To enable/disable DST, you can skip to Sub-step 8A and 8B, below.
Programming
Now that your LCD Alarm Clock wiring has been completed, follow the steps below to complete the programming of your kit's Nano Board (Part C) microcontroller and DS3231 Real Time Clock (Part D):
- Begin by connecting the Mini USB Cable (Part K) to the Nano Board (Part C) and then plug it into your Mac or your Mac's USB hub (Note: Not all USB hubs work correctly with the Arduino IDE, so if you have issues while using a USB hub, connect the cable directly to your Mac, if possible).
(Note: Parts other than the Nano Board (Part C) and Mini USB Cable (Part K) have been removed from the image below for clarity)
When you upload code to the pre-programmed Nano Board (Part C), the existing program on the board will be erased and overwritten. The Nano Board (Part C) can be programmed an unlimited number of times, and each upload will overwrite the prior program, so you can always customize or alter the code in the future to fit or change your style.
-
If you have not already downloaded and installed the Arduino IDE version 1.8.X previously for another Arduino related project, you can follow this guide (linked here) for the step-by-step installation process. Once it is installed, you can continue with this step.
Use Safari for ALL downloads in this guide. Download the Arduino Code file for this project, by clicking the link below and accepting the download if prompted. This download should appear in your Downloads folder which can be accessed by opening the Finder application. If your Mac configuration places downloads in a different location, you will need to note that location for use in the following steps. (Note: If at any point, you accidentally delete or edit the code in the file and receive error notifications from the Arduino IDE, you can re-download a fresh copy of the file by clicking the link below again.)
- Once the file is downloaded, you will need to open it in the Arduino IDE. If you used the Safari browser to download the file in Step 2 above, the code file should already be unzipped in your Downloads folder.
To open the code file, open the Arduino IDE from Launchpad (or wherever you have stored the Arduino application) and press "Command+O" on your keyboard to pull up the open file dialog box; this can also be accessed by clicking "File" -> "Open..." at the top of your screen. Then navigate to the download location for the Tech-BoxIO_LCD_Alarm_Clock.ino file, click on the Arduino file, and click "Open", as shown in the image below. If the Arduino IDE requests access to the folder where the file is stored, allow it. If you have any issues or questions, feel free to contact Tech-Box Support by email at Support@Tech-Box.io
-
Connect the Nano Board (Part C) to your Mac using the Mini-USB cable (Part K) if it is not already connected. Then select Tools -> Ports and you should see that a COM port has appeared, as highlighted in blue in the image below. The COM ports are labeled by number and the values will vary by Mac, but appear at the end of the "/dev/cu.usbserial-##" port name. Our Nano Board (Part C) appeared as "/dev/cu.usbserial-10", but your board may appear as any "-#" value. To download to the Nano Board (Part C), click and select the new COM port that appeared in this menu. (Note: The COM port "-#" should not change when unplugging and reconnecting the board.) If you are unsure which COM port your Nano Board (Part C) is connected to and multiple COM ports are appearing, you can unplug your Nano Board (Part C) and then check the menu again to see which COM port is no longer present. Then, reconnect your Nano Board (Part C) and select the correct port once it reappears. Once the new COM port is selected, proceed with Step 5 below.
Troubleshooting for step 4:
If no COM port appears under the “Port:” option with the Nano Board (Part C) connected, there may be a component or wire placed incorrectly. In this event, first attempt to connect to different USB ports on your computer and check if a COM port appears under the "Port:" menu. If no ports appear, then remove the Nano Board (Part C) from the Breadboard (Part F) and attempt to select a COM port again. If the issue persists, disconnect and then reconnect the Nano Board (Part C) from/to the Mini USB cable (Part K) to power cycle the Nano Board (Part C) and attempt the COM port selection again. If the COM port selection now works, check all of your wiring and component placements to make sure that they are in the correct locations. If you have any issues with the selection, please contact Support@Tech-Box.io
USB Cable
Some third-party USB cables are meant for power only and may not have data wires included. These cables will not allow for your microcontroller to communicate with your computer. Therefore, we recommend using ONLY the provided USB cables from our guided kits as all Tech-Box.io USB cables are configured with integrated data lines. If you have any issues with the installation, please contact Support@Tech-Box.io
End Troubleshooting For Step 4
- Once the project file is opened in the Arduino IDE, select the correct board settings in your Arduino IDE to complete the upload. To do this, in your Arduino IDE, select Tools -> Board -> Arduino AVR Board -> Arduino Nano (or Tools -> Board -> Arduino Nano on some installations) as shown in the image below.
Then, ensure that the "Processor" selection that appears below the "Board" options (and highlighted by the yellow rectangle in the image below), is set to "ATmega328P" and NOT "ATmega328P (Old Bootloader)". (Note: The processor selection will only appear once the Arduino Nano Board has been selected). Once these selections are made, click the “Checkmark” in the upper left-hand corner of the Arduino IDE, as highlighted by the red square in the image below, to verify and compile the code. This selection allows the compiler to prepare the code to be uploaded to the correct microcontroller. After a short time, your compile will complete successfully.
The Arduino code file for this project has been completely commented with each variable, line, and code block’s function explained. Feel free to read through the code to learn what each section is doing and check your understanding!
Troubleshooting For Step 5:
If there are errors when attempting to compile the code in the Arduino IDE, complete the following troubleshooting steps:
1) If the error persists, restart your computer, then open the Arduino IDE and project code and attempt to compile again.
2) If the compile still fails, please open a support ticket with Tech-Box.io Customer Support by sending an email to Support@Tech-Box.io and include the name of your kit and describe or provide the error code you are encountering in the Arduino IDE (The error information will be in the area that appears orange and black at the bottom of your Arduino IDE). Customer support will get back with you as quickly as possible!
End Troubleshooting For Step 5
-
With the proper board type and COM port selected, you are now ready to configure the dial Potentiometer (Part J) and 3-position Rocker Switch (Part G) inputs and program the Nano Board (Part C). To complete the programming process for the Nano Board (Part C), follow the sub-steps below:
Sub-step 6A) Begin by pressing the 3-position Rocker Switch (Part G) into the "II" position, as shown by the right-most image in the chart below. This input will flag the DS3231 Real Time Clock (Part D) in the program, marking it for a time update.
Sub-step 6B) The Dial Potentiometer (Part J) must now be configured. If Daylight Saving Time (DST) IS currently active, rotate the knob of the dial potentiometer fully in the counter-clockwise direction until it hits a hard-stop, as shown on the left side of the image below. If DST IS NOT currently active, rotate the knob of the dial potentiometer (Part J) fully in the clockwise direction until it hits a hard-stop, as shown in the right side of the image below. (Note: Daylight Saving Time [DST] typically begins on the 2nd Sunday in March and ends on the 1st Sunday in November in most of the United States). This configuration allows the program to know the correct DST status at the time of programming.
Sub-step 6C) Finally, with the proper board type and COM port selected, click the “Arrow” in the upper left-hand corner of the Arduino IDE to upload the code to the Nano Board (Part C), as highlighted by the red square in the image below. The Arduino IDE will notify you when the file is “Done Uploading” in the lower left-hand area of the Arduino IDE, as highlighted by the yellow rectangle below. This Nano Board microcontroller (Part C) can be rewritten/re-uploaded to an unlimited number of times, if desired. Feel free to create your own custom time display and re-upload to the Nano Board microcontroller (Part C) as needed!
Note: The code for this project sets the DS3231 Real Time Clock (Part D) to the time the sketch was compiled and uploaded to the Nano Board (Part C). If the time that is displayed is incorrect or is "off", you will need to complete this entire step again to correct the time. If the time shown is still incorrect, check the system time of your Mac to ensure it is accurate to the real time in your area.
Troubleshooting for step 6:
1) Check the wiring and component placements; including the placement of the Nano Board (Part C) itself. If wires or components are in the wrong locations, it may block the code from being uploaded or prevent the Nano Board (Part C) from appearing in the COM port options. Once you have checked everything, attempt the upload again.
2) If the error persists, remove the Mini-USB cable (Part K) from the Nano Board (Part C) and then remove the Nano Board (Part C) from the Breadboard (Part F). Then reconnect the Mini-USB cable (Part K) to the Nano Board (Part C) and attempt to upload the code while it is disconnected from the breadboard (Part F). If the upload is successful now, this may mean that some part of the wiring is incorrect. So check the wiring and component placement again, then reinsert the Nano Board (Part C) into the breadboard (Part F) at the correct pin location shown in the wiring section of this guide.
3) If your program still fails to download, please open a support ticket with Tech-Box.io Customer Support by sending an email to Support@Tech-Box.io and include the name of your kit and specific issue in the email. Customer Support will get back with you as quickly as possible!
End Troubleshooting for Step 6
- Move the 3-Position Rocker Switch (Part G) back to the "O" position. (Note: It is VERY important to not restart or power-up the LCD Alarm Clock with the 3-Position Rocker Switch (Part G) in the "II" position. If the Nano Board (Part C) is restarted with the Rocker Switch in this state, the time may be reset and the alarm clock will need to be reprogrammed to display the correct time again).
At this point, the LCD Screen (Part B) should be powered and illuminating with the correct time. If no illumination is present, double check your wiring to ensure all components and wires are placed correctly, and then attempt to program the Nano Board again. If the LCD Screen (Part B) is illuminating, but the time is not visible, you may need to adjust the contrast of your LCD Screen -- Follow the troubleshooting steps below if this occurs.
If your issue persists, please reach out to Support@tech-box.io and our support team will be happy to assist you!
Troubleshooting for step 7:
1) Gently rotate the Potentiometer knob on the back of the LCD Screen (Part B) clockwise (the top of the screw rotates to the right) using a small flat tool until it stops, as shown by the arrow in the image below. This will set the LCD Screen to its maximum contrast.
2) Slowly and gently rotate the potentiometer knob back counterclockwise, again using a small flat tool, until the time is clearly displayed on the LCD Screen (Part B). The correct contrast is a personal preference, however our contrast appears in the image below.
Note: If you see the LCD Screen (Part B) flicker during this process, it was likely due to a poor connection between one of the Breadboard Wires (Part N) connected between the LCD Screen and the breadboard (Part F). Please check all connections to ensure the flickering is no longer present.
3) If your issue persists, please open a support ticket with Tech-Box.io Customer Support by sending an email to Support@Tech-Box.io and include the name of your kit and specific issue in the email. Customer Support will get back with you as quickly as possible!
End Troubleshooting for Step 7
- With the LCD Screen's (Part B) time displaying on the screen, it is time to test the 3-position Rocker Switch (Part G), the dial Potentiometer (Part J) on the front of the housing, and the Alarm Buzzer (Part H). To do this, first note the rocker switch (Part G) positions shown in the image below, and then follow the steps below.
Sub-step 8A) Start by moving the Rocker Switch (Part G) to position “I” by pushing down on the “I” side of the switch (Part G). Depending on the position of the dial potentiometer (Part J), this displays one of the following three messages on the LCD Screen (Part B): “Set Alarm for:” (shown in the image below), "Switch to 'O' to ENABLE DST", or "Switch to 'O' to DISABLE DST". If one of these messages appear, this portion of the rocker switch (Part G) is functioning correctly.
Sub-step 8B) With the rocker switch (Part G) still in position “I”, begin to rotate the dial Potentiometer knob (Part J) on the front of the clock housing clockwise/counter-clockwise to scroll through the possible alarm time settings. The time shown under “Set Alarm for:” progresses to “12:00 AM” in 15-minute increments as the knob (Part J) is turned counterclockwise and progresses to “11:45 PM” in 15-minute increments as the knob (Part J) is turned in a clockwise direction.
When the knob (Part J) is turned FULLY counterclockwise, the message "Switch to 'O' to ENABLE DST" will appear, as shown in the image below. If the 3-position rocker switch (Part G) is moved to the "O" position at this time, Daylight Saving Time will be enabled on the clock, moving the time forward by 1-hour (3:00 PM will become 4:00 PM).
When the knob (Part J) is turned FULLY clockwise, the message "Switch to 'O' to DISABLE DST" will appear, as shown in the image below. If the 3-position rocker switch (Part G) is moved to the "O" position at this time, Daylight Saving Time will be disabled on the clock, moving the time backward by 1-hour (4:00 PM will become 3:00 PM).
Sub-step 8C) With the 3-position Rocker Switch (Part G) still in the "I" position, rotate the dial potentiometer knob (Part J) as needed to set the alarm time for the 15-minute interval closest to your current time to test the Alarm Buzzer (Part H). For example, if it is 1:01PM currently, set the alarm for 1:15PM so that the alarm will trigger at that point in time. After setting the alarm, move the rocker switch (Part G) back to the "O" position, and you will briefly see the message "Alarm Set For:", as shown in the image below.
Sub-step 8D) Move the rocker switch (Part G) from the “O” position to the “II” position. This will display an asterisk “*” next to the current time once the time is re-displayed, as shown in the image below. This asterisk means that the alarm is active and will activate when the alarm time that you just set arrives.
Sub-step 8E) Following the example above, when the current time displayed changes from 1:14:59 PM to 1:15:00 PM and the rocker switch (Part G) is in the “II” position with the asterisk displayed next to the time, the Alarm Buzzer (Part H) should sound.
Sub-step 8F) To turn the alarm and buzzer (Part H) off, move the rocker switch (Part G) back to the “O” position. This will disable the alarm, even if it is currently activated. To not have the alarm active, leave the rocker switch (Part G) in position “O” and the alarm will never sound, regardless of the time it is set for.
Congratulations! Your Nano Board (Part C) is now successfully programmed and you have learned how to operate your LCD Alarm Clock! You are now ready to start assembling the Alarm Clock Housing (Part A). Continue to the next section and follow the steps in that section to complete the housing assembly.