Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 274
151  Using Arduino / Programming Questions / Re: Arduino Autonomous GPS Navigation on: July 04, 2014, 10:38:34 am
Are you sure that the GPS is getting a lock ?
152  Using Arduino / Programming Questions / Re: Just can't quite get the code right on: July 04, 2014, 04:43:44 am
Quote
I just need to figure a better delay instead of using delay()
All Together Now "BlinkWithoutDelay"
153  Using Arduino / Programming Questions / Re: Sketch Optimization and Feasibility On An ATtiny on: July 04, 2014, 01:29:46 am
Quote
I didn't fully understand what you were saying about booleans. Do you mean to be careful with checking a boolean for its intended value? As in, make sure to only check if true/false booleans are true or false, not HIGH or LOW?
Checking that booleans are true/false is what I meant.  Currently you have
Code:
boolean doorSwitch[3];
Code:
 if (doorSwitch[0] == HIGH || doorSwitch[1] == HIGH)
This works but is not as clear as it might be.
154  Using Arduino / Programming Questions / Re: elapsedMillis help on: July 03, 2014, 10:30:07 am
Code:
if( digitalRead(switchPin)==HIGH)while(digitalRead(switchPin)==LOW);
You check to see whether the switch pin is HIGH and if it is, enter a loop that is only executed if it is LOW.  Have I read that right ?

Code:
if( digitalRead(switchPin)==HIGH)
{
while(digitalRead(switchPin)==LOW);
}
155  Using Arduino / Programming Questions / Re: Breaking down a programme. on: July 03, 2014, 10:15:40 am
Quote
I have noticed that when a function calls another function , the calling function has to be located after the called one for the compiler to find the reference.
Not if you use the Arduino IDE, because it creates the function prototypes behind the scenes and puts them near the start of the program for you.
156  Using Arduino / Programming Questions / Re: How are INPUT, OUTPUT, and INPUT_PULLUP defined? on: July 03, 2014, 10:12:27 am
Use the Arduino to tell you the answer.
Code:
void setup()
{
  Serial.begin(115200);
  Serial.print("INPUT : ");
  Serial.println(INPUT);
  Serial.print("OUTPUT : ");
  Serial.println(OUTPUT);
  Serial.print("INPUT_PULLUP : ");
  Serial.println(INPUT_PULLUP);
}

void loop()
{
}
157  Using Arduino / Programming Questions / Re: Sketch Optimization and Feasibility On An ATtiny on: July 03, 2014, 10:07:34 am
Be careful with your use of boolean variables and checking their value.  Whilst it is possible to create a boolean variable whose value is normally expressed as true or false and actually check whether its value is HIGH/LOW or 1/0 it is not so obvious what is going on when you read the code.  There is also a possible problem when using boolean varaibles in that HIGH/LOW and 0/1 are either/or values whereas that is not the case for true/false.   0 is false and any other value is true.

Another thought.  How are the switches wired ?  Do they have any resistors attached to ensure a consistent voltage when not activated ?  Whilst it is admirable that you have debounced the switches is it really necessary in this application ?
158  Using Arduino / Programming Questions / Re: How to handle lots of sensors data? on: July 03, 2014, 01:56:42 am
You have not said what type of sensors you are using but here are some ideas using digital sensors
Code:
if (digitalRead(sensorPin1) == HIGH)
{
  //do stuff if the input is HIGH
}

if (digitalRead(sensorPin1) == HIGH && digitalRead(sensorPin2) == HIGH) //etc
{
  //do stuff if both are HIGH
}


if (digitalRead(sensorPin1) == HIGH || digitalRead(sensorPin2) == HIGH) //etc
{
  //do stuff if either is HIGH
}

Then you mention serial input.  You can monitor serial input by parsing the incoming data and using the value(s) derived to decide on actions to be taken.  If more than one set of serial data is to be received and parsed then it will need to include an identifier for each set of data or be in a fixed format, such as comma separated, so that it can be parsed correctly.
159  Using Arduino / Programming Questions / Re: I need 3 digital inputs to control 2 outputs on: July 02, 2014, 01:55:39 pm
There may be other problems but I looked no further than
Code:
if ((buttonState1 == 1) && (buttonState2 == 1));
Remove the semi-colon or the if will not be acted upon.
160  Using Arduino / Programming Questions / Re: Keeping all libraries in the Arduino sketch directory on: July 02, 2014, 11:15:57 am
I suspect that it will not work but it will be easy for you to check.
161  Using Arduino / Programming Questions / Re: 2 Digital Pins & 4 States = 4 Messages on LCD. Nearly done but need some advise? on: July 02, 2014, 02:49:35 am
Code:
int systemState = (digitalRead(button1) * 2) + digitalRead(button2);
systemState will have a value of 0, 1 , 2 or 3 depending on which combination of buttons are pressed.  Use that in switch/case to display the relevant message but don't forget to clear the screen if the value changes so that the previous message is removed.
162  Using Arduino / Programming Questions / Re: Stepper Motor button direction control. on: July 02, 2014, 02:25:18 am
You are confusing a for loop which causes something to happen for a fixed number of times, with the English usage of "do this for a length of time".

One way to introduce a wait for a time period is to use the delay() function
Code:
delay(1000);
will wait for 1000 milliseconds.  This is all very well, but nothing else can happen during the delay().  That's OK if that is what you want to do but often there is a need for something to happen for a period of time, but for inputs to be read during that period.

To do that you note the start time of the period and then check frequently to see if the period has elapsed.  If not, go and do something else.  The loop() function provides a very convenient mechanism to do the frequent checking.

This principle is often referred to BlinkWithoutDelay because of the example of that name in the IDE.
163  Using Arduino / Programming Questions / Re: Stepper Motor button direction control. on: July 02, 2014, 01:40:38 am
Have you tried any of the examples that come with the library ?
164  Using Arduino / Programming Questions / Re: Using Interrupt....... on: July 02, 2014, 01:08:40 am
Quote
I just want to know why the interrupt is not occurring every 60 sec
And we just want to see your code that you have not posted. 

What board are you using and which pin is the 555 connected to ?
165  Using Arduino / Programming Questions / Re: Keeping all libraries in the Arduino sketch directory on: July 01, 2014, 03:30:10 pm
Quote
However, I have tried to place the libraries in the same directory as the main PDE file
Others will be along with advice but it sounds possible.  Put the library files in the same folder as your sketch and use
Code:
#include "myLibrary.h"
instead of
Code:
#include <myLibrary.h>

Pages: 1 ... 9 10 [11] 12 13 ... 274