Skip to content

Instantly share code, notes, and snippets.

@ahmadnafi30
ahmadnafi30 / Lora.h
Created November 3, 2025 08:24
EndNode Code
/*
raw_lora_ultrasonic_ldr_debug.ino
- Raw LoRa (LoRa.h)
- Frequency : 915E6
- Ultrasonic : TRIG -> D4, ECHO -> D5
- LDR : A0 (voltage divider with 10k resistor)
- Payload : "DIST=xxx,LDR=yyy"
- Interval : 10 seconds (non-blocking)
- Logging : detailed engineering debug + runtime stats (every 60s)
- ACK window : listen for downlink up to ackWindowMs after TX (to estimate packet loss)
@ahmadnafi30
ahmadnafi30 / membaca_dir.c
Created November 2, 2025 15:51
Membaca Direktori
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc == 1) {
printf("Usage: %s [directory]\n", *argv);
exit(0);
}
@ahmadnafi30
ahmadnafi30 / membaca.c
Created November 2, 2025 15:50
Membaca File
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *fh;
int ch;
fh = fopen("Praktikum_IX.txt", "r");
if (fh == NULL) {
puts("Can't open that file!");
@ahmadnafi30
ahmadnafi30 / menulis.c
Created November 2, 2025 15:49
Menulis File
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *fh;
fh = fopen("Praktikum_IX.txt", "w");
if (fh == NULL) {
puts("Can't open that file!");
exit(1);
@ahmadnafi30
ahmadnafi30 / first-fit.c
Created October 29, 2025 03:45
firstfit
#include <stdio.h>
// mendefinisikan nilai variabel array maksimum sejumlah 20
#define max 20
int main()
{
// set setiap variabel yang dibutuhkan
int frag[max], ukuranBlok[max], ukuranProses[max], i, j, jmlBlok, jmlProses, temp;
static int alokasiBlok[max], flags[max];
@ahmadnafi30
ahmadnafi30 / bestfit.c
Created October 29, 2025 03:44
bestfit
#include <stdio.h>
// mendefinisikan nilai variabel array maksimum sejumlah 20
#define max 20
void main() {
// set setiap variabel yang dibutuhkan
int frag[max], ukuranBlok[max], ukuranProses[max], i, j, jmlBlok, jmlProses, temp, lowest = 10000;
static int alokasiBlok[max], flags[max];
@ahmadnafi30
ahmadnafi30 / worstfit.c
Created October 29, 2025 03:43
worstfit
#include <stdio.h>
// mendefinisikan nilai variabel array maksimum sejumlah 20
#define max 20
void main() {
// set setiap variabel yang dibutuhkan
int frag[max], ukuranBlok[max], ukuranProses[max], i, j, jmlBlok, jmlProses, temp, highest = 0;
static int alokasiBlok[max], flags[max];
@ahmadnafi30
ahmadnafi30 / deadlock.c
Created October 20, 2025 03:53
Deadlock Program
#include<stdio.h>
#include<stdlib.h>
void print(int x[][10],int n,int m){
int i,j;
for(i=0;i<n;i++){
printf("\n");
for(j=0;j<m;j++){
printf("%d\t",x[i][j]);
}