Hola
Necesito pasar el mensaje de cont que son contracciones enviar cada dato que sale en la pantalla LCD en Cont. a la aplicación app inventor estado intentando pero no me ha resultado, por favor alguien que me pueda ayudar. Se lo agradecería.
Hola
Necesito pasar el mensaje de cont que son contracciones enviar cada dato que sale en la pantalla LCD en Cont. a la aplicación app inventor estado intentando pero no me ha resultado, por favor alguien que me pueda ayudar. Se lo agradecería.
Hello yesid45
Well, from your Sketch code snippet, the variable 'val' does not seem to have been assigned with a value. We cannot see how you manage process execution time. Also, you would send that value via Serial like this:
Serial.print(val);
Serial.println(); //This last line tells App "End of Data" = Ascii LineFeed Char Number 10
We can't see how you set-up Bluetooth in your Blocks, so there could also be something wrong there.
Is 'val' always a single byte number?
Gracias por tu ayuda ChrisWard
Val no es un numero de un solo byte es de 8 bytes, aunque lo que deseo es que los datos que se envían a la LCD en cont que es un conteo de cada pico de una onda, al llegar su punto máximo, estos conteos se reflejen también en la aplicación app inventor por favor me podrías ayudar con eso, te lo agradecería. Gracias quedo atento
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//Inputs
int in = A0;
int ledPin = 13;
float sensorValue = 0;
int anterior=0;
int cont=0;
void setup() {
Serial.begin(9600); // inicia la comunicaciòn serial
lcd.begin(16, 2);
pinMode(in,INPUT); //configura el pin de entrada
pinMode(ledPin, OUTPUT);
}
void loop() {
//Map the value from 10 bits to 8 bits:
byte val = map(analogRead(in),0,1024.0,0,255); //byte representa una variable de 8 bits, para guardar valores enteros de 0 hasta 255.
//analogRead recibe los valores y sera la variable de los datos a convertir con map
//map valores inciales a converciòn con los finales
float y;
int x,actual;
sensorValue = analogRead(in);
y=sensorValue*5/1023;
lcd.setCursor(0, 0);
lcd.print("Vol.");
lcd.setCursor(0, 1);
lcd.print(y);
if (y>=4.18)
{digitalWrite(ledPin, HIGH);
x=1;}
else
{digitalWrite(ledPin, LOW);
x=0;}
actual=x;
if (anterior==0 & actual ==1)
{cont=cont+1;
delay(1);} //100
anterior=actual;
lcd.setCursor(7, 0);
lcd.print("Cont.");
lcd.setCursor(7, 1);
lcd.print(cont);
Serial.write(val); //Serial.write enviará solo un byte a la vez
delay(1); // retraso entre cada envío de datos
}
type or paste code here
Firstly, you shouldn't use a delay() for this type of Project because everything is stopped for the duration of the delay(). Secondly, 100 milliseconds could be too fast for your App to process - you should experiment, starting with a long time interval, tweaking it down until the is a failure in the App.
Secondly, we need to see your Blocks or your Project file (.aia)
Your Sketch defines it as a single byte @ line 20. Also, 'in' is defined as an integer, but assigned to a float 'sensorValue' @ line 25.
correct, I explained that before, if you understand what I want to do with respect to the cont that appears on the lcd being shown in the app inventor application?
It does not look right, 'val' and 'sensorValue' could differ, but we can change that by only applying analogRead() once per loop:
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//Inputs
const byte analogPinA0 = A0; //analog input pin 0
int ledPin = 13;
int igSensorValue, y;
int anterior, x, actual;
int cont = 0;
unsigned long lgUpdateTime;
void setup() {
Serial.begin(9600); // inicia la comunicaciòn serial
lcd.begin(16, 2);
pinMode(analogPinA0,INPUT); //configura el pin de entrada
pinMode(ledPin, OUTPUT);
lgUpdateTime = millis();
}
void loop() {
if(millis() - lgUpdateTime > 1000) //Loop approx every 1 seconds
{
lgUpdateTime = millis();
igSensorValue = analogRead(analogPinA0);
//Map the value from 10 bits to 8 bits:
//analogVal = map(sensorValue,0,1024.0,0,255); //byte representa una variable de 8 bits, para guardar valores enteros de 0 hasta 255.
//analogRead recibe los valores y sera la variable de los datos a convertir con map
//map valores inciales a converciòn con los finales
y = igSensorValue * 5 / 1023;
lcd.setCursor(0, 0);
lcd.print("Vol.");
lcd.setCursor(0, 1);
lcd.print(y);
if (y >= 4.18)
{digitalWrite(ledPin, HIGH);
x = 1;}
else
{digitalWrite(ledPin, LOW);
x = 0;}
actual = x;
if (anterior == 0 & actual == 1)
{cont = cont + 1;
//delay(1);} //100
anterior = actual;
lcd.setCursor(7, 0);
lcd.print("Cont.");
lcd.setCursor(7, 1);
lcd.print(cont);
if (Serial.connected())
{
Serial.print(igSensorValue); //Integer Value
Serial.println(); //Tells App "End of Data" = Ascii LineFeed Char Number 10
}
}
}
Thanks friend, I will try it like this, in the application, what adjustment would I have to make?
I'm just looking at your Project now, but it's competing with the Arsenal v Manchester Utd match
jaja thanks, I'll stay tuned
It would be better to allow the Screen sizing to be Responsive. If that is a problem for the Canvas, set it's width in pixels, as you have done for the height.
EMG_edit.aia (36.5 KB)
Thanks mate, I'll try that
Hi
Seems that Serial.connected is only available via the Software Serial Library (which is a shame). So delete the 'if{}' and just use Serial.print() and Serial.println(). In theory, you should be able to use Serial.write() but there have been troubles with it on the App side.
thanks friend, then it would be like this
lcd.setCursor(7, 0);
lcd.print("Cont.");
lcd.setCursor(7, 1);
lcd.print(cont);
Serial.print(igSensorValue); //Integer Value
Serial.println(); //Tells App "End of Data" = Ascii LineFeed Char Number 10
}
}
}
Yes, that's it.
put everything to work but the application did not work, anyway thanks for your help, I do not know if you want to look for a google meet to see what it is about
Your Project Blocks are a bit sparse - make sure the phone is connected to Bluetooth and Location is switched on.