Forum: µC & Digital Electronics c++ object of an output (LED)

Author: micro u. (Guest)
Posted on:

Rate this post
0 useful
not useful
im looking for some simple solution for my output class led.
momentary, im buildung my own litte library for simple avr applications 
for beginner.

first class will be used to set up an led object like this:

#ifndef CLED_H_
#define CLED_H_

class CLED
    short pL, pN;
    void ini(){
    // ...
    void toggle(){
    // do something
    void turnOn(){
                // do something
    void turnOff(){
                // do something
}; //CLED

#endif /* CLED_H_ */

DDRC |=  ((1 << PC0);

im looking for a solution, for the constructor or an ini method, 
whatever works.
when you generate the object, you add some paramaters (eq.: B 3 (PortB 
Pin3)) and then, when i finally control the object, it knows itself, 
where to rout the signal.

generate the object:
CLED ledRed("B", 3);

control it:

Author: Tom (Guest)
Posted on:

Rate this post
0 useful
not useful
Andreas Ferber did some template magic which does approx. what you are 
planning to do. As a bonus the compiler can remove all of the overhead 
of the class: Beitrag "IO-Register als Template-Parameter"


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.