#include "funcion.h"
const int but31=31;////teclado...
const int but32=32;
const int but33=33;
const int but34=34;///...teclado
byte lee;
void setup()
{
Serial.begin(9600);///Para poder visualizar con 'LUPA'
pinMode(but31,INPUT);
pinMode(but32,INPUT);
pinMode(but33,INPUT);
pinMode(but34,INPUT);
}
void loop()
{
lectura();
Serial.print("lee "+String(lee)+"\n");
delay(400);
}
void lectura(){
lee=0;
if(digitalRead(but31)==HIGH){ lee+=1; }
if(digitalRead(but32)==HIGH){ lee+=2; }
if(digitalRead(but33)==HIGH){ lee+=4; }
if(digitalRead(but34)==HIGH){ lee+=8; }
}
Si te va, sacas la función lectura a un .h, le pones el include y pruebas...en el prohtama principal para que trate con los demas programas como se llamen en mi caso funciopn.ide
const int but31=31;////1º
const int but32=32;
const int but33=33;
const int but34=34;///...teclado
byte lee;
#include "funcion.h"////2º
void setup()
{
// setup_funcion();
Serial.begin(9600);///Para poder visualizar con 'LUPA'
pinMode(but31,INPUT);
pinMode(but32,INPUT);
pinMode(but33,INPUT);
pinMode(but34,INPUT);
}
void loop()
{
lectura();
Serial.print("lee "+String(lee)+"\n");
}
void curvas(){
////////CURVAS....
toke[0]--;//de yy1
if(toke[0]>1){
//if(toke[0]>10){ yy1[fx]+=curva[0]; }///si toke es 10 o - se hace recta final
if(na[0]<2){ yy1[fx]+=curva[0]; } else { na[0]--; }
if(yy1[fx]<1){ yy1[fx]=1; }
else { if(yy1[fx]>fintp[0]){ yy1[fx]=fintp[0]; } } }
else { opera(0); }
toke[1]--;//de yy2
if(toke[1]>1){
///if(toke[1]>10){ yy2[fx]+=curva[1]; }
if(na[1]<2){ yy2[fx]+=curva[1]; } else { na[1]--; }
if(yy2[fx]<initp[1]){ yy2[fx]=initp[1]; }
else { if(yy2[fx]>fintp[1]){ yy2[fx]=fintp[1]; } } }
else { opera(1); }
///////....CURVAS
}
void refresca(){
///byte al=veloz/4;// altura de linea
///if(al<1){ al=1; }
for(co=ix;fx>co;co+=6){
///if(yy1[co]!=yy1[co+1]){
//// tft.fillRect(yy1[co]-3,co,3,1,BLACK); tft.fillRect(yy1[co],co,longit2,1,YELLOW); tft.fillRect(yy1[co]+longit2,co,3,1,BLACK);
///} else {
tft.fillRect(yy1[co]-3,co,3,1,BLACK); tft.fillRect(yy1[co],co,longit,1,YELLOW); tft.fillRect(yy1[co]+longit,co,3,1,BLACK);
tft.fillRect(yy2[co]-3,co,3,1,BLACK); tft.fillRect(yy2[co],co,longit,1,YELLOW); tft.fillRect(yy2[co]+longit,co,3,1,BLACK);
}///for(co)
if(infor>0){
if(rfrs){//referencia mostrar fallo
tft.fillRect(10,4,150,16,BLACK);
//// tft.fillRect(8,4,165,16,BLACK);
color0(fallo,sg); tft.setCursor(10, 5);
tft.setTextSize(2);
tft.println("fallo="+String(fallo));////+" "+String(dv)+"-"+String(dr)+"("+String(di)+")");
if(infor>1){ men2();
}//(infor>1)
rfrs=0;////ya se hizo
} }///if(infor>0)
//if(rfs1){ dificulta(); rfs1=0; }//referencia ekilibrar
}
void circulos(){
if(trampa>0){
v8=longit/2;
v16=yy1[140]+v8;
vv16=yy2[140]+v8;
switch (trampa){
case 1: cir1=v16; cir2=analogRead(ana13); cir2/=5; cir2+=245; break;
case 2: cir1=analogRead(ana12); cir1/=5; cir1+=10; cir2=vv16; break;
case 3: cir1=v16; cir2=vv16; break;
}
} else {
cir1=analogRead(ana12); //delay(20);
cir1/=5;
cir1+=10;
cir2=analogRead(ana13);
cir2/=5;
cir2+=245;
}
dibuja();
/////.....circulo
//delay(1000);
}
void scrol(){
///tft.fillRect(ix,ix,220,220,BLUE);
//tft.fillRect(ix,ix,220,220,BLACK);
for(int c1=ix;fx>c1;c1++){
yy1[c1]=yy1[c1+1];
yy2[c1]=yy2[c1+1];
}
}