text:
Exoskeleton Motor Control Code
Background:
I have been working on an exoskeleton project with a group of friends, and I need help.  I made another post on the robotics.stackexchange site for the drive system: https://robotics.stackexchange.com/questions/4323/exoskeleton-drive-system-help.  You can also check out our first prototype on youtube: https://www.youtube.com/watch?v=NL_aCwJSRiE&feature=youtu.be
The device is going to be controlled by an iPad that we created via bluetooth.  We are using the adafruit bluefruitLE
We are attempting to control 4 motors (2 knee motors and 2 hip motors) from an Arduino Mega.  We will be using 2 Roboclaw 2x60A motor controllers.  We are trying to get the motors to mimic the graph (see attached).

The graph is in degrees per percent cycle (a gait cycle).  We are using 50 gait cycles per minute for tests but we hope to make it adjustable.
We can change percent cycle to time in milliseconds using dimensional analysis (ie) 50 cycles/min = 8.333x10^-4 cycles/ms  —->  1/8.333x10^-4 cycles/ms is approx. 1200 ms/cycle.  So if you multiply the cycle times 1200 you get millisecond for a certain percent of the cycle (ie) 0.5cycles(50 percent of cycle) * 1200ms/cycle = 600 ms.
We will have a position feedback system incorporated in the drive system but because it is a prototype and I wanted to make the code as versatile as posible I created a function: getDegrees(int jointNum), so if I change the position feedback system I only have to change the getDegrees method.
In order to mimic the graph we broke the graph up into sections.  Each section represents a different velocity.  We are going to run a correction algorithm so far we have just done the P in PID, we have used a modifier of 1.5.  Then we saved the value that the section ended on so next gait cycle when it runs that section the algorithm will start off closer to the target value.
My question:
I need help developing a strategy in order to sync the movement of the 4 joints while running a correction algorithm on each joint individually.  While the device is running we need to be able to constantly check for a bluetooth message from the iPad.  The bluetooth messages come in via SPI from the adafruit bluefruitLE.
What I have done so far:
I have been able to run a single joint by using a while statement (ie)
int i = 0;
void loop(){
targetAngle = nextAngle[i]; //nextAngle is an array of points so nextAngle[0] through nextAngle[1] represents one section of the graph.
i++
if (getDegrees(1)< targetAngle){
double deg = getDegrees(1);
while (deg<targetAngle){
/*
*
*Execute drive code
*
*/
deg = getDegrees(1);
}else{
double deg = getDegrees(1);
while (deg>targetAngle){
/*
*
*Execute drive code
*
*/
deg = getDegrees(1);
}
}
}

The main problem with that code is its like using the delay() function instead of millis() is that it stops the program while its executing the code, and I cannot run multiple motors and check for bluetooth messages.
Major Challenges:
The drive commands must be based off of angle and not time.  It is ok if we tell it do 50 cycles per minute and it does 52 or 48 but its not okay if it only does 97% of the motion.
Possible solutions I have come up:
Using one arduino for each joint, and making them all slaves of a master arduino and the master arduino would act as the middle man sort of between the joints, making sure that they are synced up.  That way each arduino could use code similar to what I have already tried and confirmed to work.  But I would prefer to run it all from one arduino.
Conclusion:
I need help developing a strategy in order to sync the movement of the 4 joints while running a correction algorithm on each joint individually.
Is this the right forum for this question?  Or is it more of a Stack Overflow or Robotics question?
Any help will be greatly appreciated,
--
Joel

Writing an answer now and curious: Why do you prefer delay() over millis()?

I dont prefer delay() over millis().  I was using that as an analogy to show that while loops stop the void loop() function from continuing to loop like the delay() function does.  I prefer millis() over delay() because it doesn't stop the void loop() function.

As your question "to sync the movement of the 4 joints while running a correction algorithm on each joint individually."
Referring to the first part of your question, sync the movement, assume your are doing this at either commercial or university project level, popular practice is to use 'hard real time preemptive operating system".
RTOS, real time operating system, is a piece of system software that coordinates execution of your multi thread user software at precise and predictable time accuracy in order of millisecond.
RTOS involve money and learning time. You may want to continue using the simpler system that you already having now and work in just one joint, hence, no issue of syncing multiple joints. Once you reach some maturity on single joint, then, expand to syncing 4 joints.
RTOS can be commercial with full support or free of charge. Some are dual mode. Same software may either be free or if you choose, can buy commercial full support. There are simple and full-scale implementations where functionality, complexity, learning time and software cost (commercial  or free) varies by huge extend. You will then be more able to choose when you done the above single joint system.
Introduction http://en.wikipedia.org/wiki/RTOS
There are also real time 'executive' (smaller and less functions). For example, ucos II (older and simple version) is used by many people.
Hope it helps

Thanks for the response,  it got me to think more about how to order the processing.  What I am thinking now is to maybe stack the knee and hip graph and cut them up into equal sections.  Then have one angle as a reference and run a while loop based on that angle and run the drive commands for the other joints inside that while loop.  Theoretically when the reference joint gets to its target position the other joints should get there as well, however theoretically is not reality so inside the while loop I will add if statements to make sure the joints don't over rotate.

then after several cycles the algorithm will have hopefully honed in on the target velocity and the other joints will finish closer and closer to the target position.

Does that make any sense?  Do you think that would work?

Human and robot motion is a table of time and many independent TARGET angles at many joints.Example, at time 0,angle0 is 0,angle1 is 10; at time 0.01 second,angle0 is 10,angle1 is 30; at time 0.02sec,angle0 30,angle1 60 Then, feedback_error=actualangle-TAGET_ANGLE Use PID to control Motor based on error. Actual motion is a table of time and corresponding angles. 100 to 300 rows should be enough. One second 10 to 30 steps for smooth motion. Video human and play frame by frame to see, video is 25 to 30 frames per second.

These 'toys' robot comes with pc software for user to enter the 'time table' and the robot will move and dance. Typical has 10 to 20 joints. Comes with pc software for user to enter table and can selectively 'play back' from time point a to b. http://www.dx.com/p/32-ch-servo-motor-control-driver-board-for-arduino-works-w-official-arduino-board-blue-black-206987#.U9kvoECj7qY    http://robosavvy.com/store/images/khr3hvstore.jpg  https://www.youtube.com/watch?v=d3O2dQQTdYM

Here's what I came up with:

You have a certain percent of the gain cycle equal one "step" (step may be a bad term in this situation, but I'm using it because of stepper motors).
You have a blocking function that will move the motors and control all the P(ID) logic

Before this function is called, the main code will use a variable to store the desired time to do the next "step."
It will have a loop with "substeps." So it would look kinda like this:

void function nextStep(int var1, int var2) {
    //Read sensors and put into variables
    until(condition == true) { //Condition to see if the motors are at the right degree
        //Adjust motors not in the right place
        delayAndCheckBT(10); //Look at the bottom for this function
    }
}

You could also have it accept a few percent of variance as tolerance so it's not shakey, but that's more of the PID control than anything. You'll have to make sure that many 'steps' doesn't make the PID controller unstable.

When that code is done, the main function will check to see if the desired time for the next step has passed (or if it's now). If it's passed/now, then it will execute. Otherwise, it will not execute the next step and continue executing the main loop.

Great? No. The problem is you need to check for bluetooth! To do this, I've made two functions:
void checkBT() {
    //Checks BT. Make sure this is non blocking: if you need to, set a few global variables
    //Note this code will get called a LOT, so don't implement any delays or loops: inside here: use millis().
}
void delayAndCheckBT(int timeToWait) {
    unsigned long finishTime = millis() + timeToWait;
    while (millis()<finishTime) {
        checkBT();
    }
}


text:
Converting Arduino Uno with Ethernet Shield sketch for Arduino Yún
I'm new to the Arduino Yun and I'm trying to convert a sketch written for the Arduino Uno with a Ethernet Shield. The sketch does HTTP posts to Azure Mobile Services.
I've added in the Bridge.h and YunClient.h libraries in place of the Ethernet.h one for the Uno.
My modified sketch compiles, however, I don't think the http posts are working. I don't see my table updating in Azure.

    /*
    ** This sample Arduino sketch uploads telemetry data to Azure Mobile Services
    ** See the full article here: http://hypernephelist.com/2014/07/11/arduino-uno-azure-mobile-services.html
    **
    ** Thomas Conté @tomconte
    */
#include <Bridge.h>
#include <YunClient.h>
//#include <Ethernet.h> // removed as not used by Yun
#include <SPI.h>

// not sure if these libraries are required?
#include <HttpClient.h>
#include <Process.h>

// Ethernet shield MAC address (sticker in the back)
//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// 90:A2:DA:F8:28:38

// Azure Mobile Service address
// You can find this in your service dashboard
const char *server = "myhost.azure-mobile.net";

// Azure Mobile Service table name
// The name of the table you created
const char *table_name = "my_data";

// Azure Mobile Service Application Key
// You can find this key in the 'Manage Keys' menu on the dashboard
const char *ams_key = "HJRxFXXXXXXXXXXXXXXXXXXXNQoMcXXXXXXx99";

//EthernetClient client;
YunClient client;

char buffer[64];

/*
** Send an HTTP POST request to the Azure Mobile Service data API
*/

void send_request(int value)
{
  Serial.println("\nconnecting...");

    Serial.print("sending ");
    Serial.println(value);

    // POST URI
    sprintf(buffer, "POST /tables/%s HTTP/1.1", table_name);
    client.println(buffer);

    // Host header
    sprintf(buffer, "Host: %s", server);
    client.println(buffer);

    // Azure Mobile Services application key
    sprintf(buffer, "X-ZUMO-APPLICATION: %s", ams_key);
    client.println(buffer);

    // JSON content type
    client.println("Content-Type: application/json");

    // POST body
    sprintf(buffer, "{\"value\": %d}", value);

    // Content length
    client.print("Content-Length: ");
    client.println(strlen(buffer));

    // End of headers
    client.println();

    // Request body
    client.println(buffer);

}

/*
** Wait for response
*/

void wait_response()
{
  while (!client.available()) {
    if (!client.connected()) {
      return;
    }
  }
}

/*
** Read the response and dump to serial
*/

void read_response()
{
  bool print = true;

  while (client.available()) {
    char c = client.read();
    // Print only until the first carriage return
    if (c == '\n')
      print = false;
    if (print)
      Serial.print(c);
  }
}

/*
** Close the connection
*/

void end_request()
{
  client.stop();
}

/*
** Arduino Setup
*/

void setup()
{
Serial.begin(9600);
Serial.println("Starting Bridge");
Bridge.begin();

}

/*
** Arduino Loop
*/

void loop()
{
  int val = analogRead(A0);

  send_request(val);
  wait_response();
  read_response();
  end_request();

  delay(1000);
}

Ok I figured this one out, I was missing the code to connect to the web service
if (client.connect(server, 80)) {

So? What happen? What do you did?

(Updating answer from comments.)
The OP answered their own question, they missed the code to connect to the web service
if (client.connect(server, 80))

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Why does arduino work on usb power?
The arduino website states that the operating voltage of an arduino is 7-12V.
Why does the arduino work powered on just usb then? As usb only outputs 5V and 500ma.
Is it preferable to say run the arduino on an external 9V dc power source, or does it make no difference?

The arduino website states that the operating voltage of an arduino is 7-12V.

That's when it goes through the voltage regulator. It's a linear regulator, meaning it wastes a lot of power as heat. The regulator outputs 5V that's given to the MCU. The USB voltage bypasses the regulator and goes to a fuse before going to the common 5V for the board. If less than 7V is given to the regulator, it will produce less than 5V.

Is it preferable to say run the arduino on an external 9V dc power source, or does it make no difference?

Usually, yes. A 9V supply would give you more than 500ma, giving you flexibility to add higher current components like motors and lots of LEDs. It will make no difference if you have a single LED connected.

Although you wouldn't want to run too much off the built-in regulator...

@Ignacio, true, but IIRC it's over an amp vs 500ma max... also if you use the 9V directly for sensors.

this may seem like a dumb question but will the following be a sound power supply for the arduino? http://thepihut.com/products/7-port-usb-hub-for-the-raspberry-pi  I have a 9V 1A PSU also, not sure which is the best to power it off. Or are both sound bets?

@c_breeez I can't advise you because I don't know anything about your situation.

Note that while a 9V power supply may be reasonable, future readers should not confuse that with a small 9v battery, a very low current device.  In terms of the regulator's capability there are two issues - one is a current rating, but often the more important one is a thermal rating for dissipated power, and that depends on the difference between input and regulated voltages as well as the current drawn.  The higher the supply voltage above the minimum, the less current the regulator can pass without overheating. High current projects should use a distinct regulator for peripheral loads.

@AnnonomusPenguin im running two arduino s one powering 8 300 micro amp ir detectors and one ir led. The other 6 detectors and one ir led. I'm also running a innovations id12la rfid reader on another port. And a wifi dongle. So yeah those four things one on each port. A mega, an uno, a wifi dongle and an rfid reader

@c_breez as long as the RFID reader and the wifi dongle comply with USB 2.0 specifications (no reason why they shouldn't), then the USB hub should be plenty fine. I'd be surprised if the Arduinos used 1/10th of an amp... the only thing is I think the Pi might need to be powered on for power to be delivered to the devices...

@AnnonomusPenguin Awesome thanks a lot of the input and reassuring me on this, just wanting to make sure I get the power requirements right for my project. I just tested the hub out and it will power arduinos without the pi being connected, as it runs off a DC adapter. Thanks a lot for the help

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Analog angle conversion from +70° to -70°
I am using below sensor (accelerometer) .My application is a solar tracker, where I wanted to convert the sensor output into +70° to -70° format.
My question is how can I convert the angle?
#define ADC_ref 2.56
#define zero_x 1.569
#define zero_y 1.569
#define zero_z 1.569
#define sensitivity_x 0.3
#define sensitivity_y 0.3
#define sensitivity_z 0.3

unsigned int value_x;
unsigned int value_y;
unsigned int value_z;

float xv;
float yv;
float zv;

float angle_x;
float angle_y;
float angle_z;

void setup() {
  //analogReference(INTERNAL2V56);
  Serial.begin(9600);
}

void loop() {
  value_x = analogRead(A0);

//  value_y = analogRead(A1);
  //value_z = analogRead(A2);

  Serial.print("voltage  of x");
  Serial.println(value_x);
  /*Serial.print("voltage  of y");
   Serial.println(value_y);
   Serial.print("voltage  of z");
   Serial.println(value_z);
   */
  //xv=(value_x/1024.0*2.5)/sensitivity_x;
/*  zv=(value_z/1024.0*ADC_ref-zero_z)/sensitivity_z;
  yv=(value_y/1024.0*ADC_ref-zero_y)/sensitivity_y;
  xv=(0.0032226562499999998*value_x)/sensitivity_x;
  angle_x =atan2(-yv,-zv)*57.2957795+90;

  Serial.print ("x= ");
  Serial.println (xv);
  Serial.print("x_degree= ");
  Serial.print(angle_x);
  Serial.println(" deg");

  /*Serial.print(" g ");

   Serial.print ("y= ");
   Serial.print (yv);
   Serial.print(" g ");

   Serial.print ("z= ");
   Serial.print (zv);
   Serial.print(" g ");

   Serial.print("\n");

   Serial.print("Rotation ");

   Serial.print("x= ");

   angle_x =atan2(-yv,-zv)*57.2957795+180;

   Serial.print(angle_x);
   Serial.print(" deg");
   Serial.print(" ");

   Serial.print("y= ");

   angle_y =atan2(-xv,-zv)*57.2957795+180;

   Serial.print(angle_y);
   Serial.print(" deg");
   Serial.print(" ");

   Serial.print("z= ");

   angle_z =atan2(-yv,-xv)*57.2957795+180;

   Serial.print(angle_z);
   Serial.print(" deg");
   Serial.print("\n");
   */
  delay(1000);
  //delay(1000);
}

Description
Datasheet of ADXL335

I have inclinometer off the shelf its Vout is 0~5 V and angle measure from -70° to 70°, and I calculated as below.
void calcPos()
{
  Sensor_Value=analogRead(A3);
  voltage = Sensor_Value * ARDUINO_ANALOG_SCALING;
  tracker_actual_pos=(30*voltage)-75;
}

If you are using a multi-axis accelerometer such as you linked to measure angles, then you probably need to take an inverse tangent of the ratio between two axis.  If that proves too painful to calculate, you can make a lookup table of tangents for each degree or so, and search it for the closest value.

Wait... what is wrong with calcPos()?

CORDIC may be a suitable method as a replacement for trigonometric functions.

@CharlieHanson: Would you really use CORDIC on a CPU that does have a hardware multiplier? Have you ever tried?

With a question like this, first consider why you need an angle in degrees.  If it's to transmit to some other system, it may be possible to transmit in measurement units, and have the other system take the arctangent.  Or if it is for a display of limited resolution, a lookup table may be an option.  Likely if you are doing little else, your Arduino can calculate the arctangent by any of several methods, but in a more burdened system thinking about the nature of the problem can lead to better solutions.

So atan2(y,x) gives the angle CCW from the x axis in radians, limited to [-pi,pi].
If you want it converted to degrees CW from the Y axis, you would do
azimuth=90.0-atan2(y,x)*57.295779;

If you need to constrain it to -70,70 then:
azimuth_constrained=constrain(azimuth,-70,70);

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Can anyone tell me the best books for studying UAV?
It's kind of hard to get full guide from the internet. I just wanna buy a book for UAV guide. I gotta make DIY drones. I'd appreciat it if you recommend good books.

Welcome to Arduino SE! I'm going to close this question because this isn't based on fact, more on opinion. Feel free to edit the question if you can make this more specific. Thanks!

oh. I'm sorry. I made a mistake.
I'm gonna upload more useful information next time.
Thanks ;)

that's fine, everyone gets a question or two closed once in a while. On a side note: Related meta discussion

Not a book, but try the following course from EdX, the online MOOC:
https://www.edx.org/course/tumx/tumx-autonavx-autonomous-navigation-1658

wow. that's the great website.
I appreciate for your help.
have a good day.


text:
Raspberry pi -Arduino bridge
I am building a small wireless controlled robot using the Arduino and the raspberry pi. It works by the user wirelessly connecting through to the raspberry Pi (using vnc or some other form wirelessly) and using the user inputs to send a command to the Arduino which controls the motorised wheels. SO for example if the user presses the up button, a 'W" command is sent from the Raspberry Pi to the Arduino which then reads it and pushes the wheels forward.
I was looking to use one of the new Arduino-Raspberry Pi bridges to connect the two to make it easier to use, but I am not too familiar on how they work. Had a few question such as:
1) How exactly do they work (connection wise)?
2) is it possible to write one python code in the raspberry pi that when run can load the specific ino code into arduino?
3) which bridge would be the most suited for my project? (eg: Arduberry, alamode, gertduino, etc?)
Sorry really new to the raspberry pi and need to find a solution soon so any help would be awesome.
Cheers

1) How exactly do they work (connection wise)?

Physically they all sit on the GPIO sockets of the Pi, sitting on top of the pi. The Gertduino and AlaMode seem to have the same form factor as the Pi which makes them a little more appealing to me but I guess then is personal choice.
Communication appears to differ but it will use Serial, SPI or I2C. I would imagine that you'd be able to choose an alternate one but not read enough about them to know for sure. Serial appears to be fairly simple, and it would be easy to debug, however you might struggle if you wanted to receive data on the Pi without the communication being initiated by the Pi.  I2C would overcome this as you can run it in multi-master mode.

2) is it possible to write one python code in the raspberry pi that
  when run can load the specific ino code into arduino?

As you can call external programs with python I would say that even if you have to resort to this mechanism then it would be possible. You can turn on the debugging in the Arduino IDE to see what it actually does, then either script it or make the calls from your python program.

3) which bridge would be the most suited for my project? (eg:
  Arduberry, alamode, gertduino, etc?)

I'd go for either the gertduino or alamode purely on looks particularly the matched form factor.

Thanks Nick, this has been really helpful. I was really keen on buying the gertduino for that reason, but my lecturer gave me a arduberry to borrow for the project so probably will stick to that. Thanks again.

You're welcome, hope your project goes well.

Have you thought about using the Raspberry Pi to control the robot directly, instead of adding the complexity of having the Pi talk to the Arduino?
Python allows you to control the GPIO pins of the Pi, and as long as you connect a suitable motor driver (to protect your Pi), you should be fine.
If you want to connect the Pi to the Arduino, then you could also look at doing this using Serial communications and wouldn't need the complexity of a bridge - just need a logic-level converter to convert the 5V of the Arduino to the 3.3v of the Pi

Hey, that was exactly what I am doing atm but there are times when my robot goes over bumps and stuff and usb connections gets severed for a bit causing the whole robot to freeze which is why i was looking at these.


text:
Need a sensor to make ball roll away from pet but which sensor?
Having recently entered the world of Arduino I am seeking to make, as my first project, a ball that will sense my dogs approach and roll away.
I can handle the rolling part but I have been unable to find a sensor that will work when fully embedded in the ball (so the dog cannot bite or swallow it). This means no ultrasound or infra red or normal proximity sensor will do.
My best bet - an inductive proximity sensor (with a metal object attached to dog's collar) is only effective at a maximum distance of 8 cm and that is far too little. I need something that activates at say 1 foot.
Any ideas anyone?

How important is it that the ball roll from a foot away? Could using an accelerometer to detect when something touches it and then rolling away for a few seconds suffice? might be a lot cheaper.

yes, probably this is a better idea..

Perhaps an RFID tag on your dogs collar and a reader inside the ball will work.
You will just have to find a reader and tag combination that can work from the range you need, I think some RFID can work from over 1ft.
EDIT: You will need active tags (battery powered) to get over a foot range.
PIR sensors detect heat given off by humans and animals, so they make work through the ball. (not totally sure though).
Edit: i think PIR that is capable of detecting small animals may be your best bet you would just have to calibrate the range of detection some how

Interesting.  You may want to consider using strong,small, modern rare earth, low cost (silver color) magnetic that can work up to 1 foot, depending on size and shape of magnetic. Test different size/shape mag with simple mechanical compass to check the distance.
You may want to use one of those popular sensor board with
a) MPUxxxx (3D accel to sensor gravity in 3D to know which way is up and down)
b) 3D magnetic sensor
Both sensors are 3D and you know which direction the dog is coming (direction and mag strength, changed from background earth magnetic field when dog is coming, gives distance) and which 3D orientation of the ball is and hence to calculate which way to move a weight inside the ball to make the roll.
Biological disclaimer, no idea if dog health may be affected, positively or negatively (people sells human magnetic collar with health claim), by constant, 24 hours, magnetic collar.
Hope it helps

Roll away from dog, 10 USD hardware but significant 3D vector maths/modeling. Mag field like line from 2 poles of  magnet. The line has different shape depending on distance. The variables are 1D distance, and 3D orientation (xyz) of dog, ball, earth gravity and earth mag. the last two are constant. Mag field should be quite constant in wooden house. Steel structure high rise apartment may be complex. Due to size, not much sensor can sense direction of the dog in 3D vector. Radio not ok/cheap,need tens GHz small antenna with good directivity. Optical ok for cellphone cam in spherical formation

The original question is "sense my dogs approach and roll away". The roll AWAY part is very difficult to do as above, although the hardware cost is only a few US dollars. "Roll" to any direction (toward dog, side way or away from dog) is much easier as many suggestions, as just needs signal strength to detect dog approaching WITHOUT actually know the direction of the dog referencing to the ball.

Agree re moving away. Had not thought of that. Some further thought provoked by this reply though. Maybe I should put all the intelligence in the collar device and simply send instructions to the ball via bluetooth or radio; so I would have the proximity device in the collar and this would react when the ball is sensed. Just have to think of a suitable sensor but this is probably better in terms of not having to fit everything inside the ball!

Moving AWAY is difficult to execute on part of the ball unit. The sensors inside the ball need to know which way is up and presumably move a weight to action the roll as what human, with full advanced sensors than most robots, is doing in this video. https://www.youtube.com/watch?v=G9OfQL1D_hE  Roll in random direction is easier than roll AWAY

Yes I need to be more precise in my choice of words. For a first cut effort any movement in any direction will probably be enough! By the way my idea for obtaining the movement was based on having a small motor with an off centre weight, ideally a stepper so that I could make it move just a few degrees in a direction at a time. Not sure if I would find the really small and light steppers I need though.

Use there are plenty of micro size stepper. Many egg sized. Some can be very small, as uned inside camera for auto focus, etc. Try ebay, adafruit, sparkfun(?) or similar.

Good to know re the small steppers. I scavenged a relatively small one from an old inkjet printer which might work.

If you want the old path, Scanner and fax machines have  steppers inside. 0.5 to 1.5 egg sized.  Camera has small sized, like half of the smallest finger, may be too small for easy work. Scanner and ink jet printer are 'open and big' for easy disassembly

Great, thanks John. I have just embarked on an "asking relatives for any old camera etc" campaign and recently harvested 3 motors from an inkjet and one from a scanner. But I will definitely look at cameras.

I mentioned camera just to illustrate that there are big and small sizes. Likely, the one your got from printer and scanner are worth first test as seem right sizes and easy to work with. Me be only try camera route if that first option fails.

Floppy drives have a small stepper with a threaded spindle - might be nice for moving a weight in/out.

Idea 1:
Put a transceiver in the dogs collar, and one in the ball. Monitor the RSSI (received signal strength). If it goes above a threshold, roll away. Adjust the threshold to set the correct distance.
Idea 2:
Put an accelerometer inside the ball. Whenever it detects a knock (dog's paw etc) roll away for a few seconds.

Thanks for the idea. I now need to research transceivers. But it makes sense to put much of the intelligence on the collar rather than having to stuff it all inside the ball.

Re idea 1 would it work with bluetooth? I have a master and slave combo but I am not sure if there is any way to measure the signal strength.

Other than the answers above/below, you also could try infra-red lights and photosensitive transistors. However, that has some troubles, such as not working properly in the sunlight, or the material that the ball is made of blocking the light, and therefore not working.
AVOID MAGNETS! You could get your dog stuck in some metal, like a fridge. To get one working in such distance, you would need an awfully powered magnet, which could be strong enough to permanently impact circuitry in close range, such as a home theater which sits close to the ground.
By the way, how are you going to fit it all in a ball that is bite-sized? i'm actually interested in that. Aren't you worried of the dog munching it and breaking/swallowing circuits?

My dog has a short snout so can't really put much force on a ball. I was thinking about two central containers (maybe  those Kinder egg inserts, or what you would find in a chocolate Easter egg). The idea is to then surround this with  padding and place everything into a ball around 6 inches in diameter. Components will be: an Arduino nano, 1 or 2 small toy motors (with offset shafts), the sensor (if an accelerometer would be very small), and the battery pack (maybe use one of those button type or small pencils?). Maybe I might even fit in some sound device (small buzzer?)


text:
file directory for saving .cpp & .h for the Arduino IDE for short #include statement
I am trying to write a class/function that I think I will be using often in my Arduino IDE, I know the code but where should i save the file so that the IDE picks it up without a full directory address in the #include line, as you may guess I'm a little new to this....

You can make a header files and put it in the default search path for the compiler, or instruct the IDE to add your header-file path to the paths the compiler uses for header files. But that's only for header files. If you want source to go along with it, you should make a (static) library of your code, and put it in the linkers default search path, and tell your project to link with your library.

If you think you will be reusing this code frequently, you might want to make a library as suggested by Joachim. Your library can then be added to any sketch you write using a #include statement.
The arduino website has a nice guide on writing libraries, check it out here.
If you would just like to include your header file in a sketch without writing a library, placing the header file in the same directory as your sketch should compile if you use #include "header_file_name.h".


text:
What is this component? (range finder)
I've taken apart an old range finder (see photo here). It uses a circular, seemingly gold-plated, two-wire sensor that I'd like to re-use in an Arduino project.
I'm looking for a datasheet of the sensor and/or a circuit-diagram. Any help is welcome.

The big circular parts likely is ultrasonic transducer as used in instant camera.
http://www.uoxray.uoregon.edu/polamod/
https://www.google.com/?gws_rd=ssl#q=polaroid+ultrasonic+ranging+module&revid=399558007&safe=off
Working principle is same as modern unit, easily available at a few US dollars. The transducer does NOT work by itself, needs the associate PCB to work.

Thanks! This got me going. The first link provided shows pictures of the exact same component.


text:
Simply Button Problem (Teensy 2.0)
I am getting back into doing some hardware stuff after a fairly long time away and am having a hard time getting back into it. I have a Teensy 2.0 and am trying to run a basic sketch that when a button is pressed will output 0, but my button is always High. I think that I miswired something but my breadboard looks like all the tutorials so I'm just confused as to what is going on and would appreciate any help.
const int pinBtnUp = 0;
const int pinLEDOutput = 11;

void setup()
{
  Serial.begin(38400);

  //Setup the pin modes.
  pinMode( pinLEDOutput, OUTPUT );
  //Special for the Teensy is the INPUT_PULLUP
  //It enables a pullup resitor on the pin.
  pinMode( pinBtnUp, INPUT_PULLUP );

}

void loop()
{
  Serial.println(digitalRead(pinBtnUp));
}

Am I correct in assuming those side rails are all connected? Where is the schematic for this?

You would need to place your button over the "valley" in the centre of the breadboard, separating teh top 2 and bottom 2 legs of the button.
Currently the wire connecting the button to Pin 0 on your teensy is also connected to your pullup resistor on the breadboard, as it is in the same row.
To help troubleshoot this kind of thing I always find a digital multimeter very useful.

You should post a higher quality version next time.
Wiring:
First of all, the button looks like it's not all the way in. Fix that first.
Also, from your picture, it looks like the green wire isn't in the right row:

I can't tell for sure. Also, like mentioned before, you to put the button over the gap between the two sides of the breadboard.
Also, you have a pullup resistor in your circuit and you enable it on the Arduino. And your physical pullup resistor isn't connected to your signal line. And you short your signal line to ground. All of this is incorrect wiring...
If utilizing the internal pullup resistor (like you are in your code), all you should need to do for a circuit is like this:

Just be sure to connect the 5V rail to 5V and the green wire to your digital pin.
Code:
That's all fine. When doing logic with a button, be sure to debounce it.


text:
Using Leonardo and getting absolute x,y Mouse values
Trying to modify the native mouse methods so that it can use absolute, rather than the relative values it currently uses. This is so it can function as a touch screen pointer, and NOT a mouse.
Am using this modified HID.cpp file here
https://github.com/nospam2000/Arduino/commit/7b77d1e84d7b80819f049e5fd6e7bafa0d06521f#diff-0dd97502971c8a55546092b93abd32caR349
Mostly works, but the author has mapped to the maximum and minimum possible int values, (-32768 to 32767) and no matter what permutation of values I use with the native map method, I can't get it to work properly.
Has anyone wrestled with this problem and has a solution?
Since posting found another possible solution http://forum.arduino.cc/index.php/topic,94140.0.html
However with this solution the mouse movements are WAY too coarse for any monitor with a resolution above 100x100. Tried changing the LOGICAL_MAXIMUM value in HID.cpp but that alone doesn't work. Any C++ gurus possibly able to have a look?
Going back to the first solution this is the map method calls I am using, which should theoretically work!. TAR_WIDTH is the horizontal display resolution of my target monitor. TAR_HEIGHT is the vertical display resolution
xPos2= map(xPos, 0, TAR_WIDTH, -32768, 32767);
yPos2= map(yPos, 0, TAR_HEIGHT, -32768, 32767);

What happens is that when the x value is roughly -2800 or less than, I've reached the left edge of my monitor
Ditto for y, when less than or equal to -2800, I've reached the top.
Moving to the right and or down, once I reach roughly a value of 5000, x, OR y, the mouse wraps back to the left or top edge.
This value of 5000 represents only about 2/3 the width of my target monitor so I'm never able to fully map my mouse movement. Make sense?
So in summary, if I use solution1, I need to figure out how to fully map to my monitor. If solution 2, the movement is too coarse(and the mouseclick doesn't work).

You need to explain the nature of the failure.  What is your source of data and what is it's range?  What is this plugged into, and what range of values does that see?

Modified my question, found an alternative mod, but the problem now is that the movement is WAY too coarse for any monitor with a resolution greater than 100x100 pixels

You still need to tell us what the sensor is and what its unscaled output values are.  Perhaps you should make an ordinary (USB-serial) arduino sketch which just logs the raw (and perhaps also mapped) values to the serial console so you can play with the sensor and see what raw values it generates and if that is scaling to what you want.  Then once you have nice numbers you can switch back to the HID program.

The input values aren't the problem. Its how the absolute Mouse Move hack of HID.cpp is handling these values. I'm feeding in via i2c from a RPi. Input values are accurate.

did you solved your problem?
I have the same issue with modified HID.cpp + USBAPI.h.
Scaling seem to work ok, but what I see on the screen is not an absolute value movement...


text:
RGB LED strip with Arduino
I am trying to control an RGB LED strip with an Arduino. I have followed the tutorials in both of these websites:
Using MOSFETs: https://learn.adafruit.com/rgb-led-strips?view=all

Using LED Amplifiers: http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/

I have tried both setups and none of them work for me. When I try the setup with the MOSFETs, I am able to control each color but the blue LEDs are dimmer than the red and green, and therefore I can't mix any colors with blue.

When I try the LED Amplifiers, I am not able to control any light at all. Only the blue LEDs light up but the red and green dont. Also the blue LEDs stay ON the whole time and the only way to turn them off is to disconnect them from the DC power source.
What am I doing wrong?


text:
RGB LED Strips with Arduino
I am trying to control an RGB LED strip with an Arduino. I have followed the tutorials in both of these websites:
Using MOSFETs: https://learn.adafruit.com/rgb-led-strips?view=all

Using LED Amplifiers: http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/

I have tried both setups and none of them work for me. When I try the setup with the MOSFETs, I am able to control each color but the blue LEDs are dimmer than the red and green, and therefore I can't mix any colors with blue.

When I try the LED Amplifiers, I am not able to control any light at all. Only the blue LEDs light up but the red and green dont. Also the blue LEDs stay ON the whole time and the only way to turn them off is to disconnect them from the DC power source.
What am I doing wrong?

First of all, it's generally bad practice to have a wire with 5V that's black. Red is usually used in this scenario. Also, How dim are the blue LEDs? Not sure but you might have the terminals backwards and there might be enough voltage to trigger the breakdown voltage of the LEDs.

For the blue dimmer than the others, you may simply need to adjust the baseline duty cycle to match them.

In the first diagram, it looks like you are connecting a pin labeled "9V" to the +12V pin of the LED strip....that won't work.

@Funkyguy - that's the Vin pin, which would be whatever supply is used. Hopefully an external supply is being used, as indeed undervoltage would cause odd behavior, and the blue leds with the highest forward voltage would suffer first.

@Chris Stratton How can i modify the duty cycle such that all the led are at full brightness?

How are you powering the led strip? Blue leds require a higher voltage, so I suspect you are using something like a 9V power supply instead of a 12v one.

If you are not too invested in your current hardware, I'd suggest the adafruit neopixel. It has thorough tutorials, simple implementation and is highly scalable. No connection to company/product, just a user. http://www.adafruit.com/products/1460

Which MOSFETS are you using and what is the length of your LED strip? Also, what is the code you're using?

When dealing with LED most of the time you need an high amperage like 1.5-2.0A so it is not enough to have the right voltage if your power supply has a low amperage.

For the mosfet circuit. Are you using an external power supply? The reason why you cannot mix any color might be due to the fact that you're not providing enough current to the led strip, so it just work fine when turning on each channel individually. Check the current the led strip draws (which usually is provided as amp per channel per meter) and use a power supply that can provide enough current for it.
From the adafuit page

Connect a 9-12V power supply to the Arduino so that Vin supplies the high voltage to the LED strip. If you want, you can also just use a separate wire that connects to a power supply that provides about +12V. Make sure to connect the ground of that supply to the ground of the Arduino/MOSFETs!

The LED strip with blue ones requires a higher current drive. Arduino output pins can drive only 20mA max(ideal). Try an external power source.

They do use an external power supply and a MOSFET. Also, an Uno can supply 40mA, not 20.

From the drawings in that instructable, you need the Arduino ground and the 12 volt ground connected together - perhaps the line you have marked "+3v or 5v" should really be ground?

What you are saying is true. Butthe +3v or 5v shoudn't be ground. Connecting the Ground from the power supply to the Arduino should make things work alot better.

Your 12 strip probably puts each set of 3 LEDs in series.  3 Red LEDs take about 6V to be fully on, while 3 blue LEDs take about 9V; when you have 12v the resistors absorb the rest of the voltage drop (higher value resistors are needed for the red LEDs if you want about the same current in each color).  Driving 3 in series is good - the same current travels through 3 LEDs producing 3 times as much light per amp than if each LED was separately driven.  (Or from another perspective, with 3 in series the LEDs get 6-9v and thethe resistors and power amp need to drop the 3-6v from a 12v supply, versus a single LED dropping 2-3v and the resistors and power amp dropping the other 9-10v).
All is good, if you are driving each color with close to 12v.
BUT - your LED amplifier may expect more than 5v inputs in order to be fully on (eg: if it uses conventional FETs).  Driving it with 5v may not fully turn on the LED driving transistors.  In that case, the LEDs may be seeing less than 12V.  The blue LEDs would be the first to suffer from this voltage sag.
Note that if this is the case, the LED amplifier may also overheat - the transistors dissipate more power when not fully on, which raises the temperatures, probably leading to shortened life at best, possibly release of the magic smoke that makes electronics work.
You can test this.  Disconnect the Arduino.  Connect the +12v to one of the inputs at a time.  If that color is now fully bright, then you have shown that 12v input fully turns on the driving transistor, but 5v does not.
(If your LED amplifier says it's designed to be driven by 5v, do not do this test.  Many of them however expect to be driven by the tail end of a previous strip, at roughly 12v)
An example of an LED amplifier which IS designed for 5v inputs: http://www.usledsupply.com/shop/rgb-mini-amplifier-ttl.html  I have not used this device and am not recommending it, just using it as an example.  Note that it appears that for this amplifier, you would connect the Arduino's +5 to the input (along with the PWM outputs from the Arduino), rather than ground - and the PWM sense would be reversed, with lower PWM values being brighter, because the amp would turn on when the output pin was low.


text:
Using Arduino to learn AVR programming
I want to learn AVR C programming instead of arduino programming. I have an arduino UNO board and few Atmega328 chips that I bought, and Atmel studio for programming. Can I use Arduino Uno board as programmer to flash the chips from Atmel Studio? Or any other alternatives?

Without a lot of knowledge on this subject, this post on the Arduino Forums and it looks related. For reference, what you want to do is use the Uno as an ISP.

Do your self a favor and buy a real programmer like the Atmel ICE, Dragon etc... You will thank me.

If your chips have a bootloader already installed in them, you can use any USB -> Serial cable (FTDI cable) to program them in-circuit on their Rx/Tx pins. If not, you can use the Uno to program a boot loader into them (one time) and program them with the cable from then on.
To use standard C, you can use the bare chips or the UNO. You'll want a different environment than the Arduino IDE, though. That can be anything from an editor, the the gnu compiler tools run from a command line, to almost any other IDE. A number of people, myself included, use the Eclipse IDE with an AVR plug-in and do almost everything from writing the code to programming the AVR from within it. (I say 'almost' only because I personally prefer a full-blown programming editor, run outside of the IDE, for initial creation of sizeable projects or major edits and rewrites. That isn't necessary, though).

If you're starting out then Atmel Studio is a good option - it's very easy to install and get up and running, and I use it.
To use an Arduino as an ISP you're going to need to use AVRDude.  You can configure Atmel Studio to flash chips using AVRDude - I struggled with this but eventually got it working, you can look here if it will help - not specifically for the Arduino as ISP, but should get you started.
Finally you should also double-check whether you have ATmega328-PU or ATmega328P-PU - AVRDude doesn't support the ATmega328-PU (without the P) so you'll need to do a workaround (again something that I've been caught out with in the past, [here's how I worked around it] (http://www.crash-bang.com/resource/bootload-atmega328/)
Good luck - programming the AVR directly is more challenging but gives you more control.

AVRDude does support the ATmega328 (no P) - however, the configuration file shipped when it is distributed by the Arduino folks may not include an entry for it.

Essentially, it is to use menu Tools -> External Tools to define a new menu command that calls AVRDUDE with the appropriate parameters, using $(TargetDir) and $(TargetName) to construct the full path to the hex file created by Atmel Studio.

I want to learn AVR C programming instead of arduino programming.

It's not really clear what you think the difference is. You can use the Arduino IDE to do "straight AVR" programming, for example:
int main ()
  {
  DDRB = bit (5);  // pin 13
  DDRB |= bit (4);  // pin 12

  while (true)
    {
    PINB = bit (5); // pin 13
    PINB = bit (4); // pin 12
    }
  }

The AVR register names (eg. DDRB, PINB, PORTB and so on) will be included by the IDE, however you don't have to use a single Arduino library or function if you don't want to.

Ah, cool you can actually "override" the main function and not use the setup & loop functions?
But to be honest I would let everyone drop the arduino IDE. I think code-completion and/or code hints are very usefull for beginners.

Certainly, and you can specify an editor of your choice for the IDE. I just don't think that "Arduino programming", "C Programming" and the supplied IDE are different things. The IDE basically implements C++ so there is really no "Arduino language".

You can use the Atmel Studio + Visual Micro plugin to easily get started with atmega328 + support for the uno board (easily program, use arduino libraries etc). Checkout here.  http://www.visualmicro.com/page/Arduino-for-Atmel-Studio.aspx

Just found in this forum that a similar answer exists for a similar question. http://arduino.stackexchange.com/questions/13225/what-changes-i-have-to-take-care-while-coding-from-atmel-studio-instead-of-ardui


text:
Why can't this C++ program read my arduino's Serial.write()?
I made a super simple arduino uno sketch to send a serial byte once every second:
void setup(){
  Serial.begin(9600);
}

void loop(){
   Serial.write(12); // send a byte with the value 12
   delay(1000);
}

My arduino is hooked up to com 3.
On the other end of the line, I have a C++ program with the following read function:
int Serial::ReadData(char *buffer, unsigned int nbChar)
{
    //Number of bytes we'll have read
    DWORD bytesRead;
    //Number of bytes we'll really ask to read
    unsigned int toRead;

    //Use the ClearCommError function to get status info on the Serial port
    ClearCommError(this->hSerial, &this->errors, &this->status);

    //Check if there is something to read
    if(this->status.cbInQue>0)
    {
        //If there is we check if there is enough data to read the required number
        //of characters, if not we'll read only the available characters to prevent
        //locking of the application.
        if(this->status.cbInQue>nbChar)
        {
            toRead = nbChar;
        }
        else
        {
            toRead = this->status.cbInQue;
        }

        //Try to read the require number of chars, and return the number of read bytes on success
        if(ReadFile(this->hSerial, buffer, toRead, &bytesRead, NULL) && bytesRead != 0)
        {
            return bytesRead;
        }

    }

    //If nothing has been read, or that an error was detected return -1
    return -1;

}

This seems to check only one time if data is available, so obviously I have to loop through it until data comes in.  I did that in my main program:
#include "Serial.h"
#include <iostream>

using namespace std;

int main(void)
{
    Serial serial("COM3");

    char* c = "";
    int len = strlen(c);
    while(c == "")
    {
        serial.ReadData(c, len);
    }

    cout << "\n\n";
    system("PAUSE");
}

When I do this, my C++ program gets stuck in an infinite loop waiting for data from the arduino, and I cannot figure out why this is happening.  My program never sees the data the arduino is sending.
This Serial class works and is configured properly because I can SEND all the data I want to the arduino without any problems.  My issues are only with reading back from the arduino.
Can someone please help me figure out why this is not working?

Welcome to Arduino SE! Have you verified the Arduino code outputs the right data with the serial monitor? If so, I think this question should be migrated to another site to address the C++ code. Thanks!

I think your C++ program needs to know what data rate (baud) to use.

Can you also confirm that the receiver program works if you send some "correct" data with a terminal program? The answers to those two questions will tell you whether to look at the Arduino, the receiving CPU, or the serial line.

I want to send keypad data from Arduino to Code Composer Studio or CCS and i'm using Texas instruments (TMS320F8069). When I send the data, I hope that CCS will show the Arduino data that i already send. And the CCS will send it back. It's like a TR > RX program. But, it's not work. I mean the CCS console (serial monitor) doesn't show the data. So, can you guys help me solve this problem? Here my CCS code... const int LEN = 1; char msgg[LEN + 1]; int numBytes = 0; for(;;) { msgg [numBytes] = 0; scia_msg(msg); // Wait for inc character while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY

The problem is in your C++ program at the other end of the line (not the Arduino side):
char* c = "";
int len = strlen(c);
while(c == "")
{
    serial.ReadData(c, len);
}

Here, len is zero because that is the length of "" , the empty string! Thus, in your loop, you ask ReadData to read 0 bytes. Hence, the condition of your while loop is always true as, c never changes.
Also, the while condition seems incorrect as it is not recommended in C++ to compare 2 strings (defines as char * or char [...]) with ==. In your situation, what is important is the number of characters read by ReadData:
char c[LEN + 1];
int numBytes = 0;
while(true)
{
    numBytes = serial.ReadData(c, LEN);
    if (numBytes != -1)
    {
        // Terminate the string if we want to use c variable as a string
        c[numBytes] = 0;
        break;
    }
}

in the code above, LEN is the number of characters you want to read at one time, in you example it should be set to 1, either as a #define or as a const variable:
// either:
#define LEN 1
// or:
const int LEN = 1;

The code above also ensures that c can be used as a normal string, by adding a 0 at the end. This is mandatory only if you want to use string functions on c such as strlen, strcpy, strchr... otherwise numBytes is enough to manage the number of characters read into c.

char* c = "";
while(c == "")

The variable named c is a misnomer, because it is a pointer to a string, not a character.
For example c = 0x123456.
You should use a more explicit name for your variable.
This first line assigns a pointer to an empty string to the c pointer.
So, the value stored at address 0x123456 == whatever pointer to a static memory address containing '\0'
Note that no memory has been allocated to hold characters. Only a pointer to char has been allocated. Thus you cannot store anything in your string!!
You could write something like:
char data[2] = "";
That would allocate a pointer, and a string to hold 2 characters

The second line, while(c == "") compares a real memory pointer (e.g. 0x123456) with a compiler pointer.
"" is not a real application pointer, you should not manipulate it.
So that second line relies on a compiler behavior.

If I were you I would wrap the multi-char routine into a single-char routine. For example:
int ReadChar(char *c)
{
  return ReadData(c, 1);
}

Then:
main()
{
  char c;
  ReadChar(&c);
}

On a different note, I think the compiler should catch such error.
The line c == "" would never do anything useful and should be caught.


text:
Best way to process data received by EthernetServer
I have a program where the Arduino acts as an Ethernet Server.
The client continuously sends packets which is of the following format
Start Byte=0x7E;
Some Data/Command Bytes;      //Can be of varying length
End Byte=0x7A;

Some packets take more time to process than others.
So my question is what is the best way to read the bytes of the memory so that we always work on one packet at a time.I can read in data from the buffer one at a time and loop through till the END BYTE is reached but it doesn't seem a very efficient way to get the packets.
I would be interested if someone has better ideas on how to read in packets one at a time from the buffer in the most efficient way possible.

An important question would be if your can be sure that a packet contains exactly one message starting from the packet start - with TCP you almost certainly can't unless the sender is atypical, but with some other schemes you could.  If you can't, you will likely either need to process messages character-by-character with a state machine that can pause and continue when another packet is received, or else copy from packet(s) to a message buffer, and be able to handle a message fragmented across packets, a packet that contains the end of one message and the start of another, etc.

can you elaborate on those schemes or point me in the right direction.Thanks.


text:
How to modify Arduino boards.txt to support new MCUs
In this post, it was mentioned that to get the Arduino IDE to support an ATmega328 (only the ATmega328P is supported):

I should mention the Arduino way of doing this, is to create a new
  boards.txt file with this chip and add (not change) the avrdude.conf
  file. This will allow programing either from selecting the correct
  board. but that is another subject.

After a great deal of research in the past, and attempted modifications to boards.txt and avrdude.conf, I arrived at the conclusion that the Toolchain doesn't support the ATmega328 therefore the changes will have no effect.
Can anyone confirm that they have successfully found a way to make these changes, so we can avoid the need for a work-around?

what is the error? the same as in that other post you link to?

See these links: http://computerpr0n.com/2012/03/burning-arduino-bootrom-on-an-atmega328-pu/ | http://forum.arduino.cc/index.php?topic=58670.0 | http://www.instructables.com/id/Bootload-an-ATmega328/step6/

Please, Note that the Arduino IDE is behind on many of the tools. In this case avrdude and its conf file, along with avr-gcc
First:
.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf

needs to support the m328 in addition to m328p. This can be done by either updating
.\arduino-1.5.6-r2\hardware\tools\avr\bin\avrdude.exe

to something like avrdude-6.1-svn-20131205-mingw32. along with replacing the conf file with the new one
.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf

file that has both m328 along with the m328p. Note 6.1 supports a parent method, making it easy to duplicate chips with different signatures. Or use existing 5.11 and add to its
.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf

file by duplicating the entire m328p section and renaming the new entry to "m328" along with the correct signature.
Second:
avr-gcc need to be updated to support compiling both the m328p and m328. Yes, it just a semantic thing. But the next part will send either ATmega328p or ATmega328 to both gcc and dude. which both need to support it. One can simply copy over
.\arduino-1.5.6-r2\hardware\tools\avr\

with the new tool chain. I used avr-gcc-4.8_2013-03-06_mingw32
Third:
replace the following line in boards.txt
uno.build.mcu=atmega328p

with
## Arduino ATmega328P
## ---------------------------------------------
uno.menu.cpu.atmega328p=ATmega328P
uno.menu.cpu.atmega328p.build.mcu=atmega328p

## Arduino ATmega328
## ---------------------------------------------
uno.menu.cpu.atmega328=ATmega328
uno.menu.cpu.atmega328.build.mcu=atmega328

This will add an option to the IDE when UNO is selected for either chip. And subsequently send the correct MCU to both the compiler and avrdude.

Proof:
Below are the verbose output of the IDE with the above changes. Note the -mmcu and -p for both options. As a real unit is was not connected it yielded the "not in sync" error. Where this shows it all works.
C:\projects\Arduino\arduino-1.5.6-r2\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\variants\standard C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp -o C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp.o
...
C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.
C:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/bin/avrdude -CC:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
...
avrdude: stk500_getsync(): not in sync: resp=0x00

avrdude done.  Thank you.

C:\projects\Arduino\arduino-1.5.6-r2\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328 -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\variants\standard C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp -o C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp.o
...
C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.
C:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/bin/avrdude -CC:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328 -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
...
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude done.  Thank you.

One draw back, may be that the new compiler will have some issues on poorly written code and libraries. IDE 1.0 and early complained with latest versions of gcc. Mostly bad coding that is easily corrected. Where I do believe for the addition of the ARMs these have been corrected. At least in the IDE's core libraries.

I'm curious if you can use uno.menu.cpu.atmega328=ATmega328
uno.menu.cpu.atmega328.build.mcu=atmega328p to get it to build for a 328p with the old compiler, but flash as a 328 (ie, looking for that signature).

I looked at that first. The \arduino-1.5.6-r2\hardware\arduino\avr\platform.txt uses {build.mcu} in both the compile and avrdude. Alternatively (and not pretty) would be to define a ...build.mcu_upload in the boards.txt and replace the "-p{build.mcu}" with -p{build.mcu_upload}. However, this would require that all entries in the boards.txt have the added build.mcu_upload" added. (not very clean). This does have the advantage of supporting both chips and use the stock provided compiler.

looks like IDE 1.5.7 BETA, has just upgraded both AVR-GCC and AVR-DUDE to the latest. Which include support for both m328 and m328p or above mentioned Steps 1 and 2. Step 3 is still needed.


text:
How to send data from cc3000 to herokuapp server
I tried this code:
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#include "DHT.h"
#include<stdlib.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed

// WLAN parameters
#define WLAN_SSID       "ID"
#define WLAN_PASS       "PASS"
#define WLAN_SECURITY   WLAN_SEC_WPA

#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data
                                   // received before closing the connection.  If you know the server
                                   // you're accessing is quick to respond, you can reduce this value.
#define DHTPIN 7
#define DHTTYPE DHT11

// What page to grab!
#define WEBSITE      "myapp.herokuapp.com" //your website

uint32_t ip;
DHT dht(DHTPIN, DHTTYPE);

const unsigned long connectTimeout  = 15L * 1000L;
void setup(void)
{
    Serial.begin(115200);
    //Serial.begin(9600);
    Serial.println(F("\nInitializing..."));
    if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
    Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
    if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
    Serial.println(F("Connected!"));

    Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }
  ///if he login and he can show info/ mean he login and only then continue
    while (! displayConnectionDetails()) {
    delay(1000);
  }
}

void loop(void)
{
 float h = dht.readHumidity();
  float t = dht.readTemperature();

  int temperature = (int) t;
  int humidity = (int) h;

  String temperatures=String(temperature);
  String humiditys=String(humidity);

  Serial.print("Temperature: ");
  Serial.print(temperatures);
  Serial.print(" F /");
  Serial.print("Humidity: ");
  Serial.print(humiditys);
  Serial.print("%");
  Serial.println("");

   // Create the request.
  String request = "GET /plants/0003/create_measurement?capsules=1&humidity=" + humiditys + "&soil_moisture=40&temperature=" + temperatures + " &water_tank=10&light=20&battery=4 HTTP/1.1\r\n";
  // Print and Send the request
  Serial.println("About to send: ");
  Serial.print(request);
  Serial.print(F("Host: "));
  Serial.print(WEBSITE);
  Serial.print(F("\r\n"));
  Serial.print(F("User-Agent: Compost Monitor/1.0\r\n"));
  Serial.println();
  send_request(request);

}

void send_request (String request)
{
  Serial.println("Enter Request");
  ip = 0;
  // Try looking up the website's IP address
  Serial.print(WEBSITE); Serial.print(F(" -> "));
  while (ip == 0) {
    if (cc3000.getHostByName(WEBSITE, &ip)<0) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }

  cc3000.printIPdotsRev(ip);
    Serial.println();
Serial.println("after Ip");

  Adafruit_CC3000_Client www ;
   unsigned long t = millis();

do {
    Serial.println("Into do");
   www = cc3000.connectTCP(ip, 80);
} while((!www.connected()) &&
    ((millis() - t) < connectTimeout));

  String b="0";
  if(www.connected())
  {
  b="1";
  }
  Serial.println("! Out Do" + b);
  if (www.connected()) {
    www.print(request);
    www.print(F("Host: "));
    www.print(WEBSITE);
    www.print(F("\r\n"));
    www.print(F("User-Agent: Compost Monitor/1.0\r\n"));
    www.print(F("\r\n"));
    www.println();
  } else {
    Serial.println(F("Connection failed"));
    return;
  }

  Serial.println(F("-------------------------------------"));
Serial.println("time to reed");
  /* Read data until either the connection is closed, or the idle timeout is reached. */
  unsigned long lastRead = millis();
  while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
    while (www.available()) {
      char c = www.read();
      Serial.print(c);
      lastRead = millis();
    }
  }
  www.close();
  Serial.println(F("-------------------------------------"));
Serial.println("no time to reed");

}

bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

This sends data to my server. However, no entries are appearing on my server.

Welcome to Arduino.SE. Please can you explain your problem? What exactly are you trying to do, and what's not working?

hii Peter R. Bloomfield.
i try to send the Temperture and Humidity to my server by send them with cc3000
i did like i post  (that the full// only without the name of app) and it all work it get to the end but it not adding a record on my server
that program should to add to id ="0003" a new record with all the Info such as:
capsules=true
humidity=37 // as example
untill the end
but still it not add the record

Welcome to Arduino SE! This seems more like a server issue than an Arduino issue... is there any way to verify the server is working and this code isn't? Also, what have you tried? Can you narrow it down to a small section of the code?

use http://requestmaker.com to send a properly formatted GET request to your heroku app. If it works, it is your Arduino code, if not, it is your app.


text:
How to handle multiple input pins at once?
I am relatively new to Arduino platform and not know much. I am working on a Bicycle speedometer with turn and stop indicators.
I am planning on connecting an inductor magnet to calculate the rotation of my front wheel while providing the following services from the same arduino board:

Input horn and turn indicator switches.
Output to turn indicators.
Stop light when one of the brakes is
applied.

While I am sure of how to connect all the sensors, except the magnet, I am not sure how to handle the various inputs and the outputs at once.
I must be able to horn and stuff while the indicator blinks at a regular interval all the while the monitor keeps displaying my speed and distance covered.
Any reference or help would be greatly appreciated.
Thanks in advance.
Bharath. S.

Count rotations in an interrupt.  Monitor user inputs in your loop() whenever you have nothing better to do (which will still be very frequently in human terms).  The blink can be implemented either with a time interrupt or by checking elapsed time in the loop, with tradeoffs each way.

If you're willing to get your hands dirty, try timers. I'm probably going to write a library here soon to do that, so I'll post that if I get around to it. That would help with the blinking the LEDs...

How fast do we need to read the magnetic switch to not miss any pulses? I'll make some working assumptions:

Using 700c wheel and 28mm tire [assumed; adjust as necessary]
Rolling radius 2.1m [from here; there are other ways to arrive at this]
Max speed 22 m/sec (50mph), [working assumption; adjust as you see fit]
Magnet and switch interact for at most 3% of a rotation, [WAGuess]

The wheel will have to turn at ~10RPS at max speed giving a pulse period of 100ms. The pulse width will be at most 3% of that, or 3ms.
Your service loop would have to execute in somewhat less than 3ms, every time, in order to not miss any wheel pulses and that's if I haven't been too optimistic about the pulse width. I'd personally assume a 1ms maximum loop time, then test it on the road by sampling & logging wheel-pulse level with an Arduino at at least 10x that rate or 10+KHz.
Or I'd go with an interrupt-driven wheel pulse period timer not width) to ease the constraints on the main loop.
The main loop need only poll your turn, brake, and horn switches and a timer for blinking the turn signals. Even if the timing is a little erratic for some reason, no harm is done, and nothing is likely to be apparent to the rider or other road users.

You need a finite state machine. Then you can have code that would typically require delay() but without blocking the loop() while it waits.
Here is a crude class I wrote to do it
stateMachine.h
/*
 StateMachine

 Class to perform some state machine logic on the Arduino
*/

#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
 #include <pins_arduino.h>
#endif

class StateMachine
{
  public:
  // Constructor
  StateMachine(void (*)(void));
  // Functions
  void update(void);
  void nextState(uint16_t, uint32_t);
  uint16_t currentState(void);
  void stop(void);

  private:
  void (*callback)(void);   // Callback to state machine code
  uint16_t state;      // Current state of the machine
  uint32_t delay;      // Delay until state change. Delay of -1 is stopped
  uint32_t timer;      // Timer to keep track of last run time
  uint8_t isRunning;   // Are we running?
  int16_t counter[2];  // Two counters for general use
};

stateMachine.cpp
/*
 StateMachine

 Class to perform some state machine logic on the Arduino
*/

#include "StateMachine.h"

//
// Constructor
//
StateMachine::StateMachine(void (*callbackFunction) (void)) {
  state = 0;
  delay = 0;
  timer = 0;
  isRunning = 0;
  callback = callbackFunction;
  counter[0] = 0;
  counter[1] = 0;
}

//
// Update the state machine
//
// Use in loop()
// Will keep running over and over unless stop()ed
//
void StateMachine::update(void) {
  if (isRunning) {
    if(millis() - timer >= delay) {
      timer = millis();
      //Call the state machine
      callback();
    }
  }
}

//
// Current state
//
uint16_t StateMachine::currentState() {
  return state;
}

//
// Next state
//
void StateMachine::nextState(uint16_t nextState, uint32_t nextDelay) {
  state = nextState;
  delay = nextDelay;
  isRunning = 1;
  //Restart timer
  timer = millis();
}

//
// Stop
//
void StateMachine::stop()
{
  isRunning = 0;
}

Then you need a function with the logic:
void exampleStateMachineCallback()
{
  switch (exampleStateMachine.currentState()) {
    case 0:
      //initialise everything and then got to state 1 immediately
      exampleStateMachine.nextState(1,0);
      break;

    case 1:
      //do something then do state 2 500ms later
      exampleStateMachine.nextState(2,500);
      break;

    case 2:
      //do something then do state 1 500ms later
      exampleStateMachine.nextState(1,500);
      break;
  }
}

Finally in the global variables we join them up
StateMachine exampleStateMachine = StateMachine(exampleStateMachineCallback);

And in loop() we call update all the time
exampleStateMachine.update();
The states implement your logic. For example, state 1 in the above code could be turn on the led, and state 2 could be turn it off. State 0 might prepare some variables. If you wanted the led to start flashing with a button press it might look like
if(digitalRead(LEFT_BUTTON) == HIGH) exampleStateMachine.nextState(0,0);

And if you wanted to stop it:
exampleStateMachine.stop();

In the StateMachine class I put two counters, you could use these to do other timers. For example, to flash a led for 30 seconds it might look like
void exampleStateMachineCallback()
{
  switch (exampleStateMachine.currentState()) {
    case 0:
      exampleStateMachine.counter[0] = 0;
      exampleStateMachine.nextState(1,0);
      break;

    case 1:
      digitalWrite(13,HIGH);
      exampleStateMachine.nextState(2,500);
      break;

    case 2:
      digitalWrite(13,LOW);
      exampleStateMachine.counter[0]++;
      if (exampleStateMachine.counter[0] >= 30) exampleStateMachine.stop();
      else exampleStateMachine.nextState(1,500);
      break;
  }
}

Since I apparently can't comment yet, here's an incomplete but I think useful answer; this is a perspective on how I would go about it:
For the brake lights it's pretty easy to just put it in a loop that 'if brakes, brake light on'. I would say keep everything in one loop, no interrupts or anything. If an indicator switch is on, the loop gets the current time with millis(), sets a flag to on, and turns on the light. It then loops like normal, checks the flag and if sufficient time has passed turns off the light, gets a new time, and unchecks the flag. If i understand your needs correctly, the rest is just 'if input high, output high' that you can check every time through the loop. Can't help with the magnet though, no experience there.

Since your post mentioned that you are relatively new to Arduino, in case you have not done below, you may start by
a) get a printed book, ebook or 'well structured' tutorial, says, systematically covering 10 to 20 topics instead of short tutorial on just one topic
b) this will get you covered for your task 1 to 3, but, only as individual tasks.
c) after mastering (b), try to combine them, instead of stand alone in tutorial
d) interrupt is advance topic and not be cover in many starting books. You can see http://arduino.cc/en/Reference/attachInterrupt   Interrupt works only on certain pins, depending on which Arduino board model.


text:
Arduino Packet for Bluetooth
I'm having trouble figuring out how to start my project. The objective is to control a robot with four servo motors and six DC motors through bluetooth. I have a bluetooth shield from Adafruit and I'm using the Arduino UNO. Ideally, I want to control this robot by sending it packets through Processing. The problem is I don't know how to create a packet with a header, payload, and checksum. I can't find any examples; can anyone help me find something to help me get started?

One layer of this should already be being invisibly added, verified, and removed in the bluetooth subsystem, but you can do your own as well on top.  One thing which would make your life a LOT easier is to use a printable format so you can use a serial monitor for debugging.  For example you could simply have a line of readable text, and a two-digit hex checksum at the end followed by a carriage return (a bit like a line from a .hex file).  You could put a byte count at the start of the line, but don't need to.

I don't understand. What I'm saying is: I don't know what a packet is, or a header, or a payload, or how to create a checksum. Is there an example out there that helps me grasp what these are?

First, depending on the degree of reliability you need, you may not actually have to do this yourself, as the bluetooth implementation will already invisibly-to-you add, verify, and remove a packet and checksum framing around your data.  But let's assume you want to add your own as well.
A packet is a batch of data to be transmitted as a contained unit.  It may or may not contain exactly one useful message, but it is quite convenient if it does, and since you will be doing your own packetization (at this level) you can make sure that it does.  So basically you will transmit something that has a structure, for example:

Hi, I'm a packet
attention HAL
"Open the pod bay doors"
The bytes in this message should add up to xx if you ignore the overflow
That was a packet

There are countless ways you could implement this, but your life will be a lot easier if you make both the messages and the packet structure human readable, so that you can watch on the serial monitor, and perhaps even type manually.  So let's say you did something like
M1=200/BF\n

For simplicity sake, instead of having a "Hi I'm a packet" header, we just use the newline character '\n' to mark the end of a packet, and assume that whatever comes next is the start of a new packet.  Further, since bluetooth is already creating a one-to-one link, you don't need to address who you are talking to.
Now we have a message, for example "M1=200" meaning "drive motor 1 at PWM level 200" (out of 255).
I'm somewhat randomly choosing the '/' character to mark the division between the message body and it's checksum.
"BF" might be the low two hex digits of adding up all the previous bytes in this message (it's not, I just picked something random).
And finally you have your newline to mark the end of a message and the end of a packet, since in this scheme we've decided that 1 packet = 1 message.
For extra fun, if the robot itself is not dangerous, you can make a test mode where the receiver will accept messages with no '/' and checksum, and only check the checksum on those where it is present.  This would allow you to manually type messages into a terminal when you are experimenting.  Or you can make your own specialized terminal program which calculates and appends a checksum each time you press return

Start simple.

send serial data from PC. either use Arduino USB port or on real hardware serial port, needs USB to serial adaptor and a terminal software. (see diagram in below web)
for starting, no need for header. Just use simple text as defined yourself
on Arduino side, read serial input. For example, type letter 'a' on PC will blink LED, 'b' to move servo 30 degree
Replace serial communication (like RS-232 or a UART) with Bluetooth. Bluetooth supports many 'profiles', like headset, keyboard, etc. that are not suitable in your case.

See below video. You need to use the SPP profile. see https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles
Make sure your purchased bluetooth device supports SPP. Some bluetooth device are permanently setup to do one fix action. However, many bluetooth need to be 'programmed' (told what to do) before doing the task via AT command. Set speed, pairing, etc.
https://learn.sparkfun.com/tutorials/using-the-bluesmirf/example-code-using-command-mode
http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/

Quoted from your link, "Bluefruit EZ-Link shield is a regular 'SPP' device" so you have brought the right unit. At FAQ, "There is no command mode for EZ-Link, it is designed to be used out of the box.", so, one less thing to worry. The tutorial look excellent and should have all info you need. There are may steps and 'fine points'. Make sure you follow them precisely and carefully.  Are you using one pair of "module plus Arduino"? That is, two same_brand and same_model BT modules communicating. Thinngs are more complex if different equipment is involved, like BT module communicate with phone.

If I am at your situation, I would forget my code for the time being. Just follow the Adafruit tutorial from start to end. This ensure wiring done ok and the unit is paired (need one time pairing and two modules can communicate in all future sessions)


text:
Coding and libraries for Maxtronix Ultrasonic sensors
I need to access distance data using a LV-EZ0 Maxtronix ultrasonic sensor: MB1000
LV-MaxSonar®-EZ0™High Performance Ultrasonic Rangefinder
Can anyone suggest what particular arduino libraries or code would be most useful?
I noticed this new ping library, NewPing
Would this work for my purposes with this particular sensor?

Likely work in pulse mode (library you mentioned) and sure work in RS232 serial mode (spec. in data sheet page 2, top, read data number as text).
How many sensors do you need and how fast update rate? Serial mode is easier if you application need small number of sensor at 'nominal' update rate (Arduino has limited number of hardware serial port, although softserial library may help).
Essentially, in pulse mode, the RX and PW pin is similar to Trig and Echo pin on many widely available sensor (several models number, basically following similar principle). Need care about the high and low relationship as may differ from the default value in library.
Taken from the data sheet of LV-MaxSonar®-EZ0

R X – If held low, the EZ0™ will stop ranging. Bring high for 20uS or
  more to command a range reading.
P W – This pin outputs a pulse width representation of range

Specifically you may want to first try the simple (old) ping: Ping Ultrasonic Range Finder
Changes needed:

Your sensor data sheet requires 20 μs trigger pulse while the above is 2 μs;
The library read a high pulse. Your sensor data sheet 'send pulse' which likely imply a HIGH pulse, may not need change;
The library use one pin for both in and out. your is one pin in (in for sensor, out for Arduino) for trigger and one put out for measurement.

Also, another library. Note the author states that many sensor from the factory differs (may need small change in code): Distance Detection
with MaxSonar ultrasonic rangefinder.