Skip to content

Instantly share code, notes, and snippets.

@ozturkib
Created December 3, 2020 09:54
Show Gist options
  • Save ozturkib/663f939f09cfa9ede4c77ab81c6adab3 to your computer and use it in GitHub Desktop.
Save ozturkib/663f939f09cfa9ede4c77ab81c6adab3 to your computer and use it in GitHub Desktop.
#include "main.h"
unsigned char LedYak(unsigned char sira, unsigned int yanmaSure);
int main(void)
{
HAL_Init(); // After HAL_Init(), System is running on default HSI clock (16MHz). PLL is disabled. The clock to APB1 bus is 16Mhz (HSI clock).
SystemClock_Config();
// Kodunuz buraya!
/*
Sirasiyla 1, 2, 3, 4 ledlerini 50 ms araliklarla yakiniz
*/
LedYak(1, 50);
LedYak(2, 50);
LedYak(3, 50);
LedYak(4, 50);
}
//#define toplamLedAdeti 4 // preprocessor, on-islem
const unsigned char toplamLedAdeti = 4;
//unsigned char toplamLedAdeti = 4; //kaynak israfi
unsigned char LedYak(unsigned char sira, unsigned int yanmaSure){
/*
Secilen Led sirasina gore ilgili ledin belirtilen sure kadar yakilmasi icin fonksiyon yaziniz.
Giris parametreleri : sira, yanmaSure
sira : [0-4] arasinda bir sayi
yanmaSure : ms cinsinden [0-10000] araliginda bir sayi
Cikis parametreleri : durum
durum : true, false
*/
unsigned char durum = 0;
if(sira <= toplamLedAdeti){
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET);
HAL_Delay(yanmaSure);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET);
durum = 1;
}
return durum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment