Show Posts
Pages: 1 ... 414 415 [416] 417 418 ... 582
6226  Using Arduino / Sensors / Re: Thermocouple amp with MUX on a mega on: July 22, 2011, 01:01:36 am
I always thought it was not a good idea to run t-couples through a MUX, still if it works it works.

Code:
while(1)
  {
    delay(1000);
    Set_Mux_Channel(1); <<<<<<<<<<<<<< should be a variable, not 1

You never select the other channels. Also you don't need the while(1) but it doesn't do any harm.

Quote
you can have multiple SPI devices provided you use different CS pins?
That's normally true, but I'm not familiar with the SPI library so don't know how it does the CS stuff.

______
Rob
6227  Using Arduino / Programming Questions / Re: Virtual switch on: July 22, 2011, 12:50:56 am
Quote
All I need to do really is touch two wires together momentarly.
The problem is you don't know exactly what's on those two wires. It is possible that just applying a logic level to one of them and GND or 5V to the other will work, but you don't know that without proper documentation.

Therefore the only safe way is with a relay of some kind.

Get some proper data and there may be other options.

______
Rob
6228  Using Arduino / Programming Questions / Re: 12 button Keypad input into a string on: July 22, 2011, 12:39:58 am
You simply get the characters one by one and add them to an array. Something like this

Code:
char password[5];  // one extra char to null terminate the string
memset (password, 5, 0);  // clear the array
for (int i = 0; i < 4; i++)
  password[i] = getKey();

I'm not familiar with the keypad library and I've assumed getKey() doesn't return until a key is pressed. If getKey() returns a value indicating there was no key pressed the code would be more like this.

Code:
char password[5];  // one extra char to null terminate the string
memset (password, 5, 0);  // clear the array
int k;
for (int i = 0; i < 4; i++) {
  do {
     k = getKey();
  } while (k == -1);
  password[i] = k;
}
______
Rob

6229  Using Arduino / Programming Questions / Re: How do you program Machine Lauguage into Arduino / ATmega on: July 21, 2011, 11:10:04 pm
Quote
using digitalWrite ( pin, State ) Does Not Send at the same time.
That's true, however if that's all you need to do then you don't need to drop into ASM, C code like

PORTB = 0x55;

Will be just as good.

______
Rob
6230  Using Arduino / General Electronics / Re: Microcontroller? We don't need no microcontroller! on: July 21, 2011, 07:59:26 pm
Quote
Maybe we should have another thread ...
Yep, maybe under Exhibitions or Bar sport. I'm sure there's a lot of old projects people would display.

______
Rob
6231  Using Arduino / Microcontrollers / Re: Testing whether a pin is an interrupt on: July 21, 2011, 07:53:45 pm
In the Arduino install

C:\Program Files\Arduino\arduino-0021\hardware\tools\avr\avr\include\avr

there is a file called io.h

This has includes for every AVR type based on a value defined elsewhere (maybe on the GCC command line although I don't see it there).

Anyway if this definition is always in place (and it has to be to get the right processor include file) you can use that to have a processor-specific #define.

______
Rob
6232  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
6233  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
6234  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
6235  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
6236  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
6237  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


6238  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
6239  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
6240  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
 

Pages: 1 ... 414 415 [416] 417 418 ... 582