Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////// Class Potenciometro ////////////////////////
- class Potenciometro{
- public:
- Potenciometro();
- Potenciometro(byte);
- virtual ~Potenciometro();
- // Metodos
- float escalar();
- float getLectura();
- private:
- byte pin;
- float lectura;
- };
- Potenciometro::Potenciometro(){
- }
- Potenciometro::Potenciometro(byte _pin){
- pin = _pin;
- }
- Potenciometro::~Potenciometro(){
- }
- float Potenciometro::getLectura(){
- return analogRead(pin);
- }
- float Potenciometro::escalar()
- {
- return map(Potenciometro::getLectura(),0,1023,0,255);
- }
- /////////////////////////// Class Led ////////////////////////
- class Led{
- public:
- Led();
- Led(byte);
- virtual ~Led();
- // Metodos
- void setIntensidad(float);
- private:
- byte pin;
- float intensidad;
- };
- Led::Led(){
- }
- Led::Led(byte _pin){
- pin = _pin;
- pinMode(_pin, OUTPUT);
- }
- Led::~Led(){
- }
- void Led::setIntensidad(float _intensidad){
- intensidad = _intensidad;
- analogWrite(pin,_intensidad);
- }
- ///////////////////////////////////////////////////////////////
- Led led(6);
- Potenciometro p1(A0);
- void setup()
- {
- Serial.begin(9600);
- }
- void loop()
- {
- led.setIntensidad(p1.getLectura());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement