Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i have to follow to prompt to make the code required above. it needs to be in c and work with the arduino 1. Encoding

image text in transcribed

i have to follow to prompt to make the code required above. it needs to be in c and work with the arduino

1. Encoding Switches a. The name of this program will be lab5pl b. As described in Lab 4, the EduShield comes with a four pushbutton switches SWO on pin 12, SW1 on pin 8, SW2 on pin 7, and SW3 on pin 4 These switches pull the pins low when they are pressed and thus they are "active- low." The Arduino switch inputs must be configured to have a 20 kS2 pull-up resistor on input pin using the command: pinMode (pin, INPUT_PULLUP) c. d. To read a digital input signal, we use the function digitalRead (pin); The returned value from digitalRead) is either HIGH (1) or LOW (0) e. Write the function proto-type read switches () that has no input parameter and has as output a single integer that is a binary encoding of the four switches. f. Inside this function, read all four switches and then sum them with binary weighting, such that SWO is the LSB (with a weight of 20) and SW3s the MSB (with a weight of 2). To make the switches "active-high" invert the value of each reading before applying the binary weight. As such, "no switches pressed" will be encoded as 0, whereas all four switches will be the highest binary value g. Write a program that calls function read_switches() and displays the result in decimal and binary format (in columns). Put a delay of 1 second between each reading. Include a suitable header row for the two columns Run the program. Show the results to the TAEach student upload the source file to Canvas

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago