Lab1.2

Dependencies:   mbed

main.cpp

Committer:
GerRoche
Date:
2019-05-24
Revision:
3:06191cd608eb
Parent:
2:426f7c929554

File content as of revision 3:06191cd608eb:

#include "mbed.h"//includes mbed header

Serial pc(USBTX,  USBRX);
InterruptIn button1 (p12);
InterruptIn button2 (p13);
InterruptIn button3 (p14);
InterruptIn button4 (p15);
InterruptIn button5 (p16);

int down=0;
int left=0;
int center=0;
int up=0;
int right=0;

void print1()
{
    printf("Down Pressed\r\n");// prints to the PC when print1 is activated
    wait(0.75);// waits 0.75 seconds
}
void print2()
{
    printf("Left Pressed\r\n");// prints to the PC when print2 is activated
    wait(0.75);// waits 0.75 seconds
}
void print3()
{
    printf("Centre Pressed\r\n");// prints to the PC when print3 is activated
    wait(0.75);// waits 0.75 seconds
}
void print4()
{
    printf("Up Pressed\r\n");// prints to the PC when print4 is activated
    wait(0.75);// waits 0.75 seconds
}
void print5()
{
    printf("Right Pressed\r\n");// prints to the PC when print5 is activated
    wait(0.75);// waits 0.75 seconds
}

int main()
{
    printf("Hello\r\n");// prints "Hello" at the top of the screen
    1.rise(&print1);// prints first print statment when value goes from 0V to 3.3V and p12 is hit
    2.rise(&print2);// prints second print statment when value goes from 0V to 3.3V and p13 is hit
    3.rise(&print3);// prints third print statment when value goes from 0V to 3.3V and p14 is hit
    4.rise(&print4);// prints fourth print statment when value goes from 0V to 3.3V and p15 is hit
    5.rise(&print5);// prints fifth print statment when value goes from 0V to 3.3V and p16 is hit
    wait(0.5);// waits 0.5 seconds
    while(1) {

    }
}