diff --git a/C++/Arduino/rubberducky/rubberducky.ino b/C++/Arduino/rubberducky/rubberducky.ino new file mode 100644 index 0000000..cd1a8a6 --- /dev/null +++ b/C++/Arduino/rubberducky/rubberducky.ino @@ -0,0 +1,25 @@ +#include +#include + +void setup() { + Keyboard.begin(); + Mouse.begin(); + + delay(1000); + + Keyboard.press(KEY_LEFT_GUI); + Keyboard.press('r'); + Keyboard.releaseAll(); + delay(100); + Keyboard.print("cmd"); + Keyboard.press(KEY_RETURN); + Keyboard.releaseAll(); + delay(100); + + Keyboard.print("tree"); + Keyboard.press(KEY_RETURN); + Keyboard.releaseAll(); +} + +void loop() {} + diff --git a/C++/Arduino/transmitter/transmitter.ino b/C++/Arduino/transmitter/transmitter.ino new file mode 100644 index 0000000..642a754 --- /dev/null +++ b/C++/Arduino/transmitter/transmitter.ino @@ -0,0 +1,49 @@ +uint32_t pwmPin = 8; +uint32_t maxDutyCount = 2; +uint32_t clkAFreq = 34000000ul; +uint32_t pwmFreq = 34000000ul; + +uint32_t channel; + +void setup() { + pinMode(13, OUTPUT); + digitalWrite(13, 0); + pmc_enable_periph_clk(PWM_INTERFACE_ID); + PWMC_ConfigureClocks(clkAFreq, 0, VARIANT_MCK); + + PIO_Configure( + g_APinDescription[pwmPin].pPort, + g_APinDescription[pwmPin].ulPinType, + g_APinDescription[pwmPin].ulPin, + g_APinDescription[pwmPin].ulPinConfiguration); + + channel = g_APinDescription[pwmPin].ulPWMChannel; + PWMC_ConfigureChannel(PWM_INTERFACE, channel , pwmFreq, 0, 0); + PWMC_SetPeriod(PWM_INTERFACE, channel, maxDutyCount); + PWMC_EnableChannel(PWM_INTERFACE, channel); + PWMC_SetDutyCycle(PWM_INTERFACE, channel, 1); + digitalWrite(13, 1); +} + +void loop() { + note(200, 300); // 300Hz for 3000ms + + + delay(200); +} + +void note(int duration, int f) { + int del = (1000000 / f) / 2; + int c = (duration * 1000) / del; + bool x = true; + for (long i = 0; i < c; i++) { + if (x) { + PWMC_SetDutyCycle(PWM_INTERFACE, channel, 1); + } + else { + PWMC_SetDutyCycle(PWM_INTERFACE, channel, 0); + } + delayMicroseconds(del); + x = !x; + } +}