-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.ino
54 lines (45 loc) · 1.11 KB
/
Example.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
42
43
44
45
46
47
48
49
50
51
52
53
54
// This #include statement was automatically added by the Particle IDE.
#include "MCP4725.h"
MCP4725 dac;
int setOutVoltage(String data);
int setOutVoltageRetain(String data);
int setOutputVoltageRaw(String data);
int setInVoltage(String data);
void setup() {
if(dac.begin()){
Serial.println("Init Success");
}else{
Serial.println("Device not ready");
}
Particle.function("SetOutput", setOutVoltage);
Particle.function("SetOutputR", setOutVoltageRetain);
Particle.function("SetInput", setInVoltage);
Particle.function("SetOutputRa", setOutputVoltageRaw);
}
void loop() {
}
int setOutVoltage(String data){
if(dac.setOutputVoltage(data.toFloat(), false)){
return 1;
}else{
return 0;
}
}
int setOutVoltageRetain(String data){
if(dac.setOutputVoltage(data.toFloat(), true)){
return 1;
}else{
return 0;
}
}
int setOutputVoltageRaw(String data){
if(dac.setOutputRaw(data.toFloat(), false)){
return 1;
}else{
return 0;
}
}
int setInVoltage(String data){
dac.setInputVoltage(data.toFloat());
return 1;
}