Pages: [1] 2 3   Go Down
Author Topic: Sim. Multi-Thread Function ( Look for input while scrolling ) <Maybe Fixed >  (Read 1347 times)
0 Members and 1 Guest are viewing this topic.
Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to scroll instructions on a 16 by 2 LCD display for new users but they take 18 seconds to complete. I have it scroll only on the top line. I would like for more experienced users to use the 4 by 4 membrane to jump ahead and enter key presses while the scrolling instructions are still running.
I tried my own ideas and then I looked around the web and found the following code on the Arduino.cc forum by Efficens Systems . Perhaps I could go in a different direction but this looks like it is the closes to what I want to do.  I believe that it was intended to be a starting point to be customized. Unfortunately, I couldn’t get it to work. I got it to compile but I didn’t get responses to key entry. Perhaps I need to include a Timer function, I don’t know. I didn’t want to hijack the thread where I found the code so I am entering it here..
I want to interrupt the scroll and move on if I get a key push but I think that I can work out the details of that if I can get notice of the read.
Does anyone have any input that could help?

Code:
// My inclusions
// My declarations
// My variables
typedef struct Timer
{
unsigned long start;
unsigned long timeout;
};

char TimerExpired ( struct Timer * timer )
{
if ( millis () > timer->start + timer->timeout )
return true;

return false;
}

void TimerStart ( struct Timer * timer )
{
timer->start = millis ( );
}

//Display task running every 3000 milliseconds
Timer timerDisplay = { 0, 3000 };
//Keyboard task running every 100 milliseconds
Timer timerKeyboard = { 0, 100 };

void setup (void)
{
// Mmy particular setup stuff
}

void loop (void)
{
if ( TimerExpired ( & timerDisplay ) )
{
taskDisplay ( );                      //   I changed to scrollInstructions();
TimerStart ( & timerDisplay );
}

if ( TimerExpired ( & timerKeyboard ) )
{
taskKeyboard ( );                 )   //  I changed to checkKeypadEntry()
TimerStart ( & timerKeyboard );
}
}

void taskKeyboard ( void )   //  I changed to checkKeypadEntry()
{
//  If/ When key(s) are pressed, kill scroll, change display  and do the next think
}

void taskDisplay ( void )       //   I changed to scrollInstructions()
{                                                 //   Scrolls only the top line
}
//  Several  other Voids forOtherTasksToDo()
//  {
//  }
« Last Edit: December 14, 2013, 07:54:11 pm by Asa Herring » Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23715
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You really want the Blink Without Delay idea.
Check the time, move scroll the text if enough time elapsed since the last scroll, otherwise do other stuff, like like reading from the keypad.
Some people use an interrupt to signal when to scroll.

Code:
void loop(){
currentMillis = millis();
elapsedMillis1 = currentMillis - previousMillis1;
if (elapsedMillis1 >=holdTime1){  // holdTime1 = 1000UL for 1/second updates for example
previousMillis1 = previousMillis1 + holdTime1;  // all time elements are unsigned long
// make text scroll
} // end time check
// do other stuff, like update the array that holds the text to be displayed
elapsedMillis2 = currentMillis - previousMillis2;
if (elapsedMillis2 >= duration2){  // duration2 is some other timed event
previousMillis2 = previousMillis2 + duration2;
// do other timed, cyclic event
}
// do other stuff when not doing the timed, cyclic stuff
} // end loop
Similar to what you attempted, without all the function calls.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I use the natural timing of the scrolling FOR loops?
Code:
void scrollInstructions()
{
for (int i=16; i > -16; i--)
{
lcd.setCursor(0,0);
lcd.print("Do This");
lcd.setCursor(i, 1);
//check?
Repeat about 5 more FORs with:
lcd.print("Then do this”);
//check?
lcd.print(“And that”);
//check?
lcd.print(“and finally”);
//check?
lcd.print(“Enter THIS.”);
// With no delay()s
// Finishes after 18 seconds
}
}

« Last Edit: December 13, 2013, 03:17:05 pm by Asa Herring » Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23715
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends how responsive you want to be to other stuff.
Each lcd.print takes a 1/2 second?
I would keep a pointer in the timing loop (basically do this part manually - for (int i=16; i > -16; i--) and each 1/2 second do the next lcd.print, then be doing other stuff until the next 1/2 second came around.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

All I would need to do is check for a key press and come back and I don’t know how long that takes but if that gets done before the next loop starts then I hope that it wouldn’t slow down much.

If that is true, how can I do it? I tried and I couldn’t get the read to show up inside the FOR so that I could exit. I used globals but that didn’t help. 
Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23715
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Like I explained - you get rid of the For:
Code:
int i = 16;
void loop(){
currentMillis = millis();
elapsedMillis1 = currentMillis - previousMillis1;
if (elapsedMillis1 >=holdTime1){  // holdTime1 = 5000UL for 1/2 second updates for example
previousMillis1 = previousMillis1 + holdTime1;  // all time elements are unsigned long

// now the broken up 'for' loop
lcd.setCursor(0,0);
lcd.print("Do This");
lcd.setCursor(i, 1);

//and 'manually' keeping track of where in the 'for' loop
i=i-1;
if (i > -16){i = 16;} // reset after the end

// make text scroll
} // end time check
// do other stuff, like update the array that holds the text to be displayed
elapsedMillis2 = currentMillis - previousMillis2;
if (elapsedMillis2 >= duration2){  // duration2 is some other timed event
previousMillis2 = previousMillis2 + duration2;
// do other timed, cyclic event
}
// do other stuff when not doing the timed, cyclic stuff
} // end loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am really sorry but I don’t have enough experience to figure this out. I broke a string like this:

“Do This  And that and finally ENTER THIS.”

Into several  ‘for’ loops that follow each other, inside one function. Each loop scrolls a part of the line to look like one long one. It doesn’t loop for just 16 interations. It loops for …say 40 clicks.

How do I get rid of the set of ‘for’s?
Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Saskatchewan, Canada
Offline Offline
Edison Member
*
Karma: 34
Posts: 1180
Coding Geezer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is thee any reason you aren't showing us your entire code for scrolling? It's difficult to give advice while tryint to guess what you're doing.
Logged

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes   I am at work but I am leaving right now. I will be there at about 6:30.
Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This the code that I use to scroll a message. I wanted to be able to leave this prior to finishing if the user enters a keypad button push.

Code:
void scrollInstructons()
{
         for (int i=16; i > -1; i--)
          {  
          lcd.setCursor(i, 0);
          lcd.print("Enter Number");  
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("of Steps. ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("Then  Press ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }    
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("< or > ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("to Start");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
          lcd.setCursor(0,0);
          lcd.print("Enter #");  
}
« Last Edit: December 13, 2013, 07:07:25 pm by Asa Herring » Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is how I look to key presses.
Code:
void loop()
{
 keyPadFunction();
}
void keyPadFunction()
{
//Serial.println("keyPadFuction");  
  char key = keypad.getKey();
  
  if (key)
   {
   in = key;

  switch (in)
     {
    case '1':
       Serial.println("I read the number 1*");
       if(menL == mainMenu)
         {                    
         menL = autoMenu;
         makeMenu();
         break;
         }
       else if(menL == autoMenu)
         {                    
         Serial.println("Resume 1 Done");
         }
       else if(menL == manualMenu)
         {
         Serial.println("manualMenu");
         tempLocation = totalSteps;
         Serial.println(tempLocation);        
         menL = makeDistanceMenu;        
         makeMenu();
         }        
       else if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }
       else if(menL == manualStepMenu)
         {
         }            
      break;
     case '2':
//Followed by cases 3 through 9, 0, A, B, C, D, * and #
« Last Edit: December 13, 2013, 07:08:23 pm by Asa Herring » Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Saskatchewan, Canada
Offline Offline
Edison Member
*
Karma: 34
Posts: 1180
Coding Geezer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I wasn't fully clear. Could you post your ENTIRE code? If the keyboard code isn't in the same sketch as the lcd scrolling code, please post the entire code that includes the scrolling code. Snippets just don't work well for trying to get teh whole picture.
Logged

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

First half
This is not elegant. It's just brute force.
If you were to set it up for a normal LCD and a keypad and compile it, you would want to press '#' then '2' and then '1'. At that point you can punch in 1 to 4 digits but no more. Then you would hit C or D.
Of course it may be easier to just follow the code through the key presses.
Code:
#include <Keypad.h>
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

int i;
int in;
int DIR;
//int keyCheck = 0;
int xLocation;
int yLocation;
int tempLocation;
int totalSteps = 10;
int stepsToNextStation;
int manualStepsToNextStation;
int autoInputFork;
int inputDigitCount = 0;
String getDistance;
//       can't use 0        1         2           3               4                 5        6
enum menuLevel { UNDEF, mainMenu, autoMenu, manualMenu, manualStepMenu, makeDistanceMenu, keyCheck };
menuLevel menL = mainMenu;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char key;
char key2;
char keys[ROWS][COLS] =
{
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {45, 43, 41, 39}; //connect to the row pinouts of the keypad 37, 35, 33, 31
byte colPins[COLS] = {37, 35, 33, 31}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);      
  lcd.print("Running");  
}

void loop()
{

 keyPadFunction();

}

void keyPadFunction()
{
//Serial.println("keyPadFuction");  
  char key = keypad.getKey();
  
  if (key)
   {
   in = key;

  switch (in)
     {
    case '1':
       Serial.println("I read the number 1*");
       if(menL == mainMenu)
         {                    
         menL = autoMenu;
         makeMenu();
         break;
         }
       else if(menL == autoMenu)
         {                    
         Serial.println("Resume 1 Done");
         }
       else if(menL == manualMenu)
         {
         Serial.println("manualMenu");
         tempLocation = totalSteps;
         Serial.println(tempLocation);        
         menL = makeDistanceMenu;        
         makeMenu();
         }        
       else if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }
       else if(menL == manualStepMenu)
         {
         }            
      break;
     case '2':
       Serial.println("I read the number 2");
        if(menL == mainMenu)
         {
         menL = manualMenu;
         makeMenu();        
         }
       else if(menL == autoMenu)
         {                    
         Serial.println("Re-Start 2 Done");
         }
       else if(menL == manualMenu)
         {          
         menL = manualStepMenu;        
         makeMenu();
         }            
        else if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }        
      break;
     case '3':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }
         Serial.println("I read the number 3");
      break;
     case '4':
        if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
         Serial.println("I read the number 4");
      break;
     case '5':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
       Serial.println("I read the number 5");
      break;
     case '6':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
       Serial.println("I read the number 6");
      break;
     case '7':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
        Serial.println("I read the number 7");
      break;
     case '8':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
       Serial.println("I read the number 8");
      break;
     case '9':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
       Serial.println("I read the number 9");
      break;
     case '0':
       if(menL == makeDistanceMenu)
         {
          makeDistance(in);
          menL = makeDistanceMenu;
         }    
       Serial.println("I read the number 0");
      break;
      case 'A':
       Serial.println("I read the number A");
        if( menL == manualStepMenu )
         {
         raiseTheBoom();
         }
       break;
      case 'B':
       Serial.println("I read the number B");
       if( menL == manualStepMenu )
        {
       lowerTheBoom();
        }
       break;
      case 'C':
       Serial.println("I read the number C");
       DIR = -1;
       if( menL == makeDistanceMenu )
        {
       show();
        }
       if( menL == manualStepMenu )
        {
        goLeft();
        }      
       break;
      case 'D':
       Serial.println("I read the number D");
       DIR = 1;
       if( menL == makeDistanceMenu )
        {
        show();
        }
       if( menL == manualStepMenu )
        {
        goRight();
        }                
       break;
      case '*':
       Serial.println("I read the number STOP*");
       doAnAllStop();
       break;
      case '#':
       Serial.println("I read the number #");
       Serial.println(menL);
       if(menL == makeDistanceMenu)
       {
        Serial.println("Go to Start Point");
        yLocation = tempLocation - totalSteps;
        yLocation = abs(yLocation);
        Serial.println(xLocation);
        Serial.println(yLocation);
          if(xLocation >= 0 )
            {
            DIR = -1;
            }
          else
            {
            DIR = 1;
            }
        stepsToNextStation = yLocation;  
        moveToNextStation(stepsToNextStation, DIR);
        Serial.println("Am I back? #");
        menL = mainMenu;
        makeMenu();
       }
       else
       {
       manualEntryPoint();
       }      
       break;
      default:      
       break;
     }
   }
}  







« Last Edit: December 13, 2013, 10:50:46 pm by Asa Herring » Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Second part
Code:
void manualEntryPoint()   // <<<<<<<<<<<<<<<<<<<<<<<<<
{
    stepsToNextStation = 0;
    inputDigitCount = 0;    
    lcd.setCursor(0,0);
    lcd.print("                ");    
    lcd.setCursor(0,0);
    lcd.print("Automatic Manual");  
    lcd.print("                ");
    lcd.setCursor(0,1);    
    lcd.println("   1   or   2   ");
    menL = mainMenu;
    inputDigitCount = 0;
    stepsToNextStation = 0;
    DIR = 0;
    
}

void doAnAllStop()
{
   allStop();
}

void tooManyDigits()
{
  lcd.setCursor(0,0);
  lcd.print("                ");
  lcd.setCursor(0,1);  
  lcd.print("                ");
  lcd.setCursor(0,1);
  lcd.print("                ");  
  lcd.setCursor(0,0);
  lcd.print("Only 4 digits   ");
  delay(1000);
  menL = makeDistanceMenu;
  makeMenu();  
}

void goLeft()
{
    Serial.println("Manual Left");
    DIR = 1;
    moveToNextStation(stepsToNextStation, DIR);
    inputDigitCount = 0;    
    stepsToNextStation = 0;
}

void goRight()    
{
    Serial.println("Manual Right");  
    DIR = -1;
    moveToNextStation(stepsToNextStation, DIR);    
    inputDigitCount = 0;
    stepsToNextStation = 0;
}

void makeDistance(int in)
{
    lcd.setCursor(12,0);
    lcd.print("    ");
        
    if ( in >='0' && in <='9' )
     {
       if(inputDigitCount >= 4 )
        {
        tooManyDigits();
        }
        else
        {
        inputDigitCount = inputDigitCount + 1;      
        stepsToNextStation = stepsToNextStation * 10 + (in - '0');
        lcd.setCursor(12,0);
        lcd.print("    ");
        lcd.setCursor(12,0);        
        lcd.print(stepsToNextStation);        
        }  
     }  
}

void show()
    {
//    manualControl(manualStepsToNextStation, DIR);  
    moveToNextStation(stepsToNextStation, DIR);
    inputDigitCount = 0;
    stepsToNextStation = 0;
    DIR = 0;    
    lcd.setCursor(12,0);
    lcd.print("    ");    
    }
    
void makeMenu()
{
  switch (menL)
     {
    case mainMenu:
         clearLCD();
         lcd.print("Automatic Manual");  
         lcd.print("                ");
         lcd.setCursor(0,1);    
         lcd.println("   1   or  2    ");
         break;              
    case autoMenu:        
         clearLCD();        
         lcd.print("Resume    1");    
         lcd.setCursor(0,1);
         lcd.print("Re-Start  2");
         break;        
    case manualMenu:        
         clearLCD();        
         lcd.print("Number of Stps 1");                  
         lcd.setCursor(0,1);
         lcd.print("Manual Mode    2");          
         break;        
    case manualStepMenu:    
         clearLCD();        
         lcd.print("Enter Direction ");                  
         lcd.setCursor(0,1);
         lcd.print("A=^ B=V C=< D=> ");
         break;
    case makeDistanceMenu:
         clearLCD();
         lcd.setCursor(0,1);        
         lcd.print("<=C or D=> to Go");
         scrollInstructons();    
         break;
  }    
 }

void scrollInstructons()
{
         for (int i=16; i > -1; i--)
          {  
          lcd.setCursor(i, 0);
          lcd.print("Enter Number");  
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("of Steps. ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("Then  Press ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }    
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("< or > ");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
         for (int i=16; i > -1; i--)
          {        
          lcd.setCursor(i, 0);
          lcd.print("to Start");
          lcd.setCursor(0,0);    
          lcd.print("                ");    
          }
          lcd.setCursor(0,0);
          lcd.print("Enter #");  
}
 
// These calls are in the main program and are simulated below
// so that this program can compile and flow.


void manualControl(int manualStepsToNextStation, int DIR)
{
Serial.println(tempLocation);
stepsToNextStation + manualStepsToNextStation;
moveToNextStation(stepsToNextStation, DIR);
}

//void moveToNextStation()
void moveToNextStation(int stepsToNextStation, int DIR)
{

  //This will be removed when incorporated into bigger program.
  Serial.println(String("Translate ") + int(stepsToNextStation) + String(" steps, multiplied by ") + int(DIR) + String(" for polarity."));
  for(int i=stepsToNextStation; i > 0; i--)
    {
     totalSteps = totalSteps + DIR;
     Serial.println(tempLocation);
     Serial.println(totalSteps);
     Serial.println(i);    
     delay(1000);    
    }
}

void raiseTheBoom()
 {
 Serial.println("Raised the Boom");
 }
 
void lowerTheBoom()
 {
 Serial.println("Lowered the Boom");
 }
 
 void allStop()
 {
 Serial.println("ALL STOP");  
 }
 
void clearLCD()
{
    lcd.setCursor(0,0);      
    lcd.print("                ");
    lcd.setCursor(0,1);      
    lcd.print("                ");    
    lcd.setCursor(0,0);
    
}







Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Winston-Salem
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the key stroke map. '#' start and re-start
Logged

I have an Arduino Mega 2560. I also have a (pH) BNC Sensor Shield,an I2C/SPI/Onewire Shield(I beleive that it an on board clock.)and a Breakout Board Shield, all three are from Andrew Oke. Additionally, I have a Stepping Motor but could certainly buy a Servo Motor instead if it is any better for what I want to do, short term/long term. Trying to read the lable, I guess that it is: Type 57BYG. 12 V/Phase, 20ohm, 0-6A/Phase 1.8 Deg/Step, No. 04052 with a K179 Stepper Driver board attached. I can't confirm that the board is fully funtional

Pages: [1] 2 3   Go Up
Jump to: