Hi ,I am making a project with arduino nano. I added 12 button on breadboard and HC05 bluetooth. And I wrote a phone in MIT App Inventer. I added 12 pictures fron 1 to 12 . My goal is want to see number pictures that which button I clicked . It doesnt works completely. Example when I click button 1 , I can see number 1 pictures , after shows number 12 pictures. Bluetooth always sends number 12 signal. when I click another number , show same number after send number 12 signal. It cant send zero signal for stop.
I am new at arduino projects. I am thinking ,It should be setting HC05 . I don't know maybe there is an another problem . I want to help.
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
pinMode(11,INPUT_PULLUP);
pinMode(12,INPUT_PULLUP);
pinMode(13,INPUT_PULLUP);
}
void loop() {
byte sensorVal1 = digitalRead(2);
if (sensorVal1 == LOW)
{
Serial.println(1);
delay(1000);
}
byte sensorVal2 = digitalRead(3);
if (sensorVal2 == LOW)
{
Serial.println(2);
delay(1000);
}
byte sensorVal3 = digitalRead(4);
if (sensorVal3 == LOW)
{
Serial.println(3);
delay(1000);
}
byte sensorVal4 = digitalRead(5);
if (sensorVal4 == LOW)
{
Serial.println(4);
delay(1000);
}
byte sensorVal5 = digitalRead(6);
if (sensorVal5 == LOW)
{
Serial.println(5);
delay(1000);
}
byte sensorVal6 = digitalRead(7);
if (sensorVal6 == LOW)
{
Serial.println(6);
delay(1000);
}
byte sensorVal7 = digitalRead(8);
if (sensorVal7 == LOW)
{
Serial.println(7);
delay(1000);
}
byte sensorVal8 = digitalRead(9);
if (sensorVal8 == LOW)
{
Serial.println(8);
delay(1000);
}
byte sensorVal9 = digitalRead(10);
if (sensorVal9 == LOW)
{
Serial.println(9);
delay(1000);
}
byte sensorVal10 = digitalRead(11);
if (sensorVal10 == LOW)
{
Serial.println(10);
delay(1000);
}
byte sensorVal11 = digitalRead(12);
if (sensorVal11 == LOW)
{
Serial.println(11);
delay(1000);
}
byte sensorVal12 = digitalRead(13);
if (sensorVal12 == LOW)
{
Serial.println(12);
delay(1000);
}
}