Lab 12 - FL23 WL Microcontroller

pdf

School

Purdue University *

*We aren’t endorsed by this school

Course

177

Subject

Mechanical Engineering

Date

Dec 6, 2023

Type

pdf

Pages

7

Uploaded by DeaconTurtle993

Report
Print name (first last): ______________________ Lab partner (first last): ______________________ Course: ECET 17700 Lab date (mm/dd/yy): ______________________ Instructor: ______________________ Lab 12 Microcontroller Performance Checks 1. Check off 1 (IDE Configuration) 2. Check off 2 (Modified Blinker and ADC) 3. Check off 3 (Table 1,2) 4. Check off 4 (Table 3,4) 0. Prelab For the prelab, read the Arduino tutorial attached in Brightspace and then answer the questions in the Quiz. The quiz must be completed before your lab session to receive full prelab score. 1. Objectives The objective of this lab is to setup, configure and program using the Arduino 2560, identify and use digital IO ports and utilize the Arduino shield to perform experiments. 2. Approach and Results 1. IDE Configuration and the 'blinker' sketch In this procedure you will setup the Arduino platform. The platform consists of software known as Integrated Development Environment (IDE), hardware containing a microcontroller and supporting circuitry (Arduino Mega 2560 development board). The IDE communicates with the development board through a USB cable. The Arduino is programmed using programs known as 'sketches'. a. Start the Arduino IDE from the computer's start menu (Arduino 1.8.x). The screen shown in Figure 1 should appear.
ECET 17700 - 2 - Lab 12 Microcontroller Figure 1: Arduino IDE b. Connect your Arduino development board using USB communication to the PC. using your USB cable provided with the parts kit. c. Set the Arduino board type, Tools → Board → Arduino/Genuino Mega or Mega 2560, as illustrated in Figure 2.
ECET 17700 - 3 - Lab 12 Microcontroller Figure 2: Arduino IDE: Board Type Selection d. Using the same menu, set the proper COM port, Tools → Port → COM X (arduino/Genuino Mega or Mega 2560), as illustrated in Figure 3. Select the port with the Arduino Mega listed beside the COM port number. DO NOT USE COM 1! Figure 3: Arduino IDE: Port Selection e. Download "Onboard LED" sketch by clicking the download link below. Note: Chrome and Firefox browsers work best. Select 'Save as' and save the file to the location of your choice, I suggest your create a directy on you career account for this purpose. f. Open the downloaded sketch using the Arduino IDE, File → Open Browse to locate the downloaded sketch using the Open Diaglog Box. The file is located in Brightspace Labs Lab 12 Microcontroller OnboardLED.ino
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ECET 17700 - 4 - Lab 12 Microcontroller g. Compile and upload the sketch to the Arduino. This is accomplished using the highlighted right arrow shown in Figure 4. This button will both compile and upload the sketch to your development board. As soon as the upload is complete the sketch will begin execution. Observe the behavior of the small onboard LED next to pin 13 on the development board. Figure 4: Compiling and uploading an Arduino sketch Check off 1: Demonstrate the proper operation of the ‘blinker’ sketch to the lab instructor 2. Modification of the 'blinker' sketch a. Modify the sketch to "blink" the LED as follows: The LED is turned on for 1.5 seconds. Then turned off for 0.5 seconds b. Compile the sketch, upload it to the Arduino and run the program. Observe the behavior of the small onboard LED near pin 13 Check off 2: Demonstrate the proper operation of the modified ‘blinker’ sketch to the lab instructor. 3. Analog to Digital Converter and PWM a. In this procedure you will use one of the Analog input ports of the Arduino to read an incoming analog voltage and display its digital representation in the Arduino b. Place the provided potentiometer from your parts kit on the breadboard. Attach the wiper of the potentiometer to Pin A0 of the Arduino. Attach one of the remai ning potentiometer pins to GND and the other to 5V as indicated by the schematic in Figure 1. Look at your lecture notes to determine the pinout of the potentiometer. IMPORTANT: The +5 V and GND connections are made from the Arduino to the breadboard, NOT TO THE DC POWER SUPPLY!! Make sure to use the wires from your 140 piece wire kit, not the header jumper wires! Figure 5: Potentiometer Wiring c. Download and save the AnalogIN sketch by clicking on the link, compile and upload it your Arduino. d. Complete the following table by adjusting the potentiometer to the indicated voltage, using the DMM to measure the voltage from pin A0 to GND. At each position you will need to record the incoming digital
ECET 17700 - 5 - Lab 12 Microcontroller value (integer from 0 to 1023) and the mapped value (integer from 0 to 255) which is displayed on the serial monitor window of the IDE. The Serial Monitor is located in the top right corner of the Arduino IDE, it looks like an magnifying glass. The mapped values has converted the 10-bit value to an 8-bit value. Record your values in the following table. Table 1: Arduino Analog Input Measurements using Potentiometer Analog In (Vdc) Incoming Digital Value (0-1023) Mapped Digital Value (0-255) 0 1.25 2.50 3.75 5.00 4. Digital Output Measurements with the DMM a. In this procedure you will use the digital I/O pins of the Arduino to send outgoing digital data to each of the pins 0 – 13 b. Download, and Save the "DigitalOUT" sketch by clicking the download link below. Then Open, Compile and Upload it to your Arduino, in the same manner as you did with the sketch in Part 1. c. Note: Each of the 14 pins can be configured as an input or output. All of the pins are configured as outputs for this example. d. You will need two of the male-to-male computer jumper wires to perform the measurement. Using these wires connected to the DMM leads (Red lead to the digital pin, and the Black lead connect to GND on the Arduino) make your voltage measurement. Then record if that voltage measurement is a HIGH or LOW . e. The COM connection of t he DMM should be connected to the GND pin (through the stacking header) of the Arduino for all measurements. Table 2: Arduino Output Logic Measurements Digital Pin Number 10 11 12 13 V DC Logic Value (High / Low) Check off 3: Complete Table 1, Table 2 Demonstrate the proper operation of the sketch to the lab instructor.
ECET 17700 - 6 - Lab 12 Microcontroller 5. Digital Output Measurement with the Shield a. Remove the potentiometer connection from Arduino before proceeding to the next step b. Connect your "shield" to your Arduino microcontroller, as shown in Figure 5, being careful not to bend any pins. Note: You DO NOT need to push the pins down into the Arduino 100%, however you do need to establish a good connection. c. Download and Save the "DigitalIO" sketch in Brightspace Figure 6: Shield Attached to Arduino d. Open the sketch and complete the setup() function by inserting three lines of code. a. 1 line to declare the LEDs as outputs through Port A b. 2 other lines declare switches 1 and 2 (pins 2 and 3, respectively) as inputs. c. Look into Arduino tutorial for this information. When completed compile and upload the sketch, then determine the function of the sketch by applying the toggle switch inputs 1 and 2 shown in Table 2 (pin 2 and pin 3) and determine what output is displayed on the LED's on PORTA. Record your observations in Table 2. DO NOT alter the code in the loop() function Table 3: Arduino Output Logic Observations Switch 1 (Pin2) Switch 2 (pin 3) LED Response High High High Low Low High Low Low
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ECET 17700 - 7 - Lab 12 Microcontroller e. Use the same downloaded code from previous step on AnalogIN sketch, use the slide potentiometers adjust the voltage using the DMM. After adjusting the voltages record the digital values, from the serial monitor, in the following table. Table 4: Arduino Analog Input Measurements using Arduino Shield Analog In (Vdc) Incoming Digital Value (0-1023) Mapped Digital Value (0-255) 0 1.25 2.50 3.75 5.00 f. Download and Save the "IOCount" full sketch in Brightspace. g. This sketch is to perform the following function: d. Use pushbuttons 50 and 51 to write even integers to the serial monitor in a vertical fashion to count up and down, beginning with 50. The Serial Monitor is located in the top right corner of the Arduino IDE, it looks like an magnifying glass. The count up/ down direction is determined by the state of the pushbuttons 50 and 51 connected to pins 50 and 51, respectively. e. When pushbutton 50 is pressed and held (pin is LOW) then count up and turn on the yellow LEDs only. When pushbutton 51 is pressed and held (pin is LOW) count down and turn on the red LEDs only. There should be a 1 second delay between counts. Control the LEDs as a full port (PORTA), not as individual LEDs. f. In the VOID LOOP and VOID SETUP, change # to the correct pin number for digitalRead and pi nMode. In the VOID LOOP Change "LOW/HIGH" in the "if pbstatus" statement for the pushbutton status normally open. Check off 4: Complete Table 3, Table 4 Demonstrate the proper operation of the modified ‘IOCount’ sketch to the lab instructor. 3.Analysis and Conclusions 1. What is the ideal digital pin output voltage? 2. The following statement generates a delay of X seconds . X = ? a. Delay(4000); 3. In the Arduino IDE, under which menu is the port selected?