Primeiramente, um Feliz 2018 a todos!

Sr's estou me aperfeiçoando no Arduino, estou realizando um projeto mas estou com uma duvida no meio do caminho, o codigo a seguir, lê as portas Analogicas e me da os valores no Excel, assim realizo o Deployment, o mais dificil acho que ja consegui com ajuda de alguns tutorias.

Então agora quero que conforme o valor lido na porta analogica X, por exemplo se maior que Y, acione a porta Z.

Se alguem poder realizar um exemplo para eu estar seguindo para as outras portas ficarei grato.

Desde já, obrigado!

#include <rExcel.h>

long idx = 0; // index
int outputTiming = 1000; // packet sending timing in ms important: this dermines the output timing
float ent_analog0;
float ent_analog1;
float ent_analog2;
float ent_analog3;
float ent_analog4;
float ent_analog5;

char value[16]; // written or read value

rExcel myExcel; // class for Excel data exchanging

void setup(){

//Serial.begin(9600);
Serial.begin(115200);
delay(1000);

// rx buffer clearing
myExcel.clearInput();

// if analog input pin 5 is unconnected, random analog noise will cause the call to randomSeed() to generate different seed numbers each time the sketch runs
randomSeed(analogRead(5));
}

void loop() {

static unsigned long loopTime = 0;
static unsigned long time1 = 0;
int ret;

loopTime = millis();

// Output Task
// Arduino acts as client making requests to Excel
// instructions performed each outputTiming ms
if ((loopTime - time1) >= outputTiming) {

time1 = loopTime;

// set your custom values
ent_analog0 = (float)analogRead(0) / 1023.0 * 5.0;
ent_analog1 = (float)analogRead(1) / 1023.0 * 5.0;
ent_analog2 = (float)analogRead(2) / 1023.0 * 5.0;
ent_analog3 = (float)analogRead(3) / 1023.0 * 5.0;
ent_analog4 = (float)analogRead(4) / 1023.0 * 5.0;
ent_analog5 = (float)analogRead(5) / 1023.0 * 5.0;

// look the following examples and modify the code as you need

myExcel.write("Embarcados", "B2", ent_analog0, 2);
myExcel.write("Embarcados", "B3", ent_analog1, 2);
myExcel.write("Embarcados", "B4", ent_analog2, 2);
myExcel.write("Embarcados", "B5", ent_analog3, 2);
myExcel.write("Embarcados", "B6", ent_analog4, 2);
myExcel.write("Embarcados", "B7", ent_analog5, 2);

//HISTÓRICO
myExcel.writeIndexed("Embarcados", idx+52, 4, idx);
myExcel.writeIndexed("Embarcados", idx+52, 5,"%date%");
myExcel.writeIndexed("Embarcados", idx+52, 6,"%time%");
myExcel.writeIndexed("Embarcados", idx+52, 7, ent_analog0, 2);
myExcel.writeIndexed("Embarcados", idx+52, 8, ent_analog1, 2);
myExcel.writeIndexed("Embarcados", idx+52, 9, ent_analog2, 2);
myExcel.writeIndexed("Embarcados", idx+52, 10, ent_analog3, 2);
myExcel.writeIndexed("Embarcados", idx+52, 11, ent_analog4, 2);
myExcel.writeIndexed("Embarcados", idx+52, 12, ent_analog5, 2);

idx++;

if (idx > 100)
{
myExcel.clear("Embarcados","D52:L152");
idx = 0;
}
}
}

Exibições: 549

Responder esta

Respostas a este tópico

Certo, legal que colocando quem quiser pode fazer uso imagino, podemos ver o tamanho que ficou tbm por exemplo apos compilar e otimizar.-

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço