Bram documentation updated and code explained

This commit is contained in:
Bram Barbieri
2024-03-12 11:28:30 +01:00
parent 57ee918b64
commit 8aeca410fc

View File

@@ -111,9 +111,12 @@ the code used looks like this:
DHT dht(DHTPIN, DHTTYPE); DHT dht(DHTPIN, DHTTYPE);
void setup() { void setup() {
//the //the serial port:
Serial.begin(9600); Serial.begin(9600);
//the initial test if the code works
Serial.println(F("DHTxx test!")); Serial.println(F("DHTxx test!"));
//the library start
dht.begin(); dht.begin();
} }
@@ -121,9 +124,12 @@ dht.begin();
void loop() { void loop() {
delay(2000); delay(2000);
//a float has decimal numbers and the library reads the measurements.
float h = dht.readHumidity(); float h = dht.readHumidity();
float t = dht.readTemperature(); float t = dht.readTemperature();
float f = dht.readTemperature(true); float f = dht.readTemperature(true);
//isnan = there is no reading , the || is "or"
if (isnan(h) || isnan(t) || isnan(f)) { if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!")); Serial.println(F("Failed to read from DHT sensor!"));
@@ -163,12 +169,14 @@ I designed it to work with scanning if there is any input and then output this s
This output signal can activate over multiple pins so this one button can set off all sorts of stuff. This output signal can activate over multiple pins so this one button can set off all sorts of stuff.
The code is short and simple: The code is short and simple:
``` ```
//set up some variables
int button = 20; int button = 20;
int buzzerone = 12; int buzzerone = 12;
int buzzertwo = 11; int buzzertwo = 11;
void setup() { void setup() {
//put down some pins that will output , and some that input.
pinMode(button, INPUT); pinMode(button, INPUT);
pinMode(buzzerone, OUTPUT); pinMode(buzzerone, OUTPUT);
pinMode(buzzertwo, OUTPUT); pinMode(buzzertwo, OUTPUT);
@@ -177,6 +185,7 @@ pinMode(buzzertwo, OUTPUT);
void loop() { void loop() {
//read is there is input on the button pin, if so send output to the other pins., otherwise keep them off.
if(digitalRead(button) == HIGH){ if(digitalRead(button) == HIGH){
digitalWrite(buzzerone, HIGH); digitalWrite(buzzerone, HIGH);
digitalWrite(buzzertwo, HIGH); digitalWrite(buzzertwo, HIGH);