LDR test for Stage 1 Engineering at the University of York

Dependencies:   UoY-serial

main.cpp

Committer:
ajp109
Date:
2020-11-21
Revision:
1:3edadd59e1ef
Parent:
0:62608d16d10f
Child:
2:4dca570013d8

File content as of revision 1:3edadd59e1ef:

#include "mbed.h"
#include "UoY-utils.h"

serial_setup(USBTX, USBRX, 9600);

int main()
{
    AnalogIn x(A0);
    AnalogIn y(A1);
    DigitalIn button(D2, PullUp);

    // Loop forever...
    while (true) {
        // Always print out the X and Y values
        printf("x:%d y:%d\n", x.read_u16(), y.read_u16());
        if (button == false) {
            // If the button is being pressed, add a suitable message
             printf("\t(button pressed)\n");
        }
        thread_sleep_for(500);
    }
}