Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Led #1 is 1 Hi-Z 0 Basic C code l/O Functionality rev 2 Name Purpose: The purpos

ID: 3349553 • Letter: L

Question

Led #1 is 1 Hi-Z 0 Basic C code l/O Functionality rev 2 Name Purpose: The purpose of this laboratory exercise is to examine the basic functionality of the Arduino microcontroller board and learning how to setup 3 port pins to drive 6 LEDs through combinations of ones and zeroes while setting others as inputs to drive one LED at a time. You will be using the C code for the first time Background In the Arduino text book read "Programming Digital Outputs" on page 24. Also review "Reading Digital Inputs" Page 29-31. Also read about Digital VO instructions in the Arduino Notebook located in Content in BB. There is also a reference document in the Arduino under Help-reference Introduction: Setup the following arrangement of LEDs on a breadboard It is recommended to test them using a power supply before connecting them to your Arduino For instance if you connect 5V to 101 and Ground to 103 LED1 should go on. This is the equivalent of outputting a 1 to 101 and a zero to 103 while 1O2 is open If you reverse those connections LED6 will go on. This is the equivalent of outputting a 0 on IO1 and a 1 on 103 while IO2 is open From these examples the other LEDs can be figured out in a similar fashion Since we will have 3 pins connected, the unused pin will need to be setup as a high impedance to simulate an 'open' line. Setting it up as an input with the appropriate DDR register wil do this

Explanation / Answer

IO1 is at Digital pin 3

IO2 at Digital pin 4

IO3 at Digital pin 5

CODE;


void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
pinMode(3, OUTPUT); //its pin IO1
pinMode(4, INPUT); // Pin io2 set to high impedence
pinMode(5, OUTPUT); //pin IO3
digitalWrite(3, HIGH); //IO1 set high to turn on LED1
digitalWrite(5, LOW); //IO3 set as ground to turn on LED1
delay(500);

//turn ON LED 2
pinMode(3, OUTPUT); //its pin IO1
pinMode(4, OUTPUT); // Pin io2
pinMode(5, INPUT); //pin IO3
digitalWrite(3, LOW); //IO1 set as ground to turn on LED2
digitalWrite(5, HIGH); //IO3 set as HIGH to turn on LED2
delay(500);

//Turn on LED3
pinMode(3, OUTPUT); //its pin IO1
pinMode(4, OUTPUT); // Pin io2
pinMode(5, INPUT); //pin IO3
digitalWrite(3, HIGH); //IO1 set high to turn on LED3
digitalWrite(4, LOW); //IO2 set as ground to turn on LED3
delay(500);

//Turn on LED4
pinMode(4, OUTPUT); //its pin IO2
pinMode(3, INPUT); // Pin io1 set to high impedence
pinMode(5, OUTPUT); //pin IO3
digitalWrite(4, HIGH); //IO1 set high to turn on LED4
digitalWrite(5, LOW); //IO3 set as ground to turn on LED4
delay(500);

//Turn on LED5
pinMode(4, OUTPUT); //its pin IO2
pinMode(3, INPUT); // Pin io1 set to high impedence
pinMode(5, OUTPUT); //pin IO3
digitalWrite(3, HIGH); //IO3 set high to turn on LED5
digitalWrite(4, LOW); //IO2 set as ground to turn on LED5
delay(500);

//Turn on led6
pinMode(3, OUTPUT); //its pin IO1
pinMode(4, INPUT); // Pin io2 set to high impedence
pinMode(5, OUTPUT); //pin IO3
digitalWrite(5, HIGH); //IO3 set high to turn on LED6
digitalWrite(3, LOW); //IO1 set as ground to turn on LED6
delay(500);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote