Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing this code. prepare your Arduino code, follow these steps a.

ID: 1765959 • Letter: I

Question

I need help writing this code.

prepare your Arduino code, follow these steps a. Set the serial port speed to 115200 bits per second in the setup function. This serial speed is required by the VSA software, which will not work properly at lower speeds. If you want to observe r initial debugging, be sure to set the baud rate to your serial data in the Arduino serial monitor fo the same value in the serial monitor window In the loopO function, read the signal on the analog input pin connected to your nScope unit. Use Serial println0 to send each measured 10-bit value (0 to 1023) over the serial port to the VSA code running on your computer b. c. d. Add a delay so that you collect one data point from your analog input pin every 8t milliseconds, where 8t is determined based on the desired sampling frequency (through the relationship fs- 1000/Ot, where f is in units of [Hz] and t is in units of [ms]). Write your code so that f, s a variable you define in the code, from which ot is calculated. You will want to employ either delayO or delayMicrosecondsO, or use a timing function, millis0 or micros0, for this purpose. Using delayO is the easiest option, but will lead to poor resolution in your effective sampling rate. Using delayMicroseconds0 will yield much better resolution, but will only work for delay values lower than 16,383 s (see the Arduino reference guide for details), so this will not provide accurate results at lower values of fs. Using micros0 as a timing function i.e. with a time stamp together with a timing loop) will be the most accurate solution, but requires a bit more work.

Explanation / Answer

int analogPin = 3; // nscope unit(middle terminal) connected to analog pin 3 // outside leads to ground and +5V int val = 0; // variable to store the value read and it return in range 0 -1023 void setup() { Serial.begin(115200); // setup serial with baud rate 115200 (a) } void loop() { val = analogRead(analogPin); // read the input pin Serial.println(val); // debug value. delayMicroseconds(100); // delay in between reads for stability and higher resolution }