Why are the files not being created correctly? I have been through http://arduino.cc/en/Hacking/LibraryTutorial but I can't do it. Whenever I create a new sketch and try to save it as .cpp or .h from the Save As button in the Arduino IDE, it gets saved as _cpp and _h. I am not able to create a library this way. How do I create a new library? What am I missing here?
When you save a file using the Save As button from the Arduino IDE, it saves the current file as a sketch i.e. as an .ino file.

To create a .cpp and .h files for working on a new library, you need to create the files alongside a sketch. For this, you can use the Tab button on the top right (circled in red).


  


Click on it, and select New Tab. You will get a bar at the bottom of the screen asking for a file name. Enter the name with extension (test.cpp) and press Enter.


  


Your file has now been added to the current directory.


  


Similarly, follow the same steps for creating the .h file.

Once your library is complete and ready to ship, you can move the .cpp and .h files to a separate directory and then add it under libraries.