The DAC is just fast enough to generate low-resolution composite video that can be viewed on a television or monitor with composite video input (typically a yellow RCA connector).
There are very few pixels, and it’s only grayscale, but it’s sufficient for creating simple games or to print readings from sensors.
To use this, download and manually install the Adafruit_CompositeVideo library:
This also requires the Adafruit_GFX library, which is much easier to install using the Arduino Library Manager: Sketch→Include Library→Manage Libraries… (enter “GFX” in the search field).
Earlier versions (pre-1.8.10) also require installing Adafruit_BusIO (newer versions will handle this one automatically).
After the Adafruit_CompositeVideo library is installed, there are a couple of example sketches. One prints the current value from the Circuit Playground light sensor, another shows large horizontal-scrolling text.
At the other end, connect A0 to the “tip” (center) of the composite video connector, and ground to the “ring” (outside).
Depending on the TV/monitor connection and available cabling, you may need a spare composite cable or male-to-male adapter to get something you can clip onto.
Since I’ll be testing the code often, I cobbled together a somewhat more permanent connector from a spare cable and test leads, but it’s not necessary to go to such lengths if just trying it out.
NTSC video runs at 29.97 frames per second. Each frame is comprised of 525 horizontal scanlines. Each scanline starts and ends with carefully-timed synchronization signals, with image data in-between: an analog voltage from about 0.3 to 1.0V determines the brightness at that point along the scanline.
Twice per frame, there are also vertical synchronization signals following a specific timing and pattern.
Some of these “blips” are just a couple of microseconds long! Digital outputs can easily manage such timing, but for the SAMD DAC this is challenging…the makeshift video signal is just good enough for most screens to latch on to.
To use the library, add these two lines at the top of your sketch:
#include <Adafruit_GFX.h> #include <Adafruit_CompositeVideo.h>
Then, before the setup() function, declare a global object of type Adafruit_NTSC40x24:
Adafruit_NTSC40x24 display;
(It’s called this just in case other resolutions are supported in the future…but don’t hold your breath, I’ve tried going higher and the DAC can’t quite make a stable image.)
Then, inside your setup() function, call the object’s begin() function to enable composite video out on the A0 pin:
display.begin();
Because it builds upon the Adafruit_GFX library, all the same drawing functions (including fonts) are available as with our other Arduino-compatible displays. “Colors” passed to the drawing functions should be 8-bit grayscale values (0 to 255, where 0=black, 255=white).
display.drawLine(0, 0, 39, 23, 128); // Gray line, corner-to-corner display.setTextColor(255); // White text display.print("Hello World");
Limitations
- Circuit Playground Express speaker is disabled; tone() and other audio code will not work in combination with this
- 40x24 pixel resolution; actual usable area may be slightly smaller due to overscan
- Grayscale only
Adafruit_CompositeVideo and Adafruit_AMRadio (on the next page) both use the DAC peripheral and the same timer/counter; the two libraries can not be used at the same time.
The video resolution is extremely crude…it’s more a novelty than anything else. If you need high-quality visuals from a small board, consider a Raspberry Pi Zero!
Folks have generated much sharper video (with color, even!) from much more modest hardware. These all require extra components though. The benefit to this simple gator-clip approach is that classrooms might not allow soldering, or a lesson might not have time for assembling parts on a breadboard. Or it’s just fun showing off.
It’s not in there. And unless you’re actually using a really old CRT telly, it’s probably not necessary. Most, if not all, LCD monitors that handle composite video will automatically detect and adapt to the video signal, so NTSC is fine. This is true even if you are in a "PAL zone" like Europe!
Page last edited March 08, 2024
Text editor powered by tinymce.