瀏覽代碼

add arduino code

master
DemiSel 3 年之前
父節點
當前提交
b15d6a8a6b
共有 1 個文件被更改,包括 52 次插入0 次删除
  1. 52
    0
      arduino/cybergaziniere.ino

+ 52
- 0
arduino/cybergaziniere.ino 查看文件

@@ -0,0 +1,52 @@
1
+#include "WiFi.h"
2
+#include <OneWire.h>
3
+#include <DS18B20.h>
4
+#include <TM1637Display.h>
5
+
6
+//const char* ssid = "Antenne 5G";           
7
+//const char* password = "Un Truc Moins Chiant"; 
8
+const char* ssid = "Livebox-8DA0";           
9
+const char* password = "C3F3EE221002051A31382FFAF7"; 
10
+
11
+#define CLK 18
12
+#define DIO 5
13
+#define ONE_WIRE_BUS 4
14
+
15
+OneWire oneWire(ONE_WIRE_BUS);
16
+DS18B20 sensor(&oneWire);
17
+TM1637Display display(CLK, DIO);
18
+
19
+
20
+void setup() {
21
+   WiFi.begin(ssid, password);
22
+   
23
+  // put your setup code here, to run once:
24
+  Serial.begin(9600);
25
+  sensor.begin();
26
+  display.setBrightness(0);
27
+
28
+ Serial.print("Connecting");
29
+  while (WiFi.status() != WL_CONNECTED) {
30
+    delay(500);
31
+    Serial.print(".");
32
+  }
33
+  Serial.println();
34
+
35
+  Serial.print("Connected, IP address: ");
36
+  Serial.println(WiFi.localIP());
37
+}
38
+
39
+void loop() {
40
+  int temp = temperatureTrucs();
41
+  //Serial.println(temp);
42
+  display.showNumberDecEx(temp, 0x20);
43
+  
44
+  //;
45
+}
46
+
47
+int temperatureTrucs()
48
+{
49
+  sensor.requestTemperatures();
50
+  while (!sensor.isConversionComplete());  // wait until sensor is ready
51
+    return (int) (sensor.getTempC() * 10);
52
+}

Loading…
取消
儲存