Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Lampe.h"
- //Constucteur
- Lampe::Lampe(int pinlampe, bool digital) : m_pinlampe(pinlampe), m_etatlampe(0), m_digital(digital)
- {
- }
- //Méthodes
- void Lampe::affecter_pin ()
- {
- pinMode(m_pinlampe,OUTPUT);
- }
- void Lampe::allumer()
- {
- lampewrite(1);
- }
- void Lampe::eteindre()
- {
- lampewrite(0);
- }
- void Lampe::inverser()
- {
- lampewrite(m_etatlampe);
- }
- void Lampe::lampewrite(bool etat)
- {
- m_etatlampe = !etat;
- if (m_digital)
- {
- digitalWrite(m_pinlampe, m_etatlampe);
- }
- else
- {
- analogWrite(m_pinlampe, m_etatlampe);
- }
- }
- char Lampe::afficher_etat()
- {
- if(m_etatlampe)
- {
- return 'a';//pour allumée
- }
- else
- {
- return 'e';//pour éteinte
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement