initial commit
This commit is contained in:
commit
1ec552b85b
39
esp32_blink.ino
Normal file
39
esp32_blink.ino
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user