Hi,
In a previous thread I was advised to use an array to generate a pattern sequence to be displayed on portB of an 16f628a PIC (var i, D and pat1 previously defined)
However while this will work, I thought that a better idea would be to store the patterns in the PIC using the DATA statement, and I have generated the following patterns sequence (each number is a step in the sequence)Code:pattern3: pat1[0]=129 pat1[1]=66 pat1[2]=36 pat1[3]=24 pat1[4]=36 pat1[5]=66 pat1[6]=129 pat1[7]=0 For i =0 to 7 portb=pat1[i] pause d next i
So in the above example, Patt2 would run the sequence from 8 to 129 over and over again until the selection switches are pressed.Code:patt1 data 16,1,2,4,8,16,32,64,128,128,64,32,16,8,4,2,1 patt2 data 8,129,66,36,24,24,36,66,129 patt3 data 16,1,3,2,6,4,12,8,24,16,48,32,96,64,192,128,0 patt4 data 16,1,128,2,64,4,32,8,16,8,32,4,64,2,128,1,0 patt5 data 12,24,60,126,255,231,195,129,0,129,195,231,255 patt6 data 13,1,2,4,8,17,34,68,136,16,32,64,128,0 patt7 data 8,128,64,32,16,8,4,2,1
However I have two problems.
1) - Being a newbie, I can't see how I can use the read statement to read back the sequence and send it to the port. I did think about using an array, so that each number in thye sequence is placed in the array like the following
2) - As you can see each sequence is not the same length and thus defining the length of the array becomes complicated ?? I assume I could place a digit or some form of marker to signify the end of sequence, but then I would need to count the digits in the data "string" and then set the array length to equal the count, and I'm not sure how to do this, or if its the correct way. Advice pleaseCode:pattern[0]=8 pattern[1]=129 etc![]()
Bookmarks