Difference Between Uno and mega 2560

I want difference between arduino uno and mega 2560 r3, if all same uno program can run in mega 2560

Well, the differences between Arduino Uno and Arduino Mega 2560 are as follow. The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button.

The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 (datasheet). It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. The Mega is compatible with most shields designed for the Arduino Duemilanove or Diecimila. The Mega 2560 is an update to the Arduino Mega, which it replaces.

You can have a look at http://www.elecrow.com/crowduino-mega2560-p-1102.html for more detail info about ATmega2560.

You can run same or better similar program on UNO and MEGA since Arduino SW is designed this way, but there are some limits because resources of both are different. However, should not be a problem to change platform if you become little bit familiar with any of them.

As noted, there are differences in resources between the Uno and the Mega - but there are also certain subtle differences which you may or may not encounter.

Take for instance this third-party shield (the guy behind this shield posts often here):

It will only work with the Uno, Duemilanove, and other similar variants (heck, it would probably work with one of the original ATMega8-based serial Arduino boards from the beginning - with attendant memory limitations). It will not work with the Mega or the Leonardo (or I suspect certain other boards). Why?

See here:

http://nootropicdesign.com/ve/whynotmega.html

Essentially, one of the pins that is required by the board - while it exists on the microcontroller used by the Mega (ATMega1280/2560) - isn't brought out to an actual pin on the board! Why? Who knows!

But if you didn't know that - you would think that shield would work. There may also be other shields out there which are being sold as "works with the Mega" - in which the designer or seller doesn't actually know whether it does or not (or maybe they don't care - or maybe they do know, but they don't know why). You might find this, for instance, with third-party shields from Chinese sellers - they may or may not know, or not care - but if you have this information handy - then you can be wary about it.

As far as that VE shield is concerned, though - this is only really an issue with the "official" Mega - there are Mega clones out there which bring out -every- pin (there are others that aren't brought out to headers on the official board) to a header. Many of these are clones, some of them quite good and reliable (for instance, Seeedstudio's boards are great quality, and most have desireable features not found on official boards - even the cloned Uno boards!).

Ultimately - you should start out with the Uno - and get very familiar with it. Then get a Mega and do some research on it, the ATMega controller used on it (read those datasheets!) - and see what differences there are. Most have been documented, but I bet a few haven't. The popularity of the Mega isn't as great as that for the Uno and similar 328 based boards - likely because of the DIP packaging if nothing else.

The assignment of internal timers to PWM pins is very different, which won't matter unless you
do direct register operations on the timers (or you use a library that does, such as Servo library).