Hey ! I'm doing a project for school. I have a Grove SoundSensor and I need to send some data to my App Inventor. Here is my Arduino code :
#include <Wire.h>
#include "rgb_lcd.h"
#include <SoftwareSerial.h>
rgb_lcd lcd;
SoftwareSerial bluetooth(10, 11); // RX, TX pins
const int pinSound = A1;
const int pinLed = 2;
int thresholdValue = 80;
void setup()
{
pinMode (pinLed, OUTPUT);
Serial.begin(9600);
bluetooth.begin(9600);
lcd.begin(16, 2);
lcd.setRGB(0,255,0);
}
void loop()
{
int sensorValue = analogRead(pinSound);
int mappedValue = map(sensorValue, 0, 1023, 0, 255);
Serial.println(mappedValue);
// Envoyer les données via Bluetooth
bluetooth.print(mappedValue); // Utilisez print() au lieu de write() pour envoyer une chaîne de caractères
if (sensorValue > thresholdValue)
{
digitalWrite(pinLed, HIGH);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(mappedValue); // Affichez correctement la valeur sur l'écran LCD
}
else
{
digitalWrite(pinLed, LOW);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(mappedValue); // Affichez correctement la valeur sur l'écran LCD
}
if (sensorValue > 100)
{
bluetooth.print("STOP");
};
delay(1000);
}
So I need to send the sound values to my App. And then it will display on the screen the sound values. And when the value is bigger than 100 the phone need to vibrate. So I started to try something and I have this :
But I have 2 problems. Firstly, I don't have the first digit of sound values displayed (e.g. : I have 161 but it only display 61, I have 45 it only display 5). Secondly, my phone don't vibrate when the sound values are bigger than 100.
Could someone help me about this please ?
Thank you,
Arthur