Arduino mega 2560 and arduino uno code difference

Hello, as i ran out of memory on uno, i wanted to buy myself mega 2560, but actually my question:
Am i supposed to write exactly the same code, or other type of code. I mean do i have to program exactly the same?

imalfectyt:
Hello, as i ran out of memory on uno, i wanted to buy myself mega 2560, but actually my question:
Am i supposed to write exactly the same code, or other type of code. I mean do i have to program exactly the same?

Code is the same. You just have more flash, RAM and pins.

imalfectyt:
I mean do i have to program exactly the same?

There is a very good chance that the UNO sketch will run on the MEGA with no changes at all. Try it and if you run into problems (compile errors or the sketch no longer works the same) you can come back here and ask why that particular problem is happening.

Pin numbers may differ.

Erik_Baas:
Pin numbers may differ.

That should not be a problem. What will cause problems is direct port manipulation, directly accessing internal processor registers, etc, where you are bypassing the abstraction layer built into the standard code that gets included when you compile a sketch.

Something a bit more common, using software serial and naming the serial instance Serial1, Serial2, or Serial3 will cause an error because those are in use for the additional hardware serial ports.

Remember to change the DEVICE in the TOOLS menu to match you chip & port !