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, 08/2016
- // Organization: Department of Computer Science, FEECS,
- // VSB-Technical University of Ostrava, CZ
- //
- // File: Main program for LEDs
- //
- // **************************************************************************
- #include \"mbed.h\"
- /*DigitalOut leds[8] = { PTC0, PTC1, PTC2, PTC3, PTC4, PTC5, PTC7, PTC8 };
- DigitalIn but( PTC9 );*/
- DigitalOut b(PTB2);
- DigitalIn but1( PTC9 );
- DigitalIn but2( PTC10 );
- int main()
- {
- int jas=10;
- bool but1stav=false;
- bool but2stav=false;
- int x=0;
- while(true){
- if(x%5==0){
- but1stav=false;
- but2stav=false;
- }
- if(!but1 && jas!=20 && but1stav==false){
- jas++;
- but1stav=true;
- }
- if(!but2 && jas!=0 && but2stav==false){
- jas--;
- but2stav=true;
- }
- for(int i =0;i<20;i++){
- if(i<jas){
- b=1;
- }
- else{
- b=0;
- }
- wait_ms(1);
- }
- x++;
- }
- /*bool stop=false;
- int delay = 150;
- while(true){
- for(int i=0;i<8;i++){
- if(!but){
- stop=true;
- }
- leds[i] = 1;
- wait_ms(delay);
- leds[i] = 0;
- if(i==7){
- leds[i] = 1;
- }
- }
- while(stop){
- wait_ms(1);
- if(but){
- stop = false;
- }
- }
- for(int i=8;i>0;i--){
- if(!but){
- stop=true;
- }
- leds[i] = 1;
- wait_ms(delay);
- leds[i] = 0;
- }
- leds[0] = 1;
- while(stop){
- wait_ms(1);
- if(but){
- stop = false;
- }
- }
- } */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement