Generating NTSC with Arduino

Convert an indexed grayscale image (16-color) to a list of hex values for use in arduino program.

png2avr.py


 # copy-it-right
 import sys
 from PIL import Image

 def main():
     image =Image.open("robert_index.png")
     out_f = open("robert_index.txt", "w")

    #image = Image.open(sys.argv[1])

    assert image.mode == 'P', 'image must be indexed'

    #sys.stdout.write(chr(int('11111100', 2)))

    for i, px in enumerate(image.getdata()):
        if(i%160==0):
            out_f.write('\n// '+str(i/160))
            print('\n// '+str(i/160))
            #sys.stdout.write('\n')

        out_f.write(hex(px)+', '),
        print(hex(16-px)+', '),
        #sys.stdout.write(hex(px))
        #print('.')

    out_f.close()
    
if __name__ == '__main__':
    main()

Indexed 16 Color Grayscale Image (160x120x4bits)
robert_index

Displayed through the Arduino to NTSC video
0314001807

ntsc_out_schematic

Thanks to MeowJapan.

One thought on “Generating NTSC with Arduino”

Comments are closed.