I have two sensors one is inputted at A0 and the other is at A1. When I just use one sensor the code works just fine. when I try using both of them it gives me the Button A was not declared in this scope.
what do I have to put in the sketch do make it work.
Thanks,
Bob
#include <SoftwareSerial.h>
#define rxPin 50 // Serial input (connects to Emic 2 SOUT)
#define txPin 52 // Serial output (connects to Emic 2 SIN)
// set up a new serial port
SoftwareSerial emicSerial = SoftwareSerial(rxPin, txPin);
const int analogPin1 = A0; // pin that the motion sensor is attached to
const int analogPin2 = A1; // pin that the remolt sensor is attached to
const int ledPin = 24; // pin that the LED is attached to
const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input
void setup() {
// initialize the LED pin as an output:
pinMode(24, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
// define pin modes
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
emicSerial.begin(9600);
emicSerial.print('\n'); // Send a CR in case the system is already up
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush(); // Flush the receive buffer
}
void loop() {
// read the value of the potentiometer1:
int analogValue = analogRead(analogPin1);
// if the analog value is high enough, turn on the LED:
if (analogValue > threshold) {
Button A();
delay(10);
read the value of the potentiometer2:
int analogValue = analogRead(analogPin2);
if (analogValue > threshold) {
ButtonA();
} else {
digitalWrite(24, LOW);
}
// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability
{
}
}
void ButtonA() {
digitalWrite(24, HIGH);
delay(1900);
digitalWrite(24, LOW);
emicSerial.print('S');
emicSerial.print("[ AY<400,25> RAO<200,28> K<100> IH<100,27> N<50> DHAX<150> TRIY<150,25> TAO<200,27> P<100> AO<100,28> LX<50> DHAX<150> DEY<300,27> LX<75> uh<400,25>[n1]");
emicSerial.print('\n');
while (emicSerial.read() != ':'); // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
//while (1) // Demonstration complete!
{
}
}