Bonjour
J’essaye de creer un programme permettant de retranscrire la température et la luminosité capté par un capteur de température LM35 et un capteur de luminosité BH1750 en temps réel sur un écran arLCD ( écran tacticle + carte arduino). Grace au programme que j’ai actuellement, j’arrive à retranscrire seulement la température. J’aimerais savoir ce qu’il ne va pas dans mon programme en ce qui concerne la température.
Voici mon programme:
#include <ezLCDLib.h>
#include <Wire.h>
#include <math.h>
ezLCD3 lcd;
int xPos = 190;
int y1Pos = 30;
int y2Pos = 95;
int x1Pos = 110;
int y3Pos = 190;
int width = 100;
int height = 40;
int radius = 10;
int alignment = 0;
int option = 1;
int touch=0;
int xPos1 = 90;
int yPos2 = 100;
int yPos1 = 35;
int width1 = 60;
int option1 = 14;
int digits = 3;
int dp = 0;
int x2Pos = 30;
int y4Pos = 190;
int xpo = 10;
int ypo = 65;
int width2 = 45;
int height2 = 90;
int resolution = 1;
int maxi = 23;
int initial = 0;
int option2 = 3;
int xpo1 = 265;
int max1 = 59;
int x3Pos = 115;
int y5Pos = 50;
int y6Pos = 100;
int xPos6 = 70;
int yPos6 = 70;
int width3 = 80;
int height3 = 80;
int digits1 = 3;
int dp1 = 0;
int xPos7 = 170;
int tempPin = 0;
int tempPin2 = 1;
int dat;
int val2;
int val3;
int val;
int BH1750address = 0x23;
byte buff[2];
void setup()
{ Wire.begin();
accueil();
}
void loop(){
val2 = analogRead(tempPin);
dat= (500 * val2) / 1024;
void luminosite();
val3 = analogRead(val);
touch=lcd.wstack(0);
if (touch==1) temp();
if (touch==2) eclairage();
if (touch==3) heure();
if (touch==6) accueil();
if (touch==1) R();
if (touch==2) R();
if (touch==3) R();
if (touch==1) V();
if (touch==2) V();
if (touch==9) midi();
if (touch==10) soir();
if (touch==11) heure();
lcd.digitalMeter( 4, xPos1, yPos1, width1, height1, option1, dat, digits, dp, 4);
lcd.theme( 4, 155, 152, 3, 130, 0, 0, 1, 147, 153, 1 );
lcd.digitalMeter( 5, xPos1, yPos2, width1, height1, option1, val3, digits, dp, 5);
lcd.theme( 5, 155, 152, 3, 130, 0, 0, 1, 147, 153, 1 );
lcd.wvalue(4, dat);
lcd.wvalue(5, val3);
}
void accueil(void) {
lcd.begin( EZM_BAUD_RATE );
lcd.cls( WHITE, BLACK );
lcd.font("0");
lcd.printString("\\[5x\\[5yConsigne de temperature :");
lcd.fontw( 1, "sans24" );
lcd.theme( 1, 0, 3, 0, 2, 3, 2, 2, 2, 1, 1 );
lcd.string( 1, "Modifier" );
lcd.button( 1, xPos, y1Pos, width, height, option, alignment, radius, 1, 1 );
lcd.printString("\\[5x\\[70yConsigne d'eclairage :");
lcd.theme( 2, 0, 3, 0, 2, 3, 2, 2, 2, 1, 1 );
lcd.string( 2, "Modifier" );
lcd.button( 2, xPos, y2Pos, width, height, option, alignment, radius, 2, 2 );
lcd.printString("\\[100x\\[160yReglage horaire");
lcd.theme( 3, 0, 3, 0, 2, 3, 2, 2, 2, 1, 1 );
lcd.string( 3, "Regler" );
lcd.button( 3, x1Pos, y3Pos, width, height, option, alignment, radius, 3, 3 );
lcd.printString("\\[5x\\[40yActuelle :");
lcd.printString("\\[5x\\[105yActuelle :");
}
void luminosite(void)
{
int i;
uint16_t val=0;
BH1750_Init(BH1750address);
//delay(200);
if(2==BH1750_Read(BH1750address))
{
val=((buff[0]<<8)|buff[1])/1.2;
}
delay(150);
}
int BH1750_Read(int address)
{
int i=0;
Wire.beginTransmission(address);
Wire.requestFrom(address, 2);
while(Wire.available())
{
buff[i] = Wire.read();
i++; //incrémentation
}
Wire.endTransmission();
return i; //retour à "int i"
}
void BH1750_Init(int address)
{
Wire.beginTransmission(address);
Wire.write(0x10);
Wire.endTransmission();
}
Je serais vraiment reconnaissant à la personne m’aidant.