prova
Dependencies: mbed
Revision 2:64e3ac1c2786, committed 2022-05-03
- Comitter:
- pinofal
- Date:
- Tue May 03 12:19:17 2022 +0000
- Parent:
- 1:762bbfe2fc71
- Commit message:
Changed in this revision
DORA-myTest.cpp | Show annotated file Show diff for this revision Revisions of this file |
TestPWM.cpp | Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DORA-myTest.cpp Tue May 03 12:19:17 2022 +0000 @@ -0,0 +1,59 @@ + +#include "mbed.h" +#include<stdlib.h> + +// Definizione periferica USB seriale del PC +Serial pc(USBTX, USBRX, 921600); // seriale di comunicazione con il PC. Associati a PA_11 e PA_12 + +// User Button, LED +DigitalIn myButton(USER_BUTTON); // pulsante Blu sulla scheda. Associato a PC_13 +DigitalOut myLed(LED2); // LED verde sulla scheda. Associato a PA_5 + + +// digital Out di Prova +DigitalOut Relay5V (PA_10); + +/**********/ +/* MAIN */ +/**********/ +int main() +{ + + // messaggio di benvenuto + pc.printf("\r\n************ Hallo ************** \r\n"); + pc.printf("************* Test ***************\r\n"); + + // out di prova + Relay5V = 0; + + // Ciclo principale + while(true) + { + /* + Relay5V=0; + wait(1); + Relay5V=1; + wait(1); + */ + + // accende alimentatore se è premuto lo User Button + if(myButton == 0) + { + // accendi LED su scheda + myLed = 1; + + // accendi relay a 5V + Relay5V = 1; + } + else + { + // spegni LED su scheda + myLed = 0; + + // spegni relay a 5V + Relay5V = 0; + + } // if(myButton==0) + + } // while(true) Principale +} \ No newline at end of file
--- a/TestPWM.cpp Tue Aug 25 07:16:44 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -// Test motore CC, pilotato in PWM -// test interruttore simulato con un output OpenDrain -// testato su F070RB, F401 - -#include "mbed.h" -#include<stdlib.h> - -// Definizione periferica USB seriale del PC -Serial pc(USBTX, USBRX, 921600); // seriale di comunicazione con il PC. Associati a PA_11 e PA_12 - -// Definizione periferica seriale del Modulo BLE ELETT114A -Serial myBLE(PA_9, PA_10, 9600); //Tx, Rx, bps - - -// User Button, LED -DigitalIn myButton(USER_BUTTON); // pulsante Blu sulla scheda. Associato a PC_13 -DigitalOut myLed(LED2); // LED verde sulla scheda. Associato a PA_5 - -// Output per pilotaggio di un motore PWM -PwmOut OutPWM (PB_8); - -// Output Open Drain No Pull -DigitalInOut SwitchRouter (PB_9, PIN_OUTPUT, OpenDrain, 0); - -// digital Out di Prova -DigitalOut Prova (PA_6); - -/**********/ -/* MAIN */ -/**********/ -int main() -{ - - // messaggio di benvenuto - pc.printf("\r\n************ Hallo ************** \r\n"); - pc.printf("*********** Test PWM *************\r\n"); - - // out di prova - Prova = 1; - // inizializza OpenDrain - SwitchRouter.mode(PullNone); - - // inizializza il PWM - OutPWM.period_ms(50); // periodo del PWM - OutPWM.write(0.0); // inizializza duty cycle del PWM - - // Ciclo principale - while(true) - { - // accende il motore se è premuto lo User Button - if(myButton == 0) - { - // accendi LED su scheda - myLed = 1; - // regola velocità del motore modificando duty cycle del PWM - OutPWM.write(0.4); // velocità massima = 1.0 - - // accendi/spegni il router - SwitchRouter = 1; - } - else - { - // spegni LED su scheda - myLed = 0; - // ferma il PWM - OutPWM.write(0.0); // motore fermo = 0.0 - // disattiva l'OpenDrainper il Router - SwitchRouter = 0; - } // if(myButton==0) - } // while(true) Principale -} \ No newline at end of file