Show Posts
Pages: 1 ... 792 793 [794] 795 796 ... 1118
11896  Forum 2005-2010 (read only) / Syntax & Programs / Re: serial.print or serial.write? on: November 04, 2009, 09:53:29 am
Is that correct? Doesn't:

Quote
From the point of (thought of) overhead i'll stick to Serial.write(); and change Serial.print(0, BYTE); to
int i = 0;
Serial.write(i);

Cause a complier error told here:

Quote
Serial.write() expects a byte argumet (8 bits). If you call this method with an int (16 bit) argument , the compiler will complain because there is no write method in the serial class that will accept int arguments.

Lefty
11897  Forum 2005-2010 (read only) / Syntax & Programs / Re: serial.print or serial.write? on: November 03, 2009, 09:34:50 pm
Quote
"Therefore, it will send any one-byte value as is. "

"int i = 0;  Serial.write(i);

But an int is 16 bits long, two bytes. So does it just send one byte or two? if one, the hi or low byte?

Lefty
11898  Forum 2005-2010 (read only) / Syntax & Programs / Re: Twos complement? on: October 29, 2009, 10:44:29 pm
Quote
Do you mean two parts or two binary bits? Lefty was talking about the latter.

Yes, I did take it as posted literally, as 2 bits, which on the surface is kind of silly I would think, the range would be rather restrictive, no  smiley-wink

Lefty
11899  Forum 2005-2010 (read only) / Syntax & Programs / Re: Twos complement? on: October 28, 2009, 04:37:45 pm
The signed int variables used in Arduino already uses twos complement for negative numbers. To convert a positive number to a negative number in twos complement you invert all the bits and add 1.

I think to convert a 2 bit signed number to a 16 bit signed number you just have to set the extra 14 higher bits to one if the second bit of the smaller number is a one, but not really sure.

http://en.wikipedia.org/wiki/Twos_complement

Lefty

11900  Forum 2005-2010 (read only) / Syntax & Programs / Re: Interupts by time on: November 01, 2009, 05:48:41 pm
Check out:

http://www.arduino.cc/playground/Main/MsTimer2

Lefty
11901  Forum 2005-2010 (read only) / Syntax & Programs / Re: total code NOOB trying to get 5x5x5 cube working on: September 26, 2009, 08:34:29 pm
Quote
it has been running 24/7 for 4 days straight with a simple test pattern and some text. i was actually just frustrated and got it working, so i left it on to see if it would fry it LOL. it's still running good.

No offence meant, but you have been advised by more then one poster that current limiting (by resistors or other means) is a requirement when driving LEDs. However because you have it working without, you seem to just dismiss or ignore that advice. To ask for advice but then ignore it can on first impression be a little frustrating, at least for me.

 We are not trying to sell you resistors, or otherwise make your project more complex then it needs to be. It's your controller board and you have every right to treat it as you wish. I just question if you realize the risk to your investment you are taking?

Lefty
11902  Forum 2005-2010 (read only) / Syntax & Programs / Re: total code NOOB trying to get 5x5x5 cube working on: September 17, 2009, 04:02:04 pm
Quote
am i going to kill anything running like this? should i put resistors on anywhere?

Without resistors or some other form of current limiting there is a very big risk of damaging the Mega's I/O pins. There is sure to be published 'led cube' circuits available that show how they handled interfacing to the LEDs.

Lefty
11903  Forum 2005-2010 (read only) / Syntax & Programs / Re: Vu meter help on: October 30, 2009, 07:47:57 pm
A few points:

 A VU meter is designed to display the amplitude of a audio (or other) analog signal. You are reading in a digital input pin which can only have a high or low value, so it's not clear what your program is actually doing. Assuming you have a audio signal you want to read you should be using a analogRead(pin) command.

Also to perform an analog input of a audio signal there will be external components needed to convert the AC audio voltage to a variable 0-5vdc signal that the processor can read.



Lefty
11904  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino as frequency counter on: October 30, 2009, 11:53:07 am
Check out the Pulsein() command. If you measure the high duration portion of a square wave and then double that value and then divide it into 1 you should end up with the frequency value. That assumes a 50/50 square wave. It it's not a 50/50 ratio then you should measure both the high portion and low portion and add them together and then divide into one.
http://arduino.cc/en/Reference/PulseIn

At least I think thats right  smiley-wink

Lefty
11905  Forum 2005-2010 (read only) / Syntax & Programs / Re: Bit Flipping Nibbles and Bytes on: October 22, 2009, 12:16:06 am
I recall once in the 80s where I had to flip the bits in a byte to get the CRC calculations to work for a communications link to a hardware remote telemetry unit (RTU), seems the device did their CRC generation in hardware and flipped the bits in relationship from the 'standard CRC-16' method. I did it in Turbo Pascal on a Kaypro CP/M system.

Lefty
11906  Forum 2005-2010 (read only) / Syntax & Programs / Re: pcint and Arduino Mega on: October 26, 2009, 08:03:14 pm
Quote
I tried doing this with the Mega (54, 55, etc) but it didn't seem to work.  Your help is most appreciated.  Thanks!

Should work, here is extracted from the Arduino Core:

Code:
// For each analog input that can also be a digital pin, these
// define the numbers usable with pinMode(), digitalWrite(), etc
#define CORE_ADC0_PIN            54
#define CORE_ADC1_PIN            55
#define CORE_ADC2_PIN            56
#define CORE_ADC3_PIN            57
#define CORE_ADC4_PIN            58
#define CORE_ADC5_PIN            59
#define CORE_ADC6_PIN            60
#define CORE_ADC7_PIN            61
#define CORE_ADC8_PIN            62
#define CORE_ADC9_PIN            63
#define CORE_ADC10_PIN            64
#define CORE_ADC11_PIN            65
#define CORE_ADC12_PIN            66
#define CORE_ADC13_PIN            67
#define CORE_ADC14_PIN            68
#define CORE_ADC15_PIN            69


Lefty
11907  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino Mega Pin Issues in 0017 on: October 23, 2009, 01:18:14 am
Add the following to the setup portion of your sketch:



pinMode(42, INPUT);           // set pin to input
digitalWrite(42, HIGH);       // turn on pullup resistors

pinMode(43, INPUT);           // set pin to input
digitalWrite(43, HIGH);       // turn on pullup resistors


from the reference:

http://arduino.cc/en/Tutorial/DigitalPins

Lefty
11908  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino Mega Pin Issues in 0017 on: October 23, 2009, 01:06:49 am
Have you enabled the internal pull-ups for those two pins, or are they 'floating' when the switch is not pressed?

A 'floating' pin will pick up noise and read as a random value unless you use an external pull-up or pull-down resistor or enable the internal pull-up.

Lefty
11909  Forum 2005-2010 (read only) / Syntax & Programs / Re: Having trouble with my attachInterrupt not working on: October 21, 2009, 09:22:22 pm
Quote
When I connect the digital pins #2 and #3 up to 5V and then run the button to a ground to clear out to 0V for the LOW nothing is happening on my LCD

By "connecting pins 2 & 3 up to 5v" do you mean by way of a external pull-up resistors? If not and you are wiring the pins straight to +5vdc and then shorting it to ground with switches, I'm sure that would cause a power dip such that the chip would just reset and start again.

You do need either to use external pull-up resistors or using the pinmode command turn on the internal pull-ups for pins 2 & 3.

Lefty
11910  Forum 2005-2010 (read only) / Syntax & Programs / Re: How can I free a WString? (repeated memory crash) on: October 18, 2009, 04:14:11 pm
I could be mistaken but I could swear I read a post in the recent past about a memory leak problem with the WString library and there was a patch given in the thread to correct it. You might try searching the posts here or perhaps someone else will recall.

Lefty

Pages: 1 ... 792 793 [794] 795 796 ... 1118