Problem #3 (6 points) Consider a circuit with a potentiometer connected as a vol
ID: 2268297 • Letter: P
Question
Problem #3 (6 points) Consider a circuit with a potentiometer connected as a voltage divider (as in the video lecture) to pin A2 of your Arduino. You do not have to build the physical circuit (although you are encouraged to) Describe what is (would be) displayed on the screen as you rotate the potentiometer (e.g. color, shape, size) provided the following Arduino and Processing codes Arduing void setup) [ Serial.begin (9600) void loop) t Serial.println (analogRead (2)); delay (100) Processing import processing.serial.*, Serial myPort; int circleSize; void setup) myPort new Serial (this, Serial.list ) [0], 9600); myPort.clear ); size (250,250); background (0,0,255); fill (255,0,0); stroke (0,0,0); void draw ) [ while (myPort.available) > 0) [ String serialInput = myPort.readStringUntil (' '); if (serial!nput != null) { background (0, 0,255); serlal1nput = trim (serial!nput) ; circleSize- int (serialInput); ellipse (125,125,circleSize/10,circleSize/10);Explanation / Answer
When This program will execute it will do following task
1. Read serial analog data from potentiometer
2. Convert data in equivalent value
3. set background 250X250 in "blue color" . As backgroun is (0,0,255) == (R,G,B)
4. Determine length of Major axis and Minor axis of "Ellipse" which is Circle/10
5. In this program Major axis = Minor axis as # ellipse(125,125, circle/10, cirlce/10) so shape will be "circle"
6. color of shape will be (red) as fill(255,0,0) = (R,G,B)
Ans: A Red Circle on Blue background , that will change size with change in potentiometer
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.