|
166
|
Using Arduino / Programming Questions / Re: char to string
|
on: April 29, 2013, 05:40:24 am
|
OK, don't share the whole code and we will continue to guess what you are doing, or just give up. A question. Why is GUIbutton_top an array of Strings ? Guessing based on its name it would seem more logical for it to be an array of ints or bytes. using a for/next loop I need to stick the ASCII characters 0 (49) to 9 (58) into the array Are you sure that GUIbutton_top is an array of Strings ?
|
|
|
|
|
168
|
Using Arduino / Programming Questions / Re: char to string
|
on: April 29, 2013, 05:24:05 am
|
|
You are confusing the methods for manipulating Strings with those for manipulation strings. Spot the difference in the data type names. As Paul says, a C string is an array with at least 2 elements and the last one must be NULL.
Can I suggest that you post all of your code and an explanation of what happens when you run it.
|
|
|
|
|
169
|
Using Arduino / Programming Questions / Re: Controlling the rotation of Servo Futaba S3003
|
on: April 29, 2013, 05:03:51 am
|
I can't see a picture, but if it is an external view then it would not help differentiate between the 2 types. Try this simple program #include <Servo.h> Servo myservo;
void setup() { myservo.attach(9); }
void loop() { myservo.write(170); delay(2000);
myservo.write(10); delay(2000); }
Does the servo move to a fixed position, stop there for 2 seconds, move to a fixed position in the other direction, stop there for 2 seconds and repeat ? If so, the servo is a normal one. If it runs continuously for 2 seconds on one direction for 2 seconds, reverses and runs for 2 seconds in the other direction and repeats, then it has been modified for continuous rotation. You can make a continuous rotation stop by writing a value of about 90 (you need to experiment) to it but you cannot make it move to a particular angle except by timing how long it runs from a known position but that is very unreliable. As to converting between the 2 types, it is usually not difficult to convert from normal to continuous but doing it the other way may be difficult or impossible depending on how the initial conversion was done.
|
|
|
|
|
170
|
Using Arduino / Programming Questions / Re: Controlling the rotation of Servo Futaba S3003
|
on: April 29, 2013, 04:09:51 am
|
|
Is this a continuous rotation "servo" or a normal one ? Can you provide a link to the actual servo that you are using ?
If it is a continuous rotation "servo" then myServo.write(pos) sets the speed and direction of the servo and it will keep turning at that speed. If it is a real servo then myServo.write(pos) will move the servo to the angle set by pos and it will stay there.
|
|
|
|
|
171
|
Using Arduino / Programming Questions / Re: serial while loop break
|
on: April 29, 2013, 02:20:21 am
|
|
In your program inByte is an int (a number) and you are comparing it with a char (a character). Ask yourself, will they ever match ?
Either change inChar to a char or compare int inChar to the ASCII value of what you are receiving ( 1 = 49, 2 = 50 etc). Try printing what you are receiving to see what is going on.
|
|
|
|
|
172
|
Using Arduino / Programming Questions / Re: Save state of Touch Screen
|
on: April 29, 2013, 01:18:52 am
|
if touch pressure less than trigger level Wouldn't it work better to record the values when the pressure is high enough to be recognized as a touch, and stop recording when the pressure drops off? Either way will work I think as long as loop() executes fast enough. I am sure there was a reason why I suggested the way I did but for the life of me I cannot remember what it was and I have slept since then. This morning your way seems better !
|
|
|
|
|
173
|
Using Arduino / Programming Questions / Re: Save state of Touch Screen
|
on: April 28, 2013, 03:56:07 pm
|
Now we know that it is possible to measure touch pressure the whole thing becomes easier. start of loop read finger position x y read touch pressure if touch pressure less than trigger level if x in red area save y coordinate to red variable end of if else if x in green area save y coordinate to green variable end of else else if x in blue area save y coordinate to blue variable end of else end of if set LED PWM values based on the 3 colour variables end of loop
|
|
|
|
|
174
|
Using Arduino / Programming Questions / Re: Save state of Touch Screen
|
on: April 28, 2013, 11:32:10 am
|
Paul, I see the problem with my idea but will your suggestion work either ? Since either value may be dropping from a good reading back to 0, after a finger is lifted. then all bets are off as to where the finger was when it was touching the screen as no value of Y may be safely regarded as within the "save the X coordinate" range unless I have misunderstood what you meant. I cannot see a way of leaving the LED at its RGB values returned when the finger last touched the screen without the use of another button which is pressed to record X and Y, and released to hold the last recorded values.
|
|
|
|
|
175
|
Using Arduino / Programming Questions / Re: Save state of Touch Screen
|
on: April 28, 2013, 08:35:06 am
|
start of loop read finger position x y if y > 0 if finger in red area save y coordinate to red variable end of if else if finger in green area save y coordinate to green variable end of else else if finger in blue area save y coordinate to blue variable end of else end of if set LED PWM values based on the 3 colour variables end of loop The RGB variables could be a single array with 3 elements if you want.
|
|
|
|
|
176
|
Using Arduino / Programming Questions / Re: Isolate delay for certain pin over the normal sequence of code time.
|
on: April 28, 2013, 08:17:02 am
|
|
As suggested, look at the principle used in the BlinkWithoutDelay example.
Instead of the 'start something, wait until it is finished, now do something else' principle, which blocks execution of other code whilst the 'wait until it is finished' step is executed it works like this. 'start something, has enough time passed for it to finish ?, if so then react, else do something else'. The 'do something else' step can execute each time through the loop() function and can, itself, be another non blocking 'has enough time passed' step.
In this forum you will find many questions about this method of timing and analogies to it taken from real life such as 'put meal in oven, stand by oven until cooked, eat meal, now watch TV' (the blocking approach) and 'put meal in oven, watch TV, check every so often whether enough time has elapsed for the meal to cook, if so eat the meal, else carry on watching TV'
Which would you rather do ?
|
|
|
|
|
178
|
Using Arduino / Programming Questions / Re: Help robot sketch filippo
|
on: April 27, 2013, 04:29:22 pm
|
|
One or more of the following is wrong :
You did not include the IRremote library in your program. The IRremote library is installed in the wrong place on your computer. You did not stop and start the IDE after installing the IRremote library.
|
|
|
|
|
179
|
Using Arduino / Programming Questions / Re: Trying to understand Functions
|
on: April 27, 2013, 12:40:58 pm
|
is both telling the function what variable is to be the result and also what variable is to be read. Is that correct? And it is called because that is where it is in the code. If there where an if statement before that line of code, the if would need to be true before the function is called, correct? Correct. Try changing the value sent to the function from 250 to 1000 to see the effect of passing a different value to the function. Your other observation ie that the program does not do what they say it will, is also correct ! Confusing, or what ?
|
|
|
|
|
180
|
Using Arduino / Programming Questions / Re: Trying to understand Functions
|
on: April 27, 2013, 12:04:15 pm
|
As to the first question, how is your circuit wired ? Is it exactly as in the book ? Your second question, When the blink3() function is called like this int count = blink3(250); the value in the brackets is sent to the function. The function definition int blink3(int period) indicates that it expects to receive an integer and that in the function the name of the variable holding the int will be period. The int preceding the function definition indicates that it will return an integer value, in this case the number of times that the LED blinked (held in the function in the result variable, hence return result). On return from the function this value is assigned to the count variable ready to be printed.
|
|
|
|
|