Show Posts
Pages: 1 ... 59 60 [61] 62 63 ... 71
901  Using Arduino / Programming Questions / Re: Solved: coverting a concatenated string to float on: December 05, 2011, 10:59:35 pm
I am ignorant of the meaning of the words "software serial read blocking".
FTFY

software serial = a  serial connection on pins other than 0 and 1
read = a function that looks at what was sent over the serial
blocking = takes a lot of time; more specifically don't go on to the next function until some sort of external response is gotten (in this case, whether or not read() returns some value if nothing was received over the serial lines).

Broken down:
Is ((the (software serial) read()) blocking)?
"Does the read() function used by the software serial library wait until a character is received, or does it just give an "error" value?"
902  Using Arduino / Programming Questions / Re: how to use if statement on: December 04, 2011, 08:58:04 pm
Might you want to move the servo if the sensor was either above 725 OR below 720?

Code:
if (pinkyflex > 725 && pinkyflex < 720) {
  pinkyservo.write(pinkyflex);
}
903  Using Arduino / Programming Questions / Re: Timed method on: December 03, 2011, 11:58:08 pm
If the code is just like this:
Code:
requestStuff();
while (haventReceivedStuff());

you could change it to this:
Code:
requestStuff();
unsigned long beginTime = millis();
while (haventReceivedStuff() && millis() - beginTime < 10000);

or, if you want to be notified of the failure:
Code:
requestStuff();
bool timedOut = false;
unsigned long beginTime = millis();
while (haventReceivedStuff()) {
  if (millis() - beginTime < 10000) {
    timedOut = true;
  }
}

...which is essentially Paul's first suggestion.
904  Using Arduino / Project Guidance / Re: DIP switch? on: December 03, 2011, 12:50:02 am
I think your code may look a little more like this:
Code:
if (digitalRead(switch1Pin)) {
  digitalWrite(LED1Pin);
}
else if (digitalRead(switch2Pin)) {
  digitalWrite(LED2Pin);
}
905  Using Arduino / Project Guidance / Re: Driving lots of 7-segment displays. (Or possibly 14-segment) on: December 03, 2011, 12:48:04 am
Try checking out the MAX7221 chip. It's pretty expensive ($10) but you don't need to wire up resistors for the LEDs (save one for setting current) and you can just send it a string like "09221" over SPI (three pins) and it'll display them (ie a 7segment decoder). It can handle up to 8 digits (and you can string them up without using any extra arduino pins). It'll also do a LED Matrix if you like those.

The only other reasonable option from a string of breadboards is to have a custom PCB. And if you go with the breadboard route, the wiring will get pretty intense. Then again, custom PCBs are scary and somewhat expensive.

Also, you really don't need to worry about update speed; I doubt anything you'll have will be slower than the PC Serial connection, and you can only really perceive updates more than about 50ms apart (I believe that's 80000 clock cycles).
906  Using Arduino / Installation & Troubleshooting / Re: I think deleting WProgram.h was a bad idea on: December 03, 2011, 12:33:05 am
like
Code:
#if ARDUINO >= 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif

?
907  Using Arduino / Programming Questions / Re: How do I make an I2C-slave Arduino just wait? on: December 03, 2011, 12:17:44 am
Code:
bool valuerequested = false; //global variable

void onRequest() {//not sure how this syntax is...
   valuerequested = true;
}

void setup() {
  //Stuff
}

void loop() {
  //Read sensors
  while (!valuerequested); /*Busywait - don't do anything until valuerequested is true*/
  valuerequested = false;
}
908  Using Arduino / Programming Questions / Re: .cpp and .h file locations on: November 27, 2011, 08:19:15 pm
You'll want to have the pitches.h file in the same directory as your .pde file. The IDE creates a .cpp file out of your .pde file after it adds some things, the location of which can be found when holding shift while compiling (but not uploading).

Also, you'll want to use this syntax:
Code:
#include "pitches.h"
909  Using Arduino / Programming Questions / Re: Sampling Rate on: November 25, 2011, 09:37:39 pm
Quote
But to get there you need to forget about the Arduino ADC sw layer and program directly the ADC registers (not difficult), and also condition your signal appropriately.

Can you show how?

There's a fine example in arduino-00xx/hardware/arduino/cores/arduino/wiring_analog.c and the datasheet for the 328 is certainly helpful.
910  Using Arduino / Programming Questions / Re: Inconsistency: Baffled by #ifdef and #include on: November 25, 2011, 09:33:13 pm
Things you don't use are not included.

So you aren't getting those extra objects unless you "pull in" the library. However once you refer to the library, you get the pre-instantiated objects.

Isn't that the result of the -fdata-sections and -ffunction-sections compiler flags?
911  Using Arduino / Programming Questions / Re: Serial Monitor - Can it continually print to top line? on: November 25, 2011, 07:42:50 pm
I think this may work on windows (haven't tried it though).

\r is carriage return and moves the cursor to the beginning of the line without going to the next one. You'll probably have a problem if your second message is shorter than the first one.

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

void loop() {
  int rand = random(0, 10);
  Serial.print("\r");
  Serial.print(rand);
  delay(500);
}
912  Using Arduino / Microcontrollers / Re: What to turn off, and how? on: November 24, 2011, 01:36:44 am
Your best bet is to look in the datasheet. It's really not that bad if you know what you're looking for, and I hadn't even thought of it as a good place to find information.

Here's a similar project.

Also, please don't cross-post.
913  Using Arduino / Programming Questions / Re: Waiting for Key pressed (keypad) on: November 22, 2011, 09:10:28 pm
How do you expect the key variable to change while you're looping? Put in the getKey function itself, or call it within the while loop, so that you get the current value.

Code:
int key = KeypadX.getKey();
while (key == NO_KEY) key = KeypadX.getKey();
914  Using Arduino / Programming Questions / Re: Switch case problem.... on: November 21, 2011, 08:33:04 pm
Try the randomSeed function on an unconnected analogRead pinor store a random value in EEPROM that's used to seed. If all else fails, get a geiger counter.
915  Using Arduino / Programming Questions / Re: compiler warnings on: November 20, 2011, 11:48:24 pm
What I did is put a script in place of avr-g++ that calls the real avr-g++ with the same flags -- except it ignores the -w flag (disable warnings) and adds a -Wall flag (enable all warnings).

Of course, on Windows it's a lot harder.

Note that the standard libraries that come with Arduino have a ton of warnings in them, and few people will test their own libraries for warnings either.
Pages: 1 ... 59 60 [61] 62 63 ... 71