Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 285
151  Using Arduino / Programming Questions / Re: Writing potentiometer value to EEPROM over 255 on: August 04, 2014, 02:43:44 pm
Quote
Actually, no. as long as you're consistent in reading and writing.
That seems no different to me than being consistent using lowByte() and highByte() and reading and writing.
152  Using Arduino / Programming Questions / Re: valve system code (servo help) on: August 04, 2014, 12:32:31 pm
Have either of you looked at the Sweep example in the IDE ?

It does not move as fast as possible but it will get you started and let you experiment with the servo to make sure that it is wired correctly.  Once you know that it works then making the servo move directly from 0 to 180 is trivial, as is adding a wait at 180 degrees using either a simple but limiting method or a slightly more complicated but more flexible method.

Feel free to post your programs here even if they don't work as required but please include a description of what they should  do, what they actually do and/or any error messages.
153  Using Arduino / Programming Questions / Re: Writing potentiometer value to EEPROM over 255 on: August 04, 2014, 09:57:51 am
Quote
Don't you think it would be better to reassemble them in the correct order?

Exactly right, Paul, which is why I think the union approach is easier to understand, less error prone, and more portable.
Each to his own, but I can't see that the union approach is easier.  Although it removes the need to take the endian order into account when referring to the int in the union don't you still have to use the correct array index to refer to the high and low bytes individually ?
154  Using Arduino / Programming Questions / Re: Writing potentiometer value to EEPROM over 255 on: August 03, 2014, 11:36:33 am
Here is the code I have. I added the word function, which from the documentation should be written correctly, but it only outputs 0, nothing happens.

Code:
....
    EEPROM.write(10, word(myHigh, myLow));
 ....
EEPROM.write() writes a single byte to a single location.
You could use
Code:
    EEPROM.write(10,myHigh);
    EEPROM.write(11, myLow);
to write to successive locations then read back the 2 bytes and combine them using word()
155  Using Arduino / Programming Questions / Re: Writing potentiometer value to EEPROM over 255 on: August 03, 2014, 08:44:05 am
This should give you an idea of how to do it.
Code:
void setup()
{
  Serial.begin(115200);
  int myInt = analogRead(A0);
  byte myHigh = highByte(myInt);
  byte myLow = lowByte(myInt);
  Serial.println(myLow);
  Serial.println(myHigh);
}

void loop()
{
}
156  Using Arduino / Programming Questions / Re: TFT bar graph on: August 03, 2014, 05:39:49 am
What library are you using ?  I would expect it to provide functions to draw primitive shapes such as lines and circles and to turn blocks of pixels on and off.  In the case of a bar graph, turning on a block of pixels would to equivalent to turning on an LED but you will be able to get much finer resolution using the TFT display.
157  Using Arduino / Programming Questions / Re: TFT bar graph on: August 03, 2014, 05:17:21 am
What have you managed to do with the TFT so far ?
Can you set and unset pixels on it, or maybe turn a block of pixels on and off ?
158  Using Arduino / Programming Questions / Re: arduino code not working???? I am newbie at arduino programming on: August 03, 2014, 05:13:27 am
Quote
it is not working
Can you describe what it is doing ?

Put some Serial.prints into your program so that you know which parts of it are being executed and what the values of essential variables are at various points.

Read up on the LCD library.  Could you perhaps use the lcd.clear() method instead of your function to do the same thing, for instance ?
159  Using Arduino / Programming Questions / Re: arducopter althold on: August 03, 2014, 04:25:45 am
Some guesses and inferences from the context

what is  p_thr_alt_p (actually p - thr_alt_p) doing?
Calculates the error between the p value for the altitude and the target altitude

what is limit 250 mean?
Limits the value calculated above to 250

what is limit 0.5g to 1.5g  mean?
Limits the rate of change to between 0.5G and .5G

what is earth to body frame translation mean?
Don't know

what is limit throttle_max mean?
Limits the maximum throttle applied to accomplish the change in altitude


Do some reading on PIDs if you haven't already.
160  Using Arduino / Programming Questions / Re: button as toggle switch for a servo on: August 02, 2014, 04:50:55 pm
Code:
pos = pos ? false : true;
or just
Code:
pos = !pos;
161  Using Arduino / Programming Questions / Re: button as toggle switch for a servo on: August 02, 2014, 10:53:46 am
Code:
  currentState = digitalRead(buttonPin);
  if (currentState == HIGH && lastState == LOW)
  {//if button has just been pressed
Because you have used INPUT_PULLUP in the pinMode() for the button its normal state will be HIGH and it will go LOW when pressed, assuming that is that the button os wired to take the input LOW when pressed.  Your comment is therefore wrong.
162  Using Arduino / Programming Questions / Re: libraries on: August 02, 2014, 08:43:42 am
Installing libraries ready to be used in programs is simple.

Each library goes in a folder in the libraries folder of the sketch directory.  Each library will usually consist of a .h file and a .cpp file each with the same name.  The library folder must have the same name as the .h and .cpp files.  Note that 'same name' means that they must be exactly the same.

Once installed close and restart the IDE to make the library available for inclusion in a program.
163  Using Arduino / Programming Questions / Re: Unlogical but simple errors coming from P5 to arduino on: August 02, 2014, 08:26:43 am
Sorry, I found out that the error in the code is totally somewhere else as where the error message said, so the lines I posted won't help.
Which is why it is always best to post or attach a whole program that exhibits the problem.
164  Using Arduino / Programming Questions / Re: LED Timer on: August 02, 2014, 02:25:00 am
You have this line in your program
Code:
if  (time =< 20)
but as the time variable is never updated after it is declared and initialised to zero the test is meaningless.

Try setting time = millis()/1000 just before the test.
Incidentally, the outer braces around your if/else are unnecessary and your program will not compile because of the missing semi-colon on
Code:
  lcd.print(millis()/1000)
and =< needs to be <= in the test
165  Using Arduino / Programming Questions / Re: declaring several arrays (LUTs) on: August 01, 2014, 02:17:18 pm
Before you go any further could you please say which Arduino you have as your proposed arrays are chewing up an awful lot of memory.
Pages: 1 ... 9 10 [11] 12 13 ... 285