Étape 3: Code
Connectez 3.3V à AREF
const int ap1 = A5 ;
const int ap2 = A4 ;
const int ap3 = A3 ;
sv1 int = 0 ;
ov1 int = 0 ;
sv2 int = 0 ;
ov2 int = 0 ;
sv3 int = 0 ;
int ov3 = 0 ;
void setup() {}
initialiser une communication série à 9600 bits/s :
Serial.Begin(9600) ;
}
void loop() {}
analogReference(EXTERNAL) ; Connectez 3.3V à AREF
lire l’analogue en valeur :
SV1 = analogRead(ap1) ;
mapper à la gamme de l’analogique sur :
OV1 = carte (sv1, 0, 1023, 0, 255) ;
changer l’analogue à la valeur :
Delay(2) ;
//
SV2 = analogRead(ap2) ;
ov2 = carte (sv2, 0, 1023, 0, 255) ;
//
Delay(2) ;
//
SV3 = analogRead(ap3) ;
ov3 = carte (sv3, 0, 1023, 0, 255) ;
imprimer les résultats de la série monitor :
Serial.Print ("Xsensor1 =") ;
Serial.Print(SV1) ;
Serial.Print ("\t output1 =") ;
Serial.println(OV1) ;
Serial.Print ("Ysensor2 =") ;
Serial.Print(SV2) ;
Serial.Print ("\t output2 =") ;
Serial.println(OV2) ;
Serial.Print ("Zsensor3 =") ;
Serial.Print(SV3) ;
Serial.Print ("\t output3 =") ;
Serial.println(ov3) ;
Delay(3000) ;
}