Bram documentation updated and code explained
This commit is contained in:
@@ -111,9 +111,12 @@ the code used looks like this:
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup() {
|
||||
//the
|
||||
//the serial port:
|
||||
Serial.begin(9600);
|
||||
|
||||
//the initial test if the code works
|
||||
Serial.println(F("DHTxx test!"));
|
||||
//the library start
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
@@ -121,9 +124,12 @@ dht.begin();
|
||||
|
||||
void loop() {
|
||||
delay(2000);
|
||||
//a float has decimal numbers and the library reads the measurements.
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
float f = dht.readTemperature(true);
|
||||
|
||||
//isnan = there is no reading , the || is "or"
|
||||
if (isnan(h) || isnan(t) || isnan(f)) {
|
||||
|
||||
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.
|
||||
The code is short and simple:
|
||||
|
||||
```
|
||||
```
|
||||
//set up some variables
|
||||
int button = 20;
|
||||
int buzzerone = 12;
|
||||
int buzzertwo = 11;
|
||||
|
||||
void setup() {
|
||||
//put down some pins that will output , and some that input.
|
||||
pinMode(button, INPUT);
|
||||
pinMode(buzzerone, OUTPUT);
|
||||
pinMode(buzzertwo, OUTPUT);
|
||||
@@ -177,6 +185,7 @@ pinMode(buzzertwo, OUTPUT);
|
||||
|
||||
|
||||
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){
|
||||
digitalWrite(buzzerone, HIGH);
|
||||
digitalWrite(buzzertwo, HIGH);
|
||||
|
Reference in New Issue
Block a user