0% found this document useful (0 votes)
31 views1 page

Arduino Battery Read and Control Code

The document contains a code snippet for reading battery voltage and controlling a motor based on sensor inputs. It defines functions to read analog values and set up pin modes for various inputs and outputs. The loop checks the states of the sensors to control the motor's operation accordingly.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

Arduino Battery Read and Control Code

The document contains a code snippet for reading battery voltage and controlling a motor based on sensor inputs. It defines functions to read analog values and set up pin modes for various inputs and outputs. The loop checks the states of the sensors to control the motor's operation accordingly.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

void read_batt(){

y=analogiread(A5);
tension=(y*5)/1023;
tension_batterie=(tension*28.8)/10;
return tension_batterie;
}

#definie F_motrice
#definie NH
#definie CO
#definie NB
void setup(){
pinMode(F_motrice,OUTPUT);
pinMode(NH,INPUT);
pinMode(CO,INPUT);
pinMode(NB,INPUT);
void loop(){
int nh=digitalRead(NH);
int co=digitalRead(CO);
int nb=digitalRead(NB);
if (co==HIGH && nb=HIGH && nh=LOW){
digitalWrite(F_motrice,HIGH);
}
if(nh==HiGH)
{
digitalWrite(F_motrice,LOW);
}
}

You might also like