adrian mb
/
banda
El de mi banda transportadora + FPGA
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 00004 Servo servo(p21); 00005 00006 DigitalOut l1(LED1); 00007 DigitalOut l2(LED2); 00008 DigitalOut l3(LED3); 00009 00010 DigitalIn posServo(p26); 00011 DigitalOut ready(p27); 00012 DigitalOut figura(p28); 00013 InterruptIn inicio(p29); 00014 InterruptIn foto(p30); 00015 00016 Serial pc(USBTX,USBRX); 00017 char in; 00018 00019 void tomarFoto() { 00020 pc.putc('f'); 00021 l3=1; 00022 ready=0; 00023 } 00024 00025 void reset() { 00026 ready=0; 00027 figura=0; 00028 l3=0; 00029 } 00030 00031 void dataIn() { 00032 if (pc.readable()) { 00033 in=pc.getc(); 00034 switch (in) { 00035 case '0': 00036 figura=0; 00037 ready=1; 00038 break; 00039 case '1': 00040 figura=1; 00041 ready=1; 00042 break; 00043 } 00044 } 00045 } 00046 00047 int main() { 00048 pc.baud(9600); 00049 pc.attach(&dataIn); 00050 foto.rise(&tomarFoto); 00051 inicio.rise(&reset); 00052 foto.mode(PullDown); 00053 inicio.mode(PullDown); 00054 posServo.mode(PullDown); 00055 00056 while (1) { 00057 l1=ready; 00058 l2=figura; 00059 if (posServo==1) { 00060 servo=1; 00061 } else { 00062 servo=0; 00063 } 00064 } 00065 }
Generated on Thu Aug 4 2022 06:59:15 by 1.7.2