![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
part 6 and extra credit
Dependencies: C12832 Servo mbed
Diff: main.cpp
- Revision:
- 2:1d960bbbb0fe
- Parent:
- 1:016e2bcda058
- Child:
- 3:853bc68793d0
diff -r 016e2bcda058 -r 1d960bbbb0fe main.cpp --- a/main.cpp Tue Mar 03 22:58:29 2015 +0000 +++ b/main.cpp Tue Mar 03 23:01:46 2015 +0000 @@ -18,10 +18,10 @@ while(count < 4){ val = light.read(); - lcd.locate(0,3); - lcd.printf("reading: %.3f", val); - lcd.cls(); if(val<0.5){ + lcd.locate(0,3); + lcd.printf("reading: %.3f", val); + lcd.cls(); wait(0.1); count++; while(light.read() < 0.5); @@ -32,12 +32,13 @@ while(1) { lcd.cls(); val = light.read(); - lcd.locate(0,3); - lcd.printf("Sensor reading: %.3f", val); + val2 = 1-val; //even for little light start servo with small steps(low speed) if(val2 > 0.1) { + lcd.locate(0,3); + lcd.printf("Sensor reading: %.3f", val); for(float p=0; p<1.0; p += val2) { s1 = p; wait(0.2);