Hello Erich, so you found the subtle difference between @ and c@, congrats! :-) > > Mark Roth writes: > > So because of grabbing a word it seems that I was bringing in the PINB > > register as well that had a value in it. So that is where the extra bits > > came from. >
Yeah that was just a rookie error there. I had it so stuck in my head that the port register was 8 bits, where could the rest possibly be coming from? Of course it grabbed it's neighbor. That was what I told it to do. It was a good lesson about words though. Numbers: Over time I have adopted the style to prefix each and > every number except for 0 and 1. I have been in the situation > too often, that base was not 10 like expected but rather 16. > > >: cylon > > $ff ddra c! 1 porta c! > > begin #40 ms > > #7 0 do porta c@ 2* porta c! #40 ms loop > > #7 0 do porta c@ 2/ porta c! #40 ms loop > > key? until ; > > This is good advice and serves to document in place just what you wanted for when you have to come back to it. I'll have to try that from now on. Thanks! I was going to add that perhaps I'll only do it with 2 digit numbers, but it occured to me that you do it with anything higher than 1 so that if the base is set to BIN your code could never accidentally choke. > > Cheers, > Erich > -- > May the Forth be with you ... > Slowly, ever so slowly it is. Since my son was playing along as well and wanted to change the speeds we made a few modifications. With your other advice and an added safety catch so we wouldn't have to reset so often. The binary representations of the port values were to show him exactly what we were doing. All in all a bit of learning all around. : cy-delay ( n -- n ) dup ms ; : cylon ( n -- ) depth if %11111111 ddra c! %00000001 porta c! begin #7 0 do porta c@ 2* porta c! cy-delay loop #7 0 do porta c@ 2/ porta c! cy-delay loop key? until drop %00000000 porta c! then ; Now to make it smarter so it reverses when it hits the endstops. We are following along with the Junk Box Arduino stuff since the projects are pretty simple and make a nice bridge from C to Forth. All the best, Mark _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel