Homework Assignment
dcar2013
Posts: 1
Build a circuit and write a program that will have a red LED (representing a power on light) blink once a second. Have 2 pushbuttons connected in such a way so that when button # 1 is pressed a yellow LED flashes at 20 Hz. When button # 2 is pressed a green LED flashes at 40 Hz. When both pushbuttons are pressed at the same time have the green and yellow LEDs flash alternately at 10 Hz. My problem is that I have the program for the red LED works properly and the program for the green and yellow works properly individually. But, when combined the buttons pressed simultaneously are not flashing alternately at the required durations. See attachment for code
bs2
429B
Comments
Not too many of us are fans of doing other people's homework.
At a minimum, add some comments to your code so those who want to give hints can direct you to the relevant parts.
I see a time pattern with 10,20,40 hz so maybe
PAUSE 10
x=x+1
if x>=40 then x = 0
if x=??? and in3=???...........................
and so on
LOOP
If you take an honest stab at it, show some effort, and ask for help, we are happy to nudge you in the right direction. But we can't write your program for you.
Unless you have a LOT of money.
You should comment your code so it's easier to read. Commenting is discussed in Activity #2 (Page 37 in 3.0, Page 46 in 2.2)
Currently you don't have anything for the Red LED and your timing is not correct. Look at Activity #2 and see what PAUSE times are used for different blinking rates.