ENGR351 Lab 2020 Fall
Lab 2
Name:
Nicolas Llarena
Email: Njllarenaarias@fortlewis.edu

1. Lab 2 - Arduino Basics

2. Introduction
The purpose of this lab is to get familiar with Arduino boards. We will learn the fundamentals of the board. the most basic concepts like FOR, WHILE, DO WHILE loops will be learned and applied in different problems. This will be the beginning in coding with arduino to create small projects.

3. Materials
Materials Quantity
Arduino UNO
1
10k Resistors
5
LED
5
Jumper Wires
6
Breadboard
1

4. Results

Task 1


In this task we repeated all the examples from sections 3,4, and 5 to practice with the arduino UNO and the serial monitor.


Figure 1. simple "test" string text sent to the serial monitor by using the setup.


Figure 2. Printing the same "test" string but using the loop function and ending it to prevent an infinite loop.


Figure 3. Printing "test" again, this time by assigning a variable to the string "test"


Figure 4. Having the arduino do a simple operation to show that it contains a CPU.


Figure 5.  Another example to prove simple operations are possible.


Figure 6. Testing some logical operations like AND, OR, and NOT.


Figure 7. changing boolean a to int a does not change the answer.


Figure 8. Testing the IF statement to prove that x==1.


Figure 9. Testing the FOR loop to print numbers from 1 to 9. To get numbers to 10 we could do i<11.


Figure 10. using FOR loop and IF statement together.


Figure 11. A WHILE loop will run until it meets a criteria.


Figure 12. The switch statement uses specific cases to run.


Figure 13. Fixing the double "now it's 6" with a "break" statement.


Task 2



Figure 14. Example using a do while loop that runs while x is less than 20. we add 4 to x after every iteration.

Task 3

In this task we printed the HEX number 0x1000 to decimal in the serial monitor. 1000 in HEX is 4096 in DEC.


Figure 15. Converting HEX to decimal.

Task 4

In this Task three different numbers were converted to HEX with the ARDUINO.


Figure 16. Numbers converted to hexadecimal by using the "HEX" command.

Task 5

In this task three numbers were converted from hexadecimal into binary by using the BIN command.


Figure 17. Hexadecimal to binary by using "BIN" command in ARDUINO.

Task 6

For this task bit masks were used to display a 5-bit binary number on five different LEDs on a breadboard. bits were stored in an array.


Figure 18. This displays a 5-bit binary number to 5 different LEDs. The for loops run until i <5 and mask>0. ( easier than making two for loops)





Discussion

This homework helped a lot to re-learn some things i had forgotten about arduino. Task 6 was a little bit challenging because I wanted to do everything inside one loop instead of two. Overall, this was an informative homework for the basics of arduino and logical operations using arduino.