Sensor Data Input

I want to create a reservior filling system using ultrasonic sensor. I have created the project and its working fine by pre feeding the upper limit height and lower limit height of the reservior, but I want a system in which I just input the height of the reservior by matrix keyboard, and the system will automatically turn on the pump when the water in the reservior will be empty and turn off when the reservior became full.

Kindly help me with the code.

kishalay:
Kindly help me with the code.

Please post the program that you need help with. Tell us in detail what the program actually does and what you want it to do that is different.

...R

If you've already identified a keypad you want then give us a link to a datasheet.

const int trigPin = 7;

const int echoPin = 8;

void setup() {

Serial.begin(9600);
pinMode(4, OUTPUT);
}
void loop()

{

long duration, inches, cm;

pinMode(trigPin, OUTPUT);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

pinMode(echoPin, INPUT);

duration = pulseIn(echoPin, HIGH);

inches = microsecondsToInches(duration);

cm = microsecondsToCentimeters(duration);

Serial.print(cm);

Serial.print("cm");

Serial.println();

delay(1000);

if (cm > 52)
{
digitalWrite (4,HIGH);
}

else if (cm < 46)

{
digitalWrite(4,LOW);
}

}

long microsecondsToInches(long microseconds)

{return microseconds / 74 / 2;

}

long microsecondsToCentimeters(long microseconds)

{return microseconds / 29 / 2;}

This is the code i am using in which i have to feed the centimeter limits in the if statement from the code itself .

but i want to put the centimeter limit by using a matrix keyboard.

Kindly help me with the modified code

kishalay:
This is the code i am using in which i have to feed the centimeter limits in the if statement from the code itself .

but i want to put the centimeter limit by using a matrix keyboard.

Kindly help me with the modified code

Have you got a keyboard? If so post a link to its datasheet?

Have you tried any of the example programs for the keyboard? Did they work?

...R

To make it easy for people to help you please use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

I don't have any data sheet it's a simple 8 wire matrix keyboard

Just help me with the modifications in which I can input the centimetre limits using keyboard

kishalay:
Just help me with the modifications in which I can input the centimetre limits using keyboard

I am happy to help. But I am not going to do it for you.

There must be dozens of Threads on the Forum that use keypads - have you done any searching?

...R

I searched about timers, clocks,etc but didn't understand how to feed the data.

Tell me the kind of code i want will it be any short of similar to arduino calculator cz i just wanna know the procedure to store the user input data to a variable so that I can use it in my code in place if centimetre limit