Question

In: Computer Science

The goal is to design a program that prints out "unlock" when a 3 knock pattern...

The goal is to design a program that prints out "unlock" when a 3 knock pattern is knocked on a sensor. this program will be ran on an arduino with a pizeo sensor.

Solutions

Expert Solution

Consider a pizeo transducer connected . It has to be connected to an Analog pin.

There happens to be 2 cases,

1. Any 3 knocks of any intensity.

2. 3 Knocks of predecided intensity each. like only (high high low) will open the door.

For both the cases, below program can be tweaked to get desired output. For case 1, make low intensity as minimum and high intensity as highest. For case 2 kindly decide low and high intensity.

Program:

const int pizSensor = A0;

const int Highestintensity = 300;  
const int LowestIntensity = 100;

const int LenofKnock = 4;

const int KnockPattern[ LenofKnock ] = {0, 0, 1};

int inppatterncounter = 0;
int sensorinpt = 0;

void setup() {

Serial.begin(9600);

}

void loop() {

sensorinpt = analogRead(pizSensor);

if (sensorinpt >= Highestintensity) {

if (KnockPattern[ inppatterncounter ] == 1) {

inppatterncounter++;

} else {

inppatterncounter = 0;

Serial.println("Restart Pattern");

}

delay(50);

} else if (sensorinpt >= Lowestintensity) {

if (KnockPattern[ inppatterncounter ] == 0) {

inppatterncounter++;

} else {

inppatterncounter = 0;

Serial.println("Restart Pattern");

}

delay(50);

if (inppatterncounter == (LenofKnock) ) {

Serial.println("Unlock");

delay(500);

inppatterncounter = 0;

}

}

Hope This Helps!


Related Solutions

C++ // Program Description: This program accepts three 3-letter words and prints out the reverse of...
C++ // Program Description: This program accepts three 3-letter words and prints out the reverse of each word A main(. . . ) function and the use of std::cin and std::cout to read in data and write out data as described below. Variables to hold the data read in using std::cin and a return statement. #include <iostream > int main(int argc, char *argv[]) { .... your code goes here }//main Example usage: >A01.exe Enter three 3-letter space separated words, then...
Design an experiment to knock out a certain gene of interest in the human genome. Outline...
Design an experiment to knock out a certain gene of interest in the human genome. Outline the experiment, explaining the methods you would use, and also indicate how you would verify your experiment was successful at each step.
You are out fishing, when you go to reach for the cooler, when you clumsily knock...
You are out fishing, when you go to reach for the cooler, when you clumsily knock it into the water. The cooler is in the shape of a cube with a side-length 0.2 meters. The cooler plus sandwiches inside weigh 6 pounds (26.7 N). a) How deep below the water's surface is the bottom of the cooler, assuming it floats stationary with the top and bottom level with the water's surface? b) When the cooler was just sitting on the...
Write a program which prompts the user for a positive integer, and then prints out the...
Write a program which prompts the user for a positive integer, and then prints out the prime factorization of their response. Do not import anything other than the Scanner. One way you might go about this using nested loops: Start a "factor" variable at 2 In a loop: repeatedly print the current factor, and divide the user input by it, until the user input is no longer divisible by the factor increment the factor This plan is by no stretch...
Write a program that asks the user for an integer and then prints out all its...
Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop.in c++
In Python write a program that calculates and prints out bills of the city water company....
In Python write a program that calculates and prints out bills of the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of r means residential use, a code of c means commercial use, and a code of i means industrial use. Any other code should be treated as an error. The water rates are computed as follows:Three types of customers and their billing rates: Code...
Use if statements to write a Java program that inputs a single letter and prints out...
Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way: 2 = ABC    3 = DEF   4 = GHI    5 = JKL 6 = MNO   7 = PRS   8 = TUV 9 = WXY No digit corresponds to either Q or Z. For these 2 letters your program should print a message indicating that they are not...
Write a C program that creates and prints out a linked list of strings. • Define...
Write a C program that creates and prints out a linked list of strings. • Define your link structure so that every node can store a string of up to 255 characters. • Implement the function insert_dictionary_order that receives a word (of type char*) and inserts is into the right position. • Implement the print_list function that prints the list. • In the main function, prompt the user to enter strings (strings are separated by white-spaces, such as space character,...
Write a C++ program that prints out all of the command line arguments passed to the...
Write a C++ program that prints out all of the command line arguments passed to the program. Each command line argument should be separated from the others with a comma and a space. If a command line argument ends in a comma, then another comma should NOT be added
Write a program that prints out all numbers, less than or equal to 10,000,000, that are...
Write a program that prints out all numbers, less than or equal to 10,000,000, that are evenly divisible by all numbers between 5 and 15 (inclusive). Do not use any libraries besides stdio.h. Need it in 10 minutes, please.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT