Show Posts
Pages: [1] 2 3 ... 645
1  Using Arduino / Project Guidance / Re: Servo agitating water? on: September 13, 2014, 01:42:49 am
The title is basically all that I'm asking. How would I go about constructing this to make sure it doesn't break down?

Perhaps you could hold the servo by its attached wires and dip it in and out of the water like a teabag.
2  Topics / Robotics / Re: arduino 360° servo wheels on: September 13, 2014, 01:05:53 am
Large plastic jar lids can be used for wheels by hot gluing them to the servo horns.

Why glue them?

Position the servo horn (the round one is best) in the center of the lid, mark the holes (2 to 4), drill or punch them out, then use a few small screws (or small nuts/bolts) to hold them in place. Much more secure and easier maintenance (plus you can re-use the servo and horn later).

Hot glue is generally stronger than the servo shaft, and can actually be carefully peeled/removed from the servo horn if needed. The only real extra thing that needs to be done id drill a small hole in the center of the jar lid for the servo horn screw and the slight bump that might be at the servo horn screw hole. The Below bad video shows the setup with jar lids hot glued to servo horns.




3  Topics / Robotics / Re: arduino 360° servo wheels on: September 12, 2014, 11:44:53 pm
Large plastic jar lids can be used for wheels by hot gluing them to the servo horns.
4  Topics / Home Automation and Networked Objects / Re: Control stepper motor via ethernet. on: September 12, 2014, 08:35:00 pm
Quote
The next challenge I have, is to pass an exact number of steps to the stepper.

You could use a text box web page like below to send what ever number you want to the server. Find the location of the first = in readString, Save the rest of readString from that point, take the int value of that readString, and you would have captured the number you sent.

Code:
//zoomkat 12-08-12
//get submit box code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html or use a '
//address will look like http://192.168.1.102:84 when submited
//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

#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
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84);; //server port

String readString;

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

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  //enable serial data print
  Serial.begin(9600);
  Serial.println("server text box test1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  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); //see what was captured

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          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>HTML form GET example</H1>");

          client.println("<FORM ACTION='/' method=get >"); //uses IP/port of web page

          client.println("Pin 5 'on5' or 'off5': <INPUT TYPE=TEXT NAME='LED' VALUE='' SIZE='25' MAXLENGTH='50'><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Change Pin 5!'>");

          client.println("</FORM>");

          client.println("<BR>");

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

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

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

        }
      }
    }
  }
}

5  Using Arduino / Programming Questions / Re: Need help in read rain forcast using arduino ethernet sheild on: September 10, 2014, 10:28:11 pm
You might use TextFinder or code like bottom.

http://playground.arduino.cc/Code/TextFinder

Code:
// Include description files for other libraries used (if any)
#include <SPI.h>
#include <Ethernet.h>

// Define Constants
// Max string length may have to be adjusted depending on data to be extracted
#define MAX_STRING_LEN  20

// Setup vars
char tagStr[MAX_STRING_LEN] = "";
char dataStr[MAX_STRING_LEN] = "";
char tmpStr[MAX_STRING_LEN] = "";
char endTag[3] = {'<', '/', '\0'};
int len;

// Flags to differentiate XML tags from document elements (ie. data)
boolean tagFlag = false;
boolean dataFlag = false;

// Ethernet vars
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
byte server[] = { 140, 90, 113, 200 }; // www.weather.gov

// Start ethernet client
EthernetClient client;

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting WebWx");
  Serial.println("connecting...");
  Ethernet.begin(mac, ip);
  delay(1000);

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /xml/current_obs/KRDU.xml HTTP/1.0");   
    client.println();
    delay(2000);
  } else {
    Serial.println("connection failed");
  } 
}

void loop() {

  // Read serial data in from web:
  while (client.available()) {
    serialEvent();
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnected");
    Serial.println("==================================");
    Serial.println("");
    client.stop();

    // Time until next update
    //Serial.println("Waiting");
    for (int t = 1; t <= 15; t++) {
      delay(60000); // 1 minute
    }

    if (client.connect(server, 80)) {
      //Serial.println("Reconnected");
      client.println("GET /xml/current_obs/KRDU.xml HTTP/1.0");   
      client.println();
      delay(2000);
    } else {
      Serial.println("Reconnect failed");
    }     
  }
}

// Process each char from web
void serialEvent() {

   // Read a char
char inChar = client.read();
   //Serial.print(".");
 
   if (inChar == '<') {
      addChar(inChar, tmpStr);
      tagFlag = true;
      dataFlag = false;

   } else if (inChar == '>') {
      addChar(inChar, tmpStr);

      if (tagFlag) {     
         strncpy(tagStr, tmpStr, strlen(tmpStr)+1);
      }

      // Clear tmp
      clearStr(tmpStr);

      tagFlag = false;
      dataFlag = true;     
     
   } else if (inChar != 10) {
      if (tagFlag) {
         // Add tag char to string
         addChar(inChar, tmpStr);

         // Check for </XML> end tag, ignore it
         if ( tagFlag && strcmp(tmpStr, endTag) == 0 ) {
            clearStr(tmpStr);
            tagFlag = false;
            dataFlag = false;
         }
      }
     
      if (dataFlag) {
         // Add data char to string
         addChar(inChar, dataStr);
      }
   } 
 
   // If a LF, process the line
   if (inChar == 10 ) {

/*
      Serial.print("tagStr: ");
      Serial.println(tagStr);
      Serial.print("dataStr: ");
      Serial.println(dataStr);
*/

      // Find specific tags and print data
      if (matchTag("<temp_f>")) {
      Serial.print("Temp: ");
         Serial.print(dataStr);
      }
      if (matchTag("<relative_humidity>")) {
      Serial.print(", Humidity: ");
         Serial.print(dataStr);
      }
      if (matchTag("<pressure_in>")) {
      Serial.print(", Pressure: ");
         Serial.print(dataStr);
         Serial.println("");
      }

      // Clear all strings
      clearStr(tmpStr);
      clearStr(tagStr);
      clearStr(dataStr);

      // Clear Flags
      tagFlag = false;
      dataFlag = false;
   }
}

/////////////////////
// Other Functions //
/////////////////////

// Function to clear a string
void clearStr (char* str) {
   int len = strlen(str);
   for (int c = 0; c < len; c++) {
      str[c] = 0;
   }
}

//Function to add a char to a string and check its length
void addChar (char ch, char* str) {
   char *tagMsg  = "<TRUNCATED_TAG>";
   char *dataMsg = "-TRUNCATED_DATA-";

   // Check the max size of the string to make sure it doesn't grow too
   // big.  If string is beyond MAX_STRING_LEN assume it is unimportant
   // and replace it with a warning message.
   if (strlen(str) > MAX_STRING_LEN - 2) {
      if (tagFlag) {
         clearStr(tagStr);
         strcpy(tagStr,tagMsg);
      }
      if (dataFlag) {
         clearStr(dataStr);
         strcpy(dataStr,dataMsg);
      }

      // Clear the temp buffer and flags to stop current processing
      clearStr(tmpStr);
      tagFlag = false;
      dataFlag = false;

   } else {
      // Add char to string
      str[strlen(str)] = ch;
   }
}

// Function to check the current tag for a specific string
boolean matchTag (char* searchTag) {
   if ( strcmp(tagStr, searchTag) == 0 ) {
      return true;
   } else {
      return false;
   }
}
6  Using Arduino / Motors, Mechanics, and Power / Re: Control from my PC, 5 motors independently on: September 10, 2014, 10:17:31 pm
Quote
input : 120 V

Relays might be an option.

http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&_nkw=arduino+relay&rt=nc&LH_BIN=1
7  Using Arduino / Project Guidance / Re: Question regarding Serial Monitor on: September 09, 2014, 11:07:03 pm
Quote
I am trying to do this from a different programming software but i run intro a problem when trying to send some command through rs232.

The arduino input is TTL, so have you made an inverter to convert rs232 to TTL levels, or are you still using the arduino USB serial interface?
8  Using Arduino / Programming Questions / Re: Need help with some coding ( 2 servos 2 potentiometers) on: September 09, 2014, 10:59:10 pm
Some multi servo/pot test code.

Code:
//zoomkat multi pot/servo test 3-23-13
//includes dead band for testing and limit servo hunting
//view output using the serial monitor

#include <Servo.h>
Servo myservo1;  //declare servos
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;

int newval1, oldval1;  //pot input values
int newval2, oldval2;
int newval3, oldval3;
int newval4, oldval4;
int newval5, oldval5;

void setup()
{
  Serial.begin(9600); 
  myservo1.attach(2); 
  myservo2.attach(3);
  myservo3.attach(4);
  myservo4.attach(5);
  myservo5.attach(6);
  Serial.println("testing multi pot servo"); 
}

void loop()
{
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179);
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){ //dead band
    myservo1.write(newval1); //position the servo
    Serial.print("1- ");
    Serial.println(newval1); //print the new value for testing
    oldval1=newval1; //set the current old value
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){ 
    myservo2.write(newval2);
    Serial.print("2- ");   
    Serial.println(newval2);
    oldval2=newval2;
  }

  newval3 = analogRead(potpin3);           
  newval3 = map(newval3, 0, 1023, 0, 179);
  if (newval1 < (oldval1-2) || newval3 > (oldval3+2)){ 
    myservo1.write(newval3);
    Serial.print("3- ");
    Serial.println(newval3);
    oldval3=newval3;
  }

  newval4 = analogRead(potpin4);           
  newval4 = map(newval4, 0, 1023, 0, 179);
  if (newval1 < (oldval1-2) || newval4 > (oldval4+2)){ 
    myservo1.write(newval4);
    Serial.print("4- ");
    Serial.println(newval4);
    oldval4=newval4;
  }

  newval5 = analogRead(potpin5);           
  newval5 = map(newval5, 0, 1023, 0, 179);
  if (newval1 < (oldval5-2) || newval5 > (oldval5+2)){ 
    myservo1.write(newval5);
    Serial.print("5- ");
    Serial.println(newval5);
    oldval5=newval5;
  }
  delay(50);  //to slow loop for testing
}


9  Using Arduino / General Electronics / Re: Multiple serial devices on single port (one at a time) on: September 09, 2014, 10:48:49 pm
Quote
I was thinking of having two devices share an RX and TX and only powering on one at a time, but I figured there should be a more elegant solution to switch the outputs using digital pins. Before working up something using transistors/AND gates, I figured there must be a standard way of doing this. Is there?

If you are having the master poll the slave units and then receive the reply from the slaves, you can connect the master tx pin to all the slave rx pins. the master can include a slave identifier in the slave request such that such that only the desired slave responds. You can put a diode on the slave tx pins so all the slave tx lines can be connected to the master rx pin.
10  Using Arduino / Networking, Protocols, and Devices / Re: Scan network using Ethernet Shield on: September 09, 2014, 10:36:10 pm
Past postings.

https://www.google.com/search?as_q=scan+network&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl
11  Using Arduino / Programming Questions / Re: Webclientrepeating on: September 08, 2014, 09:25:11 pm
Basic client test code you can try to see if you get a reply from the server.

Code:
//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

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

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600);
  Serial.println("Better client test 9/22/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(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println("Connection: close");  //close 1.1 persistent connection 
    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

}

[/code

12  Using Arduino / Motors, Mechanics, and Power / Re: DFRobot DF15RSMG 360 degree rotation (20kg) Programming help on: September 07, 2014, 03:39:39 pm
Below is a basic setup for external power to a servo. Generally trying to power a servo from an arduino does not work.

13  Using Arduino / Project Guidance / Re: read several characters in arduino mega on: September 07, 2014, 11:07:35 am
A simple example of capturing characters sent from the serial monitor and operating the arduino LED.

Code:
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(3); 
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
    }

    readString="";
  }
}

14  Using Arduino / Project Guidance / Re: Arduino as I/O device for RaspberryPi web server on: September 07, 2014, 10:57:36 am
Quote
I could write a separate web page / server for each location, accessible via unique IP addresses (what i do now), but what I really want is one very nice web page/server that is the GUI for my lighting controls.  One-stop-shop for all controls, and the ability to have "macros' that turn on sets of lights (e.g. all exterior lights) through that server.

Generally what is done for a setup like you want is serve the main control page from one server, and in that page have the control links for other servers embedded. Probably the majority of control web pages are made. Look at the below web page which is served from a main web server. if you look at the page source, you will see the control links embedded which connect to an apache web server and web cam application on an old computer I have. You could do the same for a bunch of arduino servers.

http://web.comporium.net/~shb/wc2000-PT-script.htm


15  Using Arduino / Programming Questions / Re: Serial Monitor doesn't show anything on: September 07, 2014, 10:38:56 am
Quote
When I press my pushbutton, d is pressed ,
my serial monitor however, stays blank.

Did I break my board or is something wrong with my arduino?

How do you have a keyboard wired to your arduino?
Pages: [1] 2 3 ... 645