Go Down

Topic: Adding keypad to enter a number to change int value (Read 273 times) previous topic - next topic

laughingcamera

Jul 17, 2018, 04:20 pm Last Edit: Sep 25, 2018, 01:14 am by laughingcamera
I need to add to this sketch a keypad so I can enter a number to change the value of  the int numShootMoveLR=4; and the int numShootMoveUp=1; before pressing the start button to run the sketch.

Can someone modify my sketch for me for a very reasonable price? I am a newbie and have been struggling with this part. Thanks.

PaulS

Code: [Select]
for (int j=1;j<=numShootMoveLR; j=j+1){
   
      lcd.clear(); //clears the lcd
      lcd.print("TAKING PHOTO"); //alerts camera is shooting
      digitalWrite(cameraFirePin, HIGH); //fires camera shutter through relay board
      delay(3000);
      digitalWrite(cameraFirePin, LOW); //de-powers relay board
      delay(3000);
      lcd.clear(); //clears the lcd
      lcd.print("MOVING TO NEXT"); //alerts camera is moving
      myStepperMOVINGLeft.step(25000);    // MOVINGs table to left
      lcd.clear(); //clears the lcd
}

Why do you need to clear the LCD at the start AND end of the loop?

Which pins have you connected the keypad too?

Reading the keypad, and storing the keys, and converting the stored data to an int, when the appropriate event happens (undefined), is trivial.

What event should indicate that the move LR value is complete? What event should indicate that the move Up value is complete? What event should indicate that you made a mistake entering the previous digit? What event should indicate that the whole collection of digits is rubbish and should be discarded?
The art of getting good answers lies in asking good questions.

laughingcamera

>>Why do you need to clear the LCD at the start AND end of the loop?

My newbie is showing

>>Which pins have you connected the keypad too?

I have not connected yet. I realize I will need more pins so have on order a Audrino MEGA

>>Reading the keypad, and storing the keys, and converting the stored data to an int, when the appropriate event happens (undefined), is trivial.

I don't understand what you mean

>>What event should indicate that the move LR value is complete?
When it fires the camera.

>>What event should indicate that the move Up value is complete?When it fires the camera

>>What event should indicate that you made a mistake entering the previous digit? What event should indicate that the whole collection of digits is rubbish and should be discarded?

I don't understand what you mean

PaulS

Quote
I don't understand what you mean
You need to say more than that.

Notice that last sentence. Spaces indicate the end of words. Periods indicate the end of sentences.

Suppose that you want to enter 14 as the value for numShootMoveLR and 20 as the value for numShootMoveUp. Let me ask again. What event will occur in the sequence of pressing the '1' key, pressing the '4' key, pressing the '2' key, and pressing the '0' key that indicates that the characters '1' and '4' are to be used to create the value 14, and to store the value of 14 in the variable numShootMoveLR?

Typically, there would be some enter key, some backspace key, and some "oops, start over" key.

You might not need a "oops, start over" key, since you just backspace more than once.If you are entering much larger values, and notice that you entered the first character wrong 27 digits into the number, backspacing 27 times is annoying. But, if you are planning a maximum of 3 digit numbers, backspacing 3 times is not so bad.

The "use the entered digits" event then might be pressing the '#' key. The backspace event might be the '.' key.

Quote
>>What event should indicate that the move LR value is complete?
When it fires the camera.
When what fires the camera? Pressing the switch to start moving the camera/taking pictures as the event to indicate that the collection of keys is now to be used for making the value for numShootMoveLR is a bad idea, since you then have no opportunity to enter characters for the numShootMoveUp value.

Quote
>>What event should indicate that the move Up value is complete?When it fires the camera
The same event can not indicate that the collection of key values is to be used for two different purposes.
The art of getting good answers lies in asking good questions.

laughingcamera

I see what you mean. So if the "#" key is made the "enter" key and the "." key is made the backspace key. That would work for me.

So I guess the sequence would be...

it asks - ENTER THE VALUE FOR MOVE LR, I would press the 1 and then the 4 key (example) and then press the # key. Correct?

Then it would wait for the next input and ask - ENTER THE VALUE FOR THE MOVE UP, and i would enter 5 (example) and then press the # key.

Then I could hit the START button.

I hope that makes sense...

PaulS

Quote
I hope that makes sense...
It's what I was thinking, so, yes, it does.

The next question, then, is what should happen if the start switch is pressed before the '#' key is pressed the second time. Should it be ignored? Or should the partially entered data be discarded, and the default values used?
The art of getting good answers lies in asking good questions.

laughingcamera

I would like it to require the two numbers be added before the start switch can be pushed.

PaulS

I would like it to require the two numbers be added before the start switch can be pushed.
You can't do that. What you can do is count the number of '#' key presses/values entered, and, if that number is less then 2, ignore the start switch.
The art of getting good answers lies in asking good questions.


Go Up