![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
after pressing button ten times led will light up
counter.cpp
- Committer:
- jakebonney10
- Date:
- 2017-10-05
- Revision:
- 1:557aa2690340
- Parent:
- 0:7a1c2b296ffe
File content as of revision 1:557aa2690340:
#include "mbed.h" //Assignment1 //Jake_Bonney //OCE 360 //count_10_redled_on_greenled_off //led_switches@10count DigitalOut redled(p5); DigitalOut greenled(p6); DigitalIn button(p7); int main() { int count = 0; redled = 1; greenled = 0; while(count < 10) { if(button == 1){ int check_value = button; wait(0.005); // so it doesnt bounce when button is being pressed down while(check_value){ if(check_value - button == 1){ count++; check_value = 0; } } } } redled = 0; greenled = 1; }