Show Posts
Pages: [1] 2 3 ... 840
1  Using Arduino / Programming Questions / Re: Can't user Serial1 and Serial when cable is not connected on: July 30, 2014, 11:51:15 am
The problem comes when I don't connect the USB cable to the PC and then I power it on with battery. Everything switches ON, and I can see the lights working Okay. But, I've no response of the board on my internet service... So, I guess the problem is the Serial1 communication with the mobile board

There is a common convention of putting code in setup() which waits until the Serial port has initialised. On some boards, this will block the sketch until a PC application opens the serial port:

Code:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

If you have this code in your setup() function, I suggest you take it out.

I am sure Serial1 becomes Serial when USB cable is not connected...

I am sure it does not.
2  Using Arduino / Programming Questions / Re: x +=y; is the same as x=x; ??? on: July 30, 2014, 11:45:23 am
so the short version is that I am trying to do a running average with code like this:

Please post a complete sketch that demonstrates the problem - preferably one that demonstrates it in the simplest possible way without relying on any external hardware or non-standard libraries. Explain what your input values are, what output value you expect and what output values you actually get.
3  Using Arduino / Project Guidance / Re: Help with how to approach my aquarium controller on: July 30, 2014, 11:40:47 am
This is how it determines which button is pressed, do you have any pointers on how I could perhaps do this another way?

It seems that your shield is combining all the buttons with a resister network so the Arduino sees a different voltage on an analog pin depending which buttons are pressed. The code to handle this type of input is similar to reading an ordinary pushbutton on a digital I/O pin, except that it can return multiple values not just high and low. In order to detect button presses you need to keep track of what button is currently pressed, and see when this changes.

Code:
// global data
int previousButton = btnNONE;

// code called from loop()
currentButton = read_LCD_buttons();
if(currentButton  != previousButton)
{
    // button press or release has occurred
    if(currentButton != btnNONE)
    {
        // button press has occurred
        handleButtonPress(currentButton);
    }
    previousButton = currentButton;
}

// function you will write to do something when a button press occurs
void handleButtonPress(int button)
{
    your code here
}
4  Using Arduino / Project Guidance / Re: Parsing JSON from serialized data on: July 30, 2014, 11:30:26 am
How can I parse {"win":"yes"} out of the serialized data in arduino?

Do you want both fields, or just the "yes" string?

For each field you want to keep, you need to read and discard everything up to the start of that field and then read and buffer everything up to the end of the field. Since the fields are delimited by unique character sequences {", ":", "} that is easy to do. You can do it either using a little state machine to keep track of where you are in the parsing sequence, or by buffering the whole lot and using strstr() to detect where the delimiters are within the buffer and then using strncpy() to extract the part you want to keep into a separate buffer.

If you only want to know whether the value is "yes" or "no" it gets even easier - you can just use strstr() to test whether the input buffer contains \"win\":\"yes\" or \"win\":\"no\".

5  Using Arduino / Project Guidance / Re: RC controller stick input bypass on: July 30, 2014, 11:18:44 am
How about using a micro servo or similar to adjust the trim? Usually this works by physically moving the body of the potentiometer. You may need to hack the mechanism to achieve a sufficient range of motion. Alternatively if you only need a few discrete movements you could use a micro relay to connect a resister in series with the pot to bias the pot output. I don't know how much current the pots take, but if it's of the order of 20mA or so you could even use I/O pins directly to add pull-up/pull-down resistance to the signal pin.
6  Using Arduino / Project Guidance / Re: Write string to EEPROM on: July 30, 2014, 11:14:14 am
I am trying to write a string to EEPROM but I have been having some trouble getting it to work. I've tried using the "write anything", "eepromex", and "EepromUtil" libraries but still can't get it to work.

What you're trying to do is certainly possible. If your attempt isn't working, post your code and perhaps somebody can explain what you're doing wrong.
7  Using Arduino / Project Guidance / Re: Ardi Noob Here - Identifiation & Tracking System - The Talos Project on: July 30, 2014, 11:11:54 am
UV based laser

Do you know enough about lasers to understand the associated dangers? By the time it's powerful enough to have any chance of zapping an insect, I suspect it'll be dangerous to unprotected eyes.

http://www.sciencebuddies.org/science-fair-projects/project_ideas/Phys_Laser_Safety.shtml
8  Using Arduino / Project Guidance / Re: Crittercam project - Camera won't take focused pictures on: July 30, 2014, 11:04:20 am
There's no detail at all about the technical specifications of the camera. Do you have any idea what the focal length is supposed to be? Does the camera use / support using an external lens to achieve the correct focus?
9  Using Arduino / Interfacing w/ Software on the Computer / Re: How to get output of system() command? on: July 30, 2014, 10:59:56 am
What Arduino are you using? If you're trying to get metrics back from the PC via the USB serial connection, what operating system is running on the PC? If you aren't trying to do that, please explain what you're trying to do.
10  Using Arduino / Programming Questions / Re: Serial.read on: July 29, 2014, 07:26:41 pm
Where is the "Yes" coming from? If it's coming from the serial monitor, you can use the line ending to indicate when you have received a complete command. In that case you can buffer and process it like this:

Code:
// incomplete, untested
void handleSerial()
{
    const int BUFF_SIZE = 32; // make it big enough to hold your longest command
    static char buffer[BUFF_SIZE+1]; // +1 allows space for the null terminator
    static int length = 0; // number of characters currently in the buffer

    if(Serial.available())
    {
        char c = Serial.read();
        if((c == '\r') || (c == '\n'))
        {
            // end-of-line received
            if(length > 0)
            {
                handleReceivedMessage(buffer);
            }
            length = 0;
        }
        else
        {
            if(length < BUFF_SIZE)
            {
                buffer[length++] = c; // append the received character to the array
                buffer[length] = 0; // append the null terminator
            }
            else
            {
                // buffer full - discard the received character
            }
        }
    }
}

void handleReceivedMessage(char *msg)
{
if(strcmp(msg, "Yes") == 0)
{
// handle the command "Yes"
}
else
{
// etc
}
}
11  Using Arduino / Programming Questions / Re: Global variables not updating on: July 29, 2014, 07:23:48 pm
I think you should only process the received message when you actually receive it, i.e. inside the if(network.available()) block.

I suggest you separate out the code dealing with network reception with the logic handling scene numbers. You could do that by writing a function to handle a received scene number and calling that with the received scene number as an argument each time you receive a new scene number.

The timeout logic should be simple enough to implement but it would be sensible to leave that out until you have got the basic logic to handle a sequence of scene numbers working correctly.

Make sure your sketch prints out trace messages to show what it has received and what it is doing to the scene number as a result, so that you can check whether it's working correctly.
12  Using Arduino / Project Guidance / Re: Servo Motor Signal Problem on: July 29, 2014, 07:17:09 pm
It just doesn't hold its location when something else is turned on.
Code:
    servo1.write(0);
    delay(200);
    servo1.write(180);

Your sketch will run the code above repeatedly as long as the input is low, and leave it in the '180' position when the input is high. I have no idea whether this is the behaviour you intend - if it isn't I suggest you explain exactly what behaviour you are trying to achieve.
13  Using Arduino / Project Guidance / Re: Help with how to approach my aquarium controller on: July 29, 2014, 07:10:56 pm
I don't know how the buttons work ojn the shield you're using but I suspect they'll just be connected to I/O pins. In that case, reading the button state will be as easy for the shield as in any other case. Look at the state change detection example to see how to debounce an input and detect button presses - you could probably get that working using your lcd/button shield by creating a copy that uses the pin numbers your shield connects the buttons to.

None of what you're trying to do seems especially difficult, and I suspect the reason that you're finding it so intimidating is that you're trying to solve the whole thing in one go. That's not the best way to tackle problems like this. Take it one step at a time, reading and trying the examples that show you how to use the techniques relevant to that step. You need to be able to detect button presses on the shield, you need to display text, and you should plan to implement a simple state machine to manage the menu system you're going to write. Individually, none of these things are especially difficult to do.
14  Using Arduino / Project Guidance / Re: Arduino unresponsive after a long time on: July 29, 2014, 07:04:21 pm
There is a huge amount of code there that presumably has nothing to do with the Arduino turning on and off. I don't pretend to understand your description of how the Arduino will be turned on and off but I suggest that you write a minimal sketch that does as little as possible while supporting being turned on and off in the way your real sketch will be turned on and off. Add a simple timer to make an LED flash in a recognisable pattern which tells you what the Arduino is doing. See whether it produces the same problem. This will tell you whether there is a system design issue or just a software bug.
15  Using Arduino / Project Guidance / Re: How to detect length of circuit? on: July 29, 2014, 06:51:21 pm
If the wire has a known resistance per unit length then you could measure the resistance and calculate the length from that. To be usable in practice, the resistance would need to be fairly high so you'd need to use resistive wire, not ordinary copper wire. If the wire is connected in discrete segments you could use an ordinary resistor in series with each segment to give you the known resistance.
Pages: [1] 2 3 ... 840