Azra Ismail
/
BAT_senior_design
A device supporting students learning to type braille
Revision 0:9eda4611081a, committed 2017-10-04
- Comitter:
- aismail1997
- Date:
- Wed Oct 04 14:47:07 2017 +0000
- Commit message:
- initial commit - servo and push buttons work;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Wed Oct 04 14:47:07 2017 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 04 14:47:07 2017 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "Servo.h" + +PwmOut myservo(p21); +DigitalIn pb1 (p20); +//AnalogIn linpot(p20); +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); + +int main() +{ + // button up: state = 0, button halfway: state = 1; button down: state = 2 + //int state = 0; + pc.printf("begin\n"); + int state = 2; + pb1.mode(PullUp); + wait(.001); + for(int i=0; i<=3; i++) { + myservo = i/100.0; + wait(0.01); + } + while(1) { + // Servo code + if (pb1 == 1 && state == 2) { + while(pb1 == 1) + myled = 1; + // rotate 90 degrees one way + for(int i=3; i<=7; i++) { + myservo = i/100.0; + wait(0.01); + } + state = 1; + } + //wait(1.0); + // rotate 90 degrees other way + if (pb1 == 1 && state == 1) { + while(pb1 == 1) + myled = 0; + for(int i=7; i>3; i--) { + myservo = i/100.0; + wait(0.01); + } + //wait(0.1); + state = 2; + } + //wait(1.0); + + // read linear potentiometer + //if (linpot < 0.5) { + //float potval = linpot; + //pc.printf("linear pot: %f\n", potval); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 04 14:47:07 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/675da3299148 \ No newline at end of file