switching from uno to mega?

I've been using the Arduino Uno & I was wondering if I can use the same sketches on the Mega 2560, assuming I make sure all the pin numbers right.

Just about. There are a very small number of libraries that don't support all boards (see the documentation for the library - I know Adafruit has a few that only work with the Uno, and some that are Uno/Mega only

Also if you're doing anything to directly manipulate registers, naturally that may have to change.

Libraries that come with the IDE should all work the same.

Be aware that pins associated with serial, interrupts, I2C, and SPI are in different locations.

The Mega2560 is feature and pin rich.

A 328 can add pins and external RAM but by adding shift registers and serial RAM on SPI bus.

One thing to note, both have one core, same processing power.

One goal of the Uno board is to teach the user how to develop an app on the board then take the chip out and place it in an end product/project. That is stated in more words on the Arduino site. That is why the Uno is called a Development Board. When your project is done, you still have your Dev Board to pop a new bootloaded 328 in and do the next thing.

You can divide large jobs up across 2 or more 328 chips, every chip adds a core. Extend in parallel.

But the 2560 can do tricks the 328 just can't do without adding parts and even then, much slower.

Only thing may be to have both boards. I do.

You also have the option of using a Atmega1284. The Bobuino and Bobuino2 might be good options for you.

Thanks for all the replies,

Processing power is not much of a concern but memory is. I need the capability to handle larger scripts with decent sized arrays & I’m running out of options with the Uno. The only problem i might have with the Mega 2560 is the physical size might be a little too big for my project but it’s close.

Atmega1284 128K Flash 4K EEPROM 16K SRAM

Can I just change the chip on the Uno board with an Atmega1284? Is that all there is to it?

Replace a 28-pin chip with a 40-pin one? Piece of cake… :stuck_out_tongue:

I need the capability to handle larger scripts with decent sized arrays & I’m running out of options with the Uno.

Have you tried serial RAM? It’s slower but 8K byte chips (32Kb = 8KB, they sell them using the bits numbers) are pretty cheap. It’s a hack but it’s a cheap hack.

The 1284P does cost 3-4 times what a 328P does, what you put it in/on may also cost more but you get a faster and easier to program packge with it.

All you need to program 1284P AVR is in the lower half of this tutorial.
It is for breadboard duinos but a circuit is a circuit and can be made more permanent, like the Bobuino.

http://www.gammon.com.au/breadboard

Too bad the Mega2560 is too big, Rugged Circuits makes a bank-switched ram card for them (got mine for $25 + ship) that gives 8 x 56KB usable banks of ram.

Also have a look at the Teensy 3.2 as an Arduino-compatible if you want small, fast, 64KB ram. The end joint of my thumb is bigger, the chip is a 32-bit ARM, the board with pins is still < $30.

I might try the Mega2560 & see if I can change the dimensions of the case a little. I guess I'll also need to be concerned more about battery life since I assume it draws more current than the Uno does without a load. Does anyone know the actual current draw of the board without any load on it?

A 1284P fits a 40 pin socket. A breakout for that would be pretty small, the components it would have to have are covered in the minimal breadboard duino tutorial I linked.

36 I/O pins
2 serial ports, either capable of full speed master mode SPI.
16K RAM, 128K flash, 4K(?) EEPROM
You can get 1 for about $7, socket for maybe 50 cents.

Suppose you soldered a bypass cap, crystal and caps and power/gnd hookup to a 40 pin socket then soldered 20x1 pin headers to the socket pins (leaving out the crystal pins)? Print stick on labels for the headers so they read rightside up when the chip is down to label the pinholes. Program the chip and pop it in, you have a dev-socket. Power… a USB charger will do, or any DC 6V to 24V 200+mA supply and a DC-DC converter. Small enough?

leftyg: I might try the Mega2560 & see if I can change the dimensions of the case a little. I guess I'll also need to be concerned more about battery life since I assume it draws more current than the Uno does without a load. Does anyone know the actual current draw of the board without any load on it?

Go to the atmel site and get the ATmega2560 family datasheet.

http://www.atmel.com/devices/ATMEGA2560.aspx