proba

Dependencies:   Light_show_Konstrukcijski_rad

Files at this revision

API Documentation at this revision

Comitter:
mikroupravljaci2021
Date:
Thu Sep 01 09:26:20 2022 +0000
Commit message:
v1.5

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
CONTRIBUTING.md Show annotated file Show diff for this revision Revisions of this file
flasher.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-os.lib Show annotated file Show diff for this revision Revisions of this file
resources/official_armmbed_example_badge.png Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Thu Sep 01 09:26:20 2022 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CONTRIBUTING.md	Thu Sep 01 09:26:20 2022 +0000
@@ -0,0 +1,5 @@
+# Contributing to Mbed OS
+
+Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor.
+
+To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/mbed-os/latest/contributing/index.html).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flasher.lib	Thu Sep 01 09:26:20 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/TVZ2020/code/Light_show_Konstrukcijski_rad/#267171ba1e5b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 01 09:26:20 2022 +0000
@@ -0,0 +1,86 @@
+//REFERENCE/Korišteni dijelovi koda:
+//https://os.mbed.com/handbook/Ticker
+//https://os.mbed.com/handbook/InterruptIn
+//https://os.mbed.com/questions/5979/mbed-1768-Button-input/
+//https://os.mbed.com/users/4180_1/notebook/pushbuttons/
+//https://os.mbed.com/cookbook/Writing-a-Library
+
+#include "mbed.h"
+#include "flasher.h" //library
+
+InterruptIn myButton(USER_BUTTON);
+Flasher led1(D5);
+Flasher led2(D4);
+Flasher led3(D3);
+DigitalOut myled(LED1);
+Ticker blink1;
+InterruptIn button(D6);
+ 
+Flasher::Flasher(PinName pin) : _pin(pin) {
+    _pin = 0;
+}
+ 
+void Flasher::flash(int n) {
+    for(int i=0; i<n*2; i++) {
+        _pin = !_pin;
+        wait(0.2);
+    }
+}
+ 
+volatile bool buttonPressed; //zastavica da je tipkalo pritisnuto
+ 
+void onButtonPush() {
+  if (myButton == 1) {  //potvrda da nije bouncing
+    buttonPressed = true;
+  }
+}
+
+void RADI() //potvrda da program radi ok
+{
+    myled = !myled;
+}
+
+void OFF() //funkcija sve ledice na nulu
+{
+    NVIC_SystemReset();
+}
+
+
+int main () {
+ 
+ blink1.attach(&RADI, 2.0); //ticker
+ 
+ button.mode(PullUp);
+ button.rise(&OFF); //hw interrupt
+
+ int count=0;
+ 
+ myButton.rise(&onButtonPush); // kada pin prelazi in "0" i "1" pozovi funkciju
+ 
+  while (1) {
+ 
+    if (buttonPressed) { //tipkalo pritisnuto
+      count++;
+      buttonPressed = false; //tipkalo reset
+    }
+    //wait_ms(10); 
+    if (count==1)
+        led1.flash(2);
+    else if (count==2){
+        led3.flash(1);
+        led1.flash(1);
+        }
+    else if (count==3){
+        led3.flash(3);
+        led2.flash(2);
+        led1.flash(1);
+        }
+    else if (count==4){
+        led3.flash(0);
+        led2.flash(0);
+        led1.flash(0);
+        count=0;
+        }
+  }
+ 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Sep 01 09:26:20 2022 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
Binary file resources/official_armmbed_example_badge.png has changed