Show Posts
Pages: 1 [2] 3 4 ... 225
16  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
17  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"
18  Using Arduino / Programming Questions / Re: Problem with the command on: July 22, 2014, 10:08:13 am
void loop ()

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

Loop runs very quickly, and doesn't stop and wait until there is something in the buffer, so you're leaving it up to change as to which 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.
19  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:

if (someEventOccurs)
   // turn a relay on
   relayTurnOnTime = millis();

if (millis() - relayTurnOnTime > 1000)
   // turn off relay
20  Using Arduino / Programming Questions / Re: Invalid cast from type ‘String’ to type ‘int’ on: July 18, 2014, 02:22:04 pm
        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.
21  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.
22  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.
23  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?
24  Using Arduino / Programming Questions / Re: Invalid cast from type ‘String’ to type ‘int’ on: July 18, 2014, 01:04:11 pm
why I can't convert String to int ?

You can if you do it properly.

Look at the available functions.
25  Using Arduino / Programming Questions / Re: myFirstLibrary, miles out? on: July 18, 2014, 10:39:09 am
Don't cross-post.
26  Using Arduino / Programming Questions / Re: Serial Monitor -> GUI on: July 18, 2014, 10:33:55 am
Not by using the Serial Monitor; you'll need a different terminal program.
27  Using Arduino / Programming Questions / Re: Merge servo and relay sketches on: July 18, 2014, 10:23:08 am
How to use this forum - please read.


// read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);

So the entire purpose of this function is to just set the LED to the state of the button? This could be done much easier by wiring it up that way, but if you insist on using software, then the entire function can be boiled down to a single line.

digitalWrite(ledPin, digitalRead(buttonPin));

I would also not recommend naming a function "pumprelay" if all it is doing it controlling an LED.

// process times
  now = millis();
  endtime = now + FEEDINGDELAY;
  while(now < endtime) {
   Serial.print("soon... ");
   now = millis();  

What exactly is the point of endtime here? You set it to three hundred milliseconds after the current time, then wait 20 seconds. May as well just remove the while structure, because it's not doing anything for you.

Previously the pump relay code would only detect change or be implemented when the servo was operating. Is this solved by the way I have placed the void pumprelay function?

Your pumprelay function has zero coupling with the servo. In other words, they don't affect each other (with the exception being the delays cause the pumprelay function to be called infrequently). Is that what you're going for?
28  Using Arduino / Project Guidance / Re: run a buzzer after 10 cycles of running program on: July 18, 2014, 10:06:06 am
   if((signal1 == HIGH && signal2 == HIGH) && (signal3 == HIGH && signal4 == HIGH))

signal1, 2, 3, etc. Are pin numbers. You shouldn't be comparing pin numbers to states. You should be using digitalRead to get the state of a digital pin, then compare the results to HIGH or LOW.
29  Using Arduino / Programming Questions / Re: PC Application for controlling Arduino on: July 18, 2014, 09:58:25 am
30  Using Arduino / Project Guidance / Re: explaining of delay() please on: July 18, 2014, 09:56:53 am
Okay....I'll do that. but can I also leave the delay part out of the script/program?

How could we possibly know that without seeing the code?

Or is it a required part of the script and must I set it to delay(1)?

If you remove it, the code will sill compile, but we have no idea if the sketch "requires" it.
Pages: 1 [2] 3 4 ... 225