Instructions
IDUINO for maker’s life
78 www.openplatform.cc
3.example
Here is an example to show the real-time temperature and humidity of environment, if you
have another LCD screen to be connected, that would be better fun.
The connection as below:
******Code begin******
int DHpin = 8;
byte dat [5];
byte read_data () {
byte data;
for (int i = 0; i < 8; i ++) {
if (digitalRead (DHpin) == LOW) {
while (digitalRead (DHpin) == LOW); // wait for 50us
delayMicroseconds (30); // determine the duration of the high level
to determine the data is '0 'or '1'
if (digitalRead (DHpin) == HIGH)
data |= (1 << (7-i)); // high front and low in the post
while (digitalRead (DHpin) == HIGH); // data '1 ', wait for the next
one receiver
}
}
return data;