Hi,
I need urgent help with this code.
I am connecting a proximity sensor that plays sound when activated for one minute. I keep getting an error but am unsure why.
Is anyone able to assist? I have attached my code bellow.
Thank you!
#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>
#include <Event.h>
#include <Timer.h>
#include <Event.h>
#include <Timer.h>
#include "TMRpcm.h"
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
TMRpcm tmrpcm;
#define ds_pin A0 // Pin to which the distance sensor is connected
#define ds_pin_1 A1 // Pin to which the distance sensor is connected
#define ds_pin_2 A2 // Pin to which the distance sensor is connected
#define ds_pin_3 A3 // Pin to which the distance sensor is connected
Timer t;
int red_pin = 6;
int green_pin = 7;
int ds_value=0; // Integer to hold the sensor’s reading
int ds_value_1=0; // Integer to hold the sensor’s reading
int ds_value_2=0; // Integer to hold the sensor’s reading
int ds_value_3=0; // Integer to hold the sensor’s reading
int status_red;
void setup()
{
tmrpcm.speakerPin = 9;
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(10);
tmrpcm.play("rain.wav");
pinMode(red_pin, OUTPUT);
pinMode(green_pin, OUTPUT);
t.oscillate(red_pin, 1 * 1000, HIGH); // 10 minutes
t.oscillate(green_pin, 1 * 1000, LOW);// 10 minutes
}
void loop()
{
t.update();
ds_value = analogRead (ds_pin); // Reads the distance sensor
ds_value_1 = analogRead (ds_pin_1); // Reads the distance sensor
ds_value_2 = analogRead (ds_pin_2); // Reads the distance sensor
ds_value_3 = analogRead (ds_pin_3); // Reads the distance sensor
status_red=digitalRead(red_pin);if(ds_value<3000 && ds_value_1<300 status_red==0)
{
//play light music
tmrpcm.play("music.wav");
}
else if(ds_value_2<300 && ds_value_3<300 status_red==1)
{
//play thunder
tmrpcm.play("thunder.wav");
}
else
{
tmrpcm.stopPlayback()
}
delay (200); // Delay of 200ms
}
at the }
else if(ds_value_2<300 && ds_value_3<300 status_red==1) part it states expected ')' before 'status_red'
Arduino_task2.ino (1.71 KB)