Lampe Eveil : Différence entre versions

De Les Fabriques du Ponant
Aller à : navigation, rechercher
(Matériel)
(Code)
Ligne 18 : Ligne 18 :
  
 
===Code===
 
===Code===
 +
 +
<pre>
 +
int analogPin= A0;
 +
int sensorValue= 0;
 +
int outputValue=0;
 +
bool interuValue=false;
 +
 +
void setup() {
 +
  // put your setup code here, to run once:
 +
  Serial.begin(9600);
 +
  pinMode(analogPin, OUTPUT);
 +
 +
//led1
 +
pinMode(11,OUTPUT);
 +
pinMode(12,OUTPUT);
 +
pinMode(13,OUTPUT);
 +
 +
//led2
 +
pinMode(5,OUTPUT);
 +
pinMode(6,OUTPUT);
 +
pinMode(7,OUTPUT);
 +
 +
 +
//led3
 +
pinMode(8,OUTPUT);
 +
pinMode(9,OUTPUT);
 +
pinMode(10,OUTPUT);
 +
 +
//led4
 +
pinMode(1,OUTPUT);
 +
pinMode(2,OUTPUT);
 +
pinMode(3,OUTPUT);
 +
 +
 +
//interrupteur
 +
pinMode(4,INPUT);
 +
 +
//initialisation des leds
 +
 +
 +
digitalWrite(11,HIGH);
 +
digitalWrite(12,HIGH);
 +
digitalWrite(13,HIGH);
 +
 +
digitalWrite(5,HIGH);
 +
digitalWrite(6,HIGH);
 +
digitalWrite(7,HIGH);
 +
 +
digitalWrite(8,HIGH);
 +
digitalWrite(9,HIGH);
 +
digitalWrite(10,HIGH);
 +
 +
digitalWrite(1,HIGH);
 +
digitalWrite(2,HIGH);
 +
digitalWrite(3,HIGH);
 +
}
 +
 +
void loop() {
 +
 +
//etat photoresistance
 +
sensorValue=analogRead(analogPin);
 +
 +
//etat interrupteur
 +
interuValue=digitalRead(4);
 +
Serial.println(sensorValue);
 +
 +
if (interuValue==0)
 +
{
 +
digitalWrite(11,HIGH);
 +
digitalWrite(12,HIGH);
 +
digitalWrite(13,HIGH);
 +
digitalWrite(5,HIGH);
 +
digitalWrite(6,HIGH);
 +
digitalWrite(7,HIGH);
 +
digitalWrite(8,HIGH);
 +
digitalWrite(9,HIGH);
 +
digitalWrite(10,HIGH);
 +
digitalWrite(1,HIGH);
 +
digitalWrite(2,HIGH);
 +
digitalWrite(3,HIGH);
 +
}
 +
else {
 +
 +
if (sensorValue>=0 && sensorValue<=10){
 +
digitalWrite(11,LOW);
 +
digitalWrite(12,LOW);
 +
digitalWrite(13,LOW);
 +
digitalWrite(5,LOW);
 +
digitalWrite(6,LOW);
 +
digitalWrite(7,LOW);
 +
digitalWrite(8,LOW);
 +
digitalWrite(9,LOW);
 +
digitalWrite(10,LOW);
 +
digitalWrite(1,LOW);
 +
digitalWrite(2,LOW);
 +
digitalWrite(3,LOW);
 +
 +
 
 +
}
 +
 +
else if (sensorValue>=10 && sensorValue<=20){
 +
digitalWrite(11,LOW);
 +
digitalWrite(12,LOW);
 +
digitalWrite(13,LOW);
 +
digitalWrite(5,LOW);
 +
digitalWrite(6,LOW);
 +
digitalWrite(7,LOW);
 +
digitalWrite(8,HIGH);
 +
digitalWrite(9,HIGH);
 +
digitalWrite(10,HIGH);
 +
digitalWrite(1,HIGH);
 +
digitalWrite(2,HIGH);
 +
digitalWrite(3,HIGH);
 +
}
 +
 +
else if (sensorValue>=20 && sensorValue<=30){
 +
digitalWrite(11,LOW);
 +
digitalWrite(12,LOW);
 +
digitalWrite(13,LOW);
 +
digitalWrite(5,HIGH);
 +
digitalWrite(6,HIGH);
 +
digitalWrite(7,HIGH);
 +
digitalWrite(8,HIGH);
 +
digitalWrite(9,HIGH);
 +
digitalWrite(10,HIGH);
 +
digitalWrite(1,HIGH);
 +
digitalWrite(2,HIGH);
 +
digitalWrite(3,HIGH);
 +
}
 +
 +
 +
else{
 +
 
 +
digitalWrite(11,HIGH);
 +
digitalWrite(12,HIGH);
 +
digitalWrite(13,HIGH);
 +
digitalWrite(5,HIGH);
 +
digitalWrite(6,HIGH);
 +
digitalWrite(7,HIGH);
 +
digitalWrite(8,HIGH);
 +
digitalWrite(9,HIGH);
 +
digitalWrite(10,HIGH);
 +
digitalWrite(1,HIGH);
 +
digitalWrite(2,HIGH);
 +
digitalWrite(3,HIGH);
 +
}
 +
 
 +
 +
}
 +
 +
 +
}
 +
 +
</pre>
  
 
==L'équipe==
 
==L'équipe==

Version du 17 janvier 2019 à 15:27

Présentation

Réalisation d'une lampe qui ajuste son intensité lumineuse en fonction de la luminosité ambiante afin de réaliser des économies d'énergies.

Conception

Matériel

  • Carte Arduino UNO
  • 3 LED RGB
  • 1 Photorésistance
  • 1 Bouton poussoir
  • 11 Résistances (10 de 220Ω pour les LED et 1 de 10kΩ pour le bouton poussoir)

Code

int analogPin= A0;
int sensorValue= 0;
int outputValue=0;
bool interuValue=false;

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   pinMode(analogPin, OUTPUT); 

//led1
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

//led2
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);


//led3
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);

//led4
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);


//interrupteur
pinMode(4,INPUT);

//initialisation des leds


digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);

digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);

digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);

digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}

void loop() {
 
//etat photoresistance
sensorValue=analogRead(analogPin);

//etat interrupteur
interuValue=digitalRead(4);
Serial.println(sensorValue);

if (interuValue==0)
{
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}
else {

if (sensorValue>=0 && sensorValue<=10){
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(3,LOW);

  
}

else if (sensorValue>=10 && sensorValue<=20){
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}

else if (sensorValue>=20 && sensorValue<=30){
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}


else{
  
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}
  

}


}

L'équipe

  • DELIN Félix
  • HOCQUETTE Thibaut
  • DUFFAU Quentin
  • PHELEPP Yoann