Show Posts
Pages: 1 ... 4 5 [6] 7 8 ... 13
76  Using Arduino / Programming Questions / Re: Arduino Menu Help for a Beginner on: December 03, 2012, 11:51:16 am
It is really difficult to understand "for what you are looking".
77  Using Arduino / Programming Questions / Re: NTP Schedule on: December 03, 2012, 11:43:58 am
After one time setting of RTC you can track the time even in cases of battery outrage, controller reprogramed etc.

Search on RTC arduino explains more.
78  Using Arduino / Programming Questions / Re: TelnetClient example on: December 03, 2012, 08:43:54 am
Quote
Before I move on, please describe a real-world scenario for this TelnetClient example
http://arduino.cc/blog/2012/11/16/ardupower/
79  Using Arduino / Programming Questions / Re: WiFly and Pachube sprinf question on: December 03, 2012, 08:41:11 am
Quote
Good morning,

Can someone please help a bit here ? Many thanks.

I am trying to understand this syntax: sprintf(buff,"0,%d\n1,%d",i++,analogRead(0));
It is converting analogRead to a string in a specific format. It does work, but I failed to send multiple sensors with the same command line. Obviousely, at this stage I don' understand it very well.

Code:
sprintf(buff,"%d,%d,%d,%d\n",i++,analogRead(0),analogRead(1),analogRead(2));

output
Quote
0,3,1015,970

To understand sprintf try this
 http://www.cplusplus.com/reference/cstdio/sprintf/
80  Using Arduino / Programming Questions / Re: TelnetClient example on: December 03, 2012, 08:30:51 am
Quote
I'm trying to educate myself, not just brush things off as not important and overlook such examples.  Why does this example have me specify both ip and server?

That's good

Code:
/ Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);

firtst two comment lines explaining the purpose of IP and Mac. Actually first you need to understand what is telnet?
81  Using Arduino / Programming Questions / Re: Struggling with switching Arduino and Random numbers on: December 03, 2012, 08:18:27 am
Hi Mazza!
you post code in your reply#1 in which condition of IF statement like that
Code:
if(ranNum==3)
        {
        digitalWrite(3, HIGH);
        }

but in your reply#21

Code:
if(signal=LOW)                                                   //the input turns off
break;

and

Code:
if(signal=HIGH);

By looking first reply it's mean you know how to use IF statement

"="  is you used for assignment
==  is you used for comparing

Why you put terminator ";" at the end of third IF statement
if(signal=HIGH);
82  Using Arduino / Programming Questions / Re: NTP Schedule on: December 03, 2012, 07:06:25 am
Zoomkat code may help you how to run server and client on same machine

Code:
//zoomkat 12-08-11, combined client and server
//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor and send an g to test client and
//see what the arduino client/server receives
//web page buttons make pin 4 high/low
//use the \ slash to escape the " in the html
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
IPAddress ip(192,168,1,102); // ip in lan
IPAddress gateway(192,168,1,1); // internet access via router
IPAddress subnet(255,255,255,0); //subnet mask
IPAddress myserver(208,104,2,86); // zoomkat web page
EthernetServer server(84); //server port
EthernetClient client;
String readString;

//////////////////////

void setup(){

  pinMode(4, OUTPUT); //pin selected to control
  Ethernet.begin(mac, ip, subnet, gateway);
  server.begin();
  Serial.begin(9600);
  Serial.println("server/client 1.0 test 12/08/11"); // keep track of what is loaded
  Serial.println("Send an g in serial monitor to test client"); // what to do to test client
}

void loop(){
  // check for serial input
  if (Serial.available() > 0)
  {
    byte inChar;
    inChar = Serial.read();
    if(inChar == 'g')
    {
      sendGET(); // call sendGET function
    }
  } 

  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging

            //now output HTML data header
          if(readString.indexOf('?') >=0) { //don't send new page
            client.println("HTTP/1.1 204 Zoomkat");
            client.println();
            client.println(); 
          }
          else {
            client.println("HTTP/1.1 200 OK"); //send new page
            client.println("Content-Type: text/html");
            client.println();

            client.println("<HTML>");
            client.println("<HEAD>");
            client.println("<TITLE>Arduino GET test page</TITLE>");
            client.println("</HEAD>");
            client.println("<BODY>");

            client.println("<H1>Zoomkat's simple Arduino 1.0 button</H1>");

            client.println("<a href=\"/?on\" target=\"inlineframe\">ON</a>");
            client.println("<a href=\"/?off\" target=\"inlineframe\">OFF</a>");

            //client.println("<IFRAME name=inlineframe src=\"res://D:/WINDOWS/dnserror.htm\" width=1 height=1\">");
            client.println("<IFRAME name=inlineframe style=\"display:none\" >");         
            client.println("</IFRAME>");

            client.println("</BODY>");
            client.println("</HTML>");
          }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

//////////////////////////
void sendGET() //client function to send/receie GET request data.
{
  if (client.connect(myserver, 80)) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  }
  else {
    Serial.println("connection failed");
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read();
    Serial.print(c);
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop();

}

http://arduino.cc/forum/index.php?topic=90210.0
83  Using Arduino / Programming Questions / Re: TelnetClient example on: December 03, 2012, 06:33:11 am
Code:
EthernetServer telnetServer(23);
 
Code:
telnetServer.begin();

Wow this not a way to run both client and server on same machine.


Quote
I don't see where telnet comes into place in the TelnetClient example.

Actually now Serial Port your cmd line

Code:
while (Serial.available() > 0) {
    char inChar = Serial.read();
    if (client.connected()) {
      client.print(inChar);
    }
  }
84  Using Arduino / Programming Questions / Re: Detecting button press outside of loop() on: December 03, 2012, 06:08:47 am
Quote
I was under the impression everything goes on from within the loop() function, but i've seen code where a guy is detecting button presses and rotary encoders and i can't see any relation to the functions he's using inside of loop().

Quote
yeah ive been calling functions ive make up from outside of loop, but for them to run they need to be referenced back into loop() somehow dont they?

KirAsh4 mention about "interrupts".
Yes, this can be done by "interrupts".

if you see in setup() you will find the relation.
85  Using Arduino / Programming Questions / Re: Arduino Leonardo not seen by computer on: December 01, 2012, 06:42:26 am
Restart each and everything
86  Using Arduino / Programming Questions / Re: Struct problem on: December 01, 2012, 03:15:01 am
Sorry for late reply i was litle busy in my code

"pYro_65 explains it well"
87  Using Arduino / Programming Questions / Re: Struct problem on: December 01, 2012, 02:33:27 am
Code:
MyClass obj();  //change this

to

Code:
MyClass obj;
88  Using Arduino / Programming Questions / Re: HELP on: December 01, 2012, 02:29:15 am
Code:
if( FLOW == 2)<---------the part im getting the problem at.

void FLOW (int Flow)
{
  if (digitalRead(buttonPin))
  {
    Flow = 1;
  }

  if (digitalRead(buttonPin2))
  {
   Flow = 2;
  }
}

Try guix code

Code:
void loop()
{
  if( FLOW() == 2 )
  {
    //do something when FLOW() returns 2
  }

  else if( FLOW() == 1 )
  {
    //do something when FLOW() returns 1
  }

  else
  {
    //do something when FLOW() returns 0
  }
}


int FLOW()
{
  if (digitalRead(buttonPin))
  {
    return 1;
  }

  else if (digitalRead(buttonPin2))
  {
    return 2;
  }

  return 0;
}
89  Using Arduino / Programming Questions / Re: Arduino uno with ethernet shield problems on: November 30, 2012, 12:38:31 am
Use ping in cmd to check response of ethernet device on your network e.g. ping 192.168.3.178
90  Using Arduino / Programming Questions / Re: Arduino uno with ethernet shield problems on: November 30, 2012, 12:33:09 am
What do you mean by wireless?

Quote
I can not get the arduino uno with ethernet shield to send data to another pc wirelessly.

Did you post your exact code?

Code:
if (Ethernet.begin(mac) == 0){
      Serial.println("Failed to configure Ethernet using DHCP");
      for(;
        ;
    }

what is this?

Code:
for(;
        ;

if this comment use // for comment

Use # to post your code
Pages: 1 ... 4 5 [6] 7 8 ... 13