Show Posts
Pages: 1 ... 20 21 [22] 23 24 ... 290
316  Using Arduino / Project Guidance / Re: PING)) Ultrasonic Range Finder (#28015) on: July 24, 2014, 03:01:52 am
The principle is simple.

Start the vehicle moving forward then, each time through the loop() function measure the distance ahead.  If the distance falls below the required threshold then stop the vehicle.

Now it is up to you what you do to avoid the obstacle.
(a) Back off and turn randomly left or right and continue forward again.
(b) Move the distance scanner left and right to find a clear path then turn that way and continue forward again.
(c) Any other strategy that you can think of.

Start with the simple "move forward and stop when an obstacle is detected"  part of the program then expand it.  Or start even easier and write a program to just print the distance in front of the sensor and forget the vehicle movement for now.

Which part are you stuck on ?
How far have you got ?

317  Using Arduino / Programming Questions / Re: How to take serial in on 0 & 1 and output on 2 other pins on: July 23, 2014, 11:25:30 am
Have you looked at the SoftwareSerial examples ?  One of them does exactly what you describe.  Reduced to the bare minimum it is.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);

void setup() 

void loop()
  if (Serial.available())
318  Using Arduino / Programming Questions / Re: Waiting for Button Presses and Updating an Array on: July 23, 2014, 10:59:59 am
even though my button press is allowing me to exit the wait-and-hold while loop, it isn't using that button press status where I need it to - as part of the if statement.

What does the uniquePress method actually do ?

The documentation for the button library says
boolean uniquePress()

Checks to see if the state of the button has changed AND the button is pressed. This will only return true the first time the button has been pressed. (As opposed to the isPressed() which will return true as long as the button is pressed.
When your while loop exits because a button has been pressed and you use the uniquePress method again the button will still be pressed so the method will return false because button state has not changed.
319  Using Arduino / Programming Questions / Re: Photography - From buttons to keypad on: July 23, 2014, 04:51:00 am
I wish to run a photograpy sketch  writen for use with buttons and I would prefer to  use a keypad 
Which Arduino board are you using ?
320  Using Arduino / Programming Questions / Re: Waiting for Button Presses and Updating an Array on: July 22, 2014, 04:09:32 pm

I've changed my array and YesNo variables to boolean type. After adding in the printArray function I'm still getting an error very similar to the last one:
call of overloaded 'print(char* (&)(const char*,int))' is ambiguous

I am sorry I am not providing more informative questions. I have more or less hit a brick wall and am having a huge mental block at the moment.
Please post your new program.
321  Using Arduino / Programming Questions / Re: Waiting for Button Presses and Updating an Array on: July 22, 2014, 12:48:16 pm
Whatever else may be wrong, this for loop
 for (channelCycle = 1; channelCycle <= 12; channelCycle++){
has the wrong boundaries.  The channelUsage array is defined as having 12 elements which are indexed from 0 to 11, not 1 to 12, so this
channelUsage[channelCycle] = YesNo;
will write outside the array memory after which all bets are off.

Incidentally, by declaring the array as an int you are wasting space.  Declare it as of type byte or better still use 12 bits of a single int to hold the switch states.
322  Using Arduino / Programming Questions / Re: Reading the value of a sensor every X millis (best practise?) on: July 22, 2014, 07:14:27 am
In the 'blink without delay' code, the main action is defined into the IF branch and we don't have any ELSE branch
That's because an else is not needed.  The logic is not to turn the LED on or off at the right time OR do something else, it is to to turn the LED on or off at the right time then ALWAYS do something else.  Having said that, there could also be conditions on whether the something else happens, but that is independent of turning the LED on or off or leaving it in its current state.
323  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 21, 2014, 03:05:35 pm
Try the servo sweep program.  If the servo works with that then it is OK.

Did we establish how the servo is powered ?  From the Arduino 5V and GND pins or from the external supply ?
324  Using Arduino / Programming Questions / Re: what happens with output after if state isn't true? on: July 21, 2014, 02:01:53 pm
Once you have turned a pin HIGH or LOW with digitalWrite() it stays in that state until you explicitly change it.
325  Using Arduino / Programming Questions / Re: aduino uno+ethernet+gsm on: July 21, 2014, 05:45:06 am
How about starting with the example Ethernet programs and writing to Serial ?  Then you can move on to sending an SMS once you know that you are receiving the correct data to send.
326  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 21, 2014, 04:53:36 am
but it is better to use a pull-up resistor
Why ?

and the internal one is easiest.
Agreed wholeheartedly
327  Using Arduino / Programming Questions / Re: RPM measurement without attachInterrupt? on: July 21, 2014, 04:47:58 am
millis() - startTime >= setTime
That line of code is checking whether the required period of time (setTime) has passed between now (millis()) and the start time of the activity (startTime).  If so, then it is time to do something because the period has elapsed.  If not then go and do something else, such as reading a sensor or switch, and check again if the period has elapsed next time through loop().  Unlike using the delay() function the program does not stop whilst the period of time passes..
328  Using Arduino / Programming Questions / Re: reset static variable on: July 20, 2014, 04:41:49 pm
I don't understand what the OP wants to do either, but is there some confusion between static and const going on here ?
329  Using Arduino / Programming Questions / Re: Can't get a loop to work. on: July 20, 2014, 02:23:12 am
        while (lastPosition == currentPosition)
          currentPosition = analogRead(sensorPin);
          lastPosition = currentPosition
Note, however, that this relies on the pot returning exactly the same value all the time when stationary which is unlikely.  It would be better to build in a check to see of the pot value has changed and by how much.
        while (abs(lastPosition - currentPosition) < 20)
330  Using Arduino / Programming Questions / Re: Multiple Inputs on: July 19, 2014, 04:05:03 pm
Can you please explain more clearly what you want to do ?

Is switch 1 held on and then you wait for switch 2 or can switch 1 be pressed and released and switch 2 pressed within a time limit ?  If the latter, then if switch 2 is not pressed within the time period should the system forget the switch 1 press and start waiting for it again ?
Pages: 1 ... 20 21 [22] 23 24 ... 290