Show Posts
Pages: 1 ... 243 244 [245] 246 247 ... 844
3661  Using Arduino / Programming Questions / Re: Arduino IP and MAC Addresses? on: November 08, 2013, 02:50:40 pm
I literally have now experience, on this topic. I don't know anything about DNS, DHCP, and servers, and stuff like that.

In that case you will need to learn about these subjects before you can complete the project.

An Ethernet MAC address is an arbitrary 6-byte address which must be unique within each network. If your Ethernet adapter has a MAC address printed on it, it is usually safe to assume that is unique. If not, you will have to choose a unique one. One commonly used for Arduino projects is 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED just because it does not correspond to any of the standard assigned ranges of MAC addresses (and people think it's amusing to use hex characters that spell words).

The IP address is a 4-byte address that has to match the address range used by your router and must be unique within each network. You would normally get this by asking your router to assign an IP address via DHCP and there are standard example sketches using the Ethernet library which do that.
3662  Using Arduino / Programming Questions / Re: How to convert a string of '11001100' into an hex 'CC' on: November 08, 2013, 02:43:05 pm
So then, I receive the data in a long, want to reverse it as explained, convert it in an hex value. This will be exported in an Ascii chain.

I assume 'chain' means 'string'.

I may have misunderstood what you mean by 'reverse', but here's an example showing how you could convert the long value 0x12345678 to a hex string "0x78563412".


void setup()
  long input = 0x12345678;
  char output[12];
  byte *b = (byte *)&input;
  snprintf(output, sizeof(output), "0x%02x%02x%02x%02x", (int)b[0], (int)b[1], (int)b[2], (int)b[3]);

void loop()
Quote from: output
3663  Using Arduino / Programming Questions / Re: Issue with a condition on: November 08, 2013, 02:24:25 pm
Hi, I need help with a serious problem, when you execute this code:

boolean a;
long b = 1;
long c = 2147483647;

if (b > c) a = false;
else a = true;

You must get a true in the "a" boolean but in my program I get a false ALWAYS, even if I type on the condition (1 > 2147483647) Arduino tells me the condition is right, then executes the code of the if.

This code prints out "FALSE":

void setup()
  long b = 1;
  long c = 2147483647;
  if (b > c)

void loop(){}

If you want help with a problem in your code, you need to post code that demonstrates the problem.

If you change the value of c to 2147483648 then the sketch prints "TRUE". This seem wrong but occurs because 2147483648 exceeds the maximum number that can be stored in 31 bits so is rolling over to a negative value. If you need to handle values greater than 2147483647 then you need to store them as an unsigned 32 bit type, or a signed type with more than 32 bits.
3664  Using Arduino / Programming Questions / Re: [Q] Tone plays the desired tone AND a ~1kz unstoppable tone on: November 08, 2013, 02:13:13 pm
There is a lot there that seems unrelated to tone output. Can you produce a minimal sketch that demonstrates the problem? It may improve your own understanding of the problem and expose any false assumptions you're making about what is causing it, but in any case it would reduce the amount of code we need to understand.
3665  Using Arduino / Programming Questions / Re: Converting time from 24 hour to 12 hour on: November 08, 2013, 02:09:06 pm
I don't understand how you're confused. I assume you know what 12-hour and 24-hour time formats are. Ignoring Arduinos and computers for the moment, given a time in 24-hour format, how would you convert it to 12-hour format?
3666  Using Arduino / Project Guidance / Re: Automatic fish trap on: November 08, 2013, 02:02:40 pm
Could you recommend any similar projects, threads or good books/articles?

I recommend Google. The majority of the features you mention are quite common and you shouldn't have any trouble finding existing tutorials and past projects that cover them.
3667  Using Arduino / Programming Questions / Re: Need help to include libs on my project! on: November 08, 2013, 12:45:35 pm
I haven't looked at that Adafruit_GFX.h header but the error message you're seeing looks like a linker error telling you that the method PImage::read32(File) is implemented in two places.

One possible explanation is that the library was implemented poorly and includes method definitions inside the header file. If that was the case then you would end up with duplicate definitions for those methods in every compilation unit that included the header file.

It is a known quirk of the IDE that your sketch .ino file must explicitly include a header file for each library that the sketch uses - even if the .ino file doesn't not depend on any of the declarations in the header file. I haven't tried this, but a possible workaround for that problem may be to enclose the .ino file's #include for the problematic library in #ifdef UNDEF / #endif statements so that it is excluded from compilation. Another possible solution would be to fix the relevant library so that it does not put method definitions in the header file.

Again - this is just based on a guess as to what may be causing the problem.
3668  Using Arduino / Programming Questions / Re: keep the pin 13 led on UNO illuminated as long as you hold down a keyboard key on: November 08, 2013, 12:32:36 pm
Keep in mind that most serial applications only send data when the key is released. If you want to send one value when the key is pressed, and another value when the key is released, which seemed to be what you wanted, you will need to write your own application to do that.

YMMV but my experience is the reverse. Typical behaviour is to send a character when the key is pressed, and if the key remains held down and autorepeat is enabled for the keyboard then after a short delay the character is repeated at the autorepeat rate.
3669  Using Arduino / Programming Questions / Re: How to convert a string of '11001100' into an hex 'CC' on: November 08, 2013, 12:26:02 pm
It's hard to tell what's going on just from that snippet.

What format are you receiving the data in? Are you getting an array of ascii characters '0' and '1', or an array of byte values 0 and 1, or what?

In what format do you want the data to end up? Are you trying to produce a hexadecimal representation in an ascii string, or a byte value, or what?

Preferably answer in terms of C++ data types.
3670  Using Arduino / Programming Questions / Re: Turning stepper one revolution on: November 08, 2013, 12:19:47 pm
The motors seem to turn pretty strong with this power supply.  The power supply could affect the steps per revolution that much?  Meaning my code has to do roughly 6300 steps instead of 200 to make a full rotation.

Do you mean that when you try to prevent the output shaft from moving by twisting it against the direction of movement it still moves at the same speed, and when you try to help it by twisting in the direction of movement it doesn't go any faster? If so, this doesn't sound like an inadequate power supply causing slipping.

Does your stepper motor driver support micro-stepping, and if so what mode are you using?

Do you have a picture of the motor? Perhaps that would reassure us that you haven't simply ended up with a stepper/gearbox unit by mistake.
3671  Using Arduino / Project Guidance / Re: Stream Weather Information to ArduinoUNO and output through speaker. on: November 08, 2013, 12:13:38 pm
How are you going to 'output' it through a microphone?
3672  Using Arduino / Programming Questions / Re: Input and output pin changing and timing on: November 08, 2013, 10:31:10 am
Can you describe how this matrix is wired up in a bit more detail? At the moment it sounds almost as if you have each LED wired in parallel with its switch. Is that right? If so, where is the current-limiting resister relative to the switch?

Pin mode changes should not take any appreciable time and I don't believe that's your problem. However, these statements are nonsensical:

pinMode ((4, OUTPUT), LOW);
3673  Using Arduino / Programming Questions / Re: keep the pin 13 led on UNO illuminated as long as you hold down a keyboard key on: November 08, 2013, 10:24:32 am
You can't do exactly what you want using the Arduino's serial monitor, because the serial monitor won't actually send anything to the Arduino unless/until you hit the return/enter key. If you just hold a keyboard key down, all you'll do is fill up a buffer on the PC.

What you're trying to do would require you to use a different serial client. If you have autorepeat enabled for your keyboard, and use a client that sends each character as it is entered (I think RealTerm supports that) then you would have a steady stream of characters sent to the Arduino as long as you hold the key down. On the Arduino side, you would just need to turn the LED on each time you received a character, and turn it off if you hadn't received the next character after a while.
3674  Using Arduino / Programming Questions / Re: Alternatring between two fans - How? on: November 08, 2013, 09:59:34 am
Use edge detection to determine when the fan demand changes.
Assign a number to each fan (i.e. 0 and 1).
Have a variable recording the number of the fan currently being used.
Each time the fan demand changes from 'off' to 'on', turn the current fan on.
Each time the fan demand changes from 'on' to 'off', turn the current fan off and increment the current fan number. Use the modulus operator to ensure that the current fan number stays within the number of fans.
3675  Using Arduino / Programming Questions / Re: Can Arduino handle 8 bit ASCII? on: November 08, 2013, 09:55:17 am
On Windows with IDE 1.0.4 it's saved in UTF-8 (without BOM).
Pages: 1 ... 243 244 [245] 246 247 ... 844