Sketches not working on Arduino Zero

I had some sketches written for the Arduino Uno which I posted over on Instructables, and decided to try them out on the Zero I just got. Also, I thought they might be useful to have posted here - they all run well on Uno and have the same pin references so it is just a matter of flipping from one sketch to the other.

They are very basic but only two of them work on the Zero - would anyone have any idea why? I am not really a programmer, and can only guess that the two that work are the ones that do not need LEDControlMS.h to be called.

Is there any way I can edit so that the Zero will run all of the sketches?

EDIT - Flashing_heart_broken and flashing_smiley_face both work, the others not.

Thanks in advance

_TF_scrolling.ino (7.53 KB)

animation_countdown.ino (5.61 KB)

flashing_heart_broken.ino (2.26 KB)

pong_animation2.ino (3.17 KB)

flashing_smiley_face.ino (2.26 KB)

Which ones work, and which are not working?

You could save time for anyone who tries to help by providing a link to download LEDControlMS.

Hi Westfw, I mentioned in the original post which ones were not working, I did that in a n edit as soon as I realised I had not said which ones.

Hi Paul, thanks for pointing that out, it is linked in the instructables article mentioned in the OP, so I will just copy that over here. Link to LEDControlMS - http://www.instructables.com/files/orig/F79/UC7X/HKCJMPGV/F79UC7XHKCJMPGV.zip

and the link to the instructable where it is housed, if you do not trust zip files like that -

One issue could be because the MAX7219 chip used with your LED matrix requires a logic high input voltage minimum of 3.5V, (page 3 of the datasheet). The Zero's logic high is at 3.3V.

It might be worth passing the signals through a logic level converter, 3.3V to 5V?

HI Martin, thanks for the tip, but I am not quite sure how to do that.

But, if it was a voltage problem, surely it would not work at all? Two of the sketches run with no problem, which is why I am guessing it is an LEDControlMS problem, as the three sketches that don't work make use of that.

Had a look at the library files LedControl.h and LedControl.cpp, but the code looks compatible with the Zero.

A couple of the library's functions call the AVR function: pgm_read_byte_near(), to access data in stored in flash memory, but in my experience this should still work with the Zero.

You could try commenting out the line #include<avr/pgmspace.h> and delete the reference to PROGMEM in the LedControl.h file; also replace the lines v=pgm_read_byte_near(charTable + value); with v= (charTable + value); and v=pgm_read_byte_near(charTable + index); with v=(charTable + index); in LedControl.cpp.

But, if it was a voltage problem, surely it would not work at all?

Not necessarily. It might be that your Zero's 3.3V levels are only just switching the MAX7219's inputs.

An I2C level shifter like this: 4-channel I2C-safe Bi-directional Logic Level Converter [BSS138] : ID 757 : Adafruit Industries, Unique & fun DIY electronics and kits, can be used to shift voltage levels. It's designed for I2C, but will also work for SPI and serial ports.

MartinL:
It's designed for I2C, but will also work for SPI and serial ports.

Those mosfet+resistors level shifters are terribly slow for SPI.

Early on, Adafruit promoted these with overly optimistic language, claiming they were great for almost all level shifting needs. Sparkfun, Seeed and others copied those words when making their own. Since then, many hobbyists have suffered terrible frustration trying to use these with SPI chips and WS2812 LEDs.

Adafruit still writes "works great for SPI, TTL Serial, and any other digital interface both uni-directional and bidirectional", but at least they now state "10K's do make the interface a little more sluggish than using a TXB0108 or 74LVC245 so we suggest checking those out if you need high-speed transfer". This second part is realistic. The first really should not list SPI as a compatible protocol, since SPI is almost always used at 4+ Mbit/sec speed.

Arduino Zero supports 12 MBit/sec SPI. These slow circuits can't possibly work at that speed.