![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Lab exercise 2.2 Potentiometers experiment
main.cpp@0:9f16c71a1120, 2020-06-20 (annotated)
- Committer:
- ciaranom
- Date:
- Sat Jun 20 11:18:25 2020 +0000
- Revision:
- 0:9f16c71a1120
- Child:
- 1:1bb7bf26a054
Lab exercise 2.2 Potentiometers experiment;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ciaranom | 0:9f16c71a1120 | 1 | #include "mbed.h" |
ciaranom | 0:9f16c71a1120 | 2 | #include "C12832.h" |
ciaranom | 0:9f16c71a1120 | 3 | |
ciaranom | 0:9f16c71a1120 | 4 | PwmOut led1(LED1); |
ciaranom | 0:9f16c71a1120 | 5 | AnalogIn pot1(p19); |
ciaranom | 0:9f16c71a1120 | 6 | C12832 lcd(p5, p7, p6, p8, p11); |
ciaranom | 0:9f16c71a1120 | 7 | float pot1val; |
ciaranom | 0:9f16c71a1120 | 8 | |
ciaranom | 0:9f16c71a1120 | 9 | int main() { |
ciaranom | 0:9f16c71a1120 | 10 | while(1) { |
ciaranom | 0:9f16c71a1120 | 11 | led1 = pot1; |
ciaranom | 0:9f16c71a1120 | 12 | wait(0.01); |
ciaranom | 0:9f16c71a1120 | 13 | |
ciaranom | 0:9f16c71a1120 | 14 | |
ciaranom | 0:9f16c71a1120 | 15 | pot1val = pot1*100; |
ciaranom | 0:9f16c71a1120 | 16 | |
ciaranom | 0:9f16c71a1120 | 17 | lcd.cls(); |
ciaranom | 0:9f16c71a1120 | 18 | wait(.1); |
ciaranom | 0:9f16c71a1120 | 19 | lcd.locate(0,0); |
ciaranom | 0:9f16c71a1120 | 20 | lcd.printf("Pot1 value: %.4f", pot1val); |
ciaranom | 0:9f16c71a1120 | 21 | wait(1); |
ciaranom | 0:9f16c71a1120 | 22 | |
ciaranom | 0:9f16c71a1120 | 23 | lcd.cls(); |
ciaranom | 0:9f16c71a1120 | 24 | wait(.1); |
ciaranom | 0:9f16c71a1120 | 25 | lcd.locate(0,0);; |
ciaranom | 0:9f16c71a1120 | 26 | lcd.printf("Pot1 value: %.4e", pot1.read()); |
ciaranom | 0:9f16c71a1120 | 27 | wait (1); |
ciaranom | 0:9f16c71a1120 | 28 | |
ciaranom | 0:9f16c71a1120 | 29 | |
ciaranom | 0:9f16c71a1120 | 30 | } |
ciaranom | 0:9f16c71a1120 | 31 | } |