Show Posts
Pages: 1 ... 13 14 [15] 16 17 ... 231
211  Using Arduino / Programming Questions / Re: Variable variable names for code tidy up? on: March 19, 2014, 11:13:04 am
No need for a class.  Just put the sensor pin numbers in an array and use a for loop to read them in turn.
212  Using Arduino / Programming Questions / Re: simple sketch for switch and relay on: March 19, 2014, 11:08:22 am
Is SwitchA a momentary contact switch or an on/off switch ?
What should happen if SwitchA is turned on/pressed during the cycle ?
What should happen if SwitchA is still on/pressed at the end of the cycle ?

This sounds like a very easy first project.  Get writing !
213  Using Arduino / Programming Questions / Re: Stopwatch class on: March 19, 2014, 10:23:02 am
Quote
I have created the StopWatch.c and StopWatch.h  files and added them to the library
Rename StopWatch.c to StopWatch.cpp

Close and re-open the IDE and try again
214  Using Arduino / Programming Questions / Re: please can someone help me? on: March 19, 2014, 09:28:49 am
Stop guessing and read the manual installation section of this page http://arduino.cc/en/Guide/Libraries#.UymrVKh_s1I
Note that the folder name and library name must match.
215  Using Arduino / Programming Questions / Re: Timing... So Confused... on: March 19, 2014, 06:52:45 am
This is what I had in mind
Code:
const int ledPin = 13;
int ledState = LOW;
unsigned long previousMillis = 0;
unsigned long interval = 1000;

void setup()
{
  pinMode(ledPin, OUTPUT);     
}

void loop()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval)
  {
    previousMillis = currentMillis;   
    ledState = !ledState;
    digitalWrite(ledPin, ledState);

    if (interval == 1000)
    {
      interval = 100;
    }
    else
    {
      interval = 1000;
    }
  }
}
You can replace
Code:
    if (interval == 1000)
    {
      interval = 100;
    }
    else
    {
      interval = 1000;
    }
with
Code:
    interval = (interval == 1000 ? 100 : 1000);
It does the same thing but is perhaps not so obvious.
216  Using Arduino / Programming Questions / Re: PID plus Joystick on: March 19, 2014, 05:26:20 am
Have you got the balancing part working ?  Code ?  Hardware ?
217  Using Arduino / Programming Questions / Re: Timing... So Confused... on: March 19, 2014, 05:24:12 am
Quote
Surely a variable for the LOW time and the HIGH time is required??
No. When the timing period is over change the state of the relay then, if the interval was previously 10 minutes set it to 50 minutes else set it to 10 minutes.
218  Using Arduino / Programming Questions / Re: Switching between LED sequences on: March 18, 2014, 10:03:00 am
Variables that have global scope (ie available to all parts of the program) are declared at the start of the program.  Variables whose scope is limited to a function are declared within that function.
219  Using Arduino / Programming Questions / Re: SLOW GSM on: March 18, 2014, 09:08:44 am
Seeing your whole program and a link the the hardware and libraries that you are using would be helpful.........
220  Using Arduino / Programming Questions / Re: Int0 and PCINT0... on: March 18, 2014, 06:50:57 am
I don't know the answer to your question, but I do wonder if you need to use interrupts at all as the frequency of pulses sounds very low.
221  Using Arduino / Programming Questions / Re: Concurrent programs running - (topic brought from project guidance) on: March 18, 2014, 02:27:13 am
Standard answer #1 applies.

Look at the BlinkWithoutDelay example in the IDE.  It uses the principle of checking whether it is time to do something yet, maybe turn an LED on or off, and if not then do something else in the meantime.  What you absolutely must not do is to use blocking code such as delay().
222  Using Arduino / Programming Questions / Re: Weird Problem on: March 18, 2014, 01:54:55 am
Have you tried different baud rates for the GPS connection ?
223  Using Arduino / Programming Questions / Re: Weird Problem on: March 17, 2014, 05:26:21 pm
Code ?
224  Using Arduino / Programming Questions / Re: Problem regarding Setup and Loop function on: March 17, 2014, 01:14:49 pm
Quote
void cord(void); <-------------------------------------------- what is this?
A function prototype by the look of it
225  Using Arduino / Programming Questions / Re: Simple Switching Sequences on: March 17, 2014, 03:52:29 am
Please post the code here so that we all know exactly what you tried.
Pages: 1 ... 13 14 [15] 16 17 ... 231