Show Posts
Pages: 1 ... 323 324 [325] 326 327 ... 631
4861  Using Arduino / Programming Questions / Re: Arduino ethernet BOARD example on: August 30, 2012, 09:39:19 pm
Some simple client test code you can try (not PHP related).

Code:
//zoomkat 4-04-12
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605
//the arduino lan IP address { 192, 168, 1, 102 } may need
//to be modified modified to work with your router.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

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

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    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(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

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

}

4862  Using Arduino / Motors, Mechanics, and Power / Re: Sabertooth motor control - tank styled Please help young engineers! on: August 29, 2012, 10:35:49 pm
If you have the sabertooth that can be controlled using servo (RC) control signals, then the coding should be doable for using a joystick with two internal pots. I think there is arduino example code in the IDE for using pots with servos.
4863  Using Arduino / Motors, Mechanics, and Power / Re: Servo system recommendation? on: August 29, 2012, 10:27:58 pm
I'm looking to buy a servo module which can connect a Brushed-DC, BLDC, or Stepper motor with an encoder for feedback.  I need to be able to turn the motor to a precise position.  The motor will need the ability to turn up to 60 turns at a time.  Is there a product that the community likes that can do what I need?

A geared stepper motor can have high resolution (note how many dots per inch ink jet printers can make).
4864  Using Arduino / Motors, Mechanics, and Power / Re: advice about servo encoder on: August 29, 2012, 12:27:51 am
The voltage being supplied to the pot in the servo was 2.0v, so the voltage range on the wiper was 2.0v to 0.0v. To get a full range value output from the ssc-32 I was using, I had to 2.0v as the ssc-32 analog reference voltage. Some more info below.

http://www.lynxmotion.net/viewtopic.php?f=2&t=2748
http://www.lynxmotion.net/viewtopic.php?f=31&t=3182
4865  Using Arduino / Networking, Protocols, and Devices / Re: webClient example problem on: August 29, 2012, 12:00:19 am
Simple client code you can try that connects to a web site I have.

Code:
//zoomkat 4-04-12
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605
//the arduino lan IP address { 192, 168, 1, 102 } may need
//to be modified modified to work with your router.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

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

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    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(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

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

}


4866  Using Arduino / Motors, Mechanics, and Power / Re: advice about servo encoder on: August 28, 2012, 11:56:09 pm
Below is how I connected to a servo pot wiper.

4867  Using Arduino / Motors, Mechanics, and Power / Re: RC Servo motor with feedback output on: August 28, 2012, 11:45:54 pm
Does anyone sell a RC hobby "servo motor" which outputs its position?  I guess I could drill a hole into one and run some wires into it but I rather not.  What I really need is an angle position sensor, but it does not need to be very precision, so I don't need an expensive encoder.  I potentiometer is good enough.

You can read the voltage off of the servo pot wiper, but you would need to open the servo and solder a wire and have an appropriate pot reference voltage.
4868  Using Arduino / Programming Questions / Re: HTTP Request inside a loop on: August 28, 2012, 11:39:24 pm
Client test code that sends a get request to a web server based on an event, in this case an "e" received via the arduino serial port.

Code:
//zoomkat 4-04-12
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605
//the arduino lan IP address { 192, 168, 1, 102 } may need
//to be modified modified to work with your router.

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.begin(9600);
  Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

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

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    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(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

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

}

4869  Using Arduino / Programming Questions / Re: Tiny GPS + Ethernet Shield on: August 26, 2012, 04:35:42 pm
exactly!
I can't create the web server using the arduino, so how am i gonna be able to create the server using the serial monitor?
any example is appreciated!
thanks a lot!

Some simple meta refresh server code from the past you can try to see if it works ion your lan.

Code:
// zoomkat meta refresh server test code
// arduino IDE 1.0
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84 in your brouser
// or http://zoomkat.no-ip.com:84 with dynamic IP service
// use the \ slash to escape the " in the html
// meta refresh set for 2 seconds

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

int x=0; //set refresh counter to 0
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102); // ip in lan
EthernetServer server(84); //server is using port 84

void setup()
{
  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
         
          //meta-refresh page every 2 seconds
          x=x+1; //page upload counter
          client.println("<HTML>");
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
          client.println("<BODY>");
          client.print("Zoomkat's meta-refresh test IDE 1.0");
          client.println("<br />");
                   
          client.print("page refresh number ");
          client.println(x); //current refresh count
          client.println("<br />");
          client.println("<br />");
         
          client.print("Zoomkat's arduino analog input values:");
          client.println("<br />");
          client.println("<br />");
         
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
            }
           break;
          client.println("</BODY>");
          client.println("</HTML>");
         }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

4870  Using Arduino / Project Guidance / Re: Why don't Arduinos run on 5V on: August 26, 2012, 02:46:50 pm
Quote
I can directly go with 5V input.

I've powered powered my arduino with ethernet shield from a 7805 regulator chip connected to a +5v pin on the arduino (also had a 10mfd capacitor on the output for smoothing).
4871  Using Arduino / Project Guidance / Re: hardware side of fridge control on: August 26, 2012, 11:59:18 am
Just for info, below is the schematic for my refidgerator. Newer ones have door opening counters and such to modify defrost cycles and such. Never heard of a consumer level refrigerator with gas reversing valves like in a heat pump (but then I haven't been looking).

4872  Using Arduino / Programming Questions / Re: Servo not working in arduino on: August 26, 2012, 02:07:19 am
How your servo should be wired and simple servo test code.



Code:
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}

4873  Using Arduino / Project Guidance / Re: Frustration vending punchbag on: August 25, 2012, 11:39:42 pm
Hello people,
I have a spare room in my house. I don't intend to bring in my girlfriend because I hate my relationship.

I was thinking about keeping a punchbag in that room. I can install a music system over there too. Now the deal is, as I punch the bag, the music that is playing out of speaker needs to change its tempo based on the power and tone with which I punch it.

How can I implement this? I am ready to get hands on as you guys comment.

1- I am guessing I will need to buy an arduino.
2- I will also require a vibration/pressure censor that is going to be attached to the bag so that the computer to which the vibration censor is connected to, can take data and determine the value of the pressure that is falling on the bag.

I will have to a bit of coding using processing or some software, which I am absolutely clueless about. Guys, I seriously need help.
Mail me urgently to - jsmithbab6@gmail.com OR you can always comment over here.

Do you like guns? Are you eligable for weekend passes?
4874  Using Arduino / Programming Questions / Re: Reading an ethernet boards MAC on: August 25, 2012, 09:23:50 pm
Quote
It’s actually to bad because now each end unit that contains an Ethernet Arduino has to have initialization software sent along with the unit. Do I understand correctly now?

Maybe not. One usually assigns a MAC address in the code that is going to be loaded into the arduino. not sure what your initialization software is.
4875  Using Arduino / Motors, Mechanics, and Power / Re: Servo Motor Shaking Problem on: August 25, 2012, 06:02:16 pm
Make sure your wiring is like the below basic setup. A 50hz buzz often is heard when the servo is under some load or is against its internal hard stop.

Pages: 1 ... 323 324 [325] 326 327 ... 631