Show Posts
Pages: 1 [2]
16  Using Arduino / Programming Questions / Re: How to get substrings from char pointer array on: January 29, 2012, 04:24:27 pm
Thank you for the advice.
I have a feeling for me I'm  byting off more than I can chew for now.
I think I need to learn a bit more C++ before I can get my head around this.

Again, thanks for the advice.
17  Using Arduino / Programming Questions / Re: How to get substrings from char pointer array on: January 20, 2012, 06:34:42 am
I generally use strstr() function:
char buffer[]="+CBC: 0,99,4190" ; // this is a return string by GSM modem  0,charge level, millivolt
char *ptr;  //temp pointer variable for pointer artihmetic
char *fieldPtr; //temp pointer  variable for pointer artihmetic
ptr=strstr(buffer,"+CBC:"); // if substring found in buffer it return address ofstart character of matched string
                      // if not matched it returned NULL
   Serial.println(ptr);         // will print :",99,4190"
                       // you can use pointer arithmetic to get the field

pravas - Thanks.
This looks like the kind of thing I'm trying to do but for a web page rather than GPS.
I think some experimenting over the weekend will see if I understand what you are saying.


18  Using Arduino / Programming Questions / How to get substrings from char pointer array on: January 19, 2012, 09:15:09 am
I'm using the ethercard library ( to set the Arduino up as a web client so I can read data from a website.
All this is working correctly and the demo webClient sketch ( works perfectly.
I have even change the web site and page to be access and the correct output is sent to the serial monitor.

My problem is that my knowledge of C and pointers is very limited.

I know that Ethernet::buffer is an array of bytes using pointers.

What I am trying to do is read the Google XML weather data from
Extract the current temp_c, humidity, icon and wind_condition data and use them to create an output.

Where I am failing is how to parsing a char.  Any advice or pointers (sorry for pun) on how to do this would be appreciated.

Below is the webclient code I am working from

// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <>

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);

void setup () {

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP: ", ether.myip);
  ether.printIp("GW: ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
  ether.printIp("SRV: ", ether.hisip);

void loop () {
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
19  Using Arduino / Project Guidance / Re: Connecting ENC28J60 to an arduino on: January 19, 2012, 08:39:46 am
I have the same board (thanks Santa)
I read up on the different voltage levels of the board and the Arduino as well as on using the ethercard or EtherShield library.

In the end based on advice from I just wired it up directly and it works perfectly.
The ENC28J60 is tolerant of the 5V from the Arduino and the Arduino is tolerant of the 3.3v from the ENC28J60.

I did a bit of a blog post on the wiring needed for the different libraries here.  This explains how to wire up for the nuelectronics library and also the ethercard library.

I hope this helps.
20  Forum 2005-2010 (read only) / Syntax & Programs / Re: x * 1000L - what does the L do on: January 02, 2011, 06:31:47 pm

Thanks for that.  
This helped me find the reference page on

Again, thanks for this.
21  Forum 2005-2010 (read only) / Syntax & Programs / x * 1000L - what does the L do on: January 02, 2011, 06:03:48 pm

1st post.

I have been working through some Arduio code and I have what I hope is a basic question.

In the code below that works perfectly 'duration' is multiplied by 1000L.

Why the L at the end?
What does it mean.

void playTone(int tone, int duration) {
  for (long i = 0; i < duration *1000L; i += tone *2) {
    digitalWrite(speakerPin, HIGH);
    digitalWrite(speakerPin, LOW);

I'm tryingt o understand when I just multiply my 1000 and when I multiply by 1000L.

I tried removing the L from the code but it failed, so obviously it is important.

Any info much appreciated.


Pages: 1 [2]