Show Posts
Pages: [1] 2 3 ... 637
1  Using Arduino / Programming Questions / Re: Arduino Program for Bluetooth on: August 21, 2014, 10:38:05 pm
Very basic serial code for controlling 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="";
  }
}

2  Using Arduino / Project Guidance / Re: Two Arduino communicating with each other using HC-05 on: August 21, 2014, 09:18:36 pm
probably best to get the communication working over wires first then move into wireless. Below is some code I've used to test serial communications between two arduinos.

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
    }
  }
}

3  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Ethernet Shield used to Create Simple WebPage not Working on: August 21, 2014, 09:05:41 pm
The w5100 chips require a lot of power, and actually run noticeably warm. Probably quickly kill a small 9v battery.
4  Topics / Robotics / Re: Newbie trying to make a Quadcopter on: August 21, 2014, 08:48:07 pm
Previous post on quadcopters.

https://www.google.com/search?as_q=quadcopter&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
5  Topics / Robotics / Re: Control robotic arm using arduino and kinect on: August 21, 2014, 08:36:38 pm
Quote
so far i have succeed to control one servomotor of arm but when i try to control two servomotor's i cant control it at all and i believe it is because i don't fully understand how serial port works.

What are you using for servo power? Most multi servo issues arise from an inadequate power supply for the servos. Trying to power servos from the arduino generally doesn't work.
6  Topics / Robotics / Re: Unable To Use Multiple Servos On Arduino on: August 21, 2014, 08:28:13 pm
Quote
A DC power supply is connected to the Arduino to provide power to all servos (set on 6v), and the voltage from the Arduino itself powers the flex sensors.

If 6v is being supplied to the external power plug on the arduino, what is the measured voltage on the arduino 5v pin?  There may be a significant voltage drop across the onboard regulator. If your code/sensor setup is causing a lot of constant servo movement commands, then your power supply may be inadequate to supply the needed current for five servos constantly being commanded to move.
7  Using Arduino / Motors, Mechanics, and Power / Re: Drawing Current for the Servo Motor Directly from the Arduino board on: August 21, 2014, 07:56:00 pm
Quote
1st Pin of 7806 IC: Vin Pin

You probably need to supply the vin directly from the 12v. If vin goes thru the uno onboard regulator chip, the voltage to the board may be significantly below 5v due to voltage drop across the regulator chip.
8  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Ethernet Shield used to Create Simple WebPage not Working on: August 21, 2014, 06:21:18 pm
Quote
One question - if I use DHCP I delete the byte IP[] = {ip address}; correct?

If you are trying to make a server setup, then you probably should not use DHCP as you really need to use a fixed IP address. Below is some client test code you can try to see if you have some basic network/hardware issues. When you send an efrom the serial monitor, you should get a response 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

}

9  Using Arduino / Networking, Protocols, and Devices / Re: Reading a text file from internet using ethaernet shield on: August 19, 2014, 06:28:34 pm
Basic client test code that gets a simple text file from a web server.

Code:
//zoomkat 11-04-13
//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
//data from server captured in readString

#include <SPI.h>
#include <Ethernet.h>
String readString;

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("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  Serial.println();
}

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
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:" );
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor
  Serial.println(); 
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}
10  Topics / Robotics / Re: Unable To Use Multiple Servos On Arduino on: August 17, 2014, 11:50:17 pm
Quote
A DC power supply is connected to the Arduino to provide power to all servos (set on 6v),

Below is the way you should be externally powering the servos.

11  Using Arduino / Programming Questions / Re: In consistent reading with Arduino to Arduino Communication on: August 17, 2014, 11:35:02 pm
Some test code I've used on an RX arduino. I added a line to convert captured readString to an integer.

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 to serial monitor
        Serial.println(','); //prints delimiting ","
        //do stuff with the captured readString
        int n = readString.toInt();  //convert readString into a number
        readString=""; //clears variable for new input
      }
    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

12  Using Arduino / Programming Questions / Re: Send text to Arduino via serial port on: August 17, 2014, 09:34:17 pm
Simple method of capturing a string of numeric characters and converting them into an integer.

Code:
//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor

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

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  Serial.println("servo-test"); // 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
    myservo.write(n);
    readString="";
  }
}

13  Using Arduino / Motors, Mechanics, and Power / Re: Possible serial buffer overflow? on: August 17, 2014, 07:30:11 pm
Quote
sending 20 commands pr sec,

Maybe you should elaborate more on the source of the commands and just how fast the commands are being sent. I would think a serial buffer might overflow if subjected to a command spew from a micro controller or pc.
14  Using Arduino / Programming Questions / Re: Servo controlled by Button on: August 17, 2014, 12:46:39 pm
Quote
his code makes sense to me but if i press the button there's only a weak twitch inside the servo.

Well, you really need to define what type of button pushes you will be using, there are push/hold, and push/release. My simple code is designed for push/hold such that the moves to the 160 position when the button is held down, and returns to the 20 position when the button is released. If you want the servo to change positions on each push/release, then you need some toggle code.
15  Using Arduino / Project Guidance / Re: Arduino Wireless Internet Interface Configuration to Control via RS232 on: August 17, 2014, 11:29:26 am
Some simple TTL/rs232 setups.

http://www.scienceprog.com/alternatives-of-max232-in-low-budget-projects/
Pages: [1] 2 3 ... 637