Show Posts
Pages: 1 2 3 [4] 5 6 ... 8
46  Using Arduino / Project Guidance / Re: converting 2 variables into character array variable on: January 27, 2013, 11:03:08 am
Wildbill
I appreciate your feedback, I will follow the convention as I move forward.
Thank you everyone who responded to the topic
I always learn something new with every topic I post in the forum. You all are respected!
Don
47  Using Arduino / Project Guidance / Re: converting 2 variables into character array variable on: January 26, 2013, 07:25:19 pm
Peter and Mark
Thanks I have a hard time coming up with simple solutions to my problems... I hope this gets better with time. Mark I understand that code in setup runs once but is there a reason why putting that for loop in Loop() is a bad idea? I want to learn do's and don't of Arduino. I've use the for loop in WinAvr.

Can you recommend books, or web sites to help learn the best approach solving the task needed?
I knew of modus arithmetic but wasn't sure how to use it.
Don   
48  Using Arduino / Project Guidance / Re: converting 2 variables into character array variable on: January 26, 2013, 06:12:37 pm
Ill give it a try much simpler that what I had lol thanks guys
49  Using Arduino / Project Guidance / converting 2 variables into character array variable on: January 26, 2013, 05:00:32 pm
Hi
I have written some code that takes the amount on minutes called durationInMins.
durationInMins is converted to 2 byte variables named hours, and mins.

I don't know how to convert the byte variables hours, mins to a char array.
I'm trying to fill the character array with the data as follows "hh:mm" format.
Here is what I have so far I have it running on my Uno board.
Thank you
Don

Code:
#include <math.h>
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  char duration[] = {"  :  "};
  int durationInMins = 490;
  byte hours = 0;
  byte mins = 0;
  double i, r;
  r = durationInMins * .01666;
  Serial.print("Durationin mins: ");
  Serial.println(durationInMins);
  r = modf(r, &i);
  r = r * 60;
  mins = byte(round(r));
  hours = byte(i);
  Serial.print("Hours: ");
  Serial.println(hours);
  Serial.print("Mins: ");
  Serial.println(mins);
  Serial.println();
  
  /*
    I now want to convert
    variable hours to a character array;
    and variable mins to a character array
    then put them in char array duration
    char duaration[] = {"hh:mm"};
  */
 Serial.println(duration);
 Serial.println();
  
 for(;;){}  

}


 
50  Using Arduino / Networking, Protocols, and Devices / Re: Client / Server connection on: January 26, 2013, 01:33:06 pm
Hi Paul
 Does client.stop() provide a graceful disconnection from the server it was connected to? I've been using the Twitter library and a function to send and email out. I notice that neither of these use client.stop(). I added it to the email function. I haven't tried to add it to Twitter Library wanted to ask you about it's use. When I'm done communicating with the smtp server I have the command client.println("QUIT"); So I'm telling the server I'm done should I just let the server drop the connection to the client? I appreciate your input here.
Thanks
Don

Code:
bool Twitter::post(const char *msg)
{
#if defined(ARDUINO) && ARDUINO < 100 //if earliar than Ardunio 1.0
DNSError err = EthernetDNS.resolveHostName(LIB_DOMAIN, server);
if (err != DNSSuccess) {
return false;
}
#endif
parseStatus = 0;
statusCode = 0;
#if defined(ARDUINO) && ARDUINO < 100 //if eariler than Ardunio 1.0
if (client.connect()) {
#else
if (client.connect(LIB_DOMAIN, 80)) {
#endif
client.println("POST http://" LIB_DOMAIN "/update HTTP/1.0");
client.print("Content-Length: ");
client.println(strlen(msg)+strlen(token)+14);
client.println();
client.print("token=");
client.print(token);
client.print("&status=");
client.println(msg);
                            client.stop() //? should I use it?? *****************
} else {
return false;
}
return true;
}


byte postEmail()
{
  digitalWrite(ledPost,ON);
  EthernetClient client;
  if (client.connect("smtp.mail.wowway.com", 25))
    {
       delay(500);
       client.println("HELO MYSERVER");
       client.println("MAIL FROM:<user@wowway.com>");
       client.println("RCPT TO:<personat@gmail.com>");
       client.println("DATA");
       client.println("From: User <user@wowway.com>");
       client.println("To: Person at <personat@gmail.com>");
              
       client.println("SUBJECT: my subject here");
       client.println();
       client.println("Body of message");
       client.println();
       client.println(".");  //tell server we are done
       delay(500);
       client.println("QUIT");
       client.stop();  // seems to work fine should I use it?? *********************
       delay(2000);
       digitalWrite(ledPost,OFF);
       return true;
    }
  else
    {
       digitalWrite(ledError,ON);
       return false;
    }  
}

51  Using Arduino / Microcontrollers / Re: atmega1284 programming from a 328 chip on: January 25, 2013, 05:30:03 pm
Hi Crossroads
  Could I use my JTAGICE that has a ISP 6pin connector to program a bootloader into a ATMega1284p?
Would I use the Aduino IDE or AVR Studio 4.18?
  How does this chip fair as an Arduino say with the SPI system for the W5100 ethernet controller.
I ordered a few of these from Mouser. I also have a STK500 also I could use with a 16Mhz crystal too.
Don
52  Using Arduino / Programming Questions / Re: Twittering with Arduino+Ethernet Shield on: January 23, 2013, 09:10:21 pm
Peter
I think that after the Ardunio programs it resets and runs his code. Then he is watching it via serial monitor to debug and that is why he is double posting or tweeting that will give you a 403 since he is sending the same message. He will need to change his tweet some too since he can't keep sending the same thing.
Maybe read millis
Code:
unsigned long time;
 
time = millis();
  //prints time since program started
 client.println(time);
53  Using Arduino / Programming Questions / Re: Twittering with Arduino+Ethernet Shield on: January 23, 2013, 08:57:44 pm
I bet the after the Arduino is completed programing it resets runs your setup code posting the message.
Then you fire up the serial monitor and the board resets again, you double tweeted.

If you remove the posting of the tweet from setup() function and do something like this in loop() you can control it yourself using the serial monitor put a "t" in the line and press send....
Code:
void loop()
{
   byte inChar;
   
   inChar = Serial.read();
   delay(100);
   if(inChar == 't')
   {
        Serial.println("connecting ...");
       if (twitter.post(msg))
        {
           // Specify &Serial to output received response to Serial.
          // If no output is required, you can just omit the argument, e.g.
          // int status = twitter.wait();
          int status = twitter.wait();

          if (status == 200) {
          Serial.println("OK.");
        }
      else
        {
           Serial.print("failed : code ");
           Serial.println(status);
        }
   
     inChar = 0; 
   }
}

54  Using Arduino / Programming Questions / Re: Twittering with Arduino+Ethernet Shield on: January 23, 2013, 08:37:36 pm
did anything post to twitter? if you use those setting in your computer can you get on the internet
get to twitter or google, yahoo? to see if they really would maybe ping, traceroute
403 means you are trying to send a duplicate tweet...
Don
55  Using Arduino / Programming Questions / Re: Twittering with Arduino+Ethernet Shield on: January 23, 2013, 08:16:49 pm
I compared my working code with yours, the only difference I see I'm using DHCP to get a ip address it takes about 5 secs to get a ip from my router. Posting to Twitter is really fast. If you get a error 403
you send a duplicate tweet. I copied this right from my working sketch. If you want to follow me on twitter @AlertsChicago I'm posting weather and emergency broadcast alerts here in Chicago.
Don
Code:
void setup()
{
  delay(1000);
 
  if (!Ethernet.begin(mac))  // Try to connect using DHCP
    Ethernet.begin(mac, ip); // Try to connect using a Static IP address.
  delay(100);
 
  Serial.begin(9600);
  delay(100);
 
  Serial.print(F("Connected to IP address: "));  // Print out the IP address.
  for (int i = 0; i < 4; i++)
    {
      Serial.print(Ethernet.localIP()[i], DEC);
      Serial.print(".");
    }
  Serial.println();
  Serial.println();
}
 
I copied this right from my working sketch.

if you want to follow me on twitter @AlertsChicago
56  Using Arduino / Programming Questions / Re: Twittering with Arduino+Ethernet Shield on: January 23, 2013, 07:05:14 pm
What Arduino are you using? If your using the Uno there is not enough sram. I had to use my Atmega2560 board and the example worked fine.
Don
57  Using Arduino / Programming Questions / Re: Problem with Ethernet Library and Led on: January 23, 2013, 06:51:32 pm
Hi
I understand that D4 is used as the chip select for the SD card. what pin is used for the chip select of the W5100 chip?
Thanks
Don
58  Using Arduino / Project Guidance / Sram in Ardunio microcontrollers on: January 23, 2013, 06:11:19 pm
Hi
Is there a way to know how much sram is being used by the microcontroller's stack, static variables, etc.
I'm just wonder how to determine when I should not use the Uno and switch to my ATMega2560 board
that has 8k compared to the 2k in the Uno. I've been working with the ethernet shield a lot lately
and sending tweets on twitter and emailing with smtp. I'm looking for some guidance.
Thank you
Don
59  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield on: January 21, 2013, 08:46:20 pm
MT
You would need to allow or open a port in you router to steer or "forward" the request to the ip address of you Arduino. Also if your using port 80 your ISP most likely blocks requests to port 80 so if you reassign it to port 8080 that should work. You will need to know your ip address assigned to your router  you could use whatsmyip google it. Then enter http://youripaddress:8080 on your phone and if all is well it work.
Don
60  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet module startup.. on: January 20, 2013, 02:18:09 pm
Paul
 I sure did "learn a valuable lesson" I'm having a lot of fun here.
Thank you to knowledgeable folks here on the forum.
Don
Pages: 1 2 3 [4] 5 6 ... 8