You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Desired file is opened
myFile = SD.open(FILE_NAME.c_str()); // DEFAULT_FILE_NAME
if (myFile) {
Keyboard.begin();
String line = "";
while (myFile.available()) {
char m = myFile.read();
if (m == '\n'){
Line(line);
line = "";
}
else if((int) m != 13)
{
line += m;
}
}
Line(line);
myFile.close();
} else {
}
Keyboard.end();
}
void Line(String l)
{
int space_1 = l.indexOf(" ");
if (space_1 == -1)
{
Press(l);
}
else if (l.substring(0,space_1) == "STRING")
{
Keyboard.print(l.substring(space_1 + 1));
}
else if (l.substring(0,space_1) == "DELAY")
{
int delaytime = l.substring(space_1 + 1).toInt();
delay(delaytime);
}
else if(l.substring(0,space_1) == "REM"){}
else
{
String remain = l;
I have edited a code for Teensy ++ 2.0
Sorry if I'm using Github wrong, I'm new here.
You should be family with 5 bit binary, but it's simple.
Possibility of up to 32 payloads with filenames like "00000.txt" - "11111.txt"
5 DIP
1 2 3 4 5
16 8 4 2 1
(16+8+4+2+1=31)
If DIP 00001 - File is same.
Remember, DIP SWITCH is PULLUP, so it works in reverse.
On = Off, on the DIP Switch itself.
//CODE:
/*
*/
#include <SPI.h>
#include <SD.h>
#include <string.h>
#include "Keyboard.h"
File myFile;
boolean first = true;
//String DEFAULT_FILE_NAME = "";
//const char* DEFAULT_FILE_NAME = "script.txt";
//char* DEFAULT_FILE_NAME;
// change this to match your SD shield or module;
// Arduino Etihernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// Teensy audio board: pin 10
// Teensy 3.5 & 3.6 on-board: BUILTIN_SDCARD
// Wiz820+SD board: pin 4
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
const int chipSelect = 20;
void setup() {
// Serial.begin(115200);
// Sets the given pins as switches for the dip switches
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
delay(500);
String dip1 = digitalRead(13);
String dip2 = digitalRead(12);
String dip3 = digitalRead(11);
String dip4 = digitalRead(10);
String dip5 = digitalRead(9);
String dipState = String(dip1 + dip2 + dip3 + dip4 + dip5);
String FILE_NAME = String(dipState + ".txt");
delay(100);
// Serial.print(F("DIP: "));
// Serial.println(dipState);
// Serial.print(F("File: "));
// Serial.println(FILE_NAME);
if (!SD.begin(chipSelect)) {
return;
}
// Desired file is opened
myFile = SD.open(FILE_NAME.c_str()); // DEFAULT_FILE_NAME
if (myFile) {
Keyboard.begin();
} else {
}
Keyboard.end();
}
void Line(String l)
{
int space_1 = l.indexOf(" ");
if (space_1 == -1)
{
Press(l);
}
else if (l.substring(0,space_1) == "STRING")
{
Keyboard.print(l.substring(space_1 + 1));
}
else if (l.substring(0,space_1) == "DELAY")
{
int delaytime = l.substring(space_1 + 1).toInt();
delay(delaytime);
}
else if(l.substring(0,space_1) == "REM"){}
else
{
String remain = l;
}
Keyboard.releaseAll();
}
void Press(String b)
{
if(b.length() == 1)
{
char c = b[0];
Keyboard.press(c);
}
else if (b.equals("ENTER"))
{
Keyboard.press(KEY_RETURN);
}
else if (b.equals("CTRL"))
{
Keyboard.press(KEY_LEFT_CTRL);
}
else if (b.equals("SHIFT"))
{
Keyboard.press(KEY_LEFT_SHIFT);
}
else if (b.equals("ALT"))
{
Keyboard.press(KEY_LEFT_ALT);
}
else if (b.equals("GUI"))
{
Keyboard.press(KEY_LEFT_GUI);
}
else if (b.equals("UP") || b.equals("UPARROW"))
{
Keyboard.press(KEY_UP_ARROW);
}
else if (b.equals("DOWN") || b.equals("DOWNARROW"))
{
Keyboard.press(KEY_DOWN_ARROW);
}
else if (b.equals("LEFT") || b.equals("LEFTARROW"))
{
Keyboard.press(KEY_LEFT_ARROW);
}
else if (b.equals("RIGHT") || b.equals("RIGHTARROW"))
{
Keyboard.press(KEY_RIGHT_ARROW);
}
else if (b.equals("DELETE"))
{
Keyboard.press(KEY_DELETE);
}
else if (b.equals("PAGEUP"))
{
Keyboard.press(KEY_PAGE_UP);
}
else if (b.equals("PAGEDOWN"))
{
Keyboard.press(KEY_PAGE_DOWN);
}
else if (b.equals("HOME"))
{
Keyboard.press(KEY_HOME);
}
else if (b.equals("ESC"))
{
Keyboard.press(KEY_ESC);
}
else if (b.equals("INSERT"))
{
Keyboard.press(KEY_INSERT);
}
else if (b.equals("TAB"))
{
Keyboard.press(KEY_TAB);
}
else if (b.equals("END"))
{
Keyboard.press(KEY_END);
}
else if (b.equals("CAPSLOCK"))
{
Keyboard.press(KEY_CAPS_LOCK);
}
else if (b.equals("F1"))
{
Keyboard.press(KEY_F1);
}
else if (b.equals("F2"))
{
Keyboard.press(KEY_F2);
}
else if (b.equals("F3"))
{
Keyboard.press(KEY_F3);
}
else if (b.equals("F4"))
{
Keyboard.press(KEY_F4);
}
else if (b.equals("F5"))
{
Keyboard.press(KEY_F5);
}
else if (b.equals("F6"))
{
Keyboard.press(KEY_F6);
}
else if (b.equals("F7"))
{
Keyboard.press(KEY_F7);
}
else if (b.equals("F8"))
{
Keyboard.press(KEY_F8);
}
else if (b.equals("F9"))
{
Keyboard.press(KEY_F9);
}
else if (b.equals("F10"))
{
Keyboard.press(KEY_F10);
}
else if (b.equals("F11"))
{
Keyboard.press(KEY_F11);
}
else if (b.equals("F12"))
{
Keyboard.press(KEY_F12);
}
}
void loop() {
// nothing happens after setup
}
// CODE END
Or DL here: https://www.adrive.com/public/wN9grt/TeensyPlusPlus2.0_5DIP_Duckduino-microSD.ino
The text was updated successfully, but these errors were encountered: