This is a combination of multiple choice, short answer, and a programming exerci
ID: 3828189 • Letter: T
Question
This is a combination of multiple choice, short answer, and a programming exercise.
- How many analog ports are on your Arduino RedBoard? How are they numbered?
- How many digital ports are on your Arduino RedBoard? How are they numbered?
- Can an analog pin on your board act as both input and output?
- Can a digital pin on your board act as both input and output?
- What does the reset button on your board do?
- What is the purpose of the Arduino’s setup() function?
- What is the purpose of the Arduino’s loop() function?
- List three input components that can be connected to your RedBoard:
- List three output components that can be connected to your RedBoard:
- What is the name of the Arduino function used to set a pin’s mode to either input or output? Give an example that sets pin 11 to output mode.
- What is the purpose of the Arduino’s analogRead() function?
- What is the purpose of the Arduino’s digitalWrite() function?
- What are the two ways to create program comments in C/C++?
- Review the use of if/else if/else statements in C/C++.
- What are the three logical operators in C/C++?
- Review the use of loop structures in C/C++.
- Review creating your own functions. You will be asked to write the code for a function.
Explanation / Answer
Ans:
1)there are 6 analog ports are there in Arduino labelled from(A0-A5).
2)there are 14 Digital ports in the Adruino labelled from(0-13)
3)Yes,all analog pins can be used as input and output.
4)Also all digital pins can be used as input and output.
5)Reset button unplugs the board and then plugs in.i.e resets the board.(ONOff)
6)Setup() function is used to initialise and set the variables,pin modes etc.
7)Loop() function is used mainly to control the board,as the name suggests it loops consecutively and changes are made as per program.
8)three output components that can be connected to Arduino are:Leds,Sensors,Crystal oscillators
9)Setup () function is used to set pins mode:
int pin=11;
void setup()
{
pinMode(pin,OUTPUT);
}
10)Purpose of analogRead() function is to read from the specified analog pin.
11)digitalWrite() will enable (HIGH) or disable(LOW) the internal setup of the input pin.
12)Two ways to create program comments in c++:
a)// single line comment
b)/*......................*/ multiline comment
13)#include<iostream.h>//C++ codes
void main() //example of if/elseif/else
{
int a=6,b=5,c=8; //printing greatest among 3
if((a>b)&&(a>c))
cout<<"a greatest";
elseif((b>a)&&(b>c))
cout<<"b greatest";
else
cout<<"c greatest";
}
14)Three logical operators in C/C++:
a)logical AND(&&)
b)logical OR(||)
c)logical NOT(!)
15)#include<iostream.h>
void main()//example of a loop structure.C++ codes
{
int a[5];
for(int i=0;i<5;i++)
{
cin>>a[i];
}
for(int j=0;j<5;j++)
{
cout<<a[j];
}
}
16)//showing a function example
#include<iostream.h>
void myfun(int);//function prototype.
void main()
{
int a=5;
myfun(a);//function calling
}
void myfun(int x)//function definition
{
cout<<x;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.