blinks various LED when pushing a button. no external components needed.

Dependencies:   max32630fthr

Committer:
davidanasco
Date:
Wed Jul 14 06:13:34 2021 +0000
Revision:
0:c2dd4b719b00
Child:
1:2b22aebf8622
publish. done code. yet for debug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davidanasco 0:c2dd4b719b00 1 #include "mbed.h"
davidanasco 0:c2dd4b719b00 2 #include "max32630fthr.h"
davidanasco 0:c2dd4b719b00 3
davidanasco 0:c2dd4b719b00 4 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
davidanasco 0:c2dd4b719b00 5
davidanasco 0:c2dd4b719b00 6 DigitalOut redLED(LED1);
davidanasco 0:c2dd4b719b00 7 DigitalOut greenLED(LED2);
davidanasco 0:c2dd4b719b00 8 DigitalOut blueLED(LED3);
davidanasco 0:c2dd4b719b00 9 DigitalIn pushButton(P2_3, PullUp);
davidanasco 0:c2dd4b719b00 10
davidanasco 0:c2dd4b719b00 11 int main(){
davidanasco 0:c2dd4b719b00 12 printf("So it has begun...\r\n");
davidanasco 0:c2dd4b719b00 13
davidanasco 0:c2dd4b719b00 14 redLED = LED_OFF;
davidanasco 0:c2dd4b719b00 15 greenLED = LED_OFF;
davidanasco 0:c2dd4b719b00 16 blueLED = LED_OFF;
davidanasco 0:c2dd4b719b00 17 int roundabout = 0;
davidanasco 0:c2dd4b719b00 18 while(1){
davidanasco 0:c2dd4b719b00 19 wait(10);
davidanasco 0:c2dd4b719b00 20
davidanasco 0:c2dd4b719b00 21 if(pushButton==0){
davidanasco 0:c2dd4b719b00 22 roundabout++;
davidanasco 0:c2dd4b719b00 23
davidanasco 0:c2dd4b719b00 24 redLED = LED_OFF;
davidanasco 0:c2dd4b719b00 25 greenLED = LED_OFF;
davidanasco 0:c2dd4b719b00 26 blueLED = LED_OFF;
davidanasco 0:c2dd4b719b00 27
davidanasco 0:c2dd4b719b00 28 switch(roundabout){
davidanasco 0:c2dd4b719b00 29 case 1:
davidanasco 0:c2dd4b719b00 30 redLED = LED_ON;
davidanasco 0:c2dd4b719b00 31 break;
davidanasco 0:c2dd4b719b00 32 case 2:
davidanasco 0:c2dd4b719b00 33 greenLED = LED_ON;
davidanasco 0:c2dd4b719b00 34 break;
davidanasco 0:c2dd4b719b00 35 case 3:
davidanasco 0:c2dd4b719b00 36 blueLED = LED_ON;
davidanasco 0:c2dd4b719b00 37 break;
davidanasco 0:c2dd4b719b00 38 case 4:
davidanasco 0:c2dd4b719b00 39 redLED = LED_ON;
davidanasco 0:c2dd4b719b00 40 greenLED = LED_ON;
davidanasco 0:c2dd4b719b00 41 break;
davidanasco 0:c2dd4b719b00 42 case 5:
davidanasco 0:c2dd4b719b00 43 greenLED = LED_ON;
davidanasco 0:c2dd4b719b00 44 blueLED = LED_ON;
davidanasco 0:c2dd4b719b00 45 case 6:
davidanasco 0:c2dd4b719b00 46 blueLED = LED_ON;
davidanasco 0:c2dd4b719b00 47 redLED = LED_ON;
davidanasco 0:c2dd4b719b00 48 break;
davidanasco 0:c2dd4b719b00 49 case 7:
davidanasco 0:c2dd4b719b00 50 redLED = LED_ON;
davidanasco 0:c2dd4b719b00 51 greenLED = LED_ON;
davidanasco 0:c2dd4b719b00 52 blueLED = LED_ON;
davidanasco 0:c2dd4b719b00 53 break;
davidanasco 0:c2dd4b719b00 54 }
davidanasco 0:c2dd4b719b00 55 }
davidanasco 0:c2dd4b719b00 56 }
davidanasco 0:c2dd4b719b00 57 }