![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dimmerschaltung für Lab_2
Dependencies: C12832_lcd LCD_fonts mbed
main.cpp@0:ba26f4fa04ca, 2013-04-23 (annotated)
- Committer:
- Shadow
- Date:
- Tue Apr 23 23:31:51 2013 +0000
- Revision:
- 0:ba26f4fa04ca
- Child:
- 1:abdbb6ca745b
Eventuell fertiger Dimmer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Shadow | 0:ba26f4fa04ca | 1 | #include "mbed.h" |
Shadow | 0:ba26f4fa04ca | 2 | #include "C12832_lcd.h" |
Shadow | 0:ba26f4fa04ca | 3 | #include "Arial_9.h" |
Shadow | 0:ba26f4fa04ca | 4 | |
Shadow | 0:ba26f4fa04ca | 5 | C12832_LCD lcd; |
Shadow | 0:ba26f4fa04ca | 6 | DigitalIn t_left(p13); |
Shadow | 0:ba26f4fa04ca | 7 | DigitalIn t_right(p16); |
Shadow | 0:ba26f4fa04ca | 8 | DigitalIn t_on_off(p14); |
Shadow | 0:ba26f4fa04ca | 9 | PwmOut led(LED1); |
Shadow | 0:ba26f4fa04ca | 10 | //DigitalOut ledright(LED4); |
Shadow | 0:ba26f4fa04ca | 11 | |
Shadow | 0:ba26f4fa04ca | 12 | double i=0.0; |
Shadow | 0:ba26f4fa04ca | 13 | |
Shadow | 0:ba26f4fa04ca | 14 | |
Shadow | 0:ba26f4fa04ca | 15 | int main() { |
Shadow | 0:ba26f4fa04ca | 16 | lcd.cls(); |
Shadow | 0:ba26f4fa04ca | 17 | lcd.set_font((unsigned char*) Arial_9); |
Shadow | 0:ba26f4fa04ca | 18 | |
Shadow | 0:ba26f4fa04ca | 19 | led=0.0; |
Shadow | 0:ba26f4fa04ca | 20 | |
Shadow | 0:ba26f4fa04ca | 21 | while (1) { |
Shadow | 0:ba26f4fa04ca | 22 | |
Shadow | 0:ba26f4fa04ca | 23 | |
Shadow | 0:ba26f4fa04ca | 24 | |
Shadow | 0:ba26f4fa04ca | 25 | while(t_right&&i<=1.0){ |
Shadow | 0:ba26f4fa04ca | 26 | lcd.printf("DIMM %lf\n",i); |
Shadow | 0:ba26f4fa04ca | 27 | lcd.printf("LED %lf\n",led); |
Shadow | 0:ba26f4fa04ca | 28 | i+=0.01; |
Shadow | 0:ba26f4fa04ca | 29 | led=i; |
Shadow | 0:ba26f4fa04ca | 30 | wait(0.1); |
Shadow | 0:ba26f4fa04ca | 31 | if(!t_right){ |
Shadow | 0:ba26f4fa04ca | 32 | led=i; |
Shadow | 0:ba26f4fa04ca | 33 | lcd.printf("DIMM %lf\n",i); |
Shadow | 0:ba26f4fa04ca | 34 | lcd.printf("LED %lf\n",led); |
Shadow | 0:ba26f4fa04ca | 35 | } |
Shadow | 0:ba26f4fa04ca | 36 | } |
Shadow | 0:ba26f4fa04ca | 37 | |
Shadow | 0:ba26f4fa04ca | 38 | |
Shadow | 0:ba26f4fa04ca | 39 | |
Shadow | 0:ba26f4fa04ca | 40 | while(t_left&&i>=0.0){ |
Shadow | 0:ba26f4fa04ca | 41 | lcd.printf("DIMM %lf\n",i); |
Shadow | 0:ba26f4fa04ca | 42 | lcd.printf("LED %lf\n",led); |
Shadow | 0:ba26f4fa04ca | 43 | i-=0.01; |
Shadow | 0:ba26f4fa04ca | 44 | led=i; |
Shadow | 0:ba26f4fa04ca | 45 | wait(0.1); |
Shadow | 0:ba26f4fa04ca | 46 | if(!t_left){ |
Shadow | 0:ba26f4fa04ca | 47 | led=i; |
Shadow | 0:ba26f4fa04ca | 48 | lcd.printf("DIMM %lf\n",i); |
Shadow | 0:ba26f4fa04ca | 49 | lcd.printf("LED %lf\n",led); |
Shadow | 0:ba26f4fa04ca | 50 | } |
Shadow | 0:ba26f4fa04ca | 51 | } |
Shadow | 0:ba26f4fa04ca | 52 | } |
Shadow | 0:ba26f4fa04ca | 53 | } |
Shadow | 0:ba26f4fa04ca | 54 |