final exam (1)

.docx

School

St. John's University *

*We aren’t endorsed by this school

Course

3114

Subject

Mechanical Engineering

Date

Dec 6, 2023

Type

docx

Pages

2

Uploaded by GeneralMandrillPerson723

Mechatronics Spring 2020 Final Exam Question 1: (20 points) Write code using codeblocks to do the following: Ask the user for and store three integers between 0 and 255 inclusive. Output the ASCII character representation for each in a formatted sentence example: The first number 65 represents the character A. Output the three values in binary example: The first number 65 is represented in binary as 01000001. The program should work for any inputs in the specified range. Comment every line in your program using // and submit the commented code Question 2: (20 points) Write a program, using codeblock, as follows. -The program asks the user for the unit type of temperature input: C for Celsius, F for Fahrenheit, or K for Kelvin. (both upper and lower case should work) - The user then is prompted to enter the temperature that should be stored in a float type variable. - The program then outputs the temperature for all three scales for any input type. Example : if the input temperature is Fahrenheit then the program outputs the corresponding temperature in Celsius, Fahrenheit, and Kelvin. - Ask the user if any other conversions are needed, if y for yes, keep repeating the whole process, and if n for no then end the program. K = C + 273.15 C = K – 273.15 F = C * (9/5) + 32 C = (F – 32) * 5/9 Output with precision of 2. Comment every line in your program using // and submit the commented code
Question 3: (30 points) Deign a system that controls heating and cooling of a temperature-controlled room using a TMP36 temperature sensor, two LEDs, and two relays. Relay one turns the cooling system on and relay two turns the heating system on. The room temperature should be kept between 18 degrees Celsius and 22 degrees Celsius. If the temperature sensor registers a temperature lower than 18 then the heating circuit is turned on, the red LED comes on, and stays on till the temperature reaches 20, then both are turned off. If the temperature sensor registers a temperature higher than 22 then the cooling circuit is turned on, the green LED comes on, and stays on till the temperature reaches 20, then both are turned off. Assume power input to heating and cooling to be 120 v. Submit the circuit design neat and well labeled. Submit the code, well documented. Question 4: (30 points) Design a system that controls the opening and closing of an access gate for a parking lot. The gate has two ultrasound sensors and a stepper motor. Ultrasound one detects the approaching car so if it reads a distance less than one meter then a car is waiting to enter. If a car is waiting to enter then the stepper motor will open the gate by running clockwise for 6.5 turns (use the number of steps per turn from the stepper lab). The program should wait for 20 seconds after the gate is open and then check if the second ultrasound has an object that is closer than one meter, if yes then wait another 20 second and check, until ultrasound two is clear then lower the gate by running the stepper motor counter clockwise 6.5 turns. (hint: you can use millis()) Do not use stepper.h Submit the circuit design neat and well labeled. Submit the code, well documented.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help