Postepeno paljenje LED dioda pomću potenciometra.

Dependencies:   BluetoothSerial SeeedShieldBot buzzer mbed

Files at this revision

API Documentation at this revision

Comitter:
ndurdevic
Date:
Thu Sep 08 21:59:42 2022 +0000
Commit message:

Changed in this revision

BluetoothSerial.lib Show annotated file Show diff for this revision Revisions of this file
SeeedShieldBot.lib Show annotated file Show diff for this revision Revisions of this file
buzzer.lib Show annotated file Show diff for this revision Revisions of this file
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
diff -r 000000000000 -r 7ff53fefbbf2 BluetoothSerial.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BluetoothSerial.lib	Thu Sep 08 21:59:42 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yihui/code/BluetoothSerial/#f56002898ee8
diff -r 000000000000 -r 7ff53fefbbf2 SeeedShieldBot.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SeeedShieldBot.lib	Thu Sep 08 21:59:42 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/components/code/SeeedShieldBot/#9fd1722259a1
diff -r 000000000000 -r 7ff53fefbbf2 buzzer.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buzzer.lib	Thu Sep 08 21:59:42 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Reniboy/code/buzzer/#622b1d533a1c
diff -r 000000000000 -r 7ff53fefbbf2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 08 21:59:42 2022 +0000
@@ -0,0 +1,92 @@
+#include "buzzer.h"
+#include "mbed.h"
+
+#ifndef MBED_BEEP_H
+#define MBED_BEEP_H
+ 
+#include "mbed.h"
+ 
+namespace mbed {
+class Beep {
+ 
+public:
+ 
+    Beep (D5);
+    
+    void beep (float frekvencija, float trajanje);
+ 
+    void nobeep();
+ 
+private :
+    PwmOut _pwm;
+    Timeout toff;
+};
+ 
+}
+#endif
+         
+ 
+Beep buzzer(D5);    
+DigitalOut red(D4);    
+DigitalOut yellow(D2);   
+DigitalOut green(D3);  
+DigitalOut LED(LED2);   
+ 
+ 
+Serial pc(USBTX, USBRX);  //potenciometar
+ 
+AnalogIn potenciometar(A0);  
+float ADCdata;
+float vrijednost;
+
+ 
+float frekvencija1 = 900;
+float frekvencija2 = 800;  
+float frekvencija3 = 700;
+float frekvencija4 = 600;  
+float trajanje=0.5;
+ 
+void titranje(void);
+void toggle(void);
+ 
+int main()
+{
+    while (1) {
+        vrijednost = potenciometar;
+ 
+        if (vrijednost <=0.2) {
+            while (1) {
+                green = 0;
+                red = 1;
+                yellow = 0;
+                break;
+            }
+        }
+        if (vrijednost >0.2 & vrijednost <=0.5) {
+               green = 0;
+                red = 0;
+                yellow = 1;
+                break;
+        }
+        if (vrijednost >0.5 & vrijednost <=0.8) {
+               green = 1;
+                red = 0;
+                yellow = 0;
+                break;
+        }
+        if (vrijednost >0.8 & vrijednost <1) {
+                 green = 1;
+                red = 1;
+                yellow = 1;
+                break;
+        }
+    }
+}
+ 
+void titranje(void) 
+{
+    yellow = !yellow;
+    red = !red;
+    green=!green; 
+}
+ 
diff -r 000000000000 -r 7ff53fefbbf2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 08 21:59:42 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file