Advertisement
Enikka

Eclairage_bureau_salon_lampe.cpp

Aug 17th, 2012
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include "Lampe.h"
  2.  
  3. //Constucteur
  4. Lampe::Lampe(int pinlampe, bool digital) : m_pinlampe(pinlampe), m_etatlampe(0), m_digital(digital)
  5. {
  6. }
  7.  
  8. //Méthodes
  9.  
  10. void Lampe::affecter_pin ()
  11. {
  12.   pinMode(m_pinlampe,OUTPUT);
  13. }
  14.  
  15.  
  16. void Lampe::allumer()
  17. {
  18.   lampewrite(1);
  19. }
  20.  
  21. void Lampe::eteindre()
  22. {
  23.   lampewrite(0);
  24. }
  25.  
  26. void Lampe::inverser()
  27. {
  28.   lampewrite(m_etatlampe);  
  29. }
  30.  
  31. void Lampe::lampewrite(bool etat)
  32. {
  33.   m_etatlampe = !etat;
  34.   if (m_digital)
  35.   {
  36.     digitalWrite(m_pinlampe, m_etatlampe);
  37.   }
  38.   else
  39.   {
  40.     analogWrite(m_pinlampe, m_etatlampe);
  41.   }
  42. }
  43.  
  44. char Lampe::afficher_etat()
  45. {
  46.   if(m_etatlampe)
  47.   {
  48.     return 'a';//pour allumée
  49.   }
  50.   else
  51.   {
  52.     return 'e';//pour éteinte
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement