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 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...
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"
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...
write a code in python Write the following functions below based on their comments. Note Pass...
write a code in python Write the following functions below based on their comments. Note Pass is a key word you can use to have a function the does not do anything. You are only allowed to use what was discussed in the lectures, labs and assignments, and there is no need to import any libraries. #!/usr/bin/python3 #(1 Mark) This function will take in a string of digits and check to see if all the digits in the string are...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Find the first- and second-order partial derivatives for the following function. z = f (x, y)...
Find the first- and second-order partial derivatives for the following function. z = f (x, y) = (ex +1)ln y.
Write the equation of a rational function with the following characteristics: Vertical asymptotes at x =...
Write the equation of a rational function with the following characteristics: Vertical asymptotes at x = 3 and x = -4, a horizontal asymptote at y = 0, no x-intercepts and a y-intercept at (0, 1/6). Consider the polynomial q(x) = 3x2 - 11x2 + kx + 8. Given that q(x) has a factor (x - 4), find the value of k: Hence or otherwise, factorize q(x) as a product of linear factors.
Jen’s utility function is U (X, Y ) = (X + 2)(Y + 1), where X...
Jen’s utility function is U (X, Y ) = (X + 2)(Y + 1), where X is her consumption of good X and Y is her consumption of good Y . a. Write an equation for Jen’s indifference curve that goes through the point (X, Y ) = (2, 8). On the axes below, sketch Jen’s indifference curve for U = 36 b. Suppose that the price of each good is 1 and that Jen has an income of 11....
Find (if they exist) the largest and smallest value of the function f (x, y, z)...
Find (if they exist) the largest and smallest value of the function f (x, y, z) = x + 2y + 4z on the set X with the equation x 2 + y 2 + z 2 = 1 (this is the surface of the sphere with a radius of 1 and a center in (0,0,0)).