Hello Forum,
I just want to thank anyone in advance for reading and helping out with my question.
I been trying this project for a few years now. Since learning Arduino and C++. This is the project.
When someone walks passed the PIR then it tells the RGB to change color and play the sound audio file. Then it turns on a motor one and then turns on motor two. Then turns on the fog machines. As I writing this down.
I am remembering someone said if your project has more then two and's, then use a raspberry Pi. Would be to much for a single Arduino to do? I think the audio might not be in this code. Because I couldn't get the sd reader to work. Maybe someone can help me just know if a Arduino could do this. Also if the uno when the right board to use. or I need Raspberry pi for this?
I wanted to make a Arduino to control
- PIR
- 2 fog machines
- Two motors
- 4 Lights or 4 RGB Led light strips
- one RGB LED
- Play a short 30 sec audio clip
This is the code I have so far. Which I don't even know if its right.
//pin variables
int pirPin = 2; //choose the input pin (for PIR sensor)
int pirState = LOW; //we start, assuming no motion detected
int val = 0; //variable for reading the pin status
int bluePin = 6; // declare pin 6 is Blue RGB
int redPin = 3; // declare pin 3 is red RGB
int greenPin = 5; // declare pin 5 is Green RGB
int motorLiftPin = 7; // choose the pin for relay 1 MOTOR 1 lift
int motorSpinPin = 8; // choose the pin for relay 2 MOTOR 2 spin
int fogPin1 = 9; // choose the pin for fog Controllor 1
int redPin = HIGH;
int greenPin = HIGH;
int bluePin = HIGH;
void setup() { //set the mode of the pins
val = digitalRead(pirPin); //read input value
if(val == Hight) { //check if the input is HIGH
digitalWrite(motorliftPin, HIGH); //turn on motor lift
pinMode(bluePin, OUTPUT); // declare BLUE LED as output
pinMode(redPin, OUTPUT); // declare RED LED as output
pinMode(greenPin, OUTPUT); // declare GREEN LED as output
pinMode(motorLiftPin, OUTPUT);
digitalWrite(motorLiftPin, HIGH); // declare motor start lift
digitalWrite(motorLiftPin,HIGH); // declare relay motor spin
pinMode(fogPin1, OUTPUT);
digitalWrite(fogPin1,HIGH); // declare relay to fog machine to turn on
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!"); // We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}
void loop(){
//turn on and off led
digitalWrite(redPin, redPin);
digitalWrite(greenPin, greenPin);
digitalWrite(bluePin, bluePin);
val = digitalRead(pirPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(bluePin, HIGH); delay(7900); // turn on blue LED 8 sec
digitalWrite(bluePin, LOW); // turn off blue LED
digitalWrite(redPin, HIGH); delay(8500); // turn on red LED 9 sec
digitalWrite(redPin, LOW); //turn on and off LED
digitalWrite(greenPin, HIGH); delay(20000); //turn on green LED 20 sec
digitalWrite(greenPin, LOW); } //turn off green LED
if (pirState == LOW) { // we have just turned on
Serial.println("Motion detected!"); // We only want to print on the output change, not state
pirState = HIGH;
}
else {
digitalWrite(bluePin, LOW); // turn Blue LED OFF
if (pirState == HIGH){ // we have just turned of
Serial.println("Motion ended!"); // We only want to print on the output change, not state
pirState = LOW;
}
}
}