Show Posts
Pages: 1 ... 117 118 [119] 120 121 ... 209
1771  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 03, 2013, 01:35:41 am
Multiply it by 10^n where n is the number of digits after the decimal point.
Assign the resulting value to an int or long depending on the size of n.
Do something like this to actually stuff it into the string:
Code:
sprintf(buffer,"MyFloat: %d.%d", myInt/n, myInt%n);
Where myInt is the result from the previous step and n is the number of digits of precision.
1772  Using Arduino / Programming Questions / Re: Sorting an array on: February 02, 2013, 02:04:44 pm
Just do a scan before the bubble sort in the same function. A single for loop that keeps track of the highest number and it's index would suffice.
1773  Topics / Home Automation and Networked Objects / Re: Arduino and the internet? on: February 02, 2013, 12:47:44 pm
Controlling the Arduino over the internet versus just the local network has nothing to do with the Arduino's code and everything to do with your network setup. Assuming you are using a small home router that provides NAT (Your local IP address is different from your external address), then you would need to configure your router to forward port 80 (or whichever port you are using) to your Arduino. Some ISPs block port 80, so that's something to keep in mind.

How to forward ports on your router depends on the router you are using. Typically, you need to log into the web interface of your router and look for the port forwarding option.
1774  Using Arduino / Programming Questions / Re: Need some pointers on some code on: February 01, 2013, 05:28:37 pm
Still not sure I understand, but here is a general answer:

Code:
if switch is pressed
  do your override stuff
else
  check potentiometer
  do potentiometer stuff

If you need help reading the state of a switch, just take a look ant many of the examples posted.
1775  Using Arduino / Programming Questions / Re: Need some pointers on some code on: February 01, 2013, 05:12:13 pm
Thats it yes Im looking to have a condition in there of some sort so that it removes that 3 rd display with out moving the potentiometer.

What do you mean "3rd" display? I thought you only had one digit?
1776  Using Arduino / Programming Questions / Re: Need some pointers on some code on: February 01, 2013, 04:44:07 pm
Thanks...like I said Im a real newbie. smiley-zipper

Iv got the numbers 1 to 7 showing as I turn the knob in one direction and when I turn it back it counts back down.

At the 3rd display when turning the knob I need to then flip a switch and it shows up the 4 th digit without turning the knob.

hang on,,, I am the knob here  smiley-grin


You still need to define your requirements a little more. Do you mean the switch will act as an override?
1777  Using Arduino / Programming Questions / Re: Need some pointers on some code on: February 01, 2013, 04:11:28 pm
turn off the write 3 and turn on write 4

What does that mean?
1778  Using Arduino / Programming Questions / Re: Using timers to stay in a loop. on: January 30, 2013, 03:42:01 pm
I understand, I thought about that.  How can I stay in that condition under a certain amount of time.  If that limit is reached then the code needs to move on to the next part.

The Blink Without Delay uses an if statement to check if it has been a certain time. Using a while instead will cause the code to get "stuck" in that part of the code until the condition is no longer met.
1779  Using Arduino / Programming Questions / Re: Using timers to stay in a loop. on: January 30, 2013, 03:24:54 pm
Code:
void loop() {
  ...
 fgo();
}
//-------------------------------------------------------
void fgo(){
...
 loop();
}

What you have here is recursion and I'm certain that's not what you are looking to do. I'm guessing that you see these function calls as more of a "go to this part of the code", which simply isn't the case.

If you want to stay within a certain portion of code until a condition is met, you need a while loop:

Code:
while (condition)
{
  // Execute code
}
1780  Using Arduino / Programming Questions / Re: Which is 'cheaper': max length char array or counting bytes? on: January 30, 2013, 10:25:31 am
Unless you are starving for those extra 50 bytes of SRAM, going from n to 2n isn't worth it.
1781  Using Arduino / Programming Questions / Re: Serial monitor infinite output on: January 28, 2013, 12:20:16 am
so the new code will be like this?

Why not try it and tell us?
1782  Using Arduino / Programming Questions / Re: Serial monitor infinite output on: January 27, 2013, 02:08:23 pm
Sounds like floating pin syndrome.

Enable the internal pull-up resistor on the pin.
1783  Using Arduino / Programming Questions / Re: Help with bytes, ints, longs on: January 26, 2013, 11:10:15 am
Sounds like an issue of Big Endian Vs. little Endian.
1784  Using Arduino / Programming Questions / Re: setting digital/analog pins by binary on: January 25, 2013, 11:38:41 am
PORTB = 64

It's converted to binary upon compilation already.
1785  Using Arduino / Programming Questions / Re: Button Sequence question on: January 24, 2013, 02:44:19 pm
Finite State Machine.
Pages: 1 ... 117 118 [119] 120 121 ... 209