Question

I am writing a program in c programming and it is supposed to do the following using mc9s12dg256.h microcontroller When...

I am writing a program in c programming and it is supposed to do the following

using mc9s12dg256.h microcontroller

  1. When both DIP switches #8 and #1 are high, turn on all LEDS.
  2. When both DIP switches #8 and #1 are low, turn off all LEDs
  3. When DIP switch #8 is high and #1 is low, turn on all the even numbered LEDs.
  4. When DIP switch #1 is high and #8 is low, turn on all the odd numbered LEDs.
  5. Your program must to read DIP switches and turn on/off corresponding LRDs continuously until a Reset.

I understand the code is supposed to look something like

void main(void)
{
  
InitSwitches();
InitLEDs();
if (DIP switches = %10000001) {
PORTB =  0;/Turn on all LEDs \   
}
}

However I don't know to to represent the "DIP switch" part in this code. Is it supposed to be a hexnumber or a built in feature?

Once I know that I know how to turn on all odd and even LEDs I just don;t know how to check which dip switch is on or off. I have read several journals and they got me really confused. I know how to do this in assembly language but in c I get really confused.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :- The DIP switches must be connected to any one of the IO ports like PORTA, PORTB etc. Like we have LEDs on port B pins. In question it must be given that which port is connected with DIP switch. Then we can read that port pins to get the DIP switch status.

Please discuss with the question provider so that it will be cleared that which port pins are responsible for DIP switch.

Dear student, you can comment if you have any further doubt. OR you can solve assuming port A as DIP pins and later modify the port name if required. Thank you.

Add a comment
Know the answer?
Add Answer to:
I am writing a program in c programming and it is supposed to do the following using mc9s12dg256.h microcontroller When...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • To become familiar with using Port A and Port H as input ports H as an input port and port B as an output port

    Goal: To become familiar with using Port A and Port H as input ports H as an input port and port B as an output port, using dragon12-Light boards as well as to improve your programming skills.Project: Write an assembly program and a C program to do the following:When DIP switch #8 is high and #1 is low, turn on all the even numbered LEDs and let them stay on even after the switch #8 is changed to low.When DIP...

  • I am having an issue with this practice problem. I understand the concept of given step,...

    I am having an issue with this practice problem. I understand the concept of given step, but I am lost to figure out how to setup in the main program in CodeWarrior software. Using the HCS12 Microcontrollers and Embedded Systems, 1st Edition, I was able to understand the instruction appendix, but I was not able to construct it in the main program. I need help to solve these steps and it is due today. Modify the Main program section of...

  • I have a program for Arduino written such that when I hold a button down, it...

    I have a program for Arduino written such that when I hold a button down, it will turn an LED off. I want to be able to print to the serial monitor how long the button was pressed for after I let go of the button. Does anybody have any ideas? Below is the code I have written thus far: Text of Code: #define LED RED_LED #define buttonPIN PUSH2 const int buttonPin = PUSH2; // the number of the pushbutton...

  • I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED str...

    I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED strips and 3 - ultrasonics. I have them working independently but I need to combine the code so they work together. Here is what I have: Memory Game #define PLAYER_WAIT_TIME 2000 // The time allowed between button presses - 2s byte sequence[100]; // Storage for the light sequence byte curLen = 0; // Current length of the sequence byte inputCount =...

  • Writing a program in C using CodeBlocks but I cannot seem to get this right. I...

    Writing a program in C using CodeBlocks but I cannot seem to get this right. I keep getting weird outputs for my high, med, low. Any help would be greatly appreciated. Code is provided in link. Write a program that will ask for a desired temperature and it shifts the conditions in the Fig. shown below. - The program will ask for the room temperature and for the desired temperature. - If desired temperature is less than 2.5 degrees from...

  • Hi, I am a student in college who is trying to make a tic tac toe...

    Hi, I am a student in college who is trying to make a tic tac toe game on Java. Basically, we have to make our own game, even ones that already exist, on Java. We also have to implement an interface, that I have no idea exactly. The professor also stated we need at least 2 different data structures and algorithms for the code. The professor said we could use code online, we'd just have to make some of our...

  • I must execute in C using parallel Programming techniques the following serial program: void producer_consumer(int *buffer,...

    I must execute in C using parallel Programming techniques the following serial program: void producer_consumer(int *buffer, int size, int *vec, int n) {    int i, j;    long long unsigned int sum = 0;    for(i=0;i<n;i++) {        if(i % 2 == 0) {   // PRODUCER            for(j=0;j<size;j++) {                buffer[j] = vec[i] + j*vec[i+1];            }        }        else {   // CONSUMER            for(j=0;j<size;j++) {...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally...

    C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally compile. Below is a picture of the error messages. //main.cpp //Semester Project //Created by J---on 5/6/2019 #include <iostream> #include <fstream> #include <string> #include <sstream> #include <bits/stdc++.h> using namespace std; void instructions(); //displays program details and instructions void openFile(); void takeInput(int*); void switchBoard(int*); struct price {...

  • Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to...

    Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to your homework program. Continually display “0123”, “4567”, “89Ab”, “cdEF” with a one second delay between each one. HINT: Expand pickNumber() to use numbers 10-15 (a-f in hex). Create new functions for a-f. (THIS IS THE CODE FROM THE HOMEWORK) /*************************************** name:Stopwatch function: you can see the number increases by one per second on the 4-digit 7-segment display. ***********************************/ //Email:support@sunfounder.com //Website:www.sunfounder.com /**************************************/ #include //the pins...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT