Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timer
17-01-2016, 11:46 PM,
#1
timer
Hello everyone,
I am totally beginner in programming. I have a board 32 Pic pinguino OTG coupled to a screen 2 * 16 lcd keypad shiel V1.0. My problem is that I try to do an action or a timer interrupt counter of a button but no way ... If someone an idea I'm interested or if you need more information do not hesitate. Thank you and sorry for my english..
Reply
18-01-2016, 03:26 AM,
#2
RE: timer
(17-01-2016, 11:46 PM)Omnimusha60 Wrote: Hello everyone,
I am totally beginner in programming. I have a board 32 Pic pinguino OTG coupled to a screen 2 * 16 lcd keypad shiel V1.0. My problem is that I try to do an action or a timer interrupt counter of a button but no way ... If someone an idea I'm interested or if you need more information do not hesitate. Thank you and sorry for my english..

First, what exactly is the problem? Are you not getting an indication of the button press, or are you having a problem telling which key is pressed? Are you using your own software or are you using a sample program?
----------------
Thanks,
j
wzumwalt
 (\__/)
 (='.'=)
 (")_(")
Reply
18-01-2016, 10:08 AM, (This post was last modified: 18-01-2016, 10:08 AM by pingotg.)
#3
RE: timer
Also, there are samples - did you try them? What happened?

Which IDE, OS versions, etc?

John
Reply
18-01-2016, 09:40 PM,
#4
RE: timer
(18-01-2016, 10:08 AM)pingotg Wrote: Also, there are samples - did you try them?  What happened?

Which IDE, OS versions, etc?

John

My operating system is Windows 10.
I using a sample program That I've changed ..
I want to make a time for a sports training (with training time and  pause adjustable).
My problem: I can not boot my time and to interrupt when I want (by pressing a button).
And I do not know if I should use a chronometer or timer.
Here is part of my program.
Thank you for your help .

/*----------------------------------------------------- 

Author:  . 
Date: 05/01/16
Description: Version 2, 

Le travail consiste à créer un programme dans le but d'assister un entrainement sportif. 
Dans le programme nous pourrons intervenir dans le temps de travail, de repos. 
Il sera possible de mettre en pause le programme à tout moment puis de le reprendre là où il en était.
Il y aura aussi un bouton de remise à zéro. 

-----------------------------------------------------*/

#include <analog.c>
#include <lcdlib.c>

// define some values used by the panel and buttons

int lcd_key     = 0;
int adc_key_in  = 0;
 
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
         
int read_LCD_buttons(){               
    adc_key_in = analogRead(0);       
 
    
    if (adc_key_in > 1000) return btnNONE; 
    
     if (adc_key_in < 50)   return btnRIGHT;  
     if (adc_key_in < 380)  return btnUP; 
     if (adc_key_in < 555)  return btnDOWN; 
     if (adc_key_in < 790)  return btnLEFT; 
     if (adc_key_in < 999) return btnSELECT; 
    
    return btnNONE;                // when all others fail, return this.
}
   
void chrono()
{
    u32 t,r;
    u8 d,h,m,s;
    
    t = millis() / 1000;   // time in sec.
    d = t / 86400;         // days
    r = t % 86400; 
    h = r / 3600;          // hours
    r = t % 3600;
    m = r / 60;            // minutes
    s = t % 60;            // seconds

    lcd.setCursor(0, 1);
    lcd.printf("%02d:%02d",m,s);
}    
            
void setup(){

    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    // Initialiser la librairie de l'affichage
    lcd.pins(8, 9, 4, 5, 6, 7, 0, 0, 0, 0);

   lcd.begin(16, 2);               // start the library
   lcd.setCursor(0,0);             // set the LCD cursor   position 
   lcd.print("Chronometre");  // print a simple message on the LCD
}
  
void loop(){
 
   lcd.setCursor(0,1);             // move to the begining of the second line
   lcd_key = read_LCD_buttons();   // read the buttons
  
   switch (lcd_key){               // depending on which button was pushed, we perform an action
 
       case btnRIGHT:{             //  push button "RIGHT" and show the word on the screen
            lcd.print("RIGHT ");
            break;
       }
       case btnLEFT:{
             lcd.print("Start   ");
             while(1)
             {
                chrono();
             }
             
             break;
       }    
       case btnUP:{
             lcd.print("UP    ");  //  push button "UP" and show the word on the screen
             break;
       }
       case btnDOWN:{
             lcd.print("DOWN  ");  //  push button "DOWN" and show the word on the screen
             break;
       }
       case btnSELECT:{
             lcd.print("SELECT");  //  push button "SELECT" and show the word on the screen
              break;
       }
       case btnNONE:{
             lcd.print("NONE  ");  //  No action  will show "None" on the screen
             break;
       }
   }
}


void cycle1()
{
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Actif");
    lcd.setCursor(1, 1);
    chrono();
    delay(5000);
    int m=0;
    int s=0;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Repos");
    lcd.setCursor(1, 1);
    chrono();
    delay(5000);
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Entrainement Terminé");
    delay(500);   
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)