int pirsensor = 0;
const int ledpin=11;
const int soundpin=A2;
const int threshold=200;
void setup()
{
pinMode(13, OUTPUT);
pinMode(2,INPUT);
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(soundpin,INPUT);
}
void loop();
const int soundsens = analogRead(soundpin);
if (soundsens >= threshold);
{
pirsensor = digitalRead(2);
if (pirsensor == HIGH)
{
digitalWrite(13,HIGH);
digitalWrite(ledpin,HIGH);
}
else
{
digitalWrite(13,LOW);
digitalWrite(ledpin,LOW);
}
delay(10);
}
delay(2);
}
The error code is copied below:
testcodefor_soundsensorandPIR:20:5: error: expected unqualified-id before 'if'
if (soundsens>=threshold,pirsensor = HIGH);
^~
testcodefor_soundsensorandPIR:21:1: error: expected unqualified-id before '{' token
{
^
testcodefor_soundsensorandPIR:36:10: error: expected constructor, destructor, or type conversion before '(' token
delay(2);
^
testcodefor_soundsensorandPIR:37:1: error: expected declaration before '}' token
}
^
> exit status 1
expected unqualified-id before 'if'
note this is my attempt to combine codes I was never taught coding

loop()function isn't a function. You've declared it but not defined it, because you put a semi-colon on the end, and then you forgot to use an opening brace{to start it. – brhans Apr 08 '22 at 00:33ifstatement like that. If you want to evaluate different things you need to use the boolean operators like&&and||, and you can't end anifwith a semi-colon. – brhans Apr 08 '22 at 00:36