Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Final Pseudo Code: (Please follow the Final Project instructions to install and verify each component is working properly before trying to write a large program

Final Pseudo Code: (Please follow the Final Project instructions to install and verify each component is working properly before trying to write a large program to get all components to work together.) (Repeat the following steps every time you compile from a new PC.) (Download the LCD12864RSPI.zip library from Moodle to the Windows desktop. Open Arduino IDE. Go to Sketch -> Include Library -> Add .zip Library. Select the IRremote.zip file from the desktop and press open.) (Include the following libraries; reference Chapter 2 lecture slide #2) Include the LCD12864RSPI.h library. (Declare the following constant global variables, reference Chapter 13 lecture slides #6. Reference Storage Classes and Scope from C Chapter 5 lecture slides #25 - #33.) Declare a constant integer variable for the pin number of the AUTO button pin, and set the value to 2. Declare a constant integer variable for the pin number of the increase intensity button pin, and set the value to 4. Declare a constant integer variable for the pin number of the decrease intensity button pin, and set the value to 5. Declare a constant integer variable for the pin number of the MAX A/C button pin, and set the value to 6. Declare a constant integer variable for the pin number of the air distribution button pin, and set the value to 7. Declare a constant integer variable for the pin number of the AUTO MODE LED pin, and set the value to 10. Declare a constant integer variable for the pin number of the MAX A/C MODE LED pin, and set the value to 11. Declare a constant integer variable for the pin number of the cooling LED pin, and set the value to 12. Declare a constant integer variable for the pin number of the heating LED pin, and set the value to 13. Declare a constant integer variable for the pin number of the temperature sensor pin, and set the value to A0. Declare a constant integer variable for the pin number of the potentiometer pin, and set the value to A1. (The following global variables are used to track the temperature and settings.) Declare an integer variable to store the desired temperature value, and set the value to 65. Declare an integer variable to store the old desired temperature value, and set the value to 65. Declare an integer variable to store the manually adjusted intensity level, and set the value to 2. Declare an integer variable to store the automatically adjusted intensity level, and set the value to 3. Declare an integer variable to store the climate control mode, and set the value to 1. (1: manual mode, 2: AUTO mode, 3: MAX A/C) Declare an integer variable to store the air distribution direction, and set the value to 1. (1: head, 2: head and upper body, 3: upper body, 4: upper body and lower body 5: lower body, 6: head and lower body 7: head, upper body, and lower body) Declare an integer variable to store the temperature in Fahrenheit, and set the value to 65. (Reference the character data type and size from the SainSmart UNO Starter Kits Tutorials, Chapter 2: Blink) (Reference the C Chapter 6 lecture slides 2-4,6-8,11-16 to declare the following arrays of 16 characters.) Declare an array of 16 characters for manual mode line 0 and initialize the character array to the following space characters and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line0 o ? (Use decimal values to replace Special Characters, for example o is 9, ? is 15, and ? is 4.) Declare an array of 16 characters for manual mode line 1 and initialize the character array to the following space, number, and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line1 6 5 . 0 ? ? Declare an array of 16 characters for manual mode line 2 and initialize the character array to the following space characters and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line2 Declare an array of 16 characters for manual mode line 3 and initialize the character array to the following space characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line3 Declare an array of 16 characters for MAX A/C mode line 1 and initialize the character array to the following space, number, and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line1 6 0 . 0 ? ? ? ? ? ? ? ? ? Declare an array of 16 characters for MAX A/C mode line 2 and initialize the character array to the following space characters and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line2 Declare an array of 16 characters for MAX A/C mode line 3 and initialize the character array to the following space characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line3 Declare an array of 16 characters for AUTO mode line 0 and initialize the character array to the following characters and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line0 o A U T O Declare an array of 16 characters for AUTO mode line 1 and initialize the character array to the following space, number, and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line1 6 5 . 0 ? Declare an array of 16 characters for AUTO mode line 2 and initialize the character array to the following space characters and special characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line2 Declare an array of 16 characters for AUTO mode line 3 and initialize the character array to the following space characters: Char 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Line3 (The setup function runs once when you press reset.) void setup() { (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 3: Hello World!) Open serial port, sets data rate to 9600 bps. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Set the variable for the pin number of the AUTO mode button pin to INPUT mode. Set the variable for the pin number of the increase intensity button pin to INTPUT mode. Set the variable for the pin number of the decrease intensity button pin to INPUT mode. Set the variable for the pin number of the MAX A/C button pin to INPUT mode. Set the variable for the pin number of the air distribution button pin to INPUT mode. Set the variable for the pin number of the AUTO mode LED pin to OUTPUT mode. Set the variable for the pin number of the MAX A/C mode LED pin to OUTPUT mode. Set the variable for the pin number of the cooling LED pin to OUTPUT mode. Set the variable for the pin number of the heating LED pin to OUTPUT mode. Write HIGH to digital pin number connected to the AUTO mode button pin. (The value reads 1 when the button is not pressed.) Write HIGH to digital pin number connected to the increase intensity button pin. Write HIGH to digital pin number connected to the decrease intensity button pin. Write HIGH to digital pin number connected to the MAX A/C button pin. Write HIGH to digital pin number connected to the air distribution button pin. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Initialize function to initialize the LCD screen. Call the LCD CLEAR function to clear the LCD screen. Call the LCD Display String function and provide line 0, character 0, the manual mode line 0 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 1, character 0, the manual mode line 1 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 2, character 0, the manual mode line 2 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 3, character 0, the manual mode line 3 character array, and 16 characters as the function inputs. Use the Arduino built-in function to delay the program for 2 seconds. } (The loop function runs over and over again forever.) void loop() { Declare a local integer variable for storing the potentiometer value. Declare a local integer variable for storing the AUTO mode button value. Declare a local integer variable for storing the increase intensity button value. Declare a local integer variable for storing the decrease intensity button value. Declare a local integer variable for storing the air distribution button value. Declare a local integer variable for storing the MAX A/C mode button value. Declare a local integer variable for storing the temperature sensor value. Declare a local float variable for storing the millivolts value. Declare a local float variable for storing the Celsius value. (Read the potentiometer only when we are not in the MAX A/C mode.) (Reference C Chapter 3 Lecture Slides for if..else syntax in c.) If the value of the variable that tracks the climate control mode is not equivalent with 3 { (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 10: Potentiometer.) Use the Arduino built-in function to read analog pin value from the pin number of the potentiometer and save the value in the variable that stores the potentiometer value. Set the desired temperature value to (the potentiometer value / 34) + 60. If the old desired temperature value is not equivalent with the current desired temperature value { (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defined function to update temperature on the LCD. Set the old desired temperature value to the current desire temperature value. } } (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 12: LM35 Temperature Sensor.) Use the Arduino built-in function to read analog pin value from the pin number of the temperature sensor and save the value in the variable that stores the temperature sensor value. Set the millivolts value to (the temperature sensor value /1024.0)*5000. Set the Celsius value to the millivolts value / 10. Set the temperature in Fahrenheit variable value to (Celsius value*9)/5+32. If the temperature in Fahrenheit is greater than the desired temperature { (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Write HIGH to the digital pin number of the cooling LED light. Write LOW to the digital pin number of the heating LED light. } If the temperature in Fahrenheit is less than the desired temperature { (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Write LOW to the digital pin number of the cooling LED light. Write HIGH to the digital pin number of the heating LED light. } (Reference the Arduino IDE built-in program from File -> Examples -> Digital -> Button.) Read from digital pin number connected to the increase intensity button pin, and save the value in the local variable that stores the increase intensity button value. (Reference C Chapter 3 Lecture Slides for if syntax in c.) If the increase intensity button value is equivalent with 0. (The button is pressed.) { If the climate control mode is equivalent to 1 AND the manually adjusted intensity level value is less than 9 { Increase the manually adjusted intensity level by 1. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to update the manually adjusted intensity on the LCD. } Else if the climate control mode is equivalent to 2 AND the automatic intensity level is less than 5 { Increase the automatically adjusted intensity level by 1. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to update the automatic intensity on the LCD. } (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Delay for 250 ms. } (Reference the Arduino IDE built-in program from File -> Examples -> Digital -> Button.) Read from digital pin number connected to the decrease intensity button pin, and save the value in the local variable that stores the decrease intensity button value. (Reference C Chapter 3 Lecture Slides for if syntax in c.) If the decrease intensity button value is equivalent with 0. (The button is pressed.) { If the climate control mode is equivalent to 1 AND the manually adjusted intensity level value is larger than 0 { Decrease the manually adjusted intensity level by 1. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to update the manually adjusted intensity on the LCD. } Else if the climate control mode is equivalent to 2 AND the automatic intensity level is greater than 1 { Decrease the automatic intensity level by 1. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to update the automatic intensity on the LCD. } (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Delay for 250 ms. } (Reference the Arduino IDE built-in program from File -> Examples -> Digital -> Button.) Read from digital pin number connected to the air distribution button pin, and save the value in the local variable that stores the air distribution button value. (Reference C Chapter 3 Lecture Slides for if syntax in c.) If the decrease intensity button value is equivalent with 0. (The button is pressed.) { If the climate control mode is not equivalent to 1 { Set the climate control mode to 1. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Write LOW to the digital pin number of the AUTO mode LED light. Write LOW to the digital pin number of the MAX A/C mode LED light. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to change the display to manual mode on the LCD. } Else (already in the manual control mode) { If the air distribution direction value is equivalent to 7 { Set the air distribution direction value to 1. } Else { Increment the air distribution direction value by 1. } (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defined function to update air distribution direction characters in the character arrays. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 1, character 0, the manual mode line 1 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 2, character 0, the manual mode line 2 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 3, character 0, the manual mode line 3 character array, and 16 characters as the function inputs. } (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Delay for 250 ms. } (Reference the Arduino IDE built-in program from File -> Examples -> Digital -> Button.) Read from digital pin number connected to the MAX A/C button pin, and save the value in the local variable that stores the MAX A/C button value. (Reference C Chapter 3 Lecture Slides for if syntax in c.) If the MAX A/C button value is equivalent with 0. (The button is pressed.) { Set the climate control mode to 3. Set the desired temperature value to 60. Set the old desired temperature value to 60. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Write LOW to the digital pin number of the AUTO mode LED light. Write HIGH to the digital pin number of the MAX A/C mode LED light. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 0, character 0, the manual mode line 0 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 1, character 0, the MAX A/C mode line 1 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 2, character 0, the MAX A/C mode line 2 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 3, character 0, the MAX A/C mode line 3 character array, and 16 characters as the function inputs. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Delay for 250 ms. } (Reference the Arduino IDE built-in program from File -> Examples -> Digital -> Button.) Read from digital pin number connected to the AUTO mode button pin, and save the value in the local variable that stores the AUTO mode button value. (Reference C Chapter 3 Lecture Slides for if syntax in c.) If the AUTO mode button value is equivalent with 0. (The button is pressed.) { Set the climate control mode to 2. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Write HIGH to the digital pin number of the AUTO mode LED light. Write LOW to the digital pin number of the MAX A/C mode LED light. (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defiend function to change the display to AUTO mode on the LCD. (Reference the SainSmart UNO Starter Kits Tutorials, Chapter 4: LED Blink.) Delay for 250 ms. } } // end of loop forever function (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) (User-defined function that will update the desired temperature set on the LCD.) Write a user-defined function to update the desired temperature set on the LCD. This function takes no input and produces no output. { (The desired temperature can be from 60 to 90. There are 2 digits.) Declare a local integer variable to be the first digit. Declare a local integer variable to be the second digit. Set the first digit to the desired temperature / 10. Set the second digit to the desired temperature % 10. If the value of the climate control mode is equivalent to 1 (manual mode) { (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Call the user-defined function that will convert one number digit to a character and provide the first digit as the function input, and save the function output to the manual mode line 1 character array index 0. Call the user-defined function that will convert one number digit to a character and provide the second digit as the function input, and save the function output to the manual mode line 1 character array index 1. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 1, character 0, the manual mode line 1 character array, and 16 characters as the function inputs. } Else if the value of the climate control mode is equivalent to 2 (auto mode) { (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Call the user-defined function that will convert one number digit to a character and provide the first digit as the function input, and save the function output to the AUTO mode line 1 character array index 0. Call the user-defined function that will convert one number digit to a character and provide the second digit as the function input, and save the function output to the AUTO mode line 1 character array index 1. Call the user-defined function that will compute the AUTO intensity. Call the user-defined function that will update the AUTO mode intensity to the LCD. } } (User-defined function that will convert one number digit to a character.) Write a user-defined function to convert one number digit to a character. This function takes an integer input, a one-digit number, and produces a character output. { Declare a local character variable to be the output. (Reference C Chapter 4 Lecture Slides for switch syntax in c.) Switch (based on the value of the one-digit number) { In case the one-digit number is 1: Set output to 1. Break to the end of the switch code block. In case the one-digit number is 2: Set output to 2. Break to the end of the switch code block. In case the one-digit number is 3: Set output to 3. Break to the end of the switch code block. In case the one-digit number is 4: Set output to 4. Break to the end of the switch code block. In case the one-digit number is 5: Set output to 5. Break to the end of the switch code block. In case the one-digit number is 6: Set output to 6. Break to the end of the switch code block. In case the one-digit number is 7: Set output to 7. Break to the end of the switch code block. In case the one-digit number is 8: Set output to 8. Break to the end of the switch code block. In case the one-digit number is 9: Set output to 9. Break to the end of the switch code block. In case the one-digit number is 0: Set output to 0. Break to the end of the switch code block. In the default case: Set output to X. Break to the end of the switch code block. } Return output to the calling program. } (User-defined function that will update the manually adjusted intensity on the LCD.) Write a user-defined function to update the manually adjusted intensity mark on the LCD. This function takes no input and produces no output. { Declare a local integer variable for storing the array index. (Reference C Chapter 4 Lecture Slides for the for loop syntax.) Write a for loop and start the loop with array index value 7; loop while the array index value is less than or equal to 15; increment the array index value by 1 after each loop { (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Set the character stored in the manual mode line 1 character array index variable to the space character ( ). } Write another for loop and start the loop with array index value 7; loop while the array index value is less than or equal to (7+the manual adjusted intensity value); increment the array index value by 1 after each loop { (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Set the character stored in the manual mode line 1 character array index variable to 4. } (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 1, character 0, the manual mode line 1 character array, and 16 characters as the function inputs. } (User-defined function that will update the air distribution mark in the manual mode character arrays.) Write a user-defined function to update the air distribution mark in the manual mode character arrays. This function takes no input and produces no output. { (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Set the character stored in the manual mode line 1 character array index 5 to the space character ( ). (head) Set the character stored in the manual mode line 2 character array index 5 to the space character ( ). (upper body) Set the character stored in the manual mode line 3 character array index 5 to the space character ( ). (lower body) (Reference C Chapter 4 Lecture Slides for switch syntax in c.) Switch (based on the global air distribution variable value) { In case the air distribution value is 1: Set the character stored in the manual mode line 1 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 2: Set the character stored in the manual mode line 1 character array index 5 to -. Set the character stored in the manual mode line 2 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 3: Set the character stored in the manual mode line 2 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 4: Set the character stored in the manual mode line 2 character array index 5 to -. Set the character stored in the manual mode line 3 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 5: Set the character stored in the manual mode line 3 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 6: Set the character stored in the manual mode line 1 character array index 5 to -. Set the character stored in the manual mode line 3 character array index 5 to -. Break to the end of the switch code block. In case the air distribution value is 7: Set the character stored in the manual mode line 1 character array index 5 to -. Set the character stored in the manual mode line 2 character array index 5 to -. Set the character stored in the manual mode line 3 character array index 5 to -. Break to the end of the switch code block. } } (User-defined function that will change the LCD display to show manual mode.) Write a user-defined function to change the LCD display to show manual mode. This function takes no input and produces no output. { (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defined function to update the air distribution mark in the manual mode character arrays. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 0, character 0, the manual mode line 0 character array, and 16 characters as the function inputs. Call the user-defined function to update the desired temperature set on the LCD. Call the user-defined function to update the manually adjusted intensity mark on the LCD. Call the LCD Display String function and provide line 2, character 0, the manual mode line 2 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 3, character 0, the manual mode line 3 character array, and 16 characters as the function inputs. } (User-defined function that will compute the auto intensity.) Write a user-defined function to compute the auto intensity value. This function takes no input and produces no output. { Declare a local integer variable for storing the temperature difference. Set the difference to the desired temperature the current temperature. (Reference C Chapter 4 Lecture Slides for the logical operators syntax.) If the difference is greater than or equal to -3 AND the difference is less than or equal to 3 { Set the global auto intensity value to 1. } If the difference is greater than or equal to -6 AND the difference is less than or equal to 6 { Set the global auto intensity value to 2. } If the difference is greater than or equal to -9 AND the difference is less than or equal to 9 { Set the global auto intensity value to 3. } If the difference is greater than or equal to -12 AND the difference is less than or equal to 12 { Set the global auto intensity value to 4. } Else { Set the global auto intensity value to 5. } } (User-defined function that will update the auto intensity on the LCD.) Write a user-defined function to update the auto intensity mark on the LCD. This function takes no input and produces no output. { Declare a local integer variable for storing the array index. (Reference C Chapter 4 Lecture Slides for the for loop syntax.) Write a for loop and start the loop with array index value 8; loop while the array index value is less than or equal to 12; increment the array index value by 1 after each loop { (Reference the C Chapter 6 lecture slides 2-4 for array variables.) Set the character stored in the AUTO mode line 1 character array index to the space character ( ). } Set the character stored in the AUTO mode line 1 character array index [7+the auto intensity value] to 4. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 1, character 0, the AUTO mode line 1 character array, and 16 characters as the function inputs. } (User-defined function that will change the LCD display to show AUTO mode.) Write a user-defined function to change the LCD display to show AUTO mode. This function takes no input and produces no output. { (Reference Chapter 5 lecture slides #7-#18 for the user-defined function syntax.) Call the user-defined function to compute the auto intensity value. (Reference the LCD test program from SainSmart website. A copy of the test program is also in the Questions and discussion forum.) Call the LCD Display String function and provide line 0, character 0, the AUTO mode line 0 character array, and 16 characters as the function inputs. Call the user-defined function to update the desired temperature set on the LCD. Call the user-defined function to update the auto intensity mark on the LCD. Call the LCD Display String function and provide line 2, character 0, the AUTO mode line 2 character array, and 16 characters as the function inputs. Call the LCD Display String function and provide line 3, character 0, the AUTO mode line 3 character array, and 16 characters as the function inputs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

=+1. What does healing mean to you now?

Answered: 1 week ago