0% found this document useful (0 votes)
28 views3 pages

Programa

The document contains two similar Arduino programs that read an analog sensor value from pin A0, calculate the average voltage, and print it to the serial monitor. Both programs initialize the sensor and use a loop to read the sensor value ten times, but there are minor syntax errors in the second program. The output includes the calculated voltage and the time taken for the operation.

Uploaded by

Urut Garliu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Programa

The document contains two similar Arduino programs that read an analog sensor value from pin A0, calculate the average voltage, and print it to the serial monitor. Both programs initialize the sensor and use a loop to read the sensor value ten times, but there are minor syntax errors in the second program. The output includes the calculated voltage and the time taken for the operation.

Uploaded by

Urut Garliu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

int pinoSensor = A0;

float sensor1 = 0;

float tensaoSensor = 0;

unsigned long tempoInicio = 0;

unsigned long tempoFim = 0;

unsigned long tempoAtual = 0;

void setup()

[Link](9600);

pinMode(pinoSensor,INPUT);

void loop()

tempoInicio = millis();

for(int cont = 0; i<10; cont++)

sensor += analogRead(pinoSensor);

delay(5);

sensor1 = sensor1/10;

tensaoSensor = (sensor1*5)/1023;

delay(1000);
tempoFim = millis();

[Link](tensaoSensor);

[Link](tempoInicio - tempoFim);

segunda programação

int pinoSensor = A0;

float sensor1 = 0;
float tensaoSensor = 0;
unsigned long tempoInicio = 0;
unsigned long tempoFim = 0;
unsigned long tempoAtual = 0;

void setup()
{
  [Link](9600);
  pinMode(pinoSensor,INPUT);
}

void loop()
{
  tempoInicio = millis();
  for(int cont = 0; i<10; cont++);
 {
    sensor1 += analogRead(pinoSensor);
    delay(5);
 }
  sensor1 = sensor1/10;
  tensaoSensor = (sensor1*5)/1023;
 
  delay(1000);
 
  tempoFim = millis();
  [Link](tensaoSensor);
  [Link](tempoInicio - tempoFim);
}

You might also like