Created
January 22, 2024 23:56
-
-
Save II245/5a2823ee8fc965ed61186f25a284d2e5 to your computer and use it in GitHub Desktop.
pi gpio 7mhz hf signaling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wiringPi.h> | |
#include <stdio.h> | |
#define PIN_NUMBER 0 // Номер GPIO порта, который будет использоваться | |
int main() { | |
if (wiringPiSetup() == -1) { | |
fprintf(stderr, "Не удалось инициализировать WiringPi\n"); | |
return 1; | |
} | |
int pin = PIN_NUMBER; | |
pinMode(pin, OUTPUT); | |
unsigned int frequency = 7000000; // Частота в Гц (7 МГц) | |
unsigned int period = 1000000 / frequency; // Период в микросекундах | |
while (1) { | |
digitalWrite(pin, HIGH); // Установить высокий уровень сигнала | |
delayMicroseconds(period / 2); // Подождать половину периода | |
digitalWrite(pin, LOW); // Установить низкий уровень сигнала | |
delayMicroseconds(period / 2); // Подождать половину периода | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment