Rubber Ducky for arduino due
This commit is contained in:
25
C++/Arduino/rubberducky/rubberducky.ino
Normal file
25
C++/Arduino/rubberducky/rubberducky.ino
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <Mouse.h>
|
||||
#include <Keyboard.h>
|
||||
|
||||
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() {}
|
||||
|
||||
49
C++/Arduino/transmitter/transmitter.ino
Normal file
49
C++/Arduino/transmitter/transmitter.ino
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user