Arduino TVout library Image Output

TV RCA Image Output with Arduino featured image
Share:

About

In this tutorial, you will learn how to output video from an Arduino and display it on a TV. Here we will specifically, see how to output an image. If you would like to know how to make the adapter or know more about the other functions available(outputting text, shapes, pixels) in the TVout library see this post.

Hardware used:

This tutorial is an extension of this original post I made about the TVout library. See the original post to see how to connect/make the circuit to connect the Arduino to the TV RCA input.  

Software

This is the main code. It is pretty straight forward and self-explanatory(else read the code comments). However, you will first have to install the TVout library. You can do that by using the Arduino library manager.  If you don’t exactly know how to install a library see the first part of this tutorial.
#include <TVout.h>
#include <fontALL.h>

//Include the image.
#include "myImage.h"

TVout TV;

void setup()
{
  //Setup display.
  TV.begin(PAL,120,96);
  //Select font.
  TV.select_font(font6x8);
}

void loop()
{
  //Clear screen at the beginning of the loop.
  TV.clear_screen();

  //Set curosr position. (x,y)
  TV.set_cursor(15, 10);
  //Print text.
  TV.println("THE EECS BLOG");

  //Add the bitmap image. (x,y,image)
  TV.bitmap(25, 30, myImage);
  
  TV.delay(60);
}
Next, we need to create a c++ header file. Put in the code below and call it myImage.h. Save this file inside the project directory.
#include <avr/pgmspace.h>

#ifndef MYIMAGE_H

#define MYIMAGE_H

extern const unsigned char myImage[];

#endif
Now we need to resize our image(64x64px). You can do this good old MS paint.
Next, we have to convert our image to a bitmap. We can use this website to do this.
Lastly, we need to make the file that is going to contain the image. Name the file myImage.cpp and save it into the project directory. In this file, we will fill our image “container” with the data(bitmap) that makes up the image.
Now just copy the hexadecimal values in the array and paste them in the array below. Make sure to put the resolution “64, 64, //resolution” before the data.
#include "myImage.h"

PROGMEM const unsigned char myImage[] = {

  64, 64, //resolution
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x19,0x33,0x26,0x64,0xCC,0x98,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00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x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x1B,0xB3,0x76,0x6E,0xCD,0xD8,0x00,
  0x00,0x19,0x12,0x22,0x44,0x48,0x98,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 
};
This is how your project directory should look like.
All that is left to do now is to upload the code …

Output:

Share:

Comments

            1. The monitor you have should be able to display the output. It supports NTSC and PAL so that can’t be a problem. Maybe you can try using your TV to see if works there. I see that the monitor has multiple inputs. I am sure you probably already did this but just in case make sure the right input is selected. Also, it might be a hardware problem with your circuit. Try using an oscilloscope to check if there a signal coming out.

Leave a Reply

Your email address will not be published. Required fields are marked *

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger