Show Posts
Pages: 1 ... 17 18 [19] 20 21 ... 289
271  Using Arduino / Programming Questions / Re: Library Error --> " 'TwoServoAdapter' does not name a type ". on: July 27, 2014, 04:37:51 am
Quote
Could you suggest any possible issues?
Yes, the current drawn by the servo may exceed the rating of the voltage regulator on the Arduino.  This could potentially damage the regulator and/or cause brownouts of the supply to the Arduino as the servo draws current.  This is particularly the case when the sevo first starts running as it will draw its stall current which is somewhere between 415 and 700 mA according to the servo data sheet.  This is way over what the Arduino regulator is rated to provide.

Powering a servo with 3V is also not a good idea, particularly as the servo is rated to run on 4.8V.  The batteries will not even maintain 3V for very long which will make things even worse.  What is the actual voltage supplied by the voltage regulator ?
272  Using Arduino / Programming Questions / Re: Library Error --> " 'TwoServoAdapter' does not name a type ". on: July 27, 2014, 02:49:05 am
Hey guys, new discovery:

When I attach both my servos to a single power source, the first command my UNO gives it works well, but when tasked with another command after a delay or whatever, the servos go haywire and just keep spinning in the same direction they were in, sometimes even moving the servo that isnt even connected to the UNO!

FIX: I plugged one servo to the auxillary power source and one to the UNO's, and they worked fine. Im assuming that if you want to power both servos from one power source, your going to have to implement soem sort of hard wall that splits the current after which they can interefer --> DIODE?.
The behaviour that you describe is bizarre.  The only reason why a servo should move is if its signal wire receives a signal that is interpreted by the servo as a command.  Beyond needing a common GND, correct voltage and sufficient current it does not matter how they are powered.  Instead of "fixing" the problem in the way that you suggest you should track down and fix the  real problem.  Firstly, what type of servos are you using and are they actually servos or bastardised versions modified to run continuously ?

You mention using the UNO's power source for one of the servos.  Do you mean an external power source or the 5V and GND pins on the UNO ?
273  Using Arduino / Programming Questions / Re: pushbutton setpoint for temp controller on: July 27, 2014, 01:56:47 am
To make your code easier to read and maintain can I suggest that you format it differently.

For instance, instead of
Code:
if(temperatureC < x){
    digitalWrite(ledPin, HIGH)
    ;Serial.println("Heater ON");
    delay(delayTime);
   }
like this
Code:
if(temperatureC < x)
{
  digitalWrite(ledPin, HIGH);
  Serial.println("Heater ON");
  delay(delayTime);
}
The block of code executed when the condition is true is easier to identify and the extent of each statement is obvious because of the terminating semi-colon on the same line.  Above all format your code with a consistent style.

Also consider using arrays to hold button pin numbers in your program.  The reading of the buttons and setting the value of x could then be reduced to a few lines by using a for loop instead of multiple ifs.
274  Using Arduino / Programming Questions / Re: Programming assistance with a servo on: July 26, 2014, 04:04:01 pm
You cannot use the standard servo library if you need to output a PWM signal on pn 9.  There is an alternative servo library (ServoTimer2) that does not interfere with PWM on that pin but you will need to download and install it.
275  Using Arduino / Programming Questions / Re: Adding a Number to a Variable (once(!)) on the press of a Button on: July 26, 2014, 03:57:55 pm
You are changing the value of the variable while the button is pressed not when the button becomes pressed.  You need to change the program so that it only changes the variable when the button changes from not pressed to pressed.  As a guide to doing this look at the state change detection example in the IDE.

When you post code please put it in code tags not quote tags as it makes it easier to read.
276  Using Arduino / Programming Questions / Re: pushbutton setpoint for temp controller on: July 26, 2014, 03:44:58 pm
Thanks zaxarias! I modify my curly braces and that works!
Can we please see your working code ?  There was much more than missing braces wrong with it.
277  Using Arduino / Programming Questions / Re: Programming assistance with a servo on: July 26, 2014, 03:41:40 pm
Quote
Pin 9 is used by the LCD.
But you are trying to output a PWM signal to it which won't work with the servo attached.
From http://arduino.cc/en/reference/servo
Quote
On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins

What about the dodgy if command lines ?
278  Using Arduino / Programming Questions / Re: Programming assistance with a servo on: July 26, 2014, 03:10:47 pm
You don't say which board you are using but whatever else is going on using the Servo library prevents the use of PWM on pins 9 and 10 on boards other than the Mega so
Code:
uint8_t BLPin = 9;
and
Code:
  analogWrite(BLPin, backlightSetting);
won't work correctly.

Your real problem with controlling the servo is in these 2 lines
Code:
  if (press1 == LOW);
Code:
  if (press2 == LOW);
Study them carefully and compare them with
Code:
  if (Cursor >= columns)
279  Using Arduino / Programming Questions / Re: [half Solved, Still in doubt]button function return wrong on: July 26, 2014, 02:21:39 pm
In the program that you just posted this is the bPress() function
Code:
int bPress(int bPin){                                                             //button function

}
Mind you, as it is never called the fact that it does nothing is not a problem.

Can you please describe the problem with your current program ?

By the way, it is a good idea to save versions of your program as it evolves/changes so that you can go back and see what you did and how/why.
280  Using Arduino / Programming Questions / Re: button function return wrong on: July 26, 2014, 01:23:47 pm
Please do us, and yourself, a favour and post a complete program that exhibits the problem rather than bits and pieces.
281  Using Arduino / Programming Questions / Re: pushbutton setpoint for temp controller on: July 26, 2014, 12:22:06 pm
Code:
    int(24);
I assume that you meant to set a variable to a value with this and similar lines.

You nearly managed it with
Code:
   float (X=28);
but why the attempt to cast it to float and why does the value assigned to X never get used in the program ?
282  Using Arduino / Programming Questions / Re: [Solved]how to simplify createChar() custom character written to 2X16 lcd? on: July 26, 2014, 12:15:43 pm
Code:
  sprintf(myText, "%c%02d:%02d:%02d %c  PigOS", TIME, HR, MIN, SEC, TIME);
  lcdPrintXYSpecialLine(0, 0, myLine);
What's the point of using sprintf() to format a buffer (myText) with data then outputting a different buffer (myLine) ?
283  Using Arduino / Programming Questions / Re: Buttons and Led's - Button switching too quickly on: July 26, 2014, 11:29:11 am
Quote
Just so I know for future use, is there a reason starting at Pin 1 is a bad thing?
It is if  you want to use the Serial functions in your program because hardware Serial uses pins 0 and 1.  Even if your program does not intrinsically use Serial it is a good idea to allow for it to be used for printing debugging information whilst testing.
284  Using Arduino / Programming Questions / Re: SmartGPU2 Software Serial on: July 26, 2014, 11:21:25 am
As an experiment try using a name other than mySerial, but what I meant was put the
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(13,12);
in your main program file, not in the library.
285  Using Arduino / Programming Questions / Re: how to simplify createChar() custom character written to 2X16 lcd? on: July 26, 2014, 11:17:20 am
Quote
is so, is it possible to use words instead of this 0x02?
Yes.  Use #defines as suggested in an earlier reply or use an enum data type.  Either will allow you to use meaningful names that will be translated into numbers to access the corresponding user defined symbol.
Pages: 1 ... 17 18 [19] 20 21 ... 289