Blink an led 10 times
sokin
Posts: 32
Hello, I am trying to make p26 blink 10 times when wL = 0 and p27 blink 10 times when wR = 0. Here is the code I have to modify to make that happen but I am confused on where to start. A hint that is on the parallax website is to nest a for loop inside an if statement. Does anyone have any suggestion about how to go about this?
#include "simpletools.h" // Include simpletools header
int main() // main function
{
freqout(4, 10, 3000); // Speaker tone: P4, 2 s, 3 kHz
while(1) // Endless loop
{
int wL = input(7); // Left whisker -> wL variable
int wR = input(8); // Right whisker -> wR variable
if(wL == 0) // Light for left whisker
{
high(26);
pause(50);
low(26);
pause(50);
}
if(wR == 0) // Light for right whisker
{
high(27);
pause(50);
low(27);
pause(50);
}
print("%c", HOME); // Terminal cursor home (top-left)
print("wL = %d wR = %d", wL, wR); // Display whisker variables
pause(50); // Pause 50 ms before repeat
}
}
#include "simpletools.h" // Include simpletools header
int main() // main function
{
freqout(4, 10, 3000); // Speaker tone: P4, 2 s, 3 kHz
while(1) // Endless loop
{
int wL = input(7); // Left whisker -> wL variable
int wR = input(8); // Right whisker -> wR variable
if(wL == 0) // Light for left whisker
{
high(26);
pause(50);
low(26);
pause(50);
}
if(wR == 0) // Light for right whisker
{
high(27);
pause(50);
low(27);
pause(50);
}
print("%c", HOME); // Terminal cursor home (top-left)
print("wL = %d wR = %d", wL, wR); // Display whisker variables
pause(50); // Pause 50 ms before repeat
}
}
Comments
Tom
for(int wL = 0; wL <= 10; wL++);
Should I be including P26 in the for statement or not?
Thanks
I hope this helps.
Tom
This helps a lot.
Thanks for your time