commit 1ec552b85b37bdd9781192237765fc9eae2256fa Author: Marc Planard Date: Thu Jan 5 22:05:51 2023 +0100 initial commit diff --git a/esp32_blink.ino b/esp32_blink.ino new file mode 100644 index 0000000..f2ee64d --- /dev/null +++ b/esp32_blink.ino @@ -0,0 +1,39 @@ +#define LED 13 + +#include "OneWire.h" +#include "DallasTemperature.h" + +OneWire oneWire(A3); +DallasTemperature ds(&oneWire); + +void setup() { + // put your setup code here, to run once: + Serial.begin(115200); + pinMode(LED, OUTPUT); + ds.begin(); +} + +void loop() { + // put your main code here, to run repeatedly: + digitalWrite(LED, HIGH); + for(int i=0; i < 100; ++i) { + delay(50); + print_light(); + } + digitalWrite(LED, LOW); + for(int i=0; i < 100; ++i) { + delay(50); + print_light(); + } +} + +void print_light() { + int val = analogRead(A0); + Serial.print("Light: "); + Serial.print(val); + + ds.requestTemperatures(); + int t = ds.getTempCByIndex(0); + Serial.print("; Temp: "); + Serial.println(t); +}