Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 04:11:13 pm
Works pretty well!

Thanks Guys!
2  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 03:33:19 pm
Can I use both your ways of setting these pins as INPUT - HIGHS?
3  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 03:29:42 pm
Pretty useful stuff !

Thanks guys.

About the Pull-Down Pull-UP...I never really got that :s
4  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 03:24:12 pm
So If I make the internal pin HIGH could I simply ground it for a LOW?
5  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 03:18:46 pm
What does the Internal PULLUP do though?

Why should I switch it on or off?

Thanks
6  Using Arduino / Programming Questions / Re: Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 03:17:33 pm
Hi Guys!

Thanks allot for the quick replies.

Well actually I have a the pull-down circuit as follows.

5V -- > 10Kohm --> PIN and from PIN -- > switch -- Ground.

Now I know this actually does pull the pin LOW cause I have tested the pin with my Multimeter.
But the Arduino doesnt seem to Respond when this happens
Could it be possible that I might have blown my PIN since I applied Clean 5V to it?
I am used to MicroChips and they can handle clean5V onto a pin.
7  Using Arduino / Programming Questions / Why wont my UNO respons to a pulled down LOW input? on: January 28, 2013, 01:41:09 pm
Hey Guys.

I am having a problem with a Pull-Down LOW input into my Arduino UNO which is weird cause I never had this problem before.
When I set it to react on HIGH it works fine.


Here is the Code.

Code:

//DigitalPins as INPUT-BUTTONS.
const int Button1 = 2;
const int Button2 = 3;
const int Button3 = 4;     
const int Button4 = 5;     
const int Button5 = 6;     
const int Button6 = 7;     

//AnalogPins as light ON/OFF.

const int Light1 = A0;
const int Light2 = A1;
const int Light3 = A2;
const int Light4 = A3;
const int Light5 = A4;
const int Light6 = A5;




int GlobalSelect = 0;

//Struct
struct Timer
  {
    unsigned long InitialTimer;
    char Track;
  };

Timer ButtonDelay = {0,0};

int Light1State = 0, Light2State = 0, Light3State = 0, Light4State = 0, Light5State = 0, Light6State = 0;

//Setup

void setup()
  {
    //DigitalPins - Buttons
      pinMode(Button1, INPUT);
      pinMode(Button2, INPUT);
      pinMode(Button3, INPUT);
      pinMode(Button4, INPUT);
      pinMode(Button5, INPUT);
      pinMode(Button6, INPUT);
     
    //AnalogPins - Lights
      pinMode(Light1, OUTPUT);
      pinMode(Light2, OUTPUT);
      pinMode(Light3, OUTPUT);
      pinMode(Light4, OUTPUT);
      pinMode(Light5, OUTPUT);
      pinMode(Light6, OUTPUT);
  }
 
void loop()
  {
    ButtonReadProto();
    SwitchF();
  }
 
  void ButtonReadProto()
 {         
            int Button1R = digitalRead(Button1);
            int Button2R = digitalRead(Button2);
            int Button3R = digitalRead(Button3);
            int Button4R = digitalRead(Button4);
            int Button5R = digitalRead(Button5);
            int Button6R = digitalRead(Button6);     
   
         if (ButtonDelay.Track==0)
          {
          ButtonDelay.InitialTimer = millis();
          ButtonDelay.Track=1;
          }
         
           unsigned long curUni = millis();
            if(curUni - ButtonDelay.InitialTimer > 250)
            {
              if (Button1R == LOW)
             {
               GlobalSelect = 1;
             
             }
             
              if (Button2R == LOW)
              { 
                GlobalSelect = 2;
              }
             
              if (Button3R == LOW)
              {
                GlobalSelect = 3;
              }
             
              if (Button4R == LOW)
              {
             
              }
             
              if (Button5R == LOW)
               {
               
               }
               
              if (Button6R == LOW)
               {
                 GlobalSelect = 6;
               }
               
             ButtonDelay.Track=0;     
            }
            else
            {

            }   
 }

void Light1F()
  {
 
    //Light1State = StateChange(Light1State);
   // if (Light1State == 1)
      //{
        digitalWrite(Light1, HIGH);
        digitalWrite(Light2, HIGH);
        digitalWrite(Light3, HIGH);
        digitalWrite(Light4, HIGH);
        digitalWrite(Light5, HIGH);
        digitalWrite(Light6, HIGH);
      //}
 
     
    GlobalSelect = 0;
   
  }
 
  void Light2F()
  {
       
        digitalWrite(Light1, LOW);
        digitalWrite(Light2, HIGH);
        digitalWrite(Light3, LOW);
        digitalWrite(Light4, LOW);
        digitalWrite(Light5, LOW);
        digitalWrite(Light6, LOW);
        GlobalSelect = 0;
   
  }
 
  void Light3F()
  {
       
        digitalWrite(Light1, HIGH);
        digitalWrite(Light2, LOW);
        digitalWrite(Light3, LOW);
        digitalWrite(Light4, LOW);
        digitalWrite(Light5, LOW);
        digitalWrite(Light6, LOW);
        GlobalSelect = 0;
   
  }
 
  void Light6F()
  {
    digitalWrite(Light1, LOW);
    digitalWrite(Light2, LOW);
    digitalWrite(Light3, LOW);
    digitalWrite(Light4, LOW);
    digitalWrite(Light5, LOW);
    digitalWrite(Light6, LOW);
    Light1State = 0; 
    GlobalSelect = 0;
   
  }
 
 /*
 int StateChange(int c)
   {
     if (c == 1)
       {
         c = 0;
       }
      else if (c == 0)
       {
         c = 1;
       }
     
     return c;
   }
   */
   
   
   void SwitchF()
     {
       switch(GlobalSelect){
       case 1:
       {
         Light1F();
         break;
       }
       
       case 2:
       {
         
         Light2F();
         break;
       }
       
       case 3:
       {
         
         Light3F();
         break;
       }
       
       case 4:
       {
         
         GlobalSelect = 0;
         break;
       }
       
       case 5:
       {
         
         GlobalSelect = 0;
         break;
       }
       
       case 6:
       {
         Light6F();
         break;
       }
       
       }//SwitchState Exit
       
     }

8  Using Arduino / Programming Questions / Re: Reset Interrupt possible? on: January 18, 2013, 08:20:18 am
Ok cool I see.

I get what you are saying. One more thing though

After roughly 50 Days it will overflow meaning Millis() should be somewhere close to " 4320000000 "
Will it be possible to say if (millis() >= 4319500000) { var1 = 0 ; } ?
9  Using Arduino / Programming Questions / Re: Reset Interrupt possible? on: January 18, 2013, 03:04:00 am
Hey Guys

Thanks allot for helping me understand the overflow problem smiley

Appreciated!!

So the way my makeshift Millis() function work is good?

Thanks
Ard
10  Using Arduino / Programming Questions / Re: Reset Interrupt possible? on: January 17, 2013, 04:21:37 pm
An example of my millis method Delay.

Code:
char  Track  = 0;
unsigned long InitialTime

void Example()
  {
 
    if (Track == 0)
      {
        InitialTime=millis();
        Track =1;
      }
     
      unsigned long yy = millis();
      if (yy - InitialTime < 5)
        {
         
        }
      else if (yy - InitialTime >=5 && yy - InitialTime < 10)
        {
         
         
        }
        else if (yy - InitialTime > 10)
        {
        Track =0;
        }
         
  }
11  Using Arduino / Programming Questions / Re: Reset Interrupt possible? on: January 17, 2013, 04:15:30 pm
The last recorded millis() variable will be recorded somewhere at the end of the 50 days and because im working with " Current-Millis() - Initial-Millis() < xx " or  "  Current-Millis() - Initial-Millis() > xx "
will undoubtedly be a problem since the Millis() a.k.a " Current-Millis() " will overflow and start from 0 which will mess up method of using Millis() above.

Plus the Restart will really not be that big deal to be honest.Wont mess up anything.
Chances are that something happens in the 3 seconds the Arduino restarts are probably not much.
12  Using Arduino / Programming Questions / Re: Reset Interrupt possible? on: January 17, 2013, 04:02:43 pm
smiley-sad  sorry...

The 50 day millis() overflow Problem.

I have some code that will ultimately after an overflow just switch on EVERYTHING it shouldn't and will do so for almost 50 days...

Unless I reset the arduino which will take like 3 seconds and then I have a new 50Days.

13  Using Arduino / Programming Questions / Reset Interrupt possible? on: January 17, 2013, 03:39:44 pm
Hi

I would like to know if it is possible to reset the arduino with code only?
I know the highest priority interrupt is the reset interrupt but how do I use it on code?

Thanks
Ard
14  Using Arduino / Displays / Trouble with Menus and Analog buttons. on: January 15, 2013, 10:19:38 am
Hey Guys.

I have the UNO with the DFRobot LCD Sheild and all I want to do is make a little up/down Scroll through menu system.
My code so far works but at a really fast pace and it pretty hard to control it that way.So i devised a piece of code that times it WITHOUT delays.
Problem is I cant seem to find what I am doing wrong but I have been sitting here for quite some time looking at the code, I bet the problem is staring me in the face.
Anyway if I press the UP button with the time code implemented it doesn't change menus like I wanted instead it does the following (Will Explain after my MAIN code):

Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

char TrackUP = 0;
unsigned long InitTimeUP=0;
 
// 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 MenuState = 0;

 
void setup()
{
 lcd.begin(16, 2);              // start the library
 lcd.setCursor(0,0);
 lcd.print("Push the buttons"); // print a simple message
}
 
void loop()
{
 lcd.setCursor(9,1);            // move cursor to second line "1" and 9 spaces over
 lcd.print(millis()/1000);      // display seconds elapsed since power-up

 read_LCD_buttons();
 
 switch (MenuState)               // depending on which button was pushed, we perform an action
 {
   
   case 0:
     {
       lcd.setCursor(0,0);
       lcd.print("Test Menu 1     ");
       lcd.setCursor(9,1);
       lcd.print(millis()/1000);
       break;
     }
     
     case 1:
     {
       lcd.setCursor(0,0);
       lcd.print("Test Menu 2     ");
       lcd.setCursor(9,1);
       lcd.print(millis()/1000);
       break;
     }
     
     case 2:
     {
       lcd.setCursor(0,0);
       lcd.print("Test Menu 3     ");
       lcd.setCursor(9,1);
       lcd.print(millis()/1000);
       break;
     }
   
     case btnNONE:
     {
     lcd.print("NONE  ");
     break;
     }
 }
 
}

// read the buttons
void read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value from the sensor
 
 if (adc_key_in > 1000) {}; //0 = btnNONE ; 1 = btnRight ; 2 = btnUP ; 3 = btnDOWN ; 4 = bntLEFT ; 5 = btnSELECT ; btnNONE.
 if (adc_key_in < 50)   ; 
 if (adc_key_in < 195) {BtnUp();};
 if (adc_key_in < 380) {BtnDown();};
 if (adc_key_in < 555) {BtnUp();} ;
 if (adc_key_in < 790)  ;   
}

void BtnUp()
  {
     if (TrackUP==0)
          {
          InitTimeUP = millis();
          TrackUP=1;
          }
         
           unsigned long RealTimerUP = millis();
            if(RealTimerUP -  InitTimeUP < 350)
            {
               lcd.setCursor(1,15);
                lcd.print("Under");
             
            }
            else
            {
             
                lcd.setCursor(1,15);
                lcd.print("Over");
                    if (MenuState < 3)
                      {
                        MenuState++ ;
                      }
                      else
                      {
                        MenuState = 0;
                      }
     
             TrackUP =0;
           
            }

}

So with the millis delay thing I have in function BtnUP() it doesnt seem to do anything accept for the
Code:

 lcd.setCursor(1,15);
lcd.print("Under");

which will really be nothing accept I made something for troubleshooting.

This however doesn't seem to be executing at all.
Code:


                lcd.setCursor(1,15);
                lcd.print("Over");
                    if (MenuState < 3)
                      {
                        MenuState++ ;
                      }
                      else
                      {
                        MenuState = 0;
                      }
     
             TrackUP =0;


All I want it to do is when I press the UP button on the sheild I dont want it to respond at clock speed I just want it to chill out on that menu for 500ms and then respond again WITHOUT delays.

Thanks and regards.
Ard
15  Using Arduino / Displays / Re: DFRobot LCD/Keypad Problem on: January 11, 2013, 01:57:26 pm
Hey

Thanks allot for the replies.

It turns out the POT is a bit lose or faulty.If I push on it it works but goes off again.

So I will return it.

Thanks guys
Pages: [1] 2 3