![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
part 6 and extra credit
Dependencies: C12832 Servo mbed
main.cpp
- Committer:
- jaredwil
- Date:
- 2015-03-03
- Revision:
- 0:ba4c01e9484b
- Child:
- 1:016e2bcda058
File content as of revision 0:ba4c01e9484b:
#include "mbed.h" #include "C12832.h" #include "Servo.h" Servo s1(p21); C12832 lcd(p5, p7, p6, p8, p11); DigitalOut myled(LED1); AnalogIn light(p16); int main() { float val,val2, count = 0; while(count < 4){ val = light.read(); lcd.locate(0,3); lcd.printf("reading: %.3f", val); lcd.cls(); if(val<0.5){ wait(0.1); count++; while(light.read() < 0.5); } } while(1) { lcd.cls(); val = light.read(); lcd.locate(0,3); lcd.printf("Sensor reading: %.3f", val); val2 = 1-val; if(val2 > 0.1) { for(float p=0; p<1.0; p += val2) { s1 = p; wait(0.2); } for(float p=1.0; p>0; p -= val2) { s1 = p; wait(0.2); } } } }