Mark Schwarzer / Mbed 2 deprecated Schwarzer_A2_Digital_Input

Dependencies:   mbed

main.cpp

Committer:
markschwarzer
Date:
2020-10-06
Revision:
4:89345ff980ea
Parent:
3:05cf74b7bad8

File content as of revision 4:89345ff980ea:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalIn switch_input(p17);
Serial pc(USBTX, USBRX);

//code compiles but the mbed has a problem with blinking at certain time intervals

int main() {
while(1) {
    if (switch_input==1) {
        led2= 0; //off
        led1= 1; //on
        wait(1); //wait one second
        led1= 0;
        wait(1);
        }
        else if (switch_input==0) {
            led1= 0;
            led2= 1;
            wait(0.3);
            led2= 0;
            wait(0.3); }
            
int second();
int count = 0;
while(count<= 10) {
        if(switch_input== 1){
            int check = switch_input;
            pc.printf("[%d] count: %d\r\n", switch_input.read(), count);
            
            while(check){
                if(check - switch_input== 1){
                count=count++;
                check= 0;
                pc.printf("[%d] count: %d\r\n", switch_input.read(), count);
                 }}} 
        return count;  }}}