"What''s a Microcontroller" Chapter 4 project 1
Archiver
Posts: 46,084
From: "lvscan" <kamikazi@r...>
>
> Thanks for taking the time to look at my code and teach me from
> experience. You have really opened my mind when it comes to the
> possibilities of the stamp.
>
You're welcome, Lu Kwan. That's what groups like this are about. With the
right coding techniques, you can do amazing things with a Basic Stamp. That
article by Jon is at http://makeashorterlink.com/?U55325267 and the help
file in the latest version of the compiler talks about other programming
techniques for each command. It's very useful also.
The conventions Jon recommends for naming are not the only style, and you'll
notice programmers using very different styles who learned on other
languages. (Or in the 18th Century<g>) Don't let that trouble you. The
important point is that you develop a consistent style because it helps you
avoid errors, and writing a line of code that works the first time is lots
easier than finding the mistakes later. If you ever program for a living,
you may find that a company will insist on their own conventions in such
things. They even publish style manuals for coding. But once you have
developed the good coding habits Jon recommends, changing to a different
style is fairly easy.
The only recommendation Jon makes that I would postpone for a beginner is
#13. He suggests using conditional compilation to make your program move to
other models of Stamp more easily. (To handle things like the different
length of time represented by a tick count in PULSOUT on different models.)
He's right -- but for a beginner it adds a level of complexity that I would
postpone until you have more experience. In the first place, unlike Jon and
many of us on this list, most beginners don't have several models of Stamp
around to test each branch of a conditional compilation statement. Worse
yet, it imposes a second level of logic on top of the program logic and that
can make it very difficult to keep track of what you're trying to achieve
when you're new to this art. (Incidentally, Jon. I agree with the
recommendation wholeheartedly. It would have made my life a lot simpler if
my own programmers could have been persuaded to use conditionals more
consistently.)
Jon has written columns for Nuts & Volts magazine that have dealt with
programming techniques as well. There's a list of downloads at
http://makeashorterlink.com/?P31423267. I don't know if any of these are
outdated by the release of the newer versions of PBasic because I haven't
read them, but good programming is good programming. Even if details have
changed I would expect the coding advice to be just as valid as it was when
the articles were published.
Good luck, Lu Kwan, and let us know when you have questions,
Gary
>
> Thanks for taking the time to look at my code and teach me from
> experience. You have really opened my mind when it comes to the
> possibilities of the stamp.
>
You're welcome, Lu Kwan. That's what groups like this are about. With the
right coding techniques, you can do amazing things with a Basic Stamp. That
article by Jon is at http://makeashorterlink.com/?U55325267 and the help
file in the latest version of the compiler talks about other programming
techniques for each command. It's very useful also.
The conventions Jon recommends for naming are not the only style, and you'll
notice programmers using very different styles who learned on other
languages. (Or in the 18th Century<g>) Don't let that trouble you. The
important point is that you develop a consistent style because it helps you
avoid errors, and writing a line of code that works the first time is lots
easier than finding the mistakes later. If you ever program for a living,
you may find that a company will insist on their own conventions in such
things. They even publish style manuals for coding. But once you have
developed the good coding habits Jon recommends, changing to a different
style is fairly easy.
The only recommendation Jon makes that I would postpone for a beginner is
#13. He suggests using conditional compilation to make your program move to
other models of Stamp more easily. (To handle things like the different
length of time represented by a tick count in PULSOUT on different models.)
He's right -- but for a beginner it adds a level of complexity that I would
postpone until you have more experience. In the first place, unlike Jon and
many of us on this list, most beginners don't have several models of Stamp
around to test each branch of a conditional compilation statement. Worse
yet, it imposes a second level of logic on top of the program logic and that
can make it very difficult to keep track of what you're trying to achieve
when you're new to this art. (Incidentally, Jon. I agree with the
recommendation wholeheartedly. It would have made my life a lot simpler if
my own programmers could have been persuaded to use conditionals more
consistently.)
Jon has written columns for Nuts & Volts magazine that have dealt with
programming techniques as well. There's a list of downloads at
http://makeashorterlink.com/?P31423267. I don't know if any of these are
outdated by the release of the newer versions of PBasic because I haven't
read them, but good programming is good programming. Even if details have
changed I would expect the coding advice to be just as valid as it was when
the articles were published.
Good luck, Lu Kwan, and let us know when you have questions,
Gary