Skip to main content

Reply to "Arduino Lesson: How to Create a Library"

I've been working on the last part of this lesson and am busy tracking down some things that are problematic. You see, even a veteran programmer can have trouble with software.

We are always trying to juggle several screens around at the same time. One with the Arduino IDE. Another looking up documentation on some library functions. One playing songs from the 70's, and here's one, oh never mind about that.

It's a lot of this and that with much experimentation and rebuilding. Eventually, it all comes together and you have what you want. Don't be discouraged if you don't get things to work after the 20th try. Break it down. Take it apart. Isolate where you think the problems exist and test, test, test. That's how it's done. As I said before, you need to harden yourself against failure. It comes with the territory.

As I was working on the new FlashLed class, I realized that the way I was building this "Flash an LED" class was independent of the 2 classes that were developed earlier. What I planned was to have them organized like this:

But FlashLed just uses the "on" and "off" functions with some timing code to create the "flashing" effect. Both PlainLed and PulseLed have their own versions of these routines. And with some changes to the PlainLed class to include some dummy operations that do nothing, the same code for FlashLed could be used to blink a PlainLed. The view of class hierarchy then becomes:

BlinkLed introduces a new class that works in the same way as FlashLed but is dependent only on PlainLed (one that turns on and off but doesn't fade) to operate. This is useful if you want to do without the fading features of PulseLed but still want independent flashing.

This indicates that we have designed this set of classes with a proper isolation of features. We can mix and match these to create the type of object that is desired.

Soon I will finish the FlashLed class and make it available for your perusal. It will include a test program as before but restructured to demonstrate the newer features. Until then, go do some programming.

  -- Leo

 

Attachments

Images (2)
  • mceclip0
  • mceclip1

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×