Show Posts
Pages: [1] 2 3 ... 268
1  Using Arduino / Programming Questions / Re: Reading the value of a sensor every X millis (best practise?) on: Today at 07:14:27 am
Quote
In the 'blink without delay' code, the main action is defined into the IF branch and we don't have any ELSE branch
That's because an else is not needed.  The logic is not to turn the LED on or off at the right time OR do something else, it is to to turn the LED on or off at the right time then ALWAYS do something else.  Having said that, there could also be conditions on whether the something else happens, but that is independent of turning the LED on or off or leaving it in its current state.
2  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 21, 2014, 03:05:35 pm
Try the servo sweep program.  If the servo works with that then it is OK.

Did we establish how the servo is powered ?  From the Arduino 5V and GND pins or from the external supply ?
3  Using Arduino / Programming Questions / Re: what happens with output after if state isn't true? on: July 21, 2014, 02:01:53 pm
Once you have turned a pin HIGH or LOW with digitalWrite() it stays in that state until you explicitly change it.
4  Using Arduino / Programming Questions / Re: aduino uno+ethernet+gsm on: July 21, 2014, 05:45:06 am
How about starting with the example Ethernet programs and writing to Serial ?  Then you can move on to sending an SMS once you know that you are receiving the correct data to send.
5  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 21, 2014, 04:53:36 am
Quote
but it is better to use a pull-up resistor
Why ?

Quote
and the internal one is easiest.
Agreed wholeheartedly
6  Using Arduino / Programming Questions / Re: RPM measurement without attachInterrupt? on: July 21, 2014, 04:47:58 am
Code:
millis() - startTime >= setTime
That line of code is checking whether the required period of time (setTime) has passed between now (millis()) and the start time of the activity (startTime).  If so, then it is time to do something because the period has elapsed.  If not then go and do something else, such as reading a sensor or switch, and check again if the period has elapsed next time through loop().  Unlike using the delay() function the program does not stop whilst the period of time passes..
7  Using Arduino / Programming Questions / Re: reset static variable on: July 20, 2014, 04:41:49 pm
I don't understand what the OP wants to do either, but is there some confusion between static and const going on here ?
8  Using Arduino / Programming Questions / Re: Can't get a loop to work. on: July 20, 2014, 02:23:12 am
Code:
        while (lastPosition == currentPosition)
        {
          currentPosition = analogRead(sensorPin);
          lastPosition = currentPosition
        }
Note, however, that this relies on the pot returning exactly the same value all the time when stationary which is unlikely.  It would be better to build in a check to see of the pot value has changed and by how much.
Code:
        while (abs(lastPosition - currentPosition) < 20)
9  Using Arduino / Programming Questions / Re: Multiple Inputs on: July 19, 2014, 04:05:03 pm
Can you please explain more clearly what you want to do ?

Is switch 1 held on and then you wait for switch 2 or can switch 1 be pressed and released and switch 2 pressed within a time limit ?  If the latter, then if switch 2 is not pressed within the time period should the system forget the switch 1 press and start waiting for it again ?
10  Using Arduino / Programming Questions / Re: Self Balancing sketch runs only when usb is connected on: July 19, 2014, 07:31:37 am
Wow, the soldering on those motor connections is awful !
11  Using Arduino / Programming Questions / Re: cozir library not finding .h file on: July 19, 2014, 05:07:34 am
Quote
I have installed the cozir library 1.0.3 for the cozir co2 module in Arduino 1.0.5 on ubuntu.
Where exactly is the file installed ?
Using
Code:
#include "cozir.h"
the header file should be in the same directory as you program.
Compare that with
Code:
#include <SoftwareSerial.h>
which indicates that the header file is in the libraries folder.
12  Using Arduino / Programming Questions / Re: Run loop one time? on: July 19, 2014, 01:44:12 am
Quote
would that mean I should just move where I have the notes being played? Or would I need some IF THEN statements?
You need some logic to detect that the PIR state has changed and that it is now HIGH and was previously LOW
Code:
currentVal = digitalRead(IRpin);
if (currentVal == HIGH  && previousVal == LOW)
{
  // the PIR has been triggered so do something
}
previousVal = currentVal;
13  Using Arduino / Programming Questions / Re: MATHS PROBLEM!!! on: July 18, 2014, 05:37:16 am
Quote
As you can see Irms is a value I read off from a device
Actually I can't see that.  Please post your whole program.
14  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 18, 2014, 02:36:20 am
Judging by the voltages that you mentioned the servo is being supplied 5V from the Arduino.  If so that is not a good idea because the servo can easily take more current than the Arduino voltage regulator can supply.  Consider powering the servo from an external supply but don't forget to connect the two grounds.
15  Using Arduino / Programming Questions / Re: Run loop one time? on: July 18, 2014, 01:43:10 am
Look at the state change detection example in the IDE.  You need to trigger the sound when the PIR becomes LOW, not when it is LOW.  All this involves is checking its current state against it previous state and acting if it has changed and is now LOW when previously it was HIGH.
Pages: [1] 2 3 ... 268