make public

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
BertieHarte
Date:
Fri Mar 26 10:18:53 2021 +0000
Commit message:
make public

Changed in this revision

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 285ec045aa05 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 26 10:18:53 2021 +0000
@@ -0,0 +1,38 @@
+// Write a program to toggle the LEDs every 1 second on the application board in the following order repeatedly. 
+// GREEN  -> RED  -> BLUE  -> ALL OFF 
+#include "mbed.h"
+
+DigitalOut R(p23); //Red pin of RGB LED
+DigitalOut G(p24); //Green pin of RGB LED
+DigitalOut B(p25); //Blue pin of RGB LED
+int t = 1; // initialise a variable of type int, as a time, 1 sec.
+//*NOTE THE RGB LED on the application board is "0" for on, "1" for off * NOTE //      
+void r(){ // led function red on
+       R = 0, G = B = 1;
+       wait(t); // takes the value from the int above - makes system wide change easier as changing the value in int t will apply to all fucntions.
+   }
+void g(){ // led function green on
+       G = 0, R = B = 1;
+       wait (t);
+   }
+   
+void b(){ // led function blue on
+       B = 0, R = G = 1;
+       wait (t);  
+   }
+   
+   void o(){ // led function all off
+       B =  R = G = 1;
+       wait (t);  
+   }
+int main() { // main program, will use this to call up the led functions.
+    R = G = B = 1; // init led to off on start up
+
+    while(1) { // do forever 
+      g(); // call the colour functions in the order specified in the question.
+      r();
+      b();
+      o();
+                
+    }
+}
diff -r 000000000000 -r 285ec045aa05 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 26 10:18:53 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file