Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: Changing Case of char Array on: February 27, 2013, 06:49:56 pm
Mr. "Smoke":

Below is how I tested your suggestion to UpCase a string.
Works good.
Doesn't look very good.
Can you suggest how I can get rid of the for loop and replace it with a while (myString != NULL) ?
I don't see how to step through the buffer without an index like "i".

Thanks.
Bob W.

Code:
 
char myString[] = "Hello";

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < 100; i++ )  // 100 set arbitrarily and excessively large
  {
    if ( myString[i] == NULL ) break;
    myString[i] = myString[i] & 0b11011111;
  }

  Serial.print( &myString[0] );
 


For the ASCII alphas, bit 5 is the difference in case.

1 loop the length of the buffer with break on NULL, if the ASCII is not alpha-only then with a range check ( data & 0xDF >= 'A' ) && ( data & 0xDF <= 'Z' ) and either set or clear bit 5.... make the state an arg and 1 function could do both change to upper or lower case.

And you don't need string.h to do that.


17  Using Arduino / Programming Questions / Re: Changing Case of char Array on: February 27, 2013, 05:34:09 pm
This is certainly easier.
I don't know why I couldn't find it myself.
Thanks you !

Bob


strupr
18  Using Arduino / Programming Questions / Re: Changing Case of char Array on: February 27, 2013, 05:30:56 pm
That worked *good*  !
I like it.
Thanks for helping me !

Bob

For the ASCII alphas, bit 5 is the difference in case.

1 loop the length of the buffer with break on NULL, if the ASCII is not alpha-only then with a range check ( data & 0xDF >= 'A' ) && ( data & 0xDF <= 'Z' ) and either set or clear bit 5.... make the state an arg and 1 function could do both change to upper or lower case.

And you don't need string.h to do that.


19  Using Arduino / Programming Questions / Changing Case of char Array on: February 27, 2013, 04:47:04 pm
I've read a lot about how some users "hate" the String Object and prefer to use char arrays when possible.  So I'm trying to become more proficient in using char arrays to store my strings.

Question:

What would the best way be to change the case of a string stored as a char array to Upper Case.
I see that there are already methods like strcmp and strcpy to perform other tasks on char arrays.
I can't seem to find something for changing case ( as exists for the String Object ).

Would appreciate any guidance on this.

Thank you.

Bob W
20  Using Arduino / General Electronics / Re: Serarate Power for Ethernet Shield on: February 25, 2013, 08:48:11 pm
That is fine and dandy, and is common practice to boot.

Very odd.
With separate power supplies, web page doesn't come up on browser.

Should I be powering up Ethernet Shield first, then applying power to Arduino ?
Resets are still connected.  Would think shield would reset when Arduino boots.
21  Using Arduino / General Electronics / Serarate Power for Ethernet Shield on: February 25, 2013, 05:28:43 pm
I've got an Arduino Duemilanova clone connected to an Ethernet shield which serves a web page that lets me send X-10 commands from a CM17a Firecracker connected to the Arduino.

They are not stacked, but rather are connected by a ribbon cable.

The thing works great when powered from a 1 Amp 5 VDC power supply.

Issue I'm having, is that when device is powered by the computer USB port (for testing and development), there is insufficient power for effective X-10 commands to be sent. The sketch works fine and connects to the internet as desired.

Question is:

Would there be a problem if I were to power the Ethernet card separately from the Arduino.
That is: Common ground, Arduino 5 volts from USB, and Ethernet card 5 volts from it's own wall wart.

I can't see that there would be any danger to hardware, but I'm not an EE, so I thought I'd ask.

Sorry if question too elementary.

Bob W.
22  Using Arduino / Project Guidance / Re: Alternative Blink without Delay on: February 20, 2013, 09:28:33 am
OK.  Good.

EEPROM useful because it can be changed while sketch running. Got it.

Also - I'm just using the flashing LED as an annunciator for an alrarm condition.
       Blinking draws attention better than steady state ON.
       Overflow thus is not an issue for me.


Finally, Re Powers and Masking - I like that better than what I did.
         Will use this instead.

The reason I was interested in a simpler way to flash the LED was just to avoid having to deal with the logic and curly brackets that go with a *proper* "blink without delay".

I can keep this line "in stock" now and paste it in the future when I need this functionality.

I'm 100% good to go now !

Thank you all.

Bob W
23  Using Arduino / Project Guidance / Re: Alternative Blink without Delay on: February 19, 2013, 09:07:14 pm
OK.  I understand.  No practical limit on reading or writing with SRAM.

I'm still weak on understanding differnce in purpose of Flash vs EEPROM.
Both non-volatile.  Bootloader and sketch stored in Flash.
What's EEPROM for then ?  Why couldn't non-volatile data be stored in flash ?
Why two kinds of non-volatile memory ?
24  Using Arduino / Project Guidance / Re: Alternative Blink without Delay on: February 19, 2013, 11:08:35 am
Jack:

One thought was: does the memory I'm writing to so many times have a life span to it ?
Doesn't flash memory have a limited number of writes in its estimated lifetime before it goes bad ?

BobW
25  Using Arduino / Project Guidance / Alternative Blink without Delay on: February 19, 2013, 10:19:02 am
The single line of code in the loop below flashes a LED without use of delay().
Only issue I see is that pin 9 is being written to on every loop cycle.
Is this a bad thing to be doing ?

Thank you.

BobW


Code:
void setup()   
{
  pinMode(9, OUTPUT);      // LED on pin 9
  pinMode(8, OUTPUT);      // virtual ground for LED
  digitalWrite (8, LOW);   // virtual ground for LED
}

void loop()
{
  digitalWrite ( 9, (millis()%500 < 250) ? 1 : 0 );  // flash LED at 2Hz

  // code that runs all the time goes here
}
26  Using Arduino / Networking, Protocols, and Devices / Re: Location Header in Served Web Page on: February 11, 2013, 02:35:30 pm
OK.
I beat it into submission.
The following code redirects properly in IE, FF and Chrome.
Problem seems to have been a missing <head> tag.
See http://thatsgoodbob.dyndns.org:8248 for demo.
Will be available for a short time longer.

Code follows.
Thanks for helping me !

Bob W.

Code:
  client.print("HTTP/1.1 301 Moved Permanently\r\n");
  client.print("Date: Mon, 11 Feb 2013 15:19:46 GMT\r\n");
  client.print("Server: Apache\r\n");
  client.print("Location: http://google.com/\r\n");
  client.print("Content-Length: 523\r\n");
  client.print("Connection: close\r\n");
  client.print("Content-Type: text/html; charset=iso-8859-1\r\n");
  client.print("\r\n");


  client.print("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n");
  client.print("<html><head>\n");
  client.print("<title>Test Page</title>\n");
  client.print("</head><body>\n");
  client.print("<h2>You should not be seeing this page . . .</h2>\n"); 
  client.print("<br>"); 
  client.print("Because \"Location: http://google.com\" is in the header before the html.<br><br>");
  client.print("It redirects as expected in FF and Chrome.<br><br>");
  client.print("But this page displays in IE 8, 9<br><br>");
  client.print("What am I doing wrong ? <br><br>");
  client.print("(v0.08 Monday)<br><br>");

  client.print("</body>");
  client.print("</html>\n");
  client.stop();     
}


27  Using Arduino / Networking, Protocols, and Devices / Re: Location Header in Served Web Page on: February 10, 2013, 06:41:14 pm
Changed to  HTTP/1.1 302 Found

No change in behavior.
28  Using Arduino / Networking, Protocols, and Devices / Re: Location Header in Served Web Page on: February 10, 2013, 04:52:51 pm
Adding trailing slash to http://google.com did not change behavior.
Still works in FF, Chrome.
Not in IE 8, 9.
Thanks anyway though !

Bob W
29  Using Arduino / Networking, Protocols, and Devices / Location Header in Served Web Page on: February 10, 2013, 04:32:02 pm
Just for fun, I've been experimenting with URL redirection using the "Location" header sent before html.

Below is my Arduino code that makes the web page I am serving at http://thatsgoodbob.dyndns.org:8248/

The page redirects, as expected, to http://google.com when viewed in Firefox or Chrome.

BUT ... if I try to view the page in IE 8 or IE 9, no redirection happens, and the page in the code below appears.


I know this is not really an Arduino issue, but all of the answers I've found on the web have to do with PHP, which is not the issue here.

Does anything see anything in my code that explains what is happening ?

Thank you for helping me.

Bob W   (code follows . . )

Code:
   
  client.println("HTTP/1.1 301 Moved Permanently");
  client.println("Location: http://google.com");
  client.println("Content-Type: text/html; charset=iso-8859-1");
  client.println("Connection: close");
  client.println();

  client.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">");
  client.println("<html>");
  client.println("<body>");
  client.println("<h2>You should not be seeing this page . . .");
  client.println("</h2>"); 
  client.println("<br>"); 
  client.println("Because \"Location: http://google.com\" is in the header before the html.<br><br>");
  client.println("It redirects as expected in FF and Chrome.<br><br>");
  client.println("But this page displays in IE 8, 9<br><br>");
  client.println("What am I doing wrong ? <br><br>");

  client.println("</body>");
  client.println("</html>");
  client.stop();     
 
30  Using Arduino / Networking, Protocols, and Devices / Re: DHCP *AND* DNS with Ethernet Shield Library on: February 07, 2013, 10:53:56 am
Yes. I use it. Call the Ethernet.begin(mac) function. The dhcp server will issue the dns server.

Tim:

Thank you so much!
That was shockingly easy !
Works great !

How did you know this ?
It was hiding in plain sight.
I never thought to try it.

Bob W

Pages: 1 [2] 3 4