Potentiometers experiment

Dependencies:   mbed C12832

Committer:
AdamCiechalski
Date:
Wed May 01 11:16:30 2019 +0000
Revision:
1:9444965b4725
Parent:
0:f842d2e7c87f
Child:
2:0df5683f5842
Inst_LAB_3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AdamCiechalski 0:f842d2e7c87f 1 #include "mbed.h"
AdamCiechalski 0:f842d2e7c87f 2 #include "C12832.h"
AdamCiechalski 0:f842d2e7c87f 3
AdamCiechalski 0:f842d2e7c87f 4 C12832 lcd(p5, p7, p6, p8, p11);
AdamCiechalski 0:f842d2e7c87f 5 PwmOut led1(LED1);
AdamCiechalski 0:f842d2e7c87f 6 AnalogIn pot1(p19);
AdamCiechalski 0:f842d2e7c87f 7
AdamCiechalski 0:f842d2e7c87f 8
AdamCiechalski 0:f842d2e7c87f 9 int main() {
AdamCiechalski 0:f842d2e7c87f 10 while(1) {
AdamCiechalski 0:f842d2e7c87f 11 led1 = pot1;
AdamCiechalski 1:9444965b4725 12 lcd.cls();//cleaning the display
AdamCiechalski 1:9444965b4725 13 lcd.locate(0,0);//position the cursor in position 0.0 - upper left corner of the display
AdamCiechalski 1:9444965b4725 14 lcd.printf("value of pot1 is %.3f\n", pot1.read());//display of the potentiometer value in the range 0-1
AdamCiechalski 1:9444965b4725 15 lcd.locate(0,10); //position the cursor in position 0.10 - first column tenth row
AdamCiechalski 1:9444965b4725 16 lcd.printf("voltage of pot1 is %.2fV\n", pot1.read() * 3.3); //display of the voltage value on the potentiometer in the range of 0 - 3.3V
AdamCiechalski 0:f842d2e7c87f 17 wait(0.05);
AdamCiechalski 0:f842d2e7c87f 18 }
AdamCiechalski 0:f842d2e7c87f 19 }
AdamCiechalski 0:f842d2e7c87f 20