Electronic Project 22: Automatic Sound Alarm when part of an object is being stretched using textile stretch sensor

in #utopian-io7 years ago (edited)

image.png

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.

image.png

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.

image.png

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.

image.png

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.

image.png

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.

image.png

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.

image.png

The amplified output of the transistor at the collector terminal is then fed to the input of the relay.

image.png

Here is the final circuit diagram for this tutorial.

image.png

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.

image.png

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.

image.png

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.

image.png

The current will now flow through the circuit allowing the speaker to alarm.

image.png

Part II. Code

Now let us do programming of our Arduino uno.
Click on code to start.

image.png

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;

image.png

int stretchValue = 0;  //initial value of stretch sensor

image.png

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);
}

image.png

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);
} }

image.png

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.

image.png

Arrange each component in the breadboard before connecting.

image.png

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

image.png

Application

The readers can create their own anti-theft automatic buzzer alarm using a stretch sensor.
Like the example below.

link source

Curriculum

Here are my other tutorials for electronic projects.

ELECTRONIC PROJECTS

Tutorial 1

Tutorial 2

Tutorial 3

Tutorial 4

Tutorial 5

Tutorial 6

Tutorial 7

Tutorial 8

Tutorial 9

Tutorial 10

Tutorial 11

Tutorial 12

Tutorial 13

Tutorial 14

Tutorial 15

Tutorial 16

Tutorial 17

Tutorial 18

Tutorial 19

Tutorial 20

Tutorial 21



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @rfece143 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

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