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/built-in-examples/09.usb/KeyboardAndMouseControl/KeyboardAndMouseControl.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ tags:
12
12
13
13
This example illustrates the use of the Mouse and Keyboard libraries together. Five momentary switches act as directional buttons for your cursor. When a button is pressed, the cursor on your screen will move, and a keypress, corresponding to the letter associated with the direction, will be sent to the computer. Once you have the Leonardo, Micro or Due programmed and wired up, open up your favorite text editor to see the results.
14
14
15
-
**NB: When you use the Mouse and Keyboard library functions, the Arduino takes over your computer's cursor! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a controller before you call Mouse.move().**
15
+
**NB: When you use the Mouse and Keyboard library functions, the Arduino takes over your computer's cursor! To ensure you don't lose control of your computer while running a sketch with this function, make sure to set up a controller before you call Mouse.move().**
16
16
17
17
### Hardware Required
18
18
@@ -57,4 +57,4 @@ You can find more basic tutorials in the [built-in examples](/built-in-examples)
57
57
58
58
You can also explore the [language reference](https://www.arduino.cc/reference/en/), a detailed collection of the Arduino programming language.
Copy file name to clipboardExpand all lines: content/cloud/iot-cloud/tutorials/03.cloud-scheduler/cloud-scheduler.md
+58-80Lines changed: 58 additions & 80 deletions
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,12 @@ software:
7
7
- iot-cloud
8
8
---
9
9
10
-
It is now possible to schedule jobs with the [Arduino IoT Cloud](https://create.arduino.cc/iot/), using the new `CloudSchedule` variable type. You can pick a start & end date for when the variable should be triggered, and for how long it should be active. This is done through the IoT Cloud dashboards.
10
+
It is now possible to schedule jobs with the [Arduino IoT Cloud](https://create.arduino.cc/iot/), using the new `CloudSchedule` variable type. You can pick a start & end date for when the variable should be triggered, and for how long it should be active. This variable can be controlled in real time using a graphical widget that you can place on an IoT Cloud dashboard.
11
11
12
12
We can for example have:
13
13
14
-
- One trigger scheduled to go off every minute, and last for 10 seconds
15
-
- One trigger scheduled to go off every hour, and last for 10 minutes.
14
+
- One trigger scheduled to run every minute for 10 seconds
15
+
- One trigger scheduled to run every hourfor 10 minutes
16
16
17
17
## Goals
18
18
@@ -21,48 +21,18 @@ The goals of this project are:
21
21
- Learn how the `CloudSchedule` variable works.
22
22
- Learn how to access local time in your sketch.
23
23
24
-
## Hardware & Software Needed
25
-
26
-
For this tutorial, you will need a cloud compatible board. You can see the full list below:
***The MKR GSM 1400 & MKR NB 1500 requires a SIM card with a data plan to work. You can read more about it in [this page](https://store.arduino.cc/digital/sim).***
24
+
Make sure you have a [cloud-compatible board](/cloud/iot-cloud/tutorials/technical-reference#compatible-hardware).
37
25
38
26
## How Does it Work?
39
27
40
-
The working principle of the scheduler is pretty straight forward. The `CloudSchedule`variable can be configured to go off at a specific time, with a specific duration. In the code, you do not need to worry about any timers, as this is done in the Arduino IoT Cloud. The "jobs" are created in the dashboard, through a widget associated to the variable.
28
+
A variable of `CloudSchedule`type can be configured to trigger at a specific time, with a specific duration. In the code, you do not need to worry about the logic for this. The configuration of the variable is done in the dashboard, through a widget associated to the variable.
41
29
42
-
For example, we can set `schedule_variable` to be:
30
+
For example, we can set such variable to be:
43
31
- ON for 10 seconds, every minute.
44
32
- ON for 8 hours, every day.
45
33
- ON for a week, and then finish.
46
34
47
-

48
-
49
-
## API
50
-
51
-
The two **variables types** introduced in this tutorial are `CloudTime` and `CloudSchedule`. These are used to retrieve local time and to schedule a job respectively.
52
-
53
-
The `CloudSchedule` variable is of a **complex type**. It has a **internal boolean state**, which can be checked through the `isActive()` function (returns `true` or `false`).
54
-
55
-
```arduino
56
-
if(schedule_variable.isActive()) {
57
-
//do something
58
-
}
59
-
```
60
-
61
-
The `CloudTime` variable is an unsigned integer which is used to store current time. We can use the `getLocalTime()` function to retrieve local time.
62
-
63
-
```arduino
64
-
time_variable = ArduinoCloud.getLocalTime();
65
-
```
35
+

66
36
67
37
## Application Examples
68
38
@@ -75,15 +45,12 @@ There are countless examples where schedulers can be used, but predominantly it
75
45
To test out functionality of your scheduler job, we can turn on an LED while the job is active.
76
46
77
47
```arduino
78
-
// whenever the job is "active", turn on the LED
79
-
if(schedule_variable.isActive()){
80
-
digitalWrite(LED, HIGH);
81
-
}
82
-
83
-
84
-
// whenever the job is "not active", turn off the LED
85
-
else{
86
-
digitalWrite(LED, LOW);
48
+
if (schedule_variable.isActive()) {
49
+
// whenever the job is "active", turn on the LED
50
+
digitalWrite(LED, HIGH);
51
+
} else {
52
+
// whenever the job is "not active", turn off the LED
53
+
digitalWrite(LED, LOW);
87
54
}
88
55
```
89
56
@@ -96,23 +63,22 @@ You can set up **multiple scheduler variables.** This way, you can have a differ
Turning on and off light sources can be a great power saver for the office, home or vacation home. This can be achieved with a few lines of code and a [relay shield](https://store.arduino.cc/products/arduino-mkr-relay-proto-shield).
123
89
124
90
```arduino
125
-
//can be configured to be ON between 8am - 5pm
126
-
if(schedule_variable.isActive()){
127
-
digitalWrite(relay, HIGH);
128
-
}
129
-
130
-
//can be set to OFF between 5pm - 8am the next morning
131
-
else{
132
-
digitalWrite(relay, LOW);
91
+
if (schedule_variable.isActive()) {
92
+
// can be configured to be ON between 8am - 5pm
93
+
digitalWrite(relay, HIGH);
94
+
} else {
95
+
//can be set to OFF between 5pm - 8am the next morning
96
+
digitalWrite(relay, LOW);
133
97
}
134
98
```
135
99
@@ -140,25 +104,21 @@ digitalWrite(relay, LOW);
140
104
For a "smart watering" setup, if you connect a pump through a relay, you can schedule a job to be on for a period of time (pumping water) and then turn off. This could for example occur for a few seconds every day to keep your plants alive.
141
105
142
106
```arduino
143
-
//configure to be "on" for 10 seconds every day
144
-
if(schedule_variable.isActive()){
145
-
digitalWrite(pump, HIGH);
146
-
}
147
-
148
-
else{
149
-
digitalWrite(pump, LOW);
107
+
// configure to be "on" for 10 seconds every day
108
+
if (schedule_variable.isActive()) {
109
+
digitalWrite(pump, HIGH);
110
+
} else {
111
+
digitalWrite(pump, LOW);
150
112
}
151
113
```
152
114
153
115
Or, if you use a driver, such as **L298N**, you can control the pump through:
154
116
155
117
```arduino
156
-
if(schedule_variable.isActive()){
157
-
analogWrite(pump, 127); //range between 0-255
158
-
}
159
-
160
-
else{
161
-
analogWrite(pump, 0);
118
+
if (schedule_variable.isActive()) {
119
+
analogWrite(pump, 127); // range between 0-255
120
+
} else {
121
+
analogWrite(pump, 0);
162
122
}
163
123
```
164
124
@@ -171,6 +131,24 @@ In this section you will find a step by step tutorial that will guide you to cre
171
131
- Create a basic sketch & upload it to the board.
172
132
- Create a dashboard.
173
133
134
+
### API
135
+
136
+
The two **variables types** introduced in this tutorial are `CloudTime` and `CloudSchedule`. These are used to retrieve local time and to schedule a job respectively.
137
+
138
+
The `CloudSchedule` variable is of a **complex type**. It has a **internal boolean state**, which can be checked through the `isActive()` function (returns `true` or `false`).
139
+
140
+
```arduino
141
+
if(schedule_variable.isActive()) {
142
+
//do something
143
+
}
144
+
```
145
+
146
+
The `CloudTime` variable is an unsigned integer which is used to store current time. We can use the `getLocalTime()` function to retrieve local time.
147
+
148
+
```arduino
149
+
time_variable = ArduinoCloud.getLocalTime();
150
+
```
151
+
174
152
### Create a Thing
175
153
176
154
***If you are new to the Arduino IoT Cloud, you can either visit the [Getting Started with Arduino IoT Cloud](https://docs.arduino.cc/cloud/iot-cloud/tutorials/iot-cloud-getting-started) guide, or any of the tutorials in the [Arduino IoT Cloud documentation](https://docs.arduino.cc/cloud/iot-cloud). There you will find detailed step by step guides.***
0 commit comments