Pages: [1]   Go Down
Author Topic: Beginner needing help with building a menu for standalone system  (Read 1360 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm a newb...I openly admit that.  I'm hoping you guys will be kind enough to offer me some guidance on building a menu system for a camera slider.

Hardware:
Arduino Uno V3
ArduMoto V2 shield (http://www.jayconsystems.com/product_detail.php?prod_id=114)
Adafruit RGB LCD Shield kit (http://www.adafruit.com/products/714)
Two - 12VDC Precision Gear Motors

Highlights I want to build into the menu:  (I'll have a standard power switch to power on the unit.)
1.  When power is switched on, LCD displays my company name for 3 seconds.
2.  Prompt to choose drive mode ("Move-Shoot-Move" or "Continuous")
   submenu.  Move-Shoot-Move
      #1 sub-submenu.  Select speed of motors
                                sub-sub-submenu. 0% to 100%
      #2 sub-submenu.  Length of time to power motors for each "Move" sequence
                                sub-sub-submenu. time in milliseconds
   submenu.  Continuous
      #1 sub-submenu.  Speed of motors (0% to 100%)
3.  Direction (Left or Right)
4.  Start/Stop toggle
5.  Once the slider is moving, I want to be able to use left and right buttons for direction and up and down buttons for speed

I have no idea how to begin with this.  I understand that I need to combine all the sketches into one sketch, but I truly do not know how to begin.  Can someone help me get started?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have no idea how to begin with this.  I understand that I need to combine all the sketches into one sketch, but I truly do not know how to begin.  Can someone help me get started?
Start with example sketches for all of the hardware. Get it all working individually and make sure you understand what it's doing and how it's doing it. Then start small, saying getting #1 to work. You can then build up from that little by little.
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That works for me and is a Major teaching tool as well. The books are great But I need more. Getting a sketch to return good information from a GPS receiver and getting a sketch to work on a Color Graphic Display is better But when you can put them together and display the GPS on the display is in my mind progress and a whole lot more fun too. Hardware is real easy for me, I have been doing it on many different types of platforms and devices for nearly 50 years... Retired now and having the time of my life learning what I want to learn, when I want to learn it. I get a retirement check from the Government every month and about 20% goes to "Goodies" for my three Arduino's. My birthday is today and I got a 3.2" 4D Systems SGC display and two of those clear breadboards as well as that Uno extender cable and shield/breadboard header thing that Liudr sells with a couple of extra breadboard headers. I guess I really made out well, best in a lot of years
 Liudr also sells a PHI panel that has a 2X16 or 4X20 LCD and keypad and comes with a customize - able menu sketch. The sketch is free licence and the panel complete is under $30.00 US. I found him by poking around for Arduino stuff one day on Ebay, Dipmicro was selling his stuff...

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Start with example sketches for all of the hardware. Get it all working individually and make sure you understand what it's doing and how it's doing it. Then start small, saying getting #1 to work. You can then build up from that little by little.
That's just it.  The examples seem so irrelevant to what I want to do, starting that way is just as confusing.  I've watched some of Jeremy Blum's tutorials on youtube, but again, they are not applicable to what I'm aiming for.

Do I start with the LCD?  Do I start with Arduomoto?  Does it even matter?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The examples seem so irrelevant to what I want to do, starting that way is just as confusing.

I fail to see how learning to control the motor, learning to write stuff to an LCD,and learning to accept inputs from buttons is irrelevant to what you are trying to do.

Quote
I understand that I need to combine all the sketches into one sketch
Statements like this really concern me, as it usually means you have a bunch of examples working and just want to throw it all into one sketch tweaking a few things along the way. This is a terrible way to start a project and will always lead to more headaches than necessary.

You've already broke it down nicely into a handful of steps, so start by getting your company logo to display for 3 seconds and go from there. You can probable get the menu's working first without touching the motors.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Statements like this really concern me, as it usually means you have a bunch of examples working and just want to throw it all into one sketch tweaking a few things along the way. This is a terrible way to start a project and will always lead to more headaches than necessary.

You've already broke it down nicely into a handful of steps, so start by getting your company logo to display for 3 seconds and go from there. You can probable get the menu's working first without touching the motors.

No, that is not what I'm doing.  I DID open the the Adafruit Library and have modified it to set the LCD color, display my company name for 3 seconds and then display "Main Menu".  From there, I don't know how to proceed to make it actually call a function.  Sure, I can make it display something else on the screen if I press any of the buttons, but that's just making it say something on the screen.  It isn't calling to a function.  This is what I need help with.

Is this where I need to incorporate an array?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Statements like this really concern me, as it usually means you have a bunch of examples working and just want to throw it all into one sketch tweaking a few things along the way. This is a terrible way to start a project and will always lead to more headaches than necessary.

You've already broke it down nicely into a handful of steps, so start by getting your company logo to display for 3 seconds and go from there. You can probable get the menu's working first without touching the motors.

No, that is not what I'm doing.  I DID open the the Adafruit Library and have modified it to set the LCD color, display my company name for 3 seconds and then display "Main Menu".  From there, I don't know how to proceed to make it actually call a function.  Sure, I can make it display something else on the screen if I press any of the buttons, but that's just making it say something on the screen.  It isn't calling to a function.  This is what I need help with.

Is this where I need to incorporate an array?

So it's responding to button presses? Calling a function is trivial:

Code:
void loop() {
  ...
  if (someButtonIsPressed) {
    // Do stuff
    runSomeFunction();
  }
}

void runSomeFunction() {
  // Do stuff
}
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this basic code should get you started.

works with Ardduino UNO,

LCD shield
http://www.dfrobot.com/index.php?route=product/product&product_id=51

and motor shield
http://www.dfrobot.com/index.php?route=product/product&product_id=69




Code:
/*
 
 
 The circuit:
 * LCD RS pin to digital pin 8
 * LCD Enable pin to digital pin 9
 * LCD D4 pin to digital pin 4
 * LCD D5 pin to digital pin 5
 * LCD D6 pin to digital pin 6
 * LCD D7 pin to digital pin 7
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 25 July 2009
 by David A. Mellis
 
 
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


//Key message
char msgs[5][17] = {
  "RIGHT pressed  ", 
  "UP pressed     ", 
  "DOWN pressed   ", 
  "LEFT pressed   ",
  "STOP pressed"};

int  adc_key_val[5] ={
  30, 150, 360, 535, 760 }; // for voltage divider
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;

int M1 = 3;
int E1 = 11;         
int rpm;
void setup() {
  Serial.begin(9600);
  // set up the LCD's number of rows and columns:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("any text here 1");
 
  delay (2000);
        lcd.setCursor(0, 1);             
   lcd.print("any text here 2"); 
     delay (2000);
//  pinMode(M1, OUTPUT);   
rpm = 70;



}

void loop()
{

  adc_key_in = analogRead(0);          // read the analog value from the keybaord keys   

  key = get_key(adc_key_in);           // call subroutine to convert analog value into key number
  if (key != oldkey)                   // if keypress is detected (key differs from oldkey)
  {
    delay(50);                         // wait for debounce time
    adc_key_in = analogRead(0);        // read the value from the sensor   
    key = get_key(adc_key_in);         // call subroutine to convert analog value into key number
    if (key != oldkey)     
    {   
      oldkey = key;
      if (key >=0){
        lcd.setCursor(0, 0);           
        lcd.print(msgs[key]);         


        lcd.setCursor(0, 1);              //line=1, x=0
        lcd.print("                ");    // clear line
        lcd.setCursor(0, 1);              //line=1, x=0lcd.print(key);                   
        lcd.print(key);                   
        Serial.println(key);             
        delay(500);                       

if (key ==1){
            rpm = rpm +5;
            if (rpm > 255) rpm = 255;
            analogWrite(E1, rpm);   //PWM Speed Control

            Serial.println(rpm);
}

if (key ==2){
            rpm = rpm -5;
            analogWrite(E1, rpm);   //PWM Speed Control

}
if (key ==0){
            digitalWrite(M1,LOW);      // set rotation direction
            analogWrite(E1, rpm);      // PWM Speed Control

}
if (key ==3){
            digitalWrite(M1,HIGH);      // set rotation direction
            analogWrite(E1, rpm);       // PWM Speed Control

}
if (key ==4){
            digitalWrite(M1,HIGH);      // set rotation direction
            analogWrite(E1, 0);         //PWM Speed Control

}
      }
    }         
  }
  else
  {
    lcd.setCursor(0, 0);               // no button pressed, display aanpassen
    lcd.print("WAIT FOR INFO   ");   
    lcd.setCursor(0, 1);             
    lcd.print("PRESS A BUTTON  ");   
  }



}
// SUBROUTINE Convert ADC value to key number

int get_key(unsigned int input)
{
  int k;                         //
  for (k = 0; k < NUM_KEYS; k++)  // increase k as long as it remains smaller than NUM_KEYS
  { 
    if (input < adc_key_val[k])  // compare input with incresing values
    { 
      return k; 
    }               
  }
  if (k >= NUM_KEYS)
    k = -1;     // No valid key pressed ,
  return k;     



}




Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, guys.  Here goes nuthin'...
Logged

Pages: [1]   Go Up
Jump to: