Question

Write a sketch in Arduino with two functions; the first function-1 find the value “y” in...

Write a sketch in Arduino with two functions; the first function-1 find the value “y” in the equation: ? = ? − 30 . The value “x” is entered by keyboard. The second function-2 test whether the value “y” (calculated with the first function) is a negative number. If it is true, then the function call again function-1 with the value a new value x = x (old value) + 40. Otherwise print the message: “Finished”.

Print all results.

Homework Answers

Answer #1

ANS:

int x;
void setup() {
Serial.begin(9600);
delay(2000);

Serial.println("Type value of x ");
}

void loop() {
if(Serial.available()){
x = Serial.read();
}
}
int Function1(int x){
int y;
y = x-30;
Function2(y,x);

}
int Function2(int y,int x){
if (y < 0)
{
x=x+40;
Function1(x);
}
else
{Serial.print("finished");}


}

Screenshot of the code:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a C++ program to compute the value of x * (x + 1) + y...
Write a C++ program to compute the value of x * (x + 1) + y * y + z * (z - 1) where x, y, and z are 3 floating point numbers entered by the user. Requirements: • You should have a function get3numbers() that asks the user to enter 3 numbers. • You should have a function computeExp() that computes the value of the expression. • Your main function should call the above 2 functions and get...
Write the functions which are called in the main function given. YOU MAY ASSUME THAT THE...
Write the functions which are called in the main function given. YOU MAY ASSUME THAT THE USER ENTERS A VALID INTEGER. printDouble should accept one value and should print the value of that number times 2. printEndMessage should not accept any values and should print a message indicating that the program has finished. def main(): num1 = int(input("Please enter your number ")) printDouble(num1) printEndMessage() main()
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
##4. What will the following program display? ##def main(): ## x = 1 ## y =...
##4. What will the following program display? ##def main(): ## x = 1 ## y = 3.4 ## print(x, y) ## first printing ## change_us(x, y) ## print(x, y) ##second printing ## ##def change_us(a, b): ## a = 0 ## b = 0 ## print(a, b) ## ##main() ## ##Yes, yes, main() displays ##1 3.4 ##0 0 ##1 3.4 ## The question is: why x and y are still the same while the second printing of (x,y)? ## It seems...
In C++ 1) Write the function definition that has 1 pass by value integer parameter. The...
In C++ 1) Write the function definition that has 1 pass by value integer parameter. The function contains logic to return true if the parameter is even and false if it is not. 2 ) Write a main function that prompts the user for a value, calls the function that you created in step one with the value entered by the user, display "even" if the function return true and otherwise displays "odd"
You need to write a permute class that will take first and second strings to rearrange...
You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null. The permute class uses a Node class as link list node to link all letters arrangement. The...
For the function y = x 3 − 2x 2 − 1, use the first and...
For the function y = x 3 − 2x 2 − 1, use the first and second derivative tests to (a) determine the intervals of increase and decrease. (b) determine the local (relative) maxima and minima. (c) determine the intervals of concavity. (d) determine the points of inflection. (e) sketch the graph with the above information indicated on the graph.
1. Write a function called compute_discount which takes a float as the cost and a Boolean...
1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and pass...
1.Simplify the following functions using ONLY Boolean Algebra Laws and Theorems. For each resulting simplified function,...
1.Simplify the following functions using ONLY Boolean Algebra Laws and Theorems. For each resulting simplified function, sketch the logic circuit using logic gates. (30points) a.SimplifyF= (A+C+D)(B+C+D)(A+B+C) Hint:UseTheorem8 ,theorem 7 and distributive ̅̅b. Show that (Z + X)(Z +Y)(Y + X) = ? ? + ? ? ̅̅c. Show that (X +Y)Z + XYZ = ?.? (15 points for simplification and 15 points for Logisim diagrams) 2. Prove the below equation using Boolean Algebra Theorems and laws Write the name of...