Show How to use buttons to control the LEDs on the AZ3166

Files at this revision

API Documentation at this revision

Comitter:
appa
Date:
Wed Feb 03 03:11:34 2021 +0000
Commit message:
Buttons Control LEDs

Changed in this revision

RPinName.h 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
diff -r 000000000000 -r a3c7c4443106 RPinName.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RPinName.h	Wed Feb 03 03:11:34 2021 +0000
@@ -0,0 +1,10 @@
+PinName led1 = PB_2;
+PinName led2 = PA_15;
+PinName led3 = PC_13;
+PinName RedRGB = PB_4;
+PinName GreenRGB = PB_3;
+PinName BlueRGB = PC_7;
+PinName tx = PA_11;
+PinName rx = PA_12;
+PinName Key2 = PA_4;
+PinName Key3 = PA_10;
\ No newline at end of file
diff -r 000000000000 -r a3c7c4443106 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 03 03:11:34 2021 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include "RPinName.h"
+
+// Blinking rate in milliseconds
+#define loopdelay    1000
+#define betweenleds 500
+
+
+int main()
+{
+
+    // Initialise the digital pins for LEDs as an output
+    DigitalOut ledg(led1);  // WiFi or same as LED1
+    DigitalOut ledb(led2);  // Azure
+    DigitalOut ledy(led3);  // User
+    
+    DigitalIn PushButtonA(Key2);
+    DigitalIn PushButtonB(Key3);
+    
+    // Initialise the pulse-width-moudulation for RGB LED
+    PwmOut RGBR(RedRGB);
+    PwmOut RGBG(GreenRGB);
+    PwmOut RGBB(BlueRGB);
+    
+    Serial AZ(tx, rx); // tx, rx
+    
+    PushButtonA.mode(PullUp);
+    PushButtonB.mode(PullUp);
+    
+    while(1) {
+        ledg = !PushButtonA;
+        ledb = !PushButtonB;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a3c7c4443106 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Feb 03 03:11:34 2021 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9