Question

In: Electrical Engineering

Write a MplabX IDE PIC10f200 code that work with three LEDs red, blue and green as...

Write a MplabX IDE PIC10f200 code that work with three LEDs red, blue and green as a mood light.( mood light has 7 colors. When all the leds terns on we will get white color, green and red tern on to get yellow, red to get red, red and blue tern on to get purple, just blue to get blue, blue and green to get light blue and just green led terns on to get green) then replay again.

Solutions

Expert Solution

#define _XTAL_FREQ 8000000

void main(void) {
int i=0;
int v;
int r,g,b; // to store the PWM ratio of each color
unsigned char c=0x00; // to store the pin output value
TRISC=0b00000000;
PORTC=0b00000000;
ANSEL = 0x00;
ANSELH = 0x00;
r=5; // Red ligt will remains fixed to intensity 5/255
for (i=0;i<=255;i++) { // a loop to vary the leds intensity
g=i; // Green led will light from 0 to 255
b=255-i; // Blue led will light from 255 to 0
for (v=0;v<=255;v++) { // loop to simulate PWM over 256 values
if (v<r) { // if current v valuer is < to the red led intensity
c|=0b00000001; // we light the led
} else {
c&=0b11111110; // else we shut it.
}
if (v<g) { // same for green
c|=0b00000010;
} else {
c&=0b11111101;
}
if (v<b) { // same for blue
c|=0b00000100;
} else {
c&=0b11111011;
}
PORTC=c; // and we finaly push the led status to PORTC (R led on C0, G led on C1 and blue on C2)
__delay_us(1); // make a short break.
}
}
return;
}


Related Solutions

Three LEDs (one red, one green, one blue) turn on when a number 0–7 is passed...
Three LEDs (one red, one green, one blue) turn on when a number 0–7 is passed through. Red turns on with even numbers, green turns on with odd numbers, blue turns on with multiples of 3. Zero means they are all off, seven means they are all on. Set–up the appropriate truth table, simplify using K–maps. Implement, using LogiSim, the simplified logic circuit with optimal number of logic gates. can someone please explain how to do the logisim?? i am...
Using the red, blue, yellow and green beads, devise and lay out a three color code...
Using the red, blue, yellow and green beads, devise and lay out a three color code for each of the following letters (codon). For example Z = green : red : green. In the spaces below the letter, record your “code”.                 E:            H:            I:            K:            L: _ _ __ _ __ _ __ _ __ _ __ _ _                O:           S:            T:            U: _ _ __ _ __ _ __ _ __ _ _ Create codons for:    Start:           ...
Write an application with three buttons labeled “Red”, “Green”, and “Blue” that changes the background color...
Write an application with three buttons labeled “Red”, “Green”, and “Blue” that changes the background color of a panel in the center of the frame to red, green, or blue. Add icons to the buttons of Exercise E19.1. Use a JButton constructor with an Icon argument and supply an ImageIcon. this is the code that I already wrote that I need to do the above to. import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame;...
There are three types of balls in a box: 5 red, 3 blue and 2 green....
There are three types of balls in a box: 5 red, 3 blue and 2 green. You draw 3 balls at once (without replacement) from this box and record: Y1=the # of red balls, Y2=the # of blue balls that you drew. Find the joint probability distribution of Y1, Y2, by first writing the possible values for y1, y2 in rows and columns and then filling in the probabilities within this table. Then check that the sum of the entries...
Suppose you have 24 items (three red, three blue, three yellow, and three green) to give...
Suppose you have 24 items (three red, three blue, three yellow, and three green) to give to 24 students. How many different ways can you distribute the things to the students? (Note: the items of the same color are identical)
1. Write a code that makes the MSP430 blink the red LED and the green LED...
1. Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
Three fair dice colored red, blue and green are rolled. 1. What will you choose the...
Three fair dice colored red, blue and green are rolled. 1. What will you choose the sample space to be in this case? How many atomic events are there in the sample space? What probability distribution will you use to model this problem? 2. What is the probability that exactly two of the dice roll the same number? 3. What is the probability that all three dice roll distinct numbers? 4. What is the probability that at least two of...
A bag contains one red marble, two blue marbles and three green marbles. A marble is...
A bag contains one red marble, two blue marbles and three green marbles. A marble is selected at random. Define a random variable X such that X=1 if a red marble is selected, X=2 if a blue marble is selected and X=3 if a green marble is selected. Find the following probabilities. Hint: The blue marbles are different; you can label one blue-1 and the other blue-2. Similarly, each of the green marbles is different. 4a) Find P(X=1) 4b) Find...
Design a security system using red, green, and yellow LEDS, along with MUX chip, buzzer and...
Design a security system using red, green, and yellow LEDS, along with MUX chip, buzzer and ultrasonic sensor.
Three fair, six-sided dice colored red, green and blue are rolled. Calculate each of the following...
Three fair, six-sided dice colored red, green and blue are rolled. Calculate each of the following probabilities: (a) The probability all three dice show the same face (“triples”). (b) The probability that the red die shows a larger number than the green die. (c) The probability that the red die shows a larger number than the green die and the green die shows a larger number than the blue die. (d) The probability that the sum of the pips on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT