Loading...
  Show Posts
Pages: [1] 2 3 ... 52
1  Using Arduino / Programming Questions / Re: for (int i =... easy peasy... on: June 17, 2013, 06:38:49 pm
Array index runs from 0 to size-1. So for int myArray[16] the indexing is 0 to 15! not 1 to 16.

So the for loop should look like

for (1=0;i<16;i++){
}

There is no bounds checking in c/c++ so you will not be given any warning if you try to read/write outside the bounds to the array.

Writing out side the array will over write other data with random results

Mark
2  Using Arduino / Project Guidance / Re: Operating voltage for servo motor on: June 17, 2013, 06:07:38 pm
Servos should not normally be powered from the arduino it's self (but you can get away with it for one micro servo and a small load). So yes you need a second power supply and of course a common ground.

Mark
3  Using Arduino / Programming Questions / Re: for (int i =... easy peasy... on: June 17, 2013, 05:59:17 pm
But first use auto format to make it readable!. I for 1 will never download large files. Why not create a small sketch to show the problem you are having. Post the errors you are getting.

Mark
4  Using Arduino / Programming Questions / Re: Interrupt problems on: June 17, 2013, 04:11:14 pm
Quote
Well, the problem is not the "bounce".

How do you know this. Are you going to post you're latest code? Where is your circuit diagram?

Mark
5  Using Arduino / Project Guidance / Re: Help please with small motor timing script on: June 17, 2013, 02:44:15 pm
You DO need a motor shield. Try using a servo instead!

Mark
6  Using Arduino / Programming Questions / Re: Interrupt problems on: June 17, 2013, 02:25:45 pm
"iswaked" should be declared volatile. All var's changed in an interrupt routine should be declared as volatile. But that's not your problem.

I think you button/switch is bouncing look at de-bouncing in the playground.

Mark
7  Using Arduino / Programming Questions / Re: Using a Variable as a Function Name on: June 16, 2013, 04:41:06 am
You can't do it. Names are gone by the time the code has been built.

Mark
8  Using Arduino / Programming Questions / Re: Function doesn't get executed on: June 15, 2013, 03:57:41 pm
Just don't see why!

Mark
9  Using Arduino / Programming Questions / Re: Function doesn't get executed on: June 15, 2013, 03:42:22 pm
What use would a prototype be at that point in the code?. I can't see a possible use and therefore would expect and error message.

Mark
10  Using Arduino / Project Guidance / Re: if analog changes by 3 or more, runThis(); on: June 15, 2013, 03:38:56 pm
What do you mean by 3 digits?

Mark
11  Using Arduino / Programming Questions / Re: Function doesn't get executed on: June 15, 2013, 03:37:22 pm
Even so it makes no sense at that point in the code!

@op DO NOT DELETE THIS THREAD

Mark
12  Using Arduino / Programming Questions / Re: Function doesn't get executed on: June 15, 2013, 03:33:50 pm
@mods, paulS, etc but why did the ops code build at all. You can't dec functions within functions and we where not within a class!

Mark
13  Using Arduino / Programming Questions / Re: How can I listen two port while they have not been initiate at the same place on: June 15, 2013, 03:01:07 pm
Use the lib or SoftwareSerial but not both!

Mark
14  Using Arduino / Programming Questions / Re: Weird behavior of external interrupts on: June 15, 2013, 02:45:36 pm
While servicing and interrupt all other interrupts are disabled. If the routine takes to long this will cause problems. Some of the things which may have trouble due over long interrupt routines include serial, the servo lib, pwm.

Serial and delay can not be used in interrupt routines.

In general interrupt routines should be kept as short as possible. You cannot run other parts of a program in an interrupt routine instead you should set a flag in the interrupt routine and then check the state of the flag in loop().

Any var modified by an interrupt routine must be declared as volatile.

Mark
15  Using Arduino / Programming Questions / Re: INSERT A VARIABLE. on: June 15, 2013, 02:24:26 pm
read up on using serial.

1. Most 99.9999% of the time x will be -1 the result of reading when there is no data.

2. If you type 1 in the serial monitor serial.read() will return 48(the vaule used to represent the char '1') and then 13(cr) and then 10 (LF) read up on ascii

Mark
Pages: [1] 2 3 ... 52