1) There are two functions that must be included in every Arduino program list t
ID: 2293258 • Letter: 1
Question
1) There are two functions that must be included in every Arduino program list them and explain what they do. Describe what the pinMode function is used for Write some code (at most five lines) that will: a) configure pin 5 as a digital input and pin 13 2) 3) as a digital output; b) read a value from pin 5; and c) write the value from pin 5 to pin 13 4) Write some code (at most five lines) that will: a) configure pin 9 as a PWM output; b) read a value from pin A0; c) write the value from pin A0 to pin 9. a. Hint: The values from the analogRead function are from 0 to 1023 while the analog Write command only accepts values from 0 to 255. Youll need to adjust the value before writing it to pin 9 5) Calculate the value of R1 in the following circuit (Vce-5 volts; forward voltage drop of diode 2 volts; recommended currents 20 milliamps) ED1 R1 GND 6) In a few sentences, describe clearly the principle behind how software-based button debouncing is achieved in Listing 2-5 of the textbookExplanation / Answer
1. Setup and loop are the two functions used. Setup is used to configure input and output modes of the pins. Loop is the main body of the program which defines the function being carried by the controller. Void is used as these functions doesn’t return values.
2. PinMode() is used to configure I/O pins on arduino as input, output modes.
3.
Int val = 0;
Void setup () {
PinMode (5, input);
PinMode (13, output);
}
Void loop (){
Val = digitalRead(5);
Digitalwrite(13, val);
}
4.
Int val = 0;
Void setup () {
PinMode (A0, input);
PinMode (9, output);
}
Void loop (){
val = analogRead(A0);
analogWrite(9, (val/4));
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.