Show Posts
Pages: 1 ... 23 24 [25] 26 27 ... 273
361  Using Arduino / Programming Questions / Re: New to arduino, and need some help with my logic on: May 23, 2014, 01:24:45 am
Quote
OK, changed that..
So post the whole program as it is now.  Do not do it by updating your original post as that will make nonsense of the thread.
362  Using Arduino / Programming Questions / Re: Robotic Arm help, Lynxmotion AL5D from RobotShop on: May 22, 2014, 02:59:00 pm
Quote
I am running into issues where the servo motors I am using (recommended by RobotShop) are not responding to the code that I am uploading.
What are they doing, if anything ?
How are they wired ?
How are they powered ?
363  Using Arduino / Programming Questions / Re: for loops aren't running one at a time. on: May 22, 2014, 02:13:41 pm
Quote
If they had to learn all the theory before they can have fun with an Arduino few people would bother.
+1 to that.
364  Using Arduino / Programming Questions / Re: Delay in receiving transmittion on adafruit cc3000 on: May 22, 2014, 10:43:58 am
Quote
I don't see ant connection between the variable name to the long delay I have.
Neither do I, but you should not have 2 variables with the same name so eliminating the problem would be a wise move.
365  Using Arduino / Programming Questions / Re: Delay in receiving transmittion on adafruit cc3000 on: May 22, 2014, 09:05:12 am
I am surprised that it works at all.

In loop() you declare the char variable recv then set it equal to the variable returned by recv_request().  Sounds OK so far, but in recv_request() you declare another (local) variable also called recv.  This variable is then set to whatever client.read() returns and is itself returned from the function.  I don't know about the compiler but I am confused as to which version of the recv variable will be seen by the calling program.

There is another anomaly with the States() function.  The recv char is passed to it but the switch/case uses integers as its case variable.  '0' is not the same as 0.
366  Using Arduino / Programming Questions / Re: Error - 'Adafruit_MCP4725' Does not name a type on: May 22, 2014, 07:13:04 am
Did you stop/start the IDE after installing the new library ?
367  Using Arduino / Programming Questions / Re: Solved on: May 22, 2014, 04:40:47 am
It's easy on Windows too as long as the user contributed libraries are where they should be.
368  Using Arduino / Programming Questions / Re: for loops aren't running one at a time. on: May 22, 2014, 04:36:45 am
Surely those of us with experience need to encourage and attempt to help here.. . Lets review what the replys have said..

1.  Declaration of the for loop control variable is not standard in the for statement in any of the ISO standards for C or C ++ it is optional but in fact professional programmers and teaching estsablishments tend to avoid declarations of variables within code segements since documentation is difficult hence maintenance becomes a problem.
It is usually regarded as good practice to declare variables with only the scope that they need.  Hence
Code:
for (int x = 0; x < 255; x++)
Where the value of x is unimportant outside of the for loop.

Quote
2. Agree don't use Globals AT ALL in fact in a real development enviroment rather than the fiddled Arduino IDE it is generaly not possible to declare Globals.. In test Sketch solutions use them but always beware of code side effects.
Despite what I said above I believe that globals have a place in the Arduino environment.  Not least to avoid the need to pass multiple parameters to functions and to complicate returning multiple results.  What is important is sensible and consistent variable names.

Quote
3. Does it matter if we call the loop void answer it majes no difference and to a newbie programmer the fact there is a void in the declaration means its a natural name to give it.
Yes it matters.  Calling a function a void shows a fundamental misunderstanding of what a function is

Quote
  My beef here is that there is no need for prototypes in the IDE you can compile anything the whole essence of C /C++ tight type control has been lost.
How does the lack of function prototypes remove tight type control.  If prototypes are important to you then use them.  Oh, and you cannot, of course, "compile anything"

Quote
4. For loops are running but running fast, proven by print statements which would distort all meaningful measurements.
The primary problem here was testing whether the for loops were running.  Precise timing, if necessary, was a secondary objective.

Quote
Come on chaps lets try and help people on this forum, Arduino is a great teach / learning tool, it also is finding good markets in fast product prototyping the subject of my latest book..
What was not helpful in this thread ?  Arduino is a great learning tool but it is at its best when you try new things for yourself based on something that worked.  When things don't behave as expected then the fun, and much of the learning starts.

Quote
In this case its fairly obvious that the guys got his hardware screwed up, its not a programming problem
Not obvious at all

Quote
Lets ask the question whats the step rate specified for the motors? its probably much slower than his for loop execution and the hardwares simply not responding..
So ask.
369  Using Arduino / Programming Questions / Re: Error - 'Adafruit_MCP4725' Does not name a type on: May 22, 2014, 03:03:49 am
http://bit.ly/1jw355E
370  Using Arduino / Programming Questions / Re: Attachinterrupt0 and attachinterrupt1 doesn't work on: May 22, 2014, 02:21:50 am
Could the fact that the Leonardo has the interrupts on pins 2 and 3 reversed compared with other Arduino boards be a factor here I wonder ?

http://arduino.cc/en/Reference/AttachInterrupt
371  Using Arduino / Programming Questions / Re: New to arduino, and need some help with my logic on: May 22, 2014, 02:10:53 am
Code:
int myArray[5];
Declare an array of ints with 5 elements numbered 0 to 4
Code:
    myArray[5] = 00000;
Write 00000, more commonly known as 0, to the sixth element of the 5 element array
Code:
    myArray[5]++;
Increment the sixth element of the 5 element array.

As the whole program had not been posted I stopped trying to understand what you were trying to do.
372  Using Arduino / Programming Questions / Re: door lock with Arduino and a servo on: May 21, 2014, 07:23:10 am
Quote
how do I do it most easily?
If the servo starts at 0, and rotates to 180(ish) to unlock:
Code:
    lockServo.write(180);
    delay(howeverLongYouWant);
    lockServo.write(0);

If the servo starts at 180, and rotates to 0 to unlock, swap the first and third lines.
Falls off chair in amazement ! 

PaulS used the delay() command in a program.  smiley  Whatever next, code on the same line as an opening brace ?
As requested, though, it is the easiest way to do it, if not the best.
373  Using Arduino / Programming Questions / Re: door lock with Arduino and a servo on: May 21, 2014, 06:19:56 am
Quote
and that the time before he locks again getting longer?
The way that it is done at the moment is madness because loop() will run so fast that the value of timer will get to zero in practically no time at all despite the waste of time pointed out by Paul.

The answer is, of course, use the BlinkWithoutDelay principle.  Save a start time then check each time through loop() whether the desired interval has elapsed and if it has, act on it.  If not, go round again until it has or until user input is used to terminate the wait prematurely.
374  Using Arduino / Programming Questions / Re: scketch in scketch on: May 21, 2014, 01:24:11 am
Quote
Know any a way to do a scketch in a schetch?
No, but you can have a separate function that runs when a button press is detected.
Code:
start of loop
  if button1 is pressed
    call functionX
  end of if
end of loop

functionX
  do stuff here
  either stay in the function
  or return to where it was called
end of function
What is it that you are trying to do ?
375  Using Arduino / Programming Questions / Re: How to send a valiable to my stringList char [] ? on: May 20, 2014, 05:03:39 pm
This seems to work OK for me
Code:
void setup()
{
  Serial.begin(115200);
  char msg[] = "# # 12 # 1 # # 13 # 0 # # 14 # 0";
  char *part;
  Serial.println(msg);
 
  part = strtok (msg,"#");
  while (part != NULL)
  {
    Serial.println(part);
    part = strtok (NULL, "#");
  }
}

void loop()
{
}
The string (note lowercase s) variable can come from anywhere and as long as its format is consistent strok() can be used to split it.  The program prints the parts as they are split off but it could equally well be used to ascertain the pin numbers and the required output.
Pages: 1 ... 23 24 [25] 26 27 ... 273