Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:b5d1c04a1e24, committed 2021-12-06
- Comitter:
- racedom
- Date:
- Mon Dec 06 11:39:00 2021 +0000
- Commit message:
- Pomocu programa se upravlja servo motorima pomocu potenciometra ili tipkom koja automatski okrene motore
Changed in this revision
| Motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp Mon Dec 06 11:39:00 2021 +0000
@@ -0,0 +1,15 @@
+#include "Motor.h"
+#include "mbed.h"
+
+Motor :: Motor(PinName pin1, PinName pin2) : A_pin(pin1),P_pin(pin2)
+{
+
+} // Deklaracija klase "Motor"
+int Motor::Control () // Deklaracija funkcije "Control"
+{
+ float Analog; // Funkcija prima vrijednost sa pina i pretvara u "PWM"
+ float PWM; // u rasponu od 900 us do 2100 us
+ Analog = A_pin;
+ PWM = 1200*Analog + 900;
+ return int(PWM); // Vraća se "PWM signal" tipa integer
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.h Mon Dec 06 11:39:00 2021 +0000
@@ -0,0 +1,14 @@
+#ifndef MOTOR // Provjera lib "MOTOR"
+#define MOTOR // Definiranje lib "MOTOR"
+#include "mbed.h"
+
+class Motor // Stvaranje klase Motor
+{
+public:
+ Motor(PinName pin1, PinName pin2); // Konstruktor klase Motor
+ int Control(); // Prototip funkcije "Control" za upravljanje motorom
+private:
+ AnalogIn A_pin; // Varijabla za prosljeđivanje Analog ulaza
+ PwmOut P_pin; // Varijabla za prosljeđivanje PWM ulaza
+};
+#endif // završava definiranje lib "MOTOR"
\ No newline at end of file