-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathadafruit_emc2101_test.ino
58 lines (46 loc) · 1.72 KB
/
adafruit_emc2101_test.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
55
56
57
58
// Basic demo for readings from Adafruit EMC2101
#include <Adafruit_EMC2101.h>
Adafruit_EMC2101 emc2101;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit EMC2101 test!");
// Try to initialize!
if (!emc2101.begin()) {
Serial.println("Failed to find EMC2101 chip");
while (1) { delay(10); }
}
Serial.println("EMC2101 Found!");
// emc2101.setDataRate(EMC2101_RATE_1_16_HZ);
Serial.print("Data rate set to: ");
switch (emc2101.getDataRate()) {
case EMC2101_RATE_1_16_HZ: Serial.println("1/16_HZ"); break;
case EMC2101_RATE_1_8_HZ: Serial.println("1/8_HZ"); break;
case EMC2101_RATE_1_4_HZ: Serial.println("1/4_HZ"); break;
case EMC2101_RATE_1_2_HZ: Serial.println("1/2_HZ"); break;
case EMC2101_RATE_1_HZ: Serial.println("1 HZ"); break;
case EMC2101_RATE_2_HZ: Serial.println("2 HZ"); break;
case EMC2101_RATE_4_HZ: Serial.println("4 HZ"); break;
case EMC2101_RATE_8_HZ: Serial.println("8 HZ"); break;
case EMC2101_RATE_16_HZ: Serial.println("16 HZ"); break;
case EMC2101_RATE_32_HZ: Serial.println("32 HZ"); break;
}
emc2101.enableTachInput(true);
emc2101.setPWMDivisor(0);
emc2101.setDutyCycle(50);
}
void loop() {
Serial.print("External Temperature: ");
Serial.print(emc2101.getExternalTemperature());
Serial.println(" degrees C");
Serial.print("Internal Temperature: ");
Serial.print(emc2101.getInternalTemperature());
Serial.println(" degrees C");
Serial.print("Duty Cycle: ");
Serial.print(emc2101.getDutyCycle());
Serial.print("% / Fan RPM: ");
Serial.print(emc2101.getFanRPM());
Serial.println(" RPM");
Serial.println("");
delay(100);
}