Description
Use any combination of input and output transducers to create
a design where input and output coincide. For this laboratory, I designed a system that would react to
pressure on the FSR. When pressure is
applied to the FSR, the signal is sent to the piezo buzzer and the LED and
results in the sounding of the piezo buzzer and lighting of the LED. This system/device is useful as an alarm system
wherever a person needs to be updated of a new situation, for instance as a
doormat to alert the host of guests arriving at an event.
Components
Arduino board
Blue LED
Breadboard
One 220-ohm resistor
One 10-ohm resistor
1 FSR
1 Piezo Buzzer
Arduino Code
int ledPin = 13; // LED connected to digital pin
13
int sensorPin = 0; //
select the input pin for the sensor
int speakerPin = 7;
int val = 0;
int FSRPin = 0; // select
the input pin for the FSR
void setup()
a // run once, when the sketch starts
{
beginSerial(9600);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(speakerPin, OUTPUT);
Serial.println("ready");
}
void loop() // run over and over again
{
val = analogRead(FSRPin); // read value from the FSR
digitalWrite(ledPin,
HIGH); // sets the LED on
for( int i=0; i<500;
i++ ) { // play it for 50 cycles
digitalWrite(speakerPin,
HIGH);
delayMicroseconds(val);
digitalWrite(speakerPin,
LOW);
delayMicroseconds(val);
}
}