Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:6a0ae423caa9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Nov 23 14:45:00 2017 +0000
@@ -0,0 +1,129 @@
+#include "mbed.h"
+DigitalIn bt0(USER_BUTTON);
+DigitalIn bt1(A0);
+DigitalIn bt2(A1);
+BusOut led(D2, D3, D4, D5);
+Timer t;
+int main() {
+ int st = 0;
+ t.start();
+ while(1){
+ if(bt0 == 0){
+ st = 0;
+ }
+ if(bt1 == 0){
+ st = 1;
+ }
+ if(bt2 == 0){
+ st = 2;
+ }
+
+ if (st==0){
+ led =1;
+ wait(0.2);
+ led =2;
+ wait(0.2);
+ led =4;
+ wait(0.2);
+ led =8;
+ wait(0.2);
+ }
+ if (st==1){
+ led =8;
+ wait(0.2);
+ led =4;
+ wait(0.2);
+ led =2;
+ wait(0.2);
+ led =1;
+ wait(0.2);
+ }
+ if (st==2){
+ led =1;
+ wait(0.2);
+ led =3;
+ wait(0.2);
+ led =7;
+ wait(0.2);
+ led =15;
+ wait(0.2);
+ }
+
+ }
+}
+/*
+#include "mbed.h"
+DigitalIn bt0(USER_BUTTON);
+DigitalIn bt1(A0);
+DigitalIn bt2(A1);
+BusOut led(D2, D3, D4, D5);
+Timer t;
+int main() {
+ int st = 0;
+ t.start();
+ while(1){
+ if(bt0 == 0){
+ st = 0;
+ }
+ if(bt1 == 0){
+ st = 1;
+ }
+ if(bt2 == 0){
+ st = 2;
+ }
+
+ if (st==0){
+ if(t.read_ms() <100) {
+ led =1;
+ }
+ else if(t.read_ms() <500) {
+ led =2;
+ }
+ else if(t.read_ms() <800) {
+ led =4;
+ }
+ else if(t.read_ms() <1000) {
+ led =8;
+ }
+ else{
+ t.reset();
+ }
+
+ }
+ if (st==1){
+ if(t.read_ms() <100) {
+ led =8;
+ }
+ else if(t.read_ms() <500) {
+ led =4;
+ }
+ else if(t.read_ms() <800) {
+ led =2;
+ }
+ else if(t.read_ms() <1000) {
+ led =1;
+ }
+ else{
+ t.reset();
+ }
+ }
+ if (st==2){
+ if(t.read_ms() <100) {
+ led =1;
+ }
+ else if(t.read_ms() <500) {
+ led =3;
+ }
+ else if(t.read_ms() <800) {
+ led =7;
+ }
+ else if(t.read_ms() <1000) {
+ led =15;
+ }
+ else{
+ t.reset();
+ }
+ }
+
+ }
+}*/
\ No newline at end of file