Can anyone help me to do this?
I suspect that answer is "NO"
I don't see a way to help a person who doesn't know the basics write such a library. To do this, someone need to read you a course of lectures from the very beginning.
This is probably what your teacher did, since he sets such assignments.
Help with what exactly ?
Have you got the code that does not use external libraries working, for instance ?
you are already getting help.
When you don't understand something - ASK a specific question.
Furthermore (I hope) no one will write you code, because each given code will not be yours.
So the more you just copy paste from other sources - the less it's your code.
Your teacher told you to write your own code. Ask yourself - what have you done in this aspect already?
If I were you, I would research how others have achieved something similar. Try, what others have tried.
If it is not working ask the source (the guy behind the code).
If the source is not responding, try another source (there are tons of examples existing). As last instance - ask here a specific question.
If it is working - take the datasheet and follow what the program is doing and how this fits to the datasheet. If you understand why the given program is working, throw away the googled program - and write your own code with the datasheet.
This will be your code you can present and explain to your teacher.
I interpret the instructors' instructions as "keep it in one project so I don't have to hunt for the library" in other words, "don't use installed libraries." That means, to me, this:
is NOT external, therefore, valid to use in a project... that is to say the following would be "external" and not allowed in the project because it would reside in the "libraries" folder and not "in the project."
#include <LiquidCrystal.h>
Semantics.
If that was acceptable, I'd check that interpretation with the teacher before I'd risk a grade on it.
If in regard to "use of any external Integrated Circuits" you are directed to
If unsure of whether a component is allowed, feel free to ask on the forums.
.... I think if you didn't confirm acceptability of importing external libraries into your project, you could well get a zero for it.
The semantics of "You may not make use of any external ..." seems clear.
1. If you have been asked to write your own codes to acquire data from DHT11 Sensor, then you have to implement the following timing diagram (Fig-1, 2) of the sensor. Is it that what you are looking for?
Figure-1:
Figure-2:
2. Example codes which I tried to implement the above timing diagram
unsigned long long data = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
dht11START();
dht11ACQ(); //acquiring response and 40-bit data
delay(2000);
}
void dht11START()
{
pinMode(A4, OUTPUT);
delay(1); //for stablization
digitalWrite(A4, HIGH); //preparing for START Command
delay(1); //for stablization
//------------
digitalWrite(A4, LOW); //sTART command
delay(18);
digitalWrite(A4, HIGH); //pullin up the signal ine
}
void dht11ACQ()
{
pinMode(A4, INPUT); //listening to respone from sensor
unsigned long duration = pulseIn(A4, HIGH);
Serial.println(duration);
if (duration >= 80 && duration <= 100)
{
Serial.println("DHT11 has responded.");
}
else
{
Serial.println("DHT11 has not responded.");
while (1);
}
for (int i = 0; i < 40; i++)
{
duration = pulseIn(A4, HIGH);
if (duration >= 20 && duration <= 30)
{
bitWrite(data, i, LOW);
}
else
{
bitWrite(data, i, HIGH);
}
}
int hum = (int)data >> 24; //Bit-0 to Bit-15 for humidity
Serial.println(hum, BIN);
}
3. DHT11 Sensor's Data Format
Figure-3:


