| WR Home Topic Home | Chapter: 1 2 3 4 |
| <Previous | Next> |
Chapter 04
Developing a Utility Library for the Propeller PCB
Page 8
Questions
Q13 Suppose if the Propeller is rotating at a constant speed of RPM = 1200
It will make 20 number of turns in a second (1200/60 = 20)
and to move one degree it will take 137.888889 micro seconds
Assume that time taken to execute the instructions is negligible.
What pattern the following code displays/renders:
// BGR
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
float D = 137.888889;
unsigned int onSequence = 0x5555; // 0101 0101 0101 0101 Even LEDs are ON
int main()
{
while(1)
{
switch_LEDs(onSequence, RED);
myDelay(D * 90);
switch_LEDs(onSequence, BLUE);
myDelay(D * 90);
switch_LEDs(onSequence, GREEN);
myDelay(D * 90);
switch_LEDs(onSequence, WHITE);
myDelay(D * 90);
}
}
Imagine: What do you see ? Scroll below to check your answer
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
To move one degree it will take 137.888889 micro seconds
To move one degree it will take D amount of time
To move one 90 degree it will take D x 90 amount of time
Since onSequence = 0x5555; // 0101 0101 0101 0101 Even LEDs are ON in RED for first 90° and
for next 90° the same LEDs are ON in BLUE color,
for next 90° the same LEDs are ON in GREEN color,
for next 90° the same LEDs are ON in WHITE color,
| WR Home Topic Home | Chapter: 1 2 3 4 |
| <Previous | Next> |