Hello, I am having some problems with my code.
In the buttom of the code in my IF AND state, it says:
exit status 1
expected idemtifier before '(' token
Here is my code:
/*
SoundSensor
Turns on and off a light emitting diode(LED) connected to digital pin 13,
when sound is detected.
The circuit:
- LED attached from pin 13 to ground
- Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 18-05-2018
by Lysrac <http://steamcommunity.com/id/Lysrac>
or via Discord <Lysrac#5973>
http://www.arduino.cc/
*/
// constants won't change. They're used here to set pin numbers:
const int SEN1 = 9; // the number of the first sensor pin
const int SEN2 = 10; // the number of the second sensor pin
const int ledPin2 = 11; //the number of the second LED pin
const int ledPin = 12; // the number of the LED pin
// variables will change:
int sen1s = 0; // variable for reading the sensor status
int sen2s = 0;
void setup() {
// sets pin 13 as an output to activate internal LED
pinMode(13, OUTPUT);
// initialize the LED pins as an output:
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(SEN1, INPUT);
pinMode(SEN2, INPUT);
//sets up serial communication on 9600
Serial.begin(9600);
}
void loop() {
// read the state of the pushbutton value:
sen1s = digitalRead(SEN1);
sen2s = digitalRead(SEN2);
// check if the sensor1 is reading. If it is, the sen1s is HIGH:
if (sen1s == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
// check if the sensor2 is reading. If it is, the sen2s is HIGH:
if (sen2s == HIGH) {
// turn LED on:
digitalWrite(ledPin2, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin2, LOW);
}
//Code for checking that both are HIGH at same time
if (sen1s == HIGH) and (sen2s == HIGH) {
Serial.println(Sound Detected);
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}
Thank you for any help