Go Down

Topic: 4x3 Keypad from Sparkfun (Read 6486 times) previous topic - next topic

Angelsbane72

Right, as that is the only relevant code for the servo.

Do I use servo.write(some angle) to get it to move to that position, and then servo.detach() to get it to stop?

raschemmel

#31
Mar 15, 2015, 11:21 pm Last Edit: Mar 15, 2015, 11:30 pm by raschemmel
You might try researching the servo library before trying to use it:
Servo Library

You just set pos=0; , pos=90; or pos=180;

Your current code moves the servo to 180 deg but never moves it back.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Angelsbane72

You make it sound as if I haven't these tutorials, but I already have.
But guess what, not all questions get answered by simply doing the basics. IN fact, almost every question I've ever had on this stiff has been because of running examples.

The application I need is so much more complex that to be honest, I don't even believe we'll be able to achieve it using an Arduino.

I've used each of my peripherals individually the past couple weeks. Now, the time comes to integrate it all together, and basic examples don't help anymore.

But thanks for your help anyway, I appreciate the effort.

raschemmel

#33
Mar 15, 2015, 11:45 pm Last Edit: Mar 16, 2015, 12:10 am by raschemmel
My point is that nobody here can debug your code without the menu tree, which you haven't provided.
Debugging it one line at a time will work but it takes so much more time. We have no idea what you're trying to do and without a proper project overview (which you never provided).

Your initial post is about the keypad  , which turned out to be a wash for what reason I don't know.
Your first reply said this:
Quote
Show an image of how you are wired to the Arduino.
Attach "your" sketch for us to see (use code tags).
but you never posted your schematic. What's up with that ? Do you know how to draw a schematic and post a photo of it ? If you do what you are told , you will get to your objective. Ignoring a request for a schematic is a red flag to us that you are not going to cooperate so why should we waste our time.

You haven't posted a project overview , a schematic or a menu tree so you're just spinning your wheels.
We have talked people through much more complex projects because they they cooperated with us. There is no point in posting on the forum if you don't cooperate with the experts who are taking THEIR time to help you. If you are requested to do something, either do it or present a reason why not.

I see nothing in your code to navigate back up the tree once you have selected a Family part so the
servo never returns to 0. If you had button names defined in addition to  "states" it would be easier to follow.
UP
DOWN
LEFT
RIGHT
SELECT


Try running the attached  code (after changing the LCD Constructor to match your pins) and see what I mean.
It displays the button pressed. If it can do that , it can tell you where you are in the tree as well (ie: Level-1,Level-2 etc.

There doesn't seem to be any error messages displayed if you press the wrong button and without any
menu tree location feedback it is impossible to tell where you are or why you can't get back (like from
CFM 1. Once you get there you're stuck and not going anywhere.)
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

#34
Mar 16, 2015, 12:12 am Last Edit: Mar 16, 2015, 12:18 am by raschemmel
Most commercial menus have display feedback that displays all your options  after each key press with
"BACK" being the last option. Also, you don't have any debug serial prints in your code to display all the states and conditions:
ie:
Code: [Select]
Serial.print("lastState = ");
Serial.println(lastState);
delay(1000);
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Angelsbane72

Here is the goal of my application, and all it encompasses.
-Use Arduino MEGA to control oil flow through a pipe system using solenoid valves and regulators.
--This means their timings, openings, etc
-The operator is responsible for picking a part number through UI Menus (LCD) and then hitting a start button to begin a test.
-Upon hitting the start button, the servo spins to a position that prevents the chamber door from opening if pulled.

The keypad was going to be used for navigation across the UI, but I am ordering a new, better version of one, so in the meantime, navigation is being run by the LCD shield buttons.

I know how to draw a schematic, but to be honest my hardware portion looks good so far only because it it using a single LCD button shield, a concave push button, and paralax basic servo.

I can draw a schematic if need be, but its nothing you guys haven't seen before, at this point. But I can make one in fritzing if need be.

I can't solder now since we are in a demo build, and so nothing is permanent yet, hence no reason to solder. I do know how, and when ready, can definitely do that on my own.

I've never heard menu tree mentioned before, so I am unsure what you mean by that, but my application will require two menus.
- Part Family-
-Parts in Selected Family-

The operator will place a part in our containment chamber, manually close door, select part using UI, and then press START (concave push) button to turn servo to a set position.

Angelsbane72

I see nothing in your code to navigate back up the tree once you have selected a Family part so the
servo never returns to 0. If you had button names defined in addition to  "states" it would be easier to follow.
UP
DOWN
LEFT
RIGHT
SELECT


Try running the attached code (after changing the LCD Constructor to match your pins) and see what I mean.
It displays the button pressed. If it can do that , it can tell you where you are in the tree as well (ie: Level-1,Level-2 etc.

There doesn't seem to be any error messages displayed if you press the wrong button and without any
menu tree location feedback it is impossible to tell where you are or why you can't get back (like from
CFM 1. Once you get there you're stuck and not going anywhere.)
So I ran this code earlier today and got the same results, simply showing the button pushed. My question is now, how does this relate to making submenus?

raschemmel

#37
Mar 16, 2015, 12:21 am Last Edit: Mar 16, 2015, 01:03 am by raschemmel
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

#38
Mar 16, 2015, 12:26 am Last Edit: Mar 16, 2015, 02:04 am by raschemmel
When designing electronic equipment that encorporates a combination of buttons and display, it is customary, during the Design Review , to create a menu tree that is ultimately printed out and included in the User Guide that is shipped with the product. By looking at the menu tree and looking at the display,it is possible to know at all times where exactly you are because a code number or acronym is displayed identifying the exact location in the tree. There are only 5 choices UP,DOWN, LEFT, RIGHT & SELECT. When the user looks at the printed menu tree , he knows which way he needs to go to get to his destination in the tree and he can always arrow down to the BACK button to get back up the tree.

It appears there are some code blocks missing from your code. Is this the complete version or a partial preliminary version ? (there is a prompt to enter a part number but no code to enter it)
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Angelsbane72

When designing electronic equipment that encorporates a combination of buttons and display, it is customary, during the Design Review , to create a menu tree that is ultimately printed out and included in the User Guide that is shipped with the product. By looking at the menu tree and looking at the display,it is possible to know at all times where exactly you are because a code number or acronym is displayed identifying the exact location in the tree. There are only 5 choices UP,DOWN, LEFT, RIGHT & SELECT. When the user looks at the printed menu tree , he knows which way he needs to go to get to his destination in the tree and he can always arrow down to the BACK button to get back up the tree.

It appears there are some code blocks missing from your code. Is this the complete version or a partial preliminary version ? (there is a prompt to enter a part number but no code to enter it)
No, this is no where near complete, just my initial attempt. I don't have any previous experience in programming or hardware.
Ideally, the menu tree would be as follows:

Main Menu:
(top row of 16x2 LCD displaying "Select Part Family")
1. CFM Family
  1.1 CFM Part 2
  1.2 CFM Part 2
  1.3 CFM Part 3
  1.4 CFM Part 4
2. Family X
  2.1 Part X 1
  2.2 Part X 2
  2.3 Part X 3
  2.4 Part X 4
3. Family Y
  3.1 Part Y 1
  3.2 Part Y 2
  3.3 Part Y 3
  3.4 Part Y 4
4. Family Z
  4.1 Part Z 1
  4.2 Part Z 2
  4.3 Part Z 3
  4.4 Part Z 4

Once a part family has been selected, the top row should display "Select Part in Family", and then the user navigates through the parts menu under the selected family.

Is that tree similar to what you mean? It won't be an over complicated system of menus, but just 1 main menu with a submenu.

raschemmel

#40
Mar 16, 2015, 05:05 pm Last Edit: Mar 16, 2015, 08:03 pm by raschemmel
Quote
1.1 CFM Part 2
  1.2 CFM Part 2
  1.3 CFM Part 3
  1.4 CFM Part 4
==>
1.1 CFM Part 2 Part 1
1.2 CFM Part 2
1.3 CFM Part 3
1.4 CFM Part 4


Quote
Is that tree similar to what you mean?  
Yes, only it seems your code is unfinished and there is nothing beyond that point yet.
Is that correct ?

It appears there are some code blocks missing from your code. Is this the complete version or a partial preliminary version ? (there is a prompt to enter a part number but no code to enter it)

Also , I have problems getting back up the menu and the servo doesn't reset to 0 if you
go back to starting point.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Angelsbane72

Yes, only it seems your code is unfinished and there is nothing beyond that point yet.
Is that correct ?

It appears there are some code blocks missing from your code. Is this the complete version or a partial preliminary version ? (there is a prompt to enter a part number but no code to enter it)

Also , I have problems getting back up the menu and the servo doesn't reset to 0 if you
go back to starting point.
Yes, my code is nowhere near complete as I am quite limited in my knowledge on the subject and am having issues as to how to implement a submenu into my current main menu. (EX: getting from 1.CFM to looking through items 1.1-1.4)
I don't know how to code the part number selection.


I am unsure as to how to code the go back one menu, but ideally I'd like to enable this feature by hitting the left button.

raschemmel

#42
Mar 17, 2015, 10:12 pm Last Edit: Mar 17, 2015, 11:47 pm by raschemmel
Like I said, S/W isn't my specialty but if I had to do it, I would use an array that indexes as you go down and reverse indexes as you go up. You can even have an array of arrays but let's not go there yet. If you have one array for each level, it's simple. You start at index-0 for that level and increment the index as you decend into that level and decrement the index as you go back. Initially you are not in a level, when you select a part family you start the index array for that family. The main trunk of the menu tree is indexed based on up/dwn. You can have a level array if you don't want to use a 2-D array. You can name the indexes with labels that help you tell where you are in the tree. You have to start by creating variables for buttons like I suggested and then UP/DWN increment/decrements the main trunk array and LEFT/RIGHT increments/decrements the branch arrays. You can post on the Programming Topic AFTER you have created a COMPLETE menu tree. Until then, don't bother because they'll just tell you to come back when you are ready.

Check out this.

Google "arduino lcd menu"
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

123Splat

What does all that have to do with oil flowing through a pipeline???  my brain hurts......

raschemmel

Quote
No, this is no where near complete, just my initial attempt. I don't have any previous experience in programming or hardware.
You need to design the algorithm before you can write the code. Stop thinking about programming because you are not ready yet. A program is a series of commands that follow an algorithm. You don't have one yet so you literally have the cart before the horse. If you come here for advice, either follow it or go somewhere else. Write an algorithm that describes the decision making process.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up