Studienleistung 1 FINAL (BETA-5)
Revision 0:738510c1e7fe, committed 2013-05-14
- Comitter:
- chrish
- Date:
- Tue May 14 08:09:04 2013 +0000
- Commit message:
- Left-Right-Blink
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue May 14 08:09:04 2013 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+Ticker systick;
+volatile char bstandby;
+DigitalOut spg(p21); // U versorgung schalter
+DigitalOut spg2(p22); // U versorgung schalter
+DigitalOut rightled(LED4);
+DigitalOut leftled(LED1);
+DigitalIn left(p8);
+DigitalIn right(p14);
+Serial pc(USBTX, USBRX);
+Timer l; // Plink Timmer links
+Timer r; // Blinktimmer Rechts
+Timer pl; //BRELLTIMER LINKS; brellen und timeverschiebung für zustand dauerhaft plinken
+Timer pr; // BRELLTIMER RECHTS; brellen und timeverschiebung für zustand dauerhaft Plinken
+int anzleft;
+int anzright;
+int auswahlleft;
+int auswahlright;
+//==================================================00
+void vTimer(void){
+bstandby =1;
+}
+//================================================
+void blinkswitch(DigitalOut *led, int *anz, int *auswahl, Timer *tim){ // tim = l oder r
+ switch(*auswahl){
+ case 0: *led =0;
+ break;
+ case 1:{
+ if(tim->read()>= 0.3 || *anz == 8){ *led =! *led; tim->reset() ; *anz -=1; pc.printf(" %d",*anz);}
+ if(*anz == 0) *auswahl = 0;}
+ break;
+ case 2:{
+ if((*tim).read() >= 0.3){ *led =! *led ; (*tim).reset();pc.printf("BIN IN SEc 2 " );}
+
+ }
+ break;
+
+ }
+}
+
+//=?======================================================000
+
+int main() {
+spg = 1; // Spannungsversorgung der angeschloosenen schalter
+spg2 =1; // Spannungsversorgung der angeschlossenen schalter
+auswahlleft = 0;
+auswahlright = 0;
+
+ while(1) {
+ // systick.attach_us(&vTimer, 200);
+ if(left == 1){
+ //pc.printf("LINKS LIEGHT AN \n\n");
+ if(auswahlleft == 0 && pl.read() >= 0.05){auswahlleft =1; anzleft =8; l.start();pl.reset();pl.start();}
+ if(auswahlleft ==1 && pl.read()>= 0.5) {auswahlleft = 2;pl.stop();pl.reset();}
+ }else {
+ if(auswahlleft ==2)auswahlleft =0;
+ pl.start();}
+ blinkswitch(&leftled,&anzleft, &auswahlleft, &l);
+
+ if(right ==1){
+ if(auswahlright ==0 && pr.read() >= 0.05) { auswahlright =1; anzright= 8; r.start () ; pr.reset(); pr.start();}
+ if(auswahlright == 1 && pr.read() >=0.5 ) { auswahlright =2 ; pr.stop(); pr.reset();}
+ }else {
+ if(auswahlright == 2) auswahlright =0;
+ pr.start();}
+ blinkswitch(&rightled,&anzright, &auswahlright, &r);
+ // while(bstandby == 0);
+ // bstandby = 1;
+ };
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 14 08:09:04 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file