Show Posts
Pages: 1 ... 425 426 [427] 428 429 ... 593
6391  Using Arduino / Microcontrollers / Re: Testing whether a pin is an interrupt on: July 21, 2011, 07:45:15 pm
Quote
So I would need list of defines, maybe, for every AVR?
That's my thinking, isn't there pre-defined processor types like "__ATMega328__"? I remember playing with something like that a while back.

Otherwise use a #define at the top of the code, but of course this means the user has to figure out which pin is which

______
Rob
6392  Using Arduino / Programming Questions / Re: How do you program Machine Lauguage into Arduino / ATmega on: July 21, 2011, 07:09:27 pm
I used to do all projects in ASM both commercial and personal, mainly because cross-compilers were very expensive at the time. After a while you find that you have such a library of macros and functions that it's almost like writing in C.

These days it's seldom necessary but I agree it's good to know what's under the hood. I have a project coming up (on an ATtiny84) that will probably be written in ASM, so it still has it's place.

______
Rob
6393  Using Arduino / Microcontrollers / Re: Testing whether a pin is an interrupt on: July 21, 2011, 06:52:26 pm
The only way I can think of to test for this at run time is a static table, much the same as used by Arduino for the pin mapping.

But you said "provided they are using arduino cores" so it will only work with Arduinos anyway won't it?

______
Rob
6394  Using Arduino / Motors, Mechanics, and Power / Re: Battery readings? on: July 21, 2011, 11:29:15 am
Quote
read the voltage of the 12v battery while its under load
This begs the question "How much load?" I can pull my 24v bank down to 22v if I turn the microwave on (yes I know that's not good for the batteries smiley) but that 22v is not very representative of the battery condition.

I have read that a 1% load is considered of no real difference to no load at all and that is OK.

______
Rob
6395  Using Arduino / Sensors / Re: How to connect LDR to arduino?(HELP) on: July 21, 2011, 10:33:15 am
You have to form a voltage divider and take your reading from the centre (the * in the above drawing). Without two resistors (the LDR is just a special type of resistor) you are just pulling the Arduino pin low and so will always read a value of 0.

Now if for some reason you live in outer mongolia and can't get a resistor and just want to play to see what happens there are two ways to do this.

1) If you have a second LDR use that instead of the fixed resistor, as you light and shade either of the LDRs the reading will change.
2) Use the internal pullup resistor instead of the external resistor (I'm pretty sure this will work with an analogue input).

Both these methods will be very imprecise but will at least allow you to have a play.

Personally I'd just go and get a resistor.

______
Rob
6396  Using Arduino / Motors, Mechanics, and Power / Re: Bigger vehicle? on: July 21, 2011, 07:46:00 am
Ask on a robot forum such as

http://www.societyofrobots.com/robotforum/index.php

______
Rob


6397  Using Arduino / General Electronics / Re: Microcontroller? We don't need no microcontroller! on: July 21, 2011, 03:35:53 am
That's fantastic, takes me back.

I wouldn't bother salvaging the chips, each one will draw more power than a modern laptop smiley Mind you they might make good heating elements for a high-altitude ballon project.

______
Rob
6398  Using Arduino / Programming Questions / Re: Help with delays on: July 20, 2011, 06:08:49 am
Quote
I was sending the LED pin low in order to make it run.
If you are controlling a LED with a transistor in the normal fashion (ie a low-side switch with the transistor on the LED cathode) then a HIGH will turn the LED on, your LOW will turn it off so this should have manifested itself as an inversion, ie the LED was on when you thought it should be off and vv.

Sorry but I've totally lost track of what's running what.

I still can't figure out why two Arduinos are in play and what their relationship is. Schematics were designed because it's too confusing to describe a circuit with words, How about a schematic.

______
Rob
6399  Using Arduino / Programming Questions / Re: A basic serial comms question on: July 20, 2011, 02:18:42 am
This works

Code:
char oldString[] = "xxx";
char *strptr = oldString;
String newString = strptr;

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

void loop () {
    Serial.println (newString);
}

as does this

Code:
char oldString[] = "xxx";
String newString = &oldString[0];

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

void loop () {
    Serial.println (newString);
}

Now they are effectively the same thing as before so I thought I'd try

Code:
char oldString[] = "xxx";
String newString = oldString;

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

void loop () {
    Serial.println (newString);
}

And that works. So I'd say you had another problem.

There's another thread running at the moment with a similar theme, ie parsing a string

http://arduino.cc/forum/index.php?topic=66981.new;topicseen#new

Have a read of that and see if it helps. You have the same issue where you want to chop a comma-delimited string into pieces and assign the pieces to variables.

______
Rob
 

6400  Using Arduino / Programming Questions / Re: A basic serial comms question on: July 20, 2011, 12:06:27 am
I never use the String class, it's a bit new-fangled for me plus I don't trust it to behave properly re allocating and freeing memory. But maybe that's me just being a control freak smiley

I would assume though that there is a constructor that takes a NULL-terminated array of char as the argument. So

char oldString[] = "xxx";
String newString = oldstring;

Should work I think.

Did you check the Arduino reference pages?
______
Rob
 
 
6401  Using Arduino / Programming Questions / Re: A basic serial comms question on: July 19, 2011, 10:31:11 pm
In a nutshell you read the characters until you have them all then use one of the atoi/atof() etc functions to convert the string into an int/float/whatever.

This is a very common request, have a search through the forum and you'll probably find a 1000 threads on it.

Meanwhile, what's the exact format of the data coming from the Razor?

______
Rob
6402  Using Arduino / Programming Questions / Re: Question regarding timer1/counter on: July 19, 2011, 08:42:19 pm
Good points (and improved code) by both Rob and David, the actual input bit doesn't matter, we just need to know the "logical" level of the input, there's no need to move the actual bit around.

Quote
delayed output signal on pins 6, 7, and 8 on PORTC?
If the signal on these pins is exactly the same why use three pins? Current-driving capacity?

______
Rob
6403  Using Arduino / Motors, Mechanics, and Power / Re: Battery readings? on: July 19, 2011, 08:27:47 pm
To get a true SOC reading by just reading the voltage on a lead acid battery you have to let it rest with no load for a long time, some even say 24 hours.

What most gadgets to is "coulomb counting", where you integrate the current in with current out and multiply by a fudge factor (Peukert’s Law).

______
Rob
6404  Using Arduino / Networking, Protocols, and Devices / Re: SPI Slave mode (example code) on: July 19, 2011, 08:19:08 pm
Does the master insert a small delay between the bytes? I've always found this to be required to give the slave time to grab the last byte (at high speeds anyway).

I did a version once that IIRC transferred 8 bytes in 100uS.

______
Rob
 
6405  Using Arduino / Programming Questions / Re: Port Registers for the Mega 328 on: July 19, 2011, 07:55:04 pm
Quote
But the 328 has 53 digital pins
Oh no it doesn't, you're thinking of the ATmega2560 family. The 168 and 328 are exactly the same pinout wise.

______
Rob
Pages: 1 ... 425 426 [427] 428 429 ... 593