Show Posts
Pages: 1 ... 347 348 [349] 350 351 ... 510
5221  Using Arduino / Programming Questions / Re: Serial.print Problems on: July 15, 2011, 03:00:01 pm
Enough discussing and no code. Post the code.
5222  Using Arduino / Programming Questions / Re: Serial Echo on: July 15, 2011, 02:23:29 pm
Code:
  while (1)


Huh?

Think for a moment that you are the arduino, waiting tirelessly at the end of a serial line for a character to come in, how do you indicate your perseverance? You keep waiting with while (1), until that character comes through and you break the endless waiting and checking.
5223  Using Arduino / Programming Questions / Re: Serial Echo on: July 15, 2011, 02:11:24 pm
Code:
/*
* Reflect serial input back.
 */

int number=0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  for (int i=0;i<4;i++)
  {
  while (1)
    {
      if (Serial.available())
      {
        number *= 10;
        number += (Serial.read() - '0');
        break;
      }
    }
  }
  Serial.print((float)(number)/1000.0);
}




5224  Using Arduino / Programming Questions / Re: Serial Echo on: July 15, 2011, 01:56:50 pm
I want a 3 digit fixed float, i.e. w.xyz for testing my DAC (feed in a voltage, check on DMM)

Thanks!
baum

Ha ha ha fixed float, what an irony. So you want a fixed point number, not a floating point number. Having a decimal point doesn't make a number a floating point number smiley
If you just need w.xyz, I suggest you not transfer the dot so it will look like wxyz and then arduino takes it and converts it into w.xyz

The code should be quite simple:

take four numbers from serial, subtract each by '0', multiple by power of 10 and add. Your posted code doesn't have a mechanism to break away once 4 digits have been transferred so add a for loop to only read serial 4 times.
5225  Using Arduino / Programming Questions / Re: Serial Echo on: July 15, 2011, 01:45:21 pm
There is no way you can do this without either an end-of-line character or a pre-determined fixed length in characters of the number. Say if I want to send the value of PI, how will arduino know when to say it has got everything?

Turning the serial input into numbers is very easy by itself once you have one of the above rules in place, either fixed length or flexible length with end-of-line character. Just use sscanf to extract number. No need to parse digit by digit. You're reinventing the wheel.
Heuristic ways exist like, if you have not received any characters within the last second the consider it done. It's not a good way when where are good ways you can take.
5226  Using Arduino / Programming Questions / Re: Error in Serial.available() on: July 15, 2011, 01:24:32 pm
As what AWOL said, a delay is a heuristic solution and is prone to overflow  smiley-wink. I would suggest the OP use end-of-message character, such as '\n' to indicate the end of one line of message so arduino will keep reading the serial port (when there is data) and buffer the data in memory until it receives this end-of-message character and then takes the whole string and processes it.
5227  Using Arduino / Displays / Re: Serial LCD BPK help !!!!!!! on: July 14, 2011, 11:11:18 am
That's what I suspect, the inverted logic as written in the document. BTW you can take robtillaart's suggestion to use NewSoftSerial, which can be set to output inverted logic.

I have a question for you: did you buy this display for a PIC?
5228  Using Arduino / Displays / Re: Another Backlight Question on: July 14, 2011, 10:21:11 am
I used a 220 ohm resistor. And I have not measured voltage on pin 19 or 20.

When i received the board it came pre wired on the breadboard and the back light worked.

I have not seen any seller doing this type of service before, kind of nice. Where did you get the display from?
5229  Community / Bar Sport / Re: If you post same question on multiple forums, are you cross-posting? on: July 14, 2011, 10:02:45 am
This discussion has made me think about the fact that occasionally an OP disappears in the middle of a discussion or before letting the forum know whether proposed solutions worked. Maybe they got help elsewhere, solved the problem but didn't get back. This is impossible to track down but I think this type of behavior should not be encouraged. I should probably ask on other forums about the same question but maybe I'll be considered cross-posting myself smiley-wink
5230  Community / Bar Sport / Re: If you post same question on multiple forums, are you mulit-posting? on: July 13, 2011, 04:48:12 pm
Just want to know people's general opinion. Let's say if the OP can't keep updating both threads on both forums then those helpers on the forum that gets less updates from the OP are hanging there wondering if their helps worked or not.
5231  Community / Bar Sport / If you post same question on multiple forums, are you cross-posting? on: July 13, 2011, 04:38:11 pm
Today I found someone posting exactly the same questions on arduino forum and at leas another online forum. I wonder how people feel about this compared to cross-posting on the same online forum. Apparently there are similarities and differences so what do you think?
5232  Development / Other Software Development / Re: keypad library with shift registers on: July 13, 2011, 02:22:56 pm
Just realized that my design can only work if one key is pressed at a time per row. If two keys are pressed in the same row and only one is being sensed, there will be a short between these two columns. I guess only I/O pins can avoid that by setting the columns not being sensed to input with internal pullup resistor and only setting one column pin to output LOW at a time. This way multiple key presses can be detected without shorting any circuit. Well, with a simple pad I don't really expect ctrl+alt+del type of input so should be OK.
5233  Using Arduino / Programming Questions / Re: String to Int on: July 13, 2011, 01:36:03 pm
http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/
5234  Using Arduino / Programming Questions / Re: Help: Reading digital pins goes crazy on: July 13, 2011, 10:56:55 am
Every time a function gets called, a small amount of memory is used to store information on how to return from the function. If you keep calling functions, these small amounts add up and will overflow in memory and your functions never returning doesn't help either. It's like in your dream you fall into another dream, then in that dream you fall into another dream and deeper and deeper until you can not return to reality any more (Sorry I was watching total recall last night, twice).
5235  Using Arduino / Displays / Re: Serial LCD BPK help !!!!!!! on: July 13, 2011, 10:44:26 am
Can you try more delays right after you send the clear screen because this command may take more than 5ms to run. You only gave it 5ms.

If you forget the clear screen for a moment and just print one character at a time every second, do you see any characters appearing on the screen?

The screen seems to be a design 10 years old so the hardware may be that old too, there is a chance it is broken.
Pages: 1 ... 347 348 [349] 350 351 ... 510