What Will I Learn?
At the end of this tutorial:
♦ The readers will be able to create a safety alarm system for important belongings like bags from snatchers
♦ The readers will be able to know how the circuit works.
♦ Learn to apply the circuit in making safety purposes or other related applications of the circuit
Introduction
Today, you will learn how to create an electronic circuit using the textile stretch sensor. This circuit will automatically give a sound alarm whenever the sensor is being stretch.
You can read more here
Requirements
Electronic Components
♦ Arduino Uno
♦ Textile stretch sensor
♦ Resistor
♦ Speaker /Piezo speaker
♦ Relay
♦ Transistor
♦ LED
♦ Battery
♦ Breadboard
♦ Connecting wires
Software
♦ Fritzing application
Difficulty
♦ Advance
Tutorial Contents
Using the fritzing software, we will create our circuit diagram, arduino codes and prototype using the breadboard
Part I. Schematic Diagram
So first let us construct our circuit diagram.
Select the electronic components needed for the circuit in the fritzing library. We need 1 arduino uno, 1 textile stretch sensor, 4 resistors, 1 led, 1 piezo speaker, 1 transistor, 1 battery and 1 relay.
Arrange the components before constructing the circuit.
In arranging the components, place all the components for the input side (left side) of the arduino and the components for the output side (right side).
In this tutorial the input components will be the textile stretch sensor and a resistor. The rest of the components are for the output side.
Now let us construct our circuit diagram. At input side of our microcontroller is the textile stretch sensor. The sensor has two pins, one for the source and one for the ground. We connect one terminal of our sensor to the analog input of our microcontroller which is pin A2. Then a resistor directed to the ground terminal.
We have two outputs at the output side of our microcontroller which are led diode and a resistor connected to the base of the transistor. For this tutorial I will use pin 12 & 13 as the output pins. So now, we connect the pin 12 to led diode and pin 13 to the resistor.
The resistor at pin 13 is then connected to the base terminal of the transistor to form an amplifier circuit. While the pin 12 which a resistor is connected in series with the led diode. Then we connect the battery, resistor, speaker and relay in series.
The amplified output of the transistor at the collector terminal is then fed to the input of the relay.
Here is the final circuit diagram for this tutorial.
When the stretch sensor is being pulled or stretched out, it will activate the arduino uno. An input signal will flow through the pin 2 of the arduino uno.
While the microcontroller is programmed to give output in pin 12 & 13. This output signal is then fed to led pin and base resistor of the transistor. The signal at the base resistor will be amplified as it flow through the amplifier circuit.
The amplified signal is then fed to the relay input. This will trigger the relay and will switch the battery to supply the external series circuit composed of the buzzer and a resistor.
The current will now flow through the circuit allowing the speaker to alarm.
Part II. Code
Now let us do programming of our Arduino uno.
Click on code to start.
We declare the input and output pins for our microcontroller. Pin 2 is the input pin and pin 12 & 13 as output pin.
int stretchPin = 2;
int ledPin = 12;
int resPin = 13;
int stretchValue = 0; //initial value of stretch sensor
void setup() {
// initialize the resistor & led pin as an output:
pinMode(resPin, OUTPUT);
pinMode(ledPin, OUTPUT);
// initialize the sensor pin as an input:
pinMode(stretchPin, INPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// read the input on analog pin 0:
int stretchValue = analogRead(A2);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
if (stretchValue == 5) {
// give output on resistor & led pin
digitalWrite(resPin, HIGH);
digitalWrite(ledPin, HIGH);
}
else {
// no output at resistor & led pin
digitalWrite(resPin, LOW);
digitalWrite(ledPin, LOW);
delay(100);
// print out the value you read:
Serial.println(voltage);
} }
Here are the arduino codes.
int stretchPin = 2;
int ledPin = 12;
int resPin = 13;
int stretchValue = 0;
void setup() {
pinMode(resPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(stretchPin, INPUT);
Serial.begin(9600);
}
void loop() {
int stretchValue = analogRead(A2);
float voltage = sensorValue * (5.0 / 1023.0);
if (stretchValue == 5) {
digitalWrite(resPin, HIGH);
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(resPin, LOW);
digitalWrite(ledPin, LOW);
delay(100);
Serial.println(voltage);
}
}
Part III. Breadboard
Click on the breadboard.
Arrange each component in the breadboard before connecting.
Now connect each component if you don’t know how to connect using breadboard just read my previous tutorial about how to construct a circuit in the breadboard
Application
The readers can create their own anti-theft automatic buzzer alarm using a stretch sensor.
Like the example below.
Curriculum
Here are my other tutorials for electronic projects.
ELECTRONIC PROJECTS
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
thanks @roj
Hey @rfece143 I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x