// main.cpp
#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalIn  button(PC_13);

int another_press(int press_num) {
    press_num += 1;
    if (press_num >= 8) {
        press_num = 0;
    };

    return press_num;
}

void set_led(int number) {
    led1 = (number & 1) ? 1 : 0;
    led2 = (number & 2) ? 1 : 0;
    led3 = (number & 4) ? 1 : 0;
}

int main()
{

    int num_presses = 0;
    while (true) {
        led1 = 0;
        led2 = 0;
        led3 = 0;

        if (button == 0) {
          num_presses = another_press(num_presses);
          set_led(num_presses);

          while (button == 0) {
            ThisThread::sleep_for(10ms);
          }
        }

        ThisThread::sleep_for(150ms);
    }
}
