c++ object of an output (LED)

Guest #3354785
Rate this post
• ▲ useful
▼ not useful
hi
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:
1
#ifndef CLED_H_
2
#define CLED_H_
3

4

5
class CLED
6
{
7
    short pL, pN;
8
    public:
9
    //constructor
10
    LED(){
11
    }
12
    //methods
13
    void ini(){
14
    // ...
15
    }
16
    void toggle(){
17
    // do something
18
                }
19
    void turnOn(){
20
                // do something
21
    }
22
    void turnOff(){
23
                // do something
24
    }
25
}; //CLED
26

27

28
#endif /* CLED_H_ */

main.cpp
1
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.

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

control it:
ledRed.toggle();

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.