Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // **************************************************************************
- //
- // Demo program for labs
- //
- // Subject: Computer Architectures and Parallel systems
- // Author: Petr Olivka, petr.olivka@vsb.cz, 09/2019
- // Organization: Department of Computer Science, FEECS,
- // VSB-Technical University of Ostrava, CZ
- //
- // File: Demo program
- //
- // **************************************************************************
- #include "mbed.h"
- void demo_leds();
- void demo_lcd();
- void demo_i2c();
- // DO NOT REMOVE OR RENAME FOLLOWING GLOBAL VARIABLES!!
- // Serial line for printf output
- Serial g_pc(USBTX, USBRX);
- // LEDs on K64F-KIT - instances of class DigitalOut
- DigitalOut g_led1(PTA1);
- DigitalOut g_led2(PTA2);
- // Buttons on K64F-KIT - instances of class DigitalIn
- DigitalIn g_but9(PTC9);
- DigitalIn g_but10(PTC10);
- DigitalIn g_but11(PTC11);
- DigitalIn g_but12(PTC12);
- int btn9_Counter = 0;
- int ledCounter;
- int ledBlink = 1000;
- int main()
- {
- // Serial line initialization
- g_pc.baud(115200);
- // uncomment selected demo
- //demo_leds();
- //demo_lcd();
- //demo_i2c();
- g_pc.printf( "Demo program started...\r\n" );
- // ******************************************************************
- // default demo for 2 LEDs and 4 buttons
- //int arr[8] = {PTC0, PTC1, PTC2, PTC3, PTC4, PTC5, PTC6, PTC7};
- while (1)
- {
- ledCounter = (ledCounter + 1) % 1000000;
- g_led2 = !g_led1; // inverse blinking
- wait_ms(1000);
- if (ledCounter % ledCounter == 0){
- g_led1 = !g_led1;
- }
- if (g_but9 == 0)
- {
- btn9_Counter++;
- if (btn9_Counter < 1000){
- ledBlink /= 2;
- }
- }
- else{
- g_led2 = 0;
- btn9_Counter = 0;
- }
- while (!g_but9 || !g_but10 || !g_but11 || !g_but12); // stop blinking
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement