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: Main program for LEDs
- //
- // ************************************************************************
- #include "mbed.h"
- #include <vector>
- // Serial line for printf output
- Serial g_pc(USBTX, USBRX);
- // LEDs on K64F-KIT - instances of class DigitalOut
- // Button on K64F-KIT - instance of class DigitalIn
- DigitalIn g_but9(PTC9);
- DigitalIn g_but10(PTC10);
- DigitalIn g_but11(PTC11);
- DigitalIn g_but12(PTC12);
- DigitalOut Hled[] = {PTC0,PTC1,PTC2,PTC3,PTC4,PTC5,PTC7,PTC8};
- struct LED{
- public:
- LED(PinName pin):led(pin){};
- void turn_on(){
- led=1;
- };
- void turn_off(){
- led=0;
- };
- int get_brightness(){
- };
- void set_brightness(int value);
- private:
- DigitalOut led;
- int brightness;
- };
- int main()
- {
- // Serial line initialization
- //g_pc.baud(115200);
- int c = 2;
- int k = 2;
- while (1)
- {
- if(g_but9 == 0 && g_but10 == 1 && g_but11 == 1 && g_but12 == 1)
- {
- Hled[0] = 1;
- }
- if(g_but9 == 1 && g_but10 == 0 && g_but11 == 1 && g_but12 == 1)
- {
- Hled[1] = 1;
- Hled[0] = 0;
- }
- if(!g_but11)
- {
- Hled[0] = 0;
- }
- if(!g_but11)
- {
- if(c % 2 == 0)
- {
- for(int i = 0; i<=8;i++)
- {
- Hled[i] = 1;
- }
- }
- else
- {
- for(int i = 0; i<=8;i++)
- {
- Hled[i] = 0;
- }
- }
- c++;
- }
- if(!g_but12)
- {
- if(k % 2 == 0)
- {
- for(int i = 0; i<=8;i = i + 2)
- {
- Hled[i] = 1;
- }
- }
- else
- {
- for(int i = 0; i<=8;i++)
- {
- Hled[i] = 0;
- }
- }
- k++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement