// Forum: https://forum.arduino.cc/t/hello-i-would-really-appreciate-help-for-my-beginner-school-project/1256909/
// This Wokwi project: https://wokwi.com/projects/397229860331694081
const int ledPinR = 11;
const int ledPinG = 10;
const int ledPinB = 9;
const int buzzPin = 3;
const int pirPin = 2;
void setup()
{
pinMode(ledPinR, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(buzzPin, OUTPUT);
pinMode(pirPin, INPUT);
// Test if the Serial Monitor is working
Serial.begin(115200);
Serial.print("Testing the parts...");
// Test if the buzzer is working
for(int i=500; i<4000; i+=i/30)
{
tone(buzzPin, i);
delay(40);
}
noTone(buzzPin);
// Test if the RGB led is working
for(int i=0; i<4; i++)
{
digitalWrite(ledPinR,HIGH);
delay(400);
digitalWrite(ledPinR,LOW);
digitalWrite(ledPinG,HIGH);
delay(400);
digitalWrite(ledPinG,LOW);
digitalWrite(ledPinB,HIGH);
delay(400);
digitalWrite(ledPinB,LOW);
}
Serial.println(" Ready");
Serial.println("Click on the PIR sensor and then click on the button \"Simulate motion\"");
}
void loop()
{
int pirValue = digitalRead(pirPin);
if(pirValue == HIGH)
{
Serial.print("█"); // UTF-8 character, full block
}
else
{
Serial.print("▁"); // UTF-8 character, lower 1/8
}
delay(250);
}