Hardware Reference
In-Depth Information
might have changed since this project. Be nice to people; don't hesitate to write
a comment if you think it could be helpful.
Ironically, one of the problems with comments is when there are too many
comments, or even useless comments. If a variable called inputPin is declared
as an int , there is no point writing a comment to say that it is an input pin and
that it is declared as an int .
Comments are not just about functionality but also about the project. Someone
reading the trafi c light header i le may understand what the library does, but
there are several types of trafi c lights. Most of the time, two trafi c lights are
identical; if the northbound light is green, then the southbound light is too,
allowing trafi c to l ow in both directions. This isn't the case for this library; the
advantage is that you can control both lights independently, but the disadvantage
is that it generates more work. Tell the user that!
/***************************************************
This library is used to control a single traffic light,
it does not allow you to create pairs, instead, you have
full control over the way you want the traffic light to
behave.
It requires three pins per traffic light
Written by an Arduino Sketches reader
BSD license, all text above must be included in any redistribution
***************************************************/
class TrafficLight
{
private:
uint8_t _redpin, _amberpin, _greenpin;
public:
TrafficLight(uint8_t redpin, uint8_t amberpin, uint8_t greenpin);
void begin();
void red();
void amber();
void green();
};
It is now clear what the library is used for. Also, you get to add your name
to a project to let people know who did this amazing library, which allows you
to set a license. All the code available in this topic has the BSD license—either
code written by myself or by other parties. The BSD license makes the code
free to use, but without any guarantee. It is free to redistribute, but the original
license must remain. It allows code to be used in part or in whole in any software
project, free or commercial. Remember that the Arduino project is open source;
be nice and give back to the community when possible.
Search WWH ::




Custom Search