Cycles between 3(4) modes: Thermometer Spirit Level Compass WIP - Etch a Sketch Move the joystick left or right to select a mode
Dependencies: C12832 FXOS8700Q LM75B mbed
Revision 2:9df380c6dd55, committed 2015-10-29
- Comitter:
- co657_ts256
- Date:
- Thu Oct 29 23:53:57 2015 +0000
- Parent:
- 1:2cd9904ca6a1
- Child:
- 3:3b1e081f6655
- Commit message:
- Working Etch aSketch
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 29 22:59:27 2015 +0000 +++ b/main.cpp Thu Oct 29 23:53:57 2015 +0000 @@ -24,6 +24,9 @@ InterruptIn left(A4); InterruptIn right(A5); +AnalogIn pot1(A0); +AnalogIn pot2(A1); + DigitalOut red_led(LED1); DigitalOut blue_led(LED2); DigitalOut green_led(LED3); @@ -123,13 +126,21 @@ } } else if(mode == 3) { + int p1, p2; shld_lcd.locate(1,1); shld_lcd.printf("Mode: Etch-A-Sketch"); shld_lcd.locate(1,10); shld_lcd.printf("Use potentiometers to draw. Click joystick to clear"); wait(2); + shld_lcd.cls(); while(mode == 3) { - + float p1 = (float)pot1; + float p2 = (float)pot2; + int x = floor((p1 * 127) + 0.5); + int y = floor((p2 * 32) + 0.5); + shld_lcd.pixel(x, y, 1); + shld_lcd.copy_to_lcd(); + wait(.001); } } }