Show Posts
Pages: 1 [2] 3 4 ... 594
16  Topics / Robotics / Re: Control 2 Servos with a photoresistor (Arduino UNO) on: April 16, 2014, 07:24:07 pm
Button push servo code that probably be modified to be operated by a photoresistor.

Code:
//zoomkat servo button test 7-30-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}


17  Topics / Robotics / Re: uArmⅠ:An open source robot arm on: April 16, 2014, 07:14:21 pm
Print out "actual size" the Teocreo's_Arm.pdf file I made and posted. The dimensions of the printed parts should be the same size as the  dimensions you printed on them. 
18  Topics / Robotics / Re: uArmⅠ:An open source robot arm on: April 16, 2014, 12:01:37 am
Well, I was able to print OldSalt1945's .dwg files from DraftSight by selecting "A4" size as the .dwg file is a little too large for "letter" selection (but the drawings still fit on 8.5"x11"). Those printouts seem to be to scale. Then I scanned those printouts to .pdf, then printing those .pdf files "actual size" produces scale drawings on letter 8.5"x11" paper. Attached is the scanned .pdf file. Clunky, but apparently gets the job done. Still need to figure out how to bisect large drawings in DraftSight into smaller parts that will fit on letter sized paper. 
19  Using Arduino / Project Guidance / Re: Robot control project on: April 15, 2014, 10:20:02 pm
Get an arduino, some servos, and an external power supply for the servos, then start experimenting.
20  Using Arduino / Project Guidance / Re: Controls for a project on: April 15, 2014, 10:17:44 pm
Quote
lets say before i power down the arduino, is there a way i can save the positions of the servos to memory so when i power up, the servos doesnt jump back to center or should i make sure the servos are at 90 before i power down

It would be easiest to have a standard "park" position for the servos before shutdown, then initially attach the servos in this position on startup.
21  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 15, 2014, 10:11:58 pm
Because coordinating use of a serial channel is easier than using separate channels?
Only in special case apps. Otherwise more trouble than it's worth.

As for Strings... you have been shown again and again about those and Arduino.

Yes, there are BAD practices that can be gotten away with. And then comes the help needed posts where as usual part of the fix is an OP UN-learning stupid/wasteful/bad habits before they can write their non-trivial projects.

Damage control? Yeah, to try and cut the HOURS WASTED over stupid/wasteful/bad practices.


You put out inaccurate information. I corrected the misinformation.  smiley-roll-blue
22  Using Arduino / Project Guidance / Re: Arduino using telnet on: April 15, 2014, 10:07:19 pm
Quote
My question was, what should I write in my TERMINAL (after connecting it to my board using telnet), to send instructions to my board?

Well, you write some type of command in your terminal, capture and evaluate the command in your telnet server code, then have the server arduno do something based on the command. You need to post your telnet server code to see what you have so far.
23  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 15, 2014, 09:50:43 pm
Quote
It is limited and it is more trouble than it's worth. Same as using String Objects on an UNO.

Damage control!  smiley-cool
24  Using Arduino / Project Guidance / Re: Interfacing the EZ Antenna Tracker with arduino. Suggestions? on: April 15, 2014, 09:46:55 pm
If the bot moves fairly slowly you might consider an Ethernet based wifi system that can stream video and provide bot controls.
25  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 15, 2014, 09:39:13 pm
Quote
You can't have the Arduino to Arduino serial on the same pins that one of the Arduinos uses to Serial Monitor.

Sure you can. I've used the below test code on two arduinos appropriately connected tx/rx/gnd. What is typed in the master serial monitor and sent to the master is echoed back to the master serial monitor and also appears on the slave serial monitor. To make the slave operate the same way to the master, put a diode in the slave tx line with the diode band toward the slave tx pin.

Code:
//zoomkat 3-5-12 simple delimited ',' string tx/rx
//from serial port input (via serial monitor)
//and print result out serial port
//Connect the sending arduino rx pin to the receiving arduino rx pin.
//Connect the arduino grounds together.
//What is sent to the tx arduino is received on the rx arduino.
//Open serial monitor on both arduinos to test

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.print(readString); //prints string to serial port out
        Serial.println(','); //prints delimiting ","
        //do stuff with the captured readString
        readString=""; //clears variable for new input
      }
    }  
    else {    
      readString += c; //makes the string readString
    }
  }
}

26  Using Arduino / Project Guidance / Re: Moving servo using a momentary push button on: April 15, 2014, 09:22:50 pm
Very simple servo/button setup.

Code:
//zoomkat servo button test 7-30-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}

27  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield Coding on: April 15, 2014, 04:53:57 pm
Server code that supplies the arduino analog pin output to a web page.

Code:
// zoomkat's meta refresh data frame test page 5/25/13
// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

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

const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
const int analogInPin3 = A3;
const int analogInPin4 = A4;
const int analogInPin5 = A5;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino 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
unsigned long int x=0; //set refresh counter to 0
String readString;

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

void setup(){
  Serial.begin(9600);
    // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.println("meta refresh data frame test 5/25/13"); // so I can keep track of what is loaded
}

void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readString.length() < 100) {
          readString += c;
         }
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received
          Serial.println(readString);

          //output HTML data header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          //generate data page
          if(readString.indexOf("data") >0) {  //checks for "data" page
            x=x+1; //page upload counter
            client.print("<HTML><HEAD>");
            //meta-refresh page every 1 seconds if "datastart" page
            if(readString.indexOf("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>");
            //meta-refresh 0 for fast data
            if(readString.indexOf("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>");
            client.print("<title>Zoomkat's meta-refresh test</title></head><BODY><br>");
            client.print("page refresh number: ");
            client.print(x); //current refresh count
            client.print("<br><br>");
           
              //output the value of each analog input pin
            client.print("analog input0 is: ");
            client.print(analogRead(analogInPin0));
           
            client.print("<br>analog input1 is: ");
            client.print(analogRead(analogInPin1));
                       
            client.print("<br>analog input2 is: ");
            client.print(analogRead(analogInPin2));
           
            client.print("<br>analog input3 is: ");
            client.print(analogRead(analogInPin3));
                                   
            client.print("<br>analog input4 is: ");
            client.print(analogRead(analogInPin4));
           
            client.print("<br>analog input5 is: ");
            client.print(analogRead(analogInPin5));
            client.println("<br></BODY></HTML>");
           }
          //generate main page with iframe
          else
          {
            client.print("<HTML><HEAD><TITLE>Zoomkat's frame refresh test</TITLE></HEAD>");
            client.print("Zoomkat's Arduino frame meta refresh test 5/25/13");
            client.print("<BR><BR>Arduino analog input data frame:<BR>");
            client.print("&nbsp;&nbsp;<a href='http://192.168.1.102:84/datastart' target='DataBox' title=''yy''>META-REFRESH</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/data' target='DataBox' title=''xx''>SINGLE-STOP</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/datafast' target='DataBox' title=''zz''>FAST-DATA</a><BR>");
            client.print("<iframe src='http://192.168.1.102:84/data' width='350' height='250' name='DataBox'>");
            client.print("</iframe><BR></HTML>");
          }
          delay(1);
          //stopping client
          client.stop();
          //clearing string for next read
          readString="";
        }
      }
    }
  }
}

28  Using Arduino / Programming Questions / Re: Having trouble "inserting" new characters to a String object. on: April 15, 2014, 04:40:30 pm
You might be able to use the StringReplace function to do what you need.

http://arduino.cc/en/Tutorial/StringReplace
29  Using Arduino / Programming Questions / Re: Misbehaving servo on: April 15, 2014, 04:27:25 pm
Quote
I have the servo and the arduino connected to the same power supply to avoid ground issues, and available current should be more than ample at 3A (no load on the servo)  Is there anything you could suggest to regulate the power to the arduino to ensure its getting what it needs while the servo is being power hungry?

The servo you have is made to work with standard RC equipment, so it should work with the servo.h library just as any analog servo. You don't mention the voltage output of your power supply, but 6v to 7.2v is recommended for your servo. Below is a way I isolated a servo controller from resetting due to servo induced low voltage dips. I put a large capacitor across the 5v/ground on the chip, and used a diode on the power to the controller to prevent the capacitor from back feeding  the servo when the servo caused the voltage dips.


30  Using Arduino / Programming Questions / Re: Parsing a part of a string of unknown length on: April 15, 2014, 03:33:43 pm
Some code samples that have String operations you might use. You could capture the String, check to see if contains key words like "TITLE", find the location of the colon : in the String, then capture the remainder of the String starting two places beyond the location of the colon smiley-small

Code:
//zoomkat 3-5-12 simple delimited ',' string 
//from serial port input (via serial monitor)
//and print result out serial port

String readString, data;
int CD, CM, CT, CS, BR;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like CD01,CM01,CT01,CS03,BR255,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
   
    if (c == ',') {
      Serial.println(readString); //prints string to serial port out
     
      if(readString.indexOf("CD") >=0) {
        data=readString.substring(2);
        Serial.print("CD is: ");
        Serial.println(data);
        CD = data.toInt();
        Serial.println(CD);
        Serial.println();
      }
      if(readString.indexOf("CM") >=0) {
        readString=readString.substring(2);
        Serial.print("CM is: ");
        Serial.println(readString);
        CM = readString.toInt();
        Serial.println(CM);
        Serial.println();
      }
      if(readString.indexOf("CT") >=0) {
        readString=readString.substring(2);
        Serial.print("CT is: ");
        Serial.println(readString);
        CT = readString.toInt();
        Serial.println(CT);
        Serial.println();
      }
       if(readString.indexOf("CS") >=0) {
        readString=readString.substring(2);
        Serial.print("CS is: ");
        Serial.println(readString);
        CS = readString.toInt();
        Serial.println(CS);
        Serial.println();
      }
       if(readString.indexOf("BR") >=0) {
        readString=readString.substring(2);
        Serial.print("BR is: ");
        Serial.println(readString);
        BR = readString.toInt();
        Serial.println(BR);
        Serial.println();
      }
     
      //do some stuff

      readString=""; //clears variable for new input
      data="";

    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

Code:
//zoomkat 3-5-12 simple delimited ',' string 
//from serial port input (via serial monitor)
//and print result out serial port

String readString, substring;
//String servo1;
int loc;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like AA BB01/10/2014 CC12:23:25 DD32.2 EE5432 FF54.35,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    //if (c == '\n') {  //looks for end of data packet marker

    if (c == ',') {
      Serial.println(readString); //prints string to serial port out
      //do stuff     
      loc = readString.indexOf("BB");
      //Serial.println(loc);
      substring = readString.substring(loc+2, loc+12);
      Serial.print("date is: ");
      Serial.println(substring);

      loc = readString.indexOf("CC");
      //Serial.println(loc);
      substring = readString.substring(loc+2, loc+11);
      Serial.print("time is: ");
      Serial.println(substring);

      loc = readString.indexOf("DD");
      //Serial.println(loc);
      substring = readString.substring(loc+2, loc+6);
      Serial.print("DD is: ");
      Serial.println(substring);

      loc = readString.indexOf("EE");
      //Serial.println(loc);
      substring = readString.substring(loc+2, loc+6);
      Serial.print("date is: ");
      Serial.println(substring);

      loc = readString.indexOf("FF");
      //Serial.println(loc);
      substring = readString.substring(loc+2);
      Serial.print("FF is: ");
      Serial.println(substring);     

      readString=""; //clears variable for new input
      substring="";

    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}
Pages: 1 [2] 3 4 ... 594