Q 1 If An Int Array Is Defined By Int Num 4 3 6 12 15 Write A Sketch Over Tinkercad To Scan The Elements Of Th 1 (125.12 KiB) Viewed 72 times
Q 1 If An Int Array Is Defined By Int Num 4 3 6 12 15 Write A Sketch Over Tinkercad To Scan The Elements Of Th 2 (197.23 KiB) Viewed 72 times
Q.1) If an int array is defined by (int Num[4] = {3,6,12,15);), write a sketch over TinkerCAD to scan the elements of the array, at 2 seconds intervals between each element and the next, to decide if the element is odd or even. Scan for all elements shall be done only one time. - if the element is odd, print below over the Serial monitor: Num[index_value] = array_element_value is an odd number LED will not blink For example, the first array element will result Num[0] = 3 is an odd number LED will not blink - if the array element is even, make the LED connected to pin 13 blink three times, and print below over the Serial monitor: Num[index_value] = array_element_value is an even number LED will blink three times For example, the second array element will result Num[1] = 6 is an even number LED will blink three times Q.2) you have two float values, x = -60.009 & y = -90.01. Write a sketch to print the result of all below operations: 1. minimum of x and y. 2. maximum of x and y. 3. result of constraining x between -60 and 0. 4. Assign x to absolute value of x, and assign y to absolute value of y. X 5. cos(x) assuming x is represented in degrees. Use Arduino precalculated constant to convert into radians. 6. sin(y) assuming y is represented in degrees. Use Arduino precalculated constant to convert into radians. 7. Result of [x0.33858761 printed up to 6 decimal digits. Use one equation to calculate the whole
term in a single Serial.println sentence. i.e. Serial.println(put your equation here); 8. Floor result of 7 using one equation in a Serial.println sentence. Q.3) A Temperature sensor reads temperature values in the range (-10,50) with an accuracy error of +0.05 degree Celsius. Use random function with a floating seed to generate 10 float number that represents 10 possible readings of the sensor. Generated float numbers shall have no decimal digits (for example 1.00 or 15.00 or -3.00 and so on), then add to each randomly generated value an accuracy error, that is also randomly generated, in the range (-0.05 to +0.05). Include your code and a screenshot of the printed output. Below is an example of 10 randomly generated readings with the accuracy error added: 2.40 21.60 41.40 -10.50 48.50 35.10 19.20 23.90 26.80 35.30 Q.4) Examine below circuit plus developed sketch. Fill below LED/pins status timetable when you execute the sketch: 1 // HW 4__4 2 int pins[] = {0,1,2,3,4,5,6,7}; 3 int i; 4 byte LEDs = 183; 5 void setup() 6 1 Serial.begin(9600); Serial.println (LED, BIN); for(i=0; i<8;1++) 10 pinMode (pins, OUTPUT); digitalWrite(pins, bitRead (LEDs, 1)); } delay(5000); } void loop() 19 20 22 DIGITAL (PWM) bitclear (LEDS, 1); bitclear (LEDs, 4); bitWrite (LEDs, 7, 0); bitset (LEDs, 6); O UNO ARDUINO for(i=0;i<8; 1++) 23 24 25 20 27 28 29 digitalWrite(pins, bitRead (LEDs, i)); 1 1 Serial Monitor LED @ pin 5 LED @ pin 4 Pin 3 LED @ pin 2 Pin 1 Time (sec) 0-1 LED @ pin 7 ON Pin 7 HIGH Pin 6 LOW Pin 0 HIGH 1-2 2-3 3-4 4-5 5-6 6 to infinity
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!