Update baud rate to 115200 and improve LED control in setup and loop functions
This commit is contained in:
+14
-7
@@ -3,15 +3,19 @@
|
|||||||
|
|
||||||
Adafruit_SHT4x sht4 = Adafruit_SHT4x();
|
Adafruit_SHT4x sht4 = Adafruit_SHT4x();
|
||||||
|
|
||||||
void setup() {
|
void setup()
|
||||||
Serial.begin(9600); // zacni seriovou komunikaci s baudrate 9600
|
{
|
||||||
|
Serial.begin(115200); // zacni seriovou komunikaci s baudrate 115200
|
||||||
Serial.println("UART OK");
|
Serial.println("UART OK");
|
||||||
|
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT); // nastav ledku na desce jako vystup
|
||||||
|
|
||||||
Serial.println("Adafruit SHT4x test"); // zadni komunikaci s SHT40 po I2C
|
Serial.println("Adafruit SHT4x test"); // zadni komunikaci s SHT40 po I2C
|
||||||
if (! sht4.begin())
|
if (!sht4.begin())
|
||||||
{
|
{
|
||||||
Serial.println("Couldn't find SHT4x"); // pokud neni sensor nalezen, program skonci v nekonecne smycce
|
Serial.println("Couldn't find SHT4x"); // pokud neni sensor nalezen, program skonci v nekonecne smycce
|
||||||
while (1) delay(1);
|
while (1)
|
||||||
|
delay(1);
|
||||||
}
|
}
|
||||||
Serial.println("Found SHT4x sensor");
|
Serial.println("Found SHT4x sensor");
|
||||||
Serial.print("Serial number 0x");
|
Serial.print("Serial number 0x");
|
||||||
@@ -20,7 +24,8 @@ void setup() {
|
|||||||
sht4.setHeater(SHT4X_NO_HEATER);
|
sht4.setHeater(SHT4X_NO_HEATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop()
|
||||||
|
{
|
||||||
sensors_event_t humidity, temp;
|
sensors_event_t humidity, temp;
|
||||||
|
|
||||||
uint32_t timestamp = millis();
|
uint32_t timestamp = millis();
|
||||||
@@ -32,6 +37,8 @@ void loop() {
|
|||||||
Serial.print(" humidity=");
|
Serial.print(" humidity=");
|
||||||
Serial.println(humidity.relative_humidity);
|
Serial.println(humidity.relative_humidity);
|
||||||
|
|
||||||
delay(1000);
|
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||||
|
delay(250); // wait for a second
|
||||||
|
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
||||||
|
delay(250); // wait for a second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user