ECE 420 Arduino Functions and Command Structures READ THE INSTRUCTIONS: this is intended to be a demo of some of the skills youve acquired so far working with parts of code from the examples do each step as outlined starting from a new sketch in the Arduino IDE ECE 420 Individual Assignment 1
Arduino Functions and Command Structures
Due: Friday March 8th (11:59PM)
INSTRUCTIONS:
READ THE INSTRUCTIONS: this is intended to be a demo of some of the skills youve acquired so far
working with parts of code from the examples do each step as outlined starting from a new sketch in
the Arduino IDE.
This assignment will be submitted via Canvas:
Please include the requested information as a SINGLE (.DOC) file
Add a complete copy of your code (copy paste) from the Arduino IDE [screen shots will not be
accepted] If you are having trouble with copying from the IDE you can save and open the sketch as an
*.INO and open it using Notepad++ or another text editor. (This file is formatted plain text).
Answers to any questions asked at the end of the exercise.
— Don’t panic! -ASSIGNMENT 1:
Generate a single Arduino code sketch*which accomplishes the tasks listed below:
1) Declare a Global boolean value with a name of your choice (for use in conditional in function A)
2) Declare an integer number* (for use in calculations function C)
*Use the last three numbers of your student id declare the value as a constant
3) Declare FIVE pins, FOUR DIGITAL and ONE ANALOG, use any names you want,
*try using good coding practices like underscores_to_separate_words (typically for variables) or
camelCaseForNames (typically for functions)
A) Select DIGITAL pins from first bank – pins 0 – 12, do not use the built in LED on pin 13.
b) You can select any ANALOG pin from A0-A15.
4) In the SETUP declare the pin modes of the DIGITAL pins one as input, the others as output
5) READ the ANALOG and DIGITAL (input) values at the start of each loop() you need to declare
a variable to store the values in be sure to watch out where you declare those variables to
insure the right access for the scope.
6) Create 3 functions which match the following types:
A) Simple if /else decision statement
(Compare value, of the ANALOG pin to some int value threshold)
This function should set the DIGITAL (output) pin to either HIGH or LOW based on the
value of your ANALOG input. (Attaching an LED to that pin will allow you to see the
current state of the decision criteria)
{ex. Set the int value [threshold] to 1000 Analog input is 3.3v value read in is 1023 which is >
1000 so the value is True}
Also: Set (change the value of) the GLOBAL BOOLEAN variable you made in step 1 to
(TRUE) in the case of a value above the threshold, and (FALSE) in all other cases (else).
B) A switch / case statement
1) Using one BIT from the DIGITAL (input) pin, and the Boolean you set from the ANALOG pin in
function A, create a switch structure with 4 conditional cases:
Digital State
Boolean State
1
1
0
1
1
0
0
0
2) Each case should set should set (assign the value of) TWO DIGITAL pins HIGH or LOW based
on the values of the DIGITAL pin (5) and the bool in function (A) based on the value threshold.
You should print a unique string to the host computer via the
SERIAL console to indicate the case selected by each binary state.
C) Build a function that TAKES as an argument, the current ANALOG value and RETURNS the
result of TWO sequential [the result of one operation is the input of the second] arithmetic
operations. Use the constant student id you declared in (2) as an input to at least one of your
operations. You may use the MATH built in functions, but they must be called inside your user
defined function.
Your function should also print the results of the sequential operations to the host
computer via the SERIAL console as a new line.
Purchase answer to see full
attachment
PSYC290N - Lifespan Development REFLECTION ASSIGNMENT Required ResourcesRead/review the following resources for this activity: Textbook:…
Unit VI Case Study Weight: 10% of course grade Grading Rubric Instructions Most would agree that…
Read the assigned article and answer the following questions. Be thorough and accurate in your responses. Create…
Please read the book The Little Prince by Antoine de Saint-Exupéry and make a book…
PlEASE ANSWER THE TWO PARTS IN TWO SEPARATE FILES. ITS TWO PARTS TO THIS QUESTION.…
PSYC290N - Lifespan Development Required ResourcesRead/review the following resources for this activity: Lesson Minimum of…