Menu

Problem with array

Help
2017-06-01
2018-01-21
  • Topaz Barziv

    Topaz Barziv - 2017-06-01

    Hi!
    I try to use display, simple 7-segment with micro 16f688. I want display show numbers from 0 to 9.
    have big problem when the display come to last number then the display show random number.

    Code:
    #chip 16F688, 4
    #config HS_OSC, WDT_OFF

    dim NumArray(10)
    NumArray= 0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0000111,0b1111111,0b1101111

    dim i as Byte
    do
    for i=0 to 9
    PORTc=NumArray(i)
    porta.2=NumArray(i).6
    wait 1000 ms
    next i
    loop

     
  • Anobium

    Anobium - 2017-06-01

    The Array index is held in byte 0 - see the Help.

    Does this work?

    #chip 16F688, 4
    #config HS_OSC, WDT_OFF
    dim NumArray(10)
    NumArray= 0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0000111,0b1111111,0b1101111
    dim ii as Byte
    do
    for ii=1 to 10
        PORTc=NumArray(ii)
        porta.2=NumArray(ii).6
        wait 1000 ms
    next ii
    loop
    

    Also, look up '7 Segment Displays Overview' in Help - this may help.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.