Show Posts
Pages: [1] 2 3 ... 225
1  Using Arduino / Programming Questions / Re: switches within a counter sketch on: July 25, 2014, 04:53:04 pm
MSlastButton is only ever read, it is never written. That's at least one problem, because the name doesn't suggest that it should be constant.
2  Using Arduino / Programming Questions / Re: Can't make my new RF Links work? on: July 25, 2014, 12:07:13 pm
Code:
    for (int i = 0; i < buflen; i++)
    Serial.println(buf[i]);

    {
     ...
    }

Code that should be executed within the for loop needs to be between the curly braces. There should never be anything between a loop/if/function statement and its opening curly brace.
3  Using Arduino / Programming Questions / Re: Can't make my new RF Links work? on: July 25, 2014, 11:38:14 am
So print out what you are receiving.
4  Using Arduino / Programming Questions / Re: problem with serial communication on: July 24, 2014, 05:28:52 pm
Post all of your code. Considering inString isn't declared anywhere in your code, that code won't compile. Ergo, that's not the code you are using.
5  Using Arduino / Programming Questions / Re: for () Statement question. on: July 24, 2014, 11:16:51 am
the void setup()

There is no such thing as "the void setup()"

There is a function called setup with a return type of void.
6  Using Arduino / Programming Questions / Re: Have arduino code respond to "down press" of button. on: July 23, 2014, 06:51:19 pm
You're looking for a transition from either HIGH to LOW or LOW to HIGH, depending on how the switch it wired, which correspond to the push down and release actions. That's accomplished with this check:

Code:
monoButtonStateReset != monoButtonState

To see which one it is, you simply need to check if the current state is HIGH, indicating a LOW to HIGH transition, or LOW, indicating a HIGH to LOW transition.

Change this
Code:
monoButtonState == 1

to either

Code:
monoButtonState == HIGH

or

Code:
monoButtonState == LOW

depending on your wiring.
7  Using Arduino / Programming Questions / Re: How to split an incoming serial into int on: July 23, 2014, 06:35:42 pm
I'm not quite sure what you mean by synchronize

Let's say I wanted to tell you what the lottery numbers were for the last 50 years. Say its 5 numbers per lottery. I start talking, and you start writing:

120, 12, 76, 23, 64, 23, 195, 123, 634, 136

At this point, since you know it's 5 numbers per lottery, and you started listening before I started talking, so you know that the first 5 numbers go to the first lottery, and the next 5 go to the next lottery. You write it down as such:

Lottery #1: 120, 12, 76, 23, 64,
Lottery #2: 23, 195, 123, 634, 136

But what happens if you don't start listening until after I've spoken the first two numbers. What you hear, instead, is

 76, 23, 64, 23, 195, 123, 634, 136, 1, 99

So you write it down as such

Lottery #1: 76, 23, 64, 23, 195,
Lottery #2: 123, 634, 136, 1, 99

That's what is meant by synchronization; you need a way for the receiver to know where in the data set the sender is when the receiver starts listening. How you do this will depend on the sender. Does it send a delimited character like a new line? Is there a temporal break in time between sets of data? Could the value tell you something about its placement in the set?
8  Using Arduino / Programming Questions / Re: Looping LED patterns and using a button to break the loop on: July 22, 2014, 10:16:41 am
Do you have an example of this?  My coding experience is mostly combining code

Blink Without Delay
9  Using Arduino / Programming Questions / Re: Save Strings on: July 22, 2014, 10:10:16 am
why it stop saving the Strings

What does that even mean? You have to describe your problem much better than an ambiguous word like "save"
10  Using Arduino / Programming Questions / Re: Problem with the Serial.read() command on: July 22, 2014, 10:08:13 am
Code:
void loop ()

 
  val = Serial.read();
 
if(val == 'a')
{
 digitalWrite(led, HIGH);
 Serial.write("led ON");
}
val = Serial.read();
  if(val == 'a')
  {
  digitalWrite(led, LOW);
Serial.write("led OFF");
}
  }
 

Loop runs very quickly, and Serial.read() doesn't stop and wait until there is something in the buffer, so you're leaving it up to change as to which Serial.read actually pulls the character out. Rarely, should there be more than one serial read per UART in a given sketch, this isn't one of those times.
11  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 03:33:30 pm
All that snippet does is tell you how long the button was pushed down for. You need some type of structure like this:

Code:
if (someEventOccurs)
{
   // turn a relay on
   relayTurnOnTime = millis();
}

if (millis() - relayTurnOnTime > 1000)
{
   // turn off relay
}
12  Using Arduino / Programming Questions / Re: Invalid cast from type ‘String’ to type ‘int’ on: July 18, 2014, 02:22:04 pm
Code:
        pos1=String(chaineReception[0]).toInt()*100 + String(chaineReception[1]).toInt()*10 + String(chaineReception[2]).toInt();

toInt() can handle more than a single character String. The above link has an example of it doing just that.
13  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 02:20:30 pm
You just reposted what you said in your first post, instead of expanding on it given the questions asked. I didn't ask where the data was coming from, I ask what was sending it. PCs don't send it. Programs on the PC, do. If there is no way to differentiate when a packet starts or ends (either through markers or time, then you're in a bit of a pickle, because you need some way to differentiate the streams, else you run into a great amount of issues with synchronization.
14  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 01:11:17 pm
Start by identifying the time at which the signal is received. Record that time with millis. Then periodically check to see how long it has been since the event was recorded, and turn off the relay when that time comes.
15  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 01:10:07 pm
Any help with code, hints, or links would be HUGE!!!

It's still unclear what you are accomplish. What's sending the data? Is it sending anything to indicate when the data has "started" or "stopped"? Is it sending the same length every time?
Pages: [1] 2 3 ... 225