Scenario One - Security.

[Temporary URL - https://www.tinkercad.com/things/l30vieWUfey]

The idea with this circuit is to trigger an alarm when there is an object close to a distance sensor.

Click on the ‘Start Simulation” button.

Click on the PIR sensor and you will see a dark green circle with a dotted line appear, in a light green cone. To simulate movement, move the green circle and see what happens. 

The buzzer should start.

Figure 25. TinkerCAD Circuits 'Security' scenario


 If you don’t move the dark green circle, after a second or two the buzzer will stop.

Stop the simulation and click on the word “Security”

Then click on “Tinker this”.

Open the ‘code’ window

Note that this simulation uses a ‘binary’ input and output – i.e., the PIR sensor either detects movement or not, and the buzzer is either on or off.

int c=0;

void setup()

{

 Serial.begin(9600);

 pinMode(6,INPUT);

 pinMode(7,OUTPUT);

}

void loop()

{

                 int a = digitalRead(6);

 Serial.println(a);

 if(a == 1){

                digitalWrite(7,1);

 }else{

 digitalWrite(7,0);

 }

}

The following scenarios use variable inputs. 

Complete and Continue