Design a hardware-software system with the following specification: The system i
ID: 2249387 • Letter: D
Question
Design a hardware-software system with the following specification: The system is going to measure a targets distance approaching the system (utilizing ultra sound transducer). The system continuously measures and display the distance on a LCD. As the target enters a predetermined distance the system. Is going to generate a hardware interrupt and is going to activate a buzzer. When the target further draws nearer the alarm is enhanced by an additional device being activated. design has to be structured and the inter-functional The schematic is part of the project. The software communication has to use pointers.
Explanation / Answer
#include <LiquidCrystal.h>
const int rs = A0, en = A1, d4 = A2, d5 = A3, d6 = A4, d7 = A5; // Analog pins used for LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
unsigned long echo = 0;
int signalpin = 9; // Ultrasound signal pin
unsigned long signalvalue = 0;
void setup()
{
lcd.begin(16, 2);
Serial.begin(115200);
pinMode(signalpin,OUTPUT);
}
unsigned long ping()
{
pinMode(signalpin, OUTPUT);
digitalWrite(signalpin, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(signalpin, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(signalpin, LOW); // Holdoff
pinMode(signalpin, INPUT); // Switch signalpin to input
digitalWrite(signalpin, HIGH); // Turn on pullup resistor
// echo = pulseIn(signalpin, HIGH, 38000)
echo = pulseIn(signalpin, HIGH); //Listen for echo
signalvalue = (echo / 58.138) * .39; //convert to CM then to inches
return signalvalue;
}
void loop()
{
int x = 0;
x = ping();
Serial.println(x);
lcd.setCursor(0, 1);
lcd.print(x);
if(x == 18 ) //predetermined disstance
{
//Buzzer On
if(x>10 || x<18 )
{
//Turn On Alarm
}
}
delay(250); //delay 1/4 seconds.
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.