/
RemotePWM.ino
41 lines (34 loc) · 1.13 KB
/
RemotePWM.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Created by Park, Nil on 2017-06-12.
* Last Revision: 2017-06-12
*
* This example reports a button or switch status to Vitcon IOT Server
*
* Attach WIFI-LINK to D0 and D1, Config WIFI-LINK access to Vitcon IOT Broker Server.
* LED-LINK should be attached to D5 (PWM pin)
*
* You should install VitconCommon library prior to VitconIOT library.
* The minimum interval calling BrokerComm.Run() function should be less than 2ms
*/
#include <VitconBrokerComm.h>
using namespace vitcon;
int pwm_value = 0;
/* A set of definition for IOT items */
#define ITEM_COUNT 2
void pwm_out(int32_t val) { pwm_value = (int)val; analogWrite(5, val); }
IOTItemInt pwm_status;
IOTItemInt pwm(pwm_out);
IOTItem *items[ITEM_COUNT] = { &pwm_status, &pwm };
/* A set of definition for IOT items */
/* IOT server communication manager */
const char device_id[] = ""; // Change device_id to yours
BrokerComm comm(&Serial, device_id, items, ITEM_COUNT);
/* IOT server communication manager */
void setup() {
Serial.begin(250000);
comm.SetInterval(200);
}
void loop() {
pwm_status.Set(pwm_value);
comm.Run();
}