SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD

How to create a .h file for Arduino library



As you might already know that notepad is a very powerful windows built in software. Which you can use for many things. For example writing normal texts files, editing software files and many more. In this post I will focus on how to write a .h file with it.

Step1:
Go to your desktop and right click on an empty space choose New then Text Document.



Step2:
Copy the code below and paste into the file.

//
//    FILE: dht11.h
// VERSION: 0.4.1
// PURPOSE: DHT11 Temperature & Humidity Sensor library for Arduino
// LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
//
// DATASHEET: http://www.micro4you.com/files/sensor/DHT11.pdf
//
//     URL: http://playground.arduino.cc/Main/DHT11Lib
//
// HISTORY:
// George Hadjikyriacou - Original version
// see dht.cpp file
//

#ifndef dht11_h
#define dht11_h

#if defined(ARDUINO) && (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

#define DHT11LIB_VERSION "0.4.1"

#define DHTLIB_OK                0
#define DHTLIB_ERROR_CHECKSUM    -1
#define DHTLIB_ERROR_TIMEOUT    -2

class dht11
{
public:
    int read(int pin);
    int humidity;
    int temperature;
};
#endif
//
// END OF FILE
//
  
 
Step3:
It's time to save the file so go to File > then click on Save As after clicking on save as you need to keep few things in your mind. Name the file, in this case dht11 and make sure you write .h  at the end and file type should be All Files and the last thing choose Encoding as ANSI then click save. That's it you've made your .h file with Notepad.


You can use the same method to create other files like .ino, .cpp and many more.

Note:
Remember which ever file you edit don't delete the file name from the dot for example .php, .html, .dll, and .h or what ever name you see. And another thing is that backup the file before you edit it. Because if you make any mistake in the coding you can always replace with the backup ones.

I hope this will help you in lot of places. Thanks



No comments:

Post a Comment



Newly posted:
Reason why rich getting richer and poor getting poorer