You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/07.opta/opta-family/opta/tutorials/18.conveyor-sorting-app-note/content.md
+15-17
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,7 @@
1
1
---
2
-
title: 'Color Sorting and Remote Monitoring with Opta™'
2
+
title: 'Conveyor belt sorting with remote monitoring using Opta™'
3
3
difficulty: intermediate
4
4
description: "This application note describes how to remotely control and monitor a conveyor and sorting system in real time using the Opta™ and its built-in cloud connectivity."
5
-
6
5
tags:
7
6
- cloud
8
7
- conveyor
@@ -11,7 +10,6 @@ tags:
11
10
- opta
12
11
- color
13
12
author: 'Davidson Dantas and Thiago Alves'
14
-
15
13
hardware:
16
14
- hardware/07.opta/opta-family/opta
17
15
---
@@ -555,19 +553,19 @@ void setup() {
555
553
556
554
The `setup` function in Arduino programming is a crucial function that executes once when the Arduino board is powered on or reset. It’s responsible for initializing settings and configuring the system before the main program starts running. In the `setup` function, you typically establish communication (such as starting the serial monitor), configure pin modes, connect to networks, and initialize variables and libraries. This function ensures the Arduino is fully prepared for the `loop` function that follows, allowing for continuous and smooth operation. In this sketch, we are setting up:
557
555
558
-
1.**Serial Communication Initialization**:
556
+
**Serial Communication Initialization**:
559
557
-`Serial.begin(9600);`: Initializes the serial communication at a baud rate of 9600 bps, allowing you to monitor the device's output through the Serial Monitor.
560
558
561
-
2.**Delay**:
559
+
**Delay**:
562
560
-`delay(1500);`: A delay of 1.5 seconds is introduced to ensure that the Serial Monitor has time to open before continuing.
563
561
564
-
3.**Properties Initialization**:
562
+
**Properties Initialization**:
565
563
-`initProperties();`: This function is defined later in the code and is responsible for linking the local variables with the Arduino Cloud properties.
566
564
567
-
4.**Arduino Cloud Connection**:
565
+
**Arduino Cloud Connection**:
568
566
-`ArduinoCloud.begin(ArduinoIoTPreferredConnection);`: This command connects the device to the Arduino Cloud using the specified WiFi credentials.
569
567
570
-
5.**Debugging Information**:
568
+
**Debugging Information**:
571
569
-`setDebugMessageLevel(2);`: Sets the level of debug information. A higher number provides more detailed information about network and cloud connection states. The default is 0 (only errors), and the maximum is 4 (most detailed).
572
570
-`ArduinoCloud.printDebugInfo();`: Prints debug information about the cloud connection to the Serial Monitor.
573
571
@@ -592,25 +590,25 @@ void loop() {
592
590
593
591
The `loop` function in Arduino programming is a core function that runs continuously after the setup function has finished executing. This is where the main logic of your program resides. The `loop` function repeats over and over, allowing the Arduino to check inputs, control outputs, and perform tasks repeatedly as long as the board is powered on. It’s in this function that you’ll handle real-time operations, such as reading sensor data, controlling motors, or updating displays. By continuously executing the code within loop, the Arduino can respond dynamically to changes in its environment, ensuring ongoing and responsive operation. The loop function in this sketch is responsible for:
594
592
595
-
1.**Cloud Connection Maintenance**:
593
+
**Cloud Connection Maintenance**:
596
594
-`ArduinoCloud.update();`: This function keeps the connection to the Arduino Cloud alive and synchronizes the cloud-linked variables with their current values.
597
595
598
-
2.**Start Button Status**:
596
+
**Start Button Status**:
599
597
-`cloudStartButton = PLCOut.out_cloudStartButtonStatus;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
600
598
601
-
3.**Stop Button Status**:
599
+
**Stop Button Status**:
602
600
-`cloudStopButton = PLCOut.out_cloudStopButtonStatus;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
603
601
604
-
4.**System Running Status**:
602
+
**System Running Status**:
605
603
-`cloudRunningSystem = PLCOut.out_cloudRunningSystem;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
606
604
607
-
5.**Red Items Sorted Count**:
605
+
**Red Items Sorted Count**:
608
606
-`cloudRedSorted = PLCOut.out_counterRed;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
609
607
610
-
6.**Green Items Sorted Count**:
608
+
**Green Items Sorted Count**:
611
609
-`cloudGreenSorted = PLCOut.out_counterGreen;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
612
610
613
-
7.**Blue Items Sorted Count**:
611
+
**Blue Items Sorted Count**:
614
612
-`cloudBlueSorted = PLCOut.out_counterBlue;`: Synchronizes the variable in the PLC with the variable in the Arduino Cloud.
615
613
616
614
### Fourth Section: InitProperties and Callbacks
@@ -647,15 +645,15 @@ void onStopButtonChange() {
647
645
648
646
**Explanation:**
649
647
650
-
1.**`initProperties` Function**:
648
+
**initProperties Function**:
651
649
652
650
`ArduinoCloud.update();`: This function links the cloud variables with their respective properties in the Arduino Cloud. Each property is set with specific attributes:
653
651
-**`READWRITE`**: The property can be read from and written to by the cloud.
654
652
-**`READ`**: The property can only be read by the cloud.
655
653
-**`ON_CHANGE`**: The associated function (callback) is called whenever the value of the property changes.
656
654
-`onStartButtonChange` and `onStopButtonChange` are callback functions that execute whenever the `cloudStartButton` or `cloudStopButton` values change.
657
655
658
-
2.**Callback Functions**:
656
+
**Callback Functions**:
659
657
-**`onStartButtonChange()`**: Updates the local start button state (`PLCIn.in_cloudStartButton`) whenever the `cloudStartButton` value changes in the cloud.
660
658
-**`onStopButtonChange()`**: Updates the local stop button state (`PLCIn.in_cloudStopButton`) whenever the `cloudStopButton` value changes in the cloud.
0 commit comments