Week 4 – Combining a Touch Sensor and a PIR Motion Sensor – Josh Milkins

We decided that the most logical and useful application of our two sensors was an intruder alarm.

The alarm consisted of a PIR sensor which was used to detect movement in a room, it also had a touch switch which could be used to reset the alarm once is had been tripped. When the alarm is tripped, LED’s flash and a buzzer is sounded to deter intruders from continuing.

This was the fritzing diagram which shows all of the components used;

fritzing combined

Photo Capture Alarm sys

And the code;

The debouce used in the previous weeks code was also used in this one and this code also used clock cycles to flash the LED instead of;

digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LOW);

We used;

if (alarm){
unsigned long currentMillis = millis();
if(currentMillis – previousMillis > interval) {
previousMillis = currentMillis;
if (ledState == LOW)
ledState = HIGH;
ledState = LOW;

This allows us to put more parameters into the if statement like seeing whether the led is currently high or low.

The video shows that when i put my hand in front of the sensor it will trigger although we found the motion sensor has a very wide detectable angle of 170 degrees and so it was hard to find position that didn’t trigger it.

Week 3 – 4 Arduino Alarm System with Motion and Touch Sensors

Photo capture of the Arduino alarm system with motion and touch sensors.

PPhoto Capture


The Fritzing Diagram of the Alarm system with motion and touch sensors.



fritzing combined

The Video Capture of the working Arduino Alarm System with motion and touch sensors


The Arduino Code of the Alarm system with motion and touch sensors


Large Code combined

Week1- 2: Arduino Motion sensor

Author: Suleyman Akbulut

Using motion sensors and an Arduino you can trigger lights, fans, etc. This kind of sensor is known as the Passive Infrared Motion Detector or PIR. These sense the infrared radiation emitted by all objects above absolute zero. When something passes in front of a PIR sensor it detects the change in background temperature and then triggers an output voltage. This voltage can be read by an Arduino digital input and then the Arduino can act upon it.

The Motion sensor I used for this project is shown below;


Here is the circuit for my Arduino motion sensor project;



P.S. I used barometric pressure sensor on this diagram as there wasn’t a motion sensor on the menu to use.

The Arduino code for the project as follows;

This code activates an LED when you wave your hand over the motion sensor.
int motion_1 = 2;
int light_1 = 13;
void setup(){
pinMode (motion_1,INPUT);
pinMode (light_1, OUTPUT);
void loop (){
digitalWrite (light_1,LOW);
delay(1000); //this delay is to let the sensor settle down before taking a reading
int sensor_1 = digitalRead(motion_1);
if (sensor_1 == LOW){

The photos of motion sensor project as follows;





Week 2 – Capacitive Touch Sensor – Josh Milkins

The sensor has two outputs, an analogue output that is dependent on how strongly a touch is detected, or a digital output that will go high if touch is detected above a threshold set by the modules potentiometer.

The example program below by hobbycomponents.com reads the status of both sensor outputs and outputs ‘TOUCH DETECTED’ to the serial port when the sensor detects it being touched.


I wired up the breadboard to work with the code with the digital output of the sensor going to pin 2 on the arduino and the analog output of the sensor going to pin A0 on the arduino


This is the flowchart for the Sudo code;

serial monitor flowchart


And the fritzing breadboard layout;

Touch fritzing

Week 1 – Capacitive Touch Sensor – Josh Milkins

I have been given the capacitive touch sensor to research.

The PCB components consist of:

  • 2x 100kohm resistors
  • 2x 1kohm resistors
  • 1x 10kohm resistor
  • 1x 150ohm resistor
  • 1x KSP13 Darlington transistor
  • 1x LM393 Dual differential comparator
  • 2x LED’s
  • 1x 100k Potentiometer

1 Analogue out
3 VCC (+5V)
4 Digital out


Above is a schematic of the PCB


When looking more in depth into the components I found the datasheets of the 2 main components;

The lm393 Dual differential comparator

The ksp13 Darlington transistor