Posts

Showing posts with the label Example Code

How to Drive DHT sensor without Library

Image
 Let's code! Expalantions are in the code area. Happy Coding! /* * DHT 11 driving without library * * http://en.devrelerim.com * Author : Hakan OZMEN (hakkanr@gmail.com) * Date : 30.03.2021 * * You can change or share all / or same part of * this code. Free of charge! :) */ uint8_t data [ 5 ] ; // to save our 8bit * 5 data void setup ( ) { Serial . begin ( 115200 ) ; } /* *  This function count an 8bit integer value *  while given signal is not changed *  no need to measure time counting is also *  need time ;) */ uint8_t expectedSignal ( bool level ) {   uint8_t count = 0 ;   while ( digitalRead ( 2 ) == level ) count ++ ;   return count ; } void loop ( ) { delay ( 2000 ) ; // wait 2 secs for sensor to initialize Serial . println ( "----------------------" ) ; pinMode ( 2 , INPUT_PULLUP ) ; // Standard is HIGH delay ( 1000 ) ; pinMode ( 2 , OUTPUT ) ; // make pin 2 output digitalWrite ( 2 , LO