Show Posts
Pages: 1 [2] 3 4 ... 192
16  Using Arduino / Programming Questions / Re: checking button hold for a period of time on: October 01, 2014, 01:45:52 am
Thanks to Nick Gammon!
 smiley-sleep
Night time
17  Using Arduino / Programming Questions / Re: checking button hold for a period of time on: October 01, 2014, 01:31:24 am
Quote
if the process goes to
"  return;  "
where does it go ?

Back to finish whatever is left in the loop() function.

When the loop() function finishes it's last instruction, execution starts at the top of the loop() function once again and things repeat over and over. . . .
18  Using Arduino / Programming Questions / Re: checking button hold for a period of time on: October 01, 2014, 01:04:49 am
A bit cleaner version maybe?


Code: ( This is only a portion of a working sketch. Look at it for ideas only.)
#include <SwitchManager.h>
SwitchManager modeSW;  // create the object

const byte ModeSW = 4;             //input from the Mode push button switch    

void setup ()
{
  modeSW.begin (ModeSW, modeSwitchManager);
}
//======================== END OF setup ==========================



void loop ()
{
  //check to see what's happening with the Mode switch
  modeSW.check();

  //other suff

}
//======================== END OF loop ===========================




//                M O D E   S W I T C H   M A N A G E R
//****************************************************************
// function looks after the Mode switch functions
void modeSwitchManager (const byte newState, const unsigned long interval)
{
  if (newState == HIGH)  //in this case ignor a switch release
  {
    return;
  }

  //the newSatate must be LOW

  //-----------------------------------
  if (interval >=3000)
  {
    //do stuff for 3 seconds
    return;  
  }  

  //-----------------------------------
  if (interval >=1000)
  {
    //do stuff for 1 second
    return;
  }

  //-----------------------------------

  if (interval <= 250)  
  {
    //do your stuff for < 1/4 second push
    return;
  }

  return;

}  //                  END of modeSwitchManager()
19  Using Arduino / Programming Questions / Re: checking button hold for a period of time on: October 01, 2014, 12:53:34 am
I collected sections out of working code to give you an idea of how you can use the SwitchManage to monitor a switch push for different times.
ex: 250ms, 1 second and 3 seconds. 
When these times are met you can do what ever you have to do.

Code: ( This is only a portion of a working sketch. Look at it for ideas only.)
#include <SwitchManager.h>
SwitchManager modeSW;  // create the object

const byte ModeSW = 4;             //input from the Mode push button switch     

void setup ()
{
 modeSW.begin (ModeSW, modeSwitchManager);
}
//======================== END OF setup ==========================



void loop ()
{
  //check to see what's happening with the Mode switch
  modeSW.check();

//other suff

}
//======================== END OF loop ===========================




//                M O D E   S W I T C H   M A N A G E R
//****************************************************************
// function looks after the Mode switch functions
void modeSwitchManager (const byte newState, const unsigned long interval)
{
  if (newState == HIGH)  //in this case ignor a switch release
  {
    return;
  }

  //newSatate must be LOW

  //Are we switching to a new mode?
  if (interval <= 250)  //has it been < 1/4 second since the last push?
  {
    modeNumber++;
    if (modeNumber > 6)  //only modes 0-6 are allowed in ths sketch
    {
      modeNumber = 0;
    }

    //Udate to the new display mode
    switch (modeNumber)
    {
      //------------------------------------------------------------
    case 0:           //In put pulse counter   displays CXXXXXXX
      //start out at zero so it takes 3 pushes reset the Prescaler
      resetCounter = 0;

      break;

      //------------------------------------------------------------
    case 1:          //Frequency counter       displays FXXXXXXX
      flag = true;
      i = 0;

      break;

      //------------------------------------------------------------
    case 2:          //High Pulse Width        displays HXXXXXXX
      prepareForInterrupts ();   

      break;

      //------------------------------------------------------------
    case 3:          //Low Pulse Width         displays LXXXXXXX
      prepareForInterrupts ();   

      break;

      //------------------------------------------------------------
    case 4:          //Auto range voltmeter    displays EXXXXXXX
      //
      break;

      //------------------------------------------------------------
    case 5:          //Pulse output 1X         displays P1_XXXXX
      clear7219();
      configure (modeNumber);
      //start out at zero
      pulsesSent = 0UL;
      break;

      //------------------------------------------------------------
    case 6:          //Pulse output 10X        displays P10XXXXX
      clear7219();
      configure (modeNumber);
      //start out at zero
      pulsesSent = 0UL;
      break;

      //------------------------------------------------------------

    } //  END of switch(mode)

    return;
  }

  //Check to see if we want to reset the 4040 Hardware Prescaler
  //modeNumber 0, this is input pulse counting mode
  if (modeNumber == 0 && interval >=1000)
  {
    resetCounter++;        //if we ever get up to 2 then we are going to reset the Prescaler

    if (resetCounter >= 2)
    {
      resetCounter = 0;

      //do it
      //Initailize the Prescaler
      digitalWrite(RST,HIGH);  //reset the Prescaler, i.e. a HIGH resets a LOW enables 
      digitalWrite(RST,LOW);   //enable the Prescaler
      topPScounter = 0UL;      //reset the overflow register
    }
    return;
  }

  //*****************
  //Check to see if we want to send one pulse out on the pulse probe
  //modeNumber 5, this is pulse output X1 mode 
  //Have to wait initially 3 seconds then 1 sec there after
  if (modeNumber == 5 && interval >=3000)
  {
    pulsesSent++;
    pulseOutput(1);
    return; 
  } 

  else if (modeNumber == 5 && pulsesSent > 0 && interval >=1000)
  {
    pulsesSent++;
    pulseOutput(1);
    return; 
  } 

  //Check to see if we want to send 10 pulses out on the pulse probe
  //modeNumber 6, this is pulse output X10 mode
  //Have to wait initially 3 seconds then 1 sec there after
  else if (modeNumber == 6 && interval >=3000)
  {
    pulsesSent += 10;
    pulseOutput(10);
    return;   
  }
  else if (modeNumber == 6 && pulsesSent > 0 && interval >=1000)
  {
    pulsesSent += 10;
    pulseOutput(10);
    return; 
  } 
  //*****************

  return;

}  //                  END of modeSwitchManager()



20  Using Arduino / Programming Questions / Re: checking button hold for a period of time on: October 01, 2014, 12:06:29 am
Nick has a tool that might help.
I have used it in a similar situation you are in.
SwitchManager
See reply #1
http://www.gammon.com.au/forum/?id=11955
Download the ZIP file  (library) found at the end of the thread.
21  Using Arduino / General Electronics / FYI flexible test lead wire on: September 30, 2014, 11:04:17 am
Came across the attached Belden test lead wire which may be of interest to some.
It is rubber coated #24 AWG.   For cold weather smiley-wink
Made up of 45 strands of #40 !
Diameter ~ 1.7mm comes in Red and Black.
1,000 working volts
Break down @10,000V
I believe some places may sell it in 25 foot lengths.

http://canada.newark.com/belden/8890-002100/test-prod-wire-100ft-24awg-cu/dp/02F3979?MER=PPSO_N_C_EverywhereElse_None

http://canada.newark.com/belden/8890-010100/test-prod-wire-100ft-24awg-cu/dp/02F3976?MER=PPSO_N_C_EverywhereElse_None

Specs:
http://www.farnell.com/datasheets/1748403.pdf

I have no connection the this product.
22  Using Arduino / Networking, Protocols, and Devices / Re: Need help understanding TTL and Arduino on: September 29, 2014, 09:30:30 pm
If you have access to a logic analyzer set the it to decode async data, auto baud to see what you can conclude.
23  Using Arduino / Programming Questions / Re: bitlash not working with d2=!d2 can someone test that :-) on: September 29, 2014, 07:37:37 pm
voidptr, it's best you not return any any comments.
24  Using Arduino / General Electronics / Re: Good Quality 10K pot? on: September 29, 2014, 07:24:19 pm
I have used these and am satisfied with there quality:
Top image.
http://www.jameco.com/1/3/potentiometer-10k-10-turn
25  Using Arduino / Programming Questions / Re: shiftOut() on: September 29, 2014, 01:15:59 pm
As you read:
26  Using Arduino / General Electronics / Re: Can anyone confirm glitches on falling edges? on: September 29, 2014, 11:25:27 am
Not the best solution, but, when I talked to Saleae, they are looking at having a glitch filter on/off option in the software.
27  Using Arduino / General Electronics / Re: Can anyone confirm glitches on falling edges? on: September 29, 2014, 11:21:53 am
Only adjustment available, Image one:

One more good reason to have a ground plane, image two:
28  Using Arduino / General Electronics / Re: Breadboard voltages on: September 29, 2014, 10:33:13 am
http://www.jameco.com/jameco/products/prodds/2125026.pdf

Says here 36 volts 2 amp.
29  Using Arduino / General Electronics / Re: Can anyone confirm glitches on falling edges? on: September 29, 2014, 10:27:09 am
Used these many years ago.
Made a huge difference at high frequency.
30  Using Arduino / General Electronics / Re: Trying to calculate gate charging current/choose a gate driver for IRLB3813 on: September 28, 2014, 09:35:51 pm
This may help:
http://reibot.org/2011/09/06/a-beginners-guide-to-the-mosfet/
Pages: 1 [2] 3 4 ... 192