Curkovic projekt TVZ2021

Dependencies:   mbed SeeedShieldBot BluetoothSerial

Files at this revision

API Documentation at this revision

Comitter:
chule
Date:
Thu May 05 19:10:43 2022 +0000
Commit message:
.

Changed in this revision

Blink.cpp Show annotated file Show diff for this revision Revisions of this file
Blink.h Show annotated file Show diff for this revision Revisions of this file
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
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/Blink.cpp	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,20 @@
+#include "Blink.h"
+#include "mbed.h"
+ 
+LED::LED(PinName pin) : _pin(pin)
+{
+    _pin = 0;
+}
+ 
+//Metoda kako se određuje stanje LED
+void LED::status(int status)
+{
+    _pin = status;
+}
+ 
+//Metoda koja mijenja stanje na LED
+void LED::flip()
+{
+    _pin = !_pin;
+}
+            
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Blink.h	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,16 @@
+#ifndef MBED_LED_H
+#define MBED_LED_H
+#include "mbed.h"
+ 
+//Klasa za LED koja odreduje funkcije za promjenu stanja
+class LED
+{
+public:
+    LED(PinName pin);
+    void status(int status);
+    void flip();
+private:
+    DigitalOut _pin;
+};
+#endif
+     
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BluetoothSerial.lib	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yihui/code/BluetoothSerial/#f56002898ee8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SeeedShieldBot.lib	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/components/code/SeeedShieldBot/#9fd1722259a1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,142 @@
+#include "mbed.h"
+#include "Blink.h"
+//Definiranje ulaza
+InterruptIn button(USER_BUTTON);
+
+//Definiranje tajmera
+Timer debounce;
+Timer Prekid1;
+Timer Prekid2;
+Ticker flipper;
+
+//Definifanje izlaza
+LED led1(D11);
+LED led2(D12);
+LED led3(D13);
+LED led4(D14);
+LED led5(D15);
+BusOut Seg1(D2,D3,D4,D5,D6,D7,D8,D9);
+
+//Definiranje funkcija
+char SegConvert(int SegValue);
+void Binary (int g);
+void prekid(void);
+
+//Funkcija upravljanja s 7 segmentnim displeom
+char SegConvert(int SegValue) {
+ char SegByte=0x00;
+ switch (SegValue) {
+ case 0 : SegByte = 0x3F;break; 
+ case 1 : SegByte = 0x06;break;
+ case 2 : SegByte = 0x5B;break;
+ case 3 : SegByte = 0x4F;break; 
+ case 4 : SegByte = 0x66;break;
+ case 5 : SegByte = 0x6D;break;
+ case 6 : SegByte = 0x7D;break;
+ case 7 : SegByte = 0x07;break;
+ case 8 : SegByte = 0x7F;break;
+ case 9 : SegByte = 0x6F;break;
+ }
+ return SegByte;
+}
+
+//Funkcija prekida
+void prekid()
+{
+    if(debounce.read_ms()>200){
+        led1.status(0);
+        led2.status(0);
+        led3.status(0);
+        led4.status(0);
+          while(Prekid1.read()<=10){
+             Prekid1.start();
+             Prekid2.start();
+             if(Prekid2.read_ms()>=500)
+             {
+             led1.flip();
+             Prekid2.stop();
+             Prekid2.reset();
+             }
+            }
+        Prekid1.stop();
+        Prekid1.reset();
+        }
+        debounce.reset();
+}
+
+//Funkcija odredivanja stanja LED
+void Binary (int g)
+{   
+    switch (g) {
+        case 0: {
+            break;
+        }
+        case 1: {
+            led1.flip();
+            break;
+        }
+        case 2: {
+            led2.flip();
+            break;
+        }
+        case 3: {
+            led1.flip();
+            led2.flip();
+            break;
+        }
+        case 4: {
+            led3.flip();
+            break;
+        }
+        case 5: {
+            led1.flip();
+            led3.flip();
+            break;
+        }
+        case 6: {
+            led3.flip();
+            led2.flip();
+            break;
+        }
+        case 7: {
+            led1.flip();
+            led2.flip();
+            led3.flip();
+            break;
+        }
+        case 8: {
+            led4.flip();
+            break;
+        }
+         case 9: {
+            led1.flip();
+            led4.flip();
+            break;
+        }
+    }
+}
+
+//funkcija Ticker-a
+void flip(){
+    led5.flip();   
+}
+
+//main funkcija
+int main()
+{
+    debounce.start();
+    button.rise(&prekid);  
+    flipper.attach(&flip,0.2);
+    int i;
+    while(1){
+        for (i=0;i<10;i++){
+        led1.status(0);
+        led2.status(0);
+        led3.status(0);
+        led4.status(0);
+        Seg1=SegConvert(i);
+        Binary(i);
+        wait_ms(1000);
+        }        
+    }            
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 05 19:10:43 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file