LDR test for Stage 1 Engineering at the University of York

Dependencies:   UoY-serial

Committer:
ajp109
Date:
Tue Sep 29 09:55:15 2020 +0000
Revision:
0:62608d16d10f
Child:
1:3edadd59e1ef
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ajp109 0:62608d16d10f 1 #include "mbed.h"
ajp109 0:62608d16d10f 2
ajp109 0:62608d16d10f 3 int main()
ajp109 0:62608d16d10f 4 {
ajp109 0:62608d16d10f 5 AnalogIn x(A0);
ajp109 0:62608d16d10f 6 AnalogIn y(A1);
ajp109 0:62608d16d10f 7 DigitalIn button(D2, PullUp);
ajp109 0:62608d16d10f 8 Serial pc(USBTX, USBRX);
ajp109 0:62608d16d10f 9
ajp109 0:62608d16d10f 10 // Loop forever...
ajp109 0:62608d16d10f 11 while (true) {
ajp109 0:62608d16d10f 12 // Always print out the X and Y values
ajp109 0:62608d16d10f 13 pc.printf("x:%d y:%d\n", x.read_u16(), y.read_u16());
ajp109 0:62608d16d10f 14 if (button == false) {
ajp109 0:62608d16d10f 15 // If the button is being pressed, add a suitable message
ajp109 0:62608d16d10f 16 pc.printf("\t(button pressed)\n");
ajp109 0:62608d16d10f 17 }
ajp109 0:62608d16d10f 18 thread_sleep_for(500);
ajp109 0:62608d16d10f 19 }
ajp109 0:62608d16d10f 20 }