Show Posts
Pages: 1 ... 39 40 [41] 42 43 ... 52
601  Using Arduino / Programming Questions / Re: waiting for input from keypad? on: April 21, 2011, 10:15:41 am
What keypad are you using and how is it connected to your Arduino?
602  Using Arduino / Programming Questions / Re: multifunction on: April 21, 2011, 09:12:52 am
Learn C++.  Then you will understand.

Google is your friend.  Try Googling a few of the following:
learning c++
c++ tutorials
getting started with c++
603  Using Arduino / Programming Questions / Re: How to receive two digit number by!n00b! on: April 21, 2011, 09:10:08 am gets a single character.

'1' is a single character.
'2' is a single character.
'20' is two characters.

I recommend separating your numbers by some non-numeric character (typically a comma).  Then you can read in characters until you see a comma, and pass those characters on to atoi() to get the int value of those characters.  Done right, it should be able to handle any size number (though you will still be limited by the size of number int can store, or long if you switch to that datatype).
604  Using Arduino / Programming Questions / Re: multifunction on: April 21, 2011, 08:31:35 am
  TIM_Stop() ;
  TIM_Set(10000) ;
  TIM_Start() ;

You've defined these function as members of your timer class.  As a result, they are only accessible through an instance of your timer class, ex:

timer myTimer;


That being said, since your timer class depends on the hardware timer, it's really not suited to creating multiple instances of timer.  You can address that by making the timer class a singleton (not really recommended), or declaring all your methods as static, making them accessible without creating an instance of the class.

I'd personally recommend you go back to the basics and learn more about how to use classes in general.  Google can provide plenty of online resources for doing so.
605  Using Arduino / Programming Questions / Re: multifunction on: April 20, 2011, 10:13:36 am
606  Using Arduino / Programming Questions / Re: How to run the program only ONCE? on: April 19, 2011, 11:24:27 am
My favourite is:
#define EVER (;;)

// then...
for EVER;

Hehe.  I like that.
607  Using Arduino / Motors, Mechanics, and Power / Re: Possible to move 2 motors, simultaneous, smoothly, accurately? on: April 19, 2011, 07:13:29 am
What type of servos were you using?  Not all servos are created equal.  What sort of positioning resolution do you  need out of the system?

The micro gear motors are only going to be half of what you need.  The motors themselves have no positional control to speak of.  You'd need some form of encoder feedback and then a controller to handle positioning of the motors, not a trivial task.  So actually, they're only about a third of what you need.

What you may want to do is look at the dynamixel servos.  They may provide the control you need.  They will not work with the sparkfun pan/tilt, but Trossen Robotics provides a dynamixel compatible pan/tilt platform as well as the dynamixel servos themselves.
608  Using Arduino / Programming Questions / Re: teensyduino code on: April 18, 2011, 01:19:22 pm
If you want to be able to handle more than 6 buttons, the code will get a bit more complicated as the USB Keyboard protocol only allows registering up to 6 keypresses at the same time (this is why the Teensyduino keyboard class has six separate methods for issuing a keypress).

Up to 6 buttons can be done fairly easily by duplicating this block of code:
boolean boolBtnUp = !digitalRead(pinBtnUp);
  if ( boolBtnUp )
    //Set key1 to the U key
    Keyboard.set_key1( KEY_U );
  } else {
    Keyboard.set_key1( 0 );

up to six times, changing the set_key# function that is called for each one, from set_key1() to set_key6().  As I said at the beginning though, writing code to handle  10 buttons becomes a non-trivial task (and you still would not be able to register more than 6 button presses at any one time)
609  Using Arduino / Programming Questions / Re: Arduino & thread on: April 18, 2011, 09:15:07 am
simply believe it is better to avoid putting the "RTC.refresh ()", solving with something that just works without requiring you to manually refresh, so I thought of the thread.

That can be solved using one of the hardware timers.  Look at the Timer2 library in the Playground.  You'll see that, once it's set up to run at some interval, there is no regular 'refresh()' call required in the main loop.  Threads are not only not necessary, but the complete opposite of an elegant and clean solution to a rather simple problem.

Though to be perfectly honest, the perceived issues with using a refresh() call in the main loop are questionable as well.  The whole point of loop() is to execute code over and over and over, so any objections to using it for that purpose are objections to it's whole existence.

Utilizing a hardware timer requires the use of an Interrupt, which has it's own suite of snares and hurdles to deal with, and should really only be used when real accuracy is required, and I can't think of anything involved with controlling an aquarium that would require more than second resolution accuracy, never mind millisecond or microsecond resolution accuracy.

So, to put it simply, I simply believe it is better to use an RTC.refresh().  You're creating a problem where there isn't one, and looking for a solution that is more complicated, more error prone, and more obtuse.
610  Topics / Robotics / Re: How to control a 4wd robot to move by arduino? on: April 14, 2011, 03:39:32 pm
1.The code above controls only two motors, when I control four motors, where should I change?

When dealing with fixed orientation motors/wheels, controlling four motors is the same as controlling two motors, because you should be controlling the motors in pairs.  There's no reason for the two motors on the left side to be driven separately (same for the right side).  Ideally, just wire the two left motors in parallel to the motor controller (making sure the motor controller can handle the current of two motors), and then wire the two right motors in parallel to the motor controller.
611  Using Arduino / Programming Questions / Re: Converting String to an Integer. on: April 14, 2011, 07:57:11 am
612  Using Arduino / Programming Questions / Re: To debug or not debug... That, is the question! on: April 14, 2011, 07:54:19 am
I was describing the behavior when the USART has not been enabled, as that was the original posters question regarding how prints work without any call to begin().  If the USART has not been enabled, then the UDRE bit of UCSRA register will always be set, because the USART will not spend any time shifting out any data, and in fact won't even bother clearing the UDRE bit when you push a byte into the UDR register.

If the transmitter is enabled, then it's a completely different story.
613  Using Arduino / Programming Questions / Re: Using encoder,visal basic GUI control motor on: April 14, 2011, 07:42:52 am
I find it hard to believe that code will ever stop the motor for several reasons.

1.  Your encoder0Pos needs to be declared volatile.

2.  You are checking your encoder0Pos value in your stop1000() function, but you only call that function 1 time when you receive an A character.  You need to be checking the value repeatedly until your stop condition has been met.

3. You're only stopping the motor when encoders0Pos exactly equals 1000.  You can't be guaranteed that the code will perform the check when the encoder value is exactly 1000.  If Encoder0Pos equals 1001, then you've missed your small window for stopping the motor.  A better approach would be to stop the motor when Encoder0Pos is greater than 1000 (but of course, you still need to be repeatedly checking the value)

614  Using Arduino / Programming Questions / Re: To debug or not debug... That, is the question! on: April 14, 2011, 07:11:19 am
2) Even if they go nowhere, at 9600 baud, they delay your program by over 1ms per character.

If the USART Transmitter has not been enabled, then it will not spend any time shifting out any characters put into the Transmit register.  The Data Register Empty and Transmit Complete flags will always be true.  The only time that will get consumed is the write operation pushing characters into the Transmit buffer and waiting for the UDRE flag to get set (which will always be set).  This still takes some time, but it'll be on the order of a few microseconds per character.

That being said, it's still a poor method of enabling/disabling debug messages.  The method westfw presents is far better (and doesn't prevent you from using the serial port for other purposes as well).
615  Using Arduino / Programming Questions / Re: Looking for feedback on and someplace to put a Tutorial on: April 13, 2011, 12:19:59 pm
I looked at the Playground myself, and it seems like an appropriate place to put the tutorial.  However, it says you have to request 'Contributor' access to submit stuff to the Playground, and the page to request such access doesn't work for me.  Instead of getting a form, I just get "(:registerform:)"

Pages: 1 ... 39 40 [41] 42 43 ... 52