Loading...
  Show Posts
Pages: 1 ... 8 9 [10] 11 12 ... 93
136  Using Arduino / Programming Questions / Re: IRQ while processing Delay. on: April 30, 2013, 01:35:17 am
Drop the delay.  Go on, you know you want to, you know you you ought to.  Do the right thing.

I assume that your question about interrupts during delay() was because you are thinking of triggering an interrupt with the switch.  No need. millis() is the way to go.  I would also suggest that you break out some of the stuff in loop() into their own functions with meaningful names.  Easier to read and maintain.
137  Using Arduino / Programming Questions / Re: Turning 6 inputs into a Binary Number on: April 30, 2013, 01:16:37 am
Have a look at the bitWrite function.
Code:
for count 0 to 5
  bitWrite(variable, count, digitalRead(count))
end of for
The real code would use an array to hold the pin numbers of the switches indexed by the count variable
138  Using Arduino / Programming Questions / Re: No information on serial monitor from Leonardo on: April 29, 2013, 10:13:07 am
I sometimes find the Leonardo temperamental to use with the Serial monitor compared with the Uno.  I prefer the Uno because starting the Serial monitor restarts the program, but that might not always be what you want.  Make sure that you set the Serial monitor baud rate to 9600 to match the program, but the TX LED should flash anyway, as should the LED in pin 13

Your program works for me on Windows 7, IDE 1.0.4 with a Leonardo.
139  Using Arduino / Programming Questions / Re: SD data logger ain't logging to the SD card on: April 29, 2013, 07:11:57 am
You have no code to prevent the creation of a new file each time that the loop() function starts.  Test the state of ENABLE_PIN before creating a new file at the start of loop().  If it is LOW then don't create a new file, take any readings or attempt to file them, else, do what you do now.
140  Using Arduino / Programming Questions / Re: Controlling the rotation of Servo Futaba S3003 on: April 29, 2013, 05:51:04 am
Quote
When I try your code, the servo turns for 2 seconds and after that, turns with a lower speed. I think that it turns with the speed of the first  provided value (170) and then with the last (10). Without any stop.
Does it significate that it was modified?
It has been modified otherwise it would move to a position, stop, wait, move to another position, stop, wait and repeat.  If it does not reverse direction with values of 170 and 10 but only changes speed then there is another complication.  The potentiometer in the servo has probably not been centered which would give the outcome that you report.
141  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.

Quote
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 ?
142  Using Arduino / Programming Questions / Re: Arduino software reset on: April 29, 2013, 05:29:05 am
Very true, but alas I don't own the Internet, and sometimes it doesn't
do what I want.

Will

What has that got to do with resetting an Arduino ?
143  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.
144  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
Code:
#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.
145  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.
146  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.
147  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: April 29, 2013, 01:18:52 am
Quote
  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 !
148  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.
Code:
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
149  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
Quote
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.


150  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: April 28, 2013, 08:35:06 am
Code:
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.
Pages: 1 ... 8 9 [10] 11 12 ... 93