void setup() { // Generated by Acceleo !! Penser � cr�er les configurations de votre programme ! // Ceci n'est pas generee par acceleo pinMode(MOTOR, OUTPUT); pinMode(OUT3, OUTPUT); CONSOLE.begin(9600); CONSOLE.println(F("setup 0")); getRam(NULL, false); keyboard.begin(KBD_DATA, KBD_CLOCK, MyKeymap_French); pinMode(CHP, OUTPUT); pinMode(RST, OUTPUT); //pinMode(LED, OUTPUT); //ESP.begin(ESP_BAUDS); /* */ CONSOLE.println(F("setup 1")); getRam(NULL, false); init_io(); StateMachine_setup(); }
void loop() { // ca boucle � l'infini #ifdef CONSOLE_PARSER char c = 0; // on donne le char 0 function_value = false; // le function value sert a entrer dans la condition d'apr�s ! if (keyboard.available()) { // ici on prend une commande depuis le clavier et on l'affiche dans le lcd ! c = keyboard.read(); unsigned int k = c; if (k > 65461) { function_key = true; } if (function_key) { function_key = false; if (k != 65475) { function_value = true; char m[4]; int fk = k - 65461; input_kb(fk); // c'est ici que opp�re le truc ! on met les variables � true si le num�ro correspond ! sprintf(m, "F%d", fk); Serial.println(fk); cm++; //if (cm % 10L == 0) { StateMachine_loop(); //} } } } //lcd.lcdWrite(c); //} #endif }
// This is the setup code to initialize the LEDs and begin listening for key input void setup() { // This line initializes the LEDs FastLED.addLeds<WS2811, DATA_PIN>(leds, NUM_LEDS); //This reads a random pin for a better random number generator randomSeed(analogRead(0)); // These lines initialize the keyboard. delay(3000); keyboard.begin(DataPin, IRQpin); Serial.begin(9600); }
void setup() { delay(1000); keyboard.begin(DataPin, IRQpin); Serial.begin(9600); setupDrives(); for (int i = 0; i < noOfDrives; i++){ pinMode(drives[i].data[0], OUTPUT); pinMode(drives[i].data[1], OUTPUT); } for (int i = 0; i < 7; i++){ pinMode(segments[i], OUTPUT); digitalWrite(segments[i], 1); } }
void loop() { /* Main program body below here */ char key; // This checks to see if a key has been pressed, and assigns that value to 'key' variable if (keyboard.available()) { key = keyboard.read(); } clear(); /* clears any led assignment */ // This switch statement will allow me to program 'macros' ie one key = several // actions, or a single activation for an individual letter key press switch (key) { case ('1'): for (count = 0; count < 3; count++) { /* run */ leds[runMacroArray[count]] = CRGB::Ivory; fastShowLED(); } break; case ('2'): for (count = 0; count < 9; count++) { /* right here */ leds[righthereMacroArray[count]] = CRGB::Ivory; fastShowLED(); } break; case ('3'): for (count = 0; count < 10; count++) { /* hello world */ leds[helloworldMacroArray[count]] = CRGB::Ivory; showLED(); } break; case ('4'): for (count = 0; count < 10; count++) { /* trust no one */ leds[trustnooneMacroArray[count]] = CRGB::Ivory; fastShowLED(); } break; case ('5'): for (count = 0; count < 7; count++) { /* onemain */ leds[onemainMacroArray[count]] = CRGB::Ivory; showLED(); } break; case ('6'): for (count = 0; count < 14; count++) { /* stranger things */ leds[strangerMacroArray[count]] = CRGB::Ivory; fastShowLED(); } break; case ('7'): for (count = 0; count < 6; count++) { /* spooky */ leds[spookyMacroArray[count]] = CRGB::Ivory; fastShowLED(); } break; case ('8'): for (count = 0; count < 13; count++) { leds[isthisMacroArray[count]] = CRGB::Ivory; /* is this thing on */ showLED(); } break; case ('9'): for (count = 0; count < 9; count++) { leds[dontblinkMacroArray[count]] = CRGB::Ivory; /* don't blink */ fastShowLED(); } break; case ('0'): for (int snake = 0; snake < NUM_LEDS; snake++) { /* ------- try and figure this out in the morning ------ */ break; } case ('a'): leds[A] = CRGB::Blue; showLED(); break; case ('b'): leds[B] = CRGB::Lime; showLED(); break; case ('c'): leds[C] = CRGB::Orange; showLED(); break; case ('d'): leds[D] = CRGB::Blue; showLED(); break; case ('e'): leds[E] = CRGB::Orange; showLED(); break; case ('f'): leds[F] = CRGB::Lime; showLED(); break; case ('g'): leds[G] = CRGB::Red; showLED(); break; case ('h'): leds[H] = CRGB::Ivory; showLED(); break; case ('i'): leds[I] = CRGB::Orange; showLED(); break; case ('j'): leds[J] = CRGB::Blue; showLED(); break; case ('k'): leds[K] = CRGB::Lime; showLED(); break; case ('l'): leds[L] = CRGB::Red; showLED(); break; case ('m'): leds[M] = CRGB::Orange; showLED(); break; case ('n'): leds[N] = CRGB::Blue; showLED(); break; case ('o'): leds[O] = CRGB::Red; showLED(); break; case ('p'): leds[P] = CRGB::Lime; showLED(); break; case ('q'): leds[Q] = CRGB::Ivory; showLED(); break; case ('r'): leds[R] = CRGB::Lime; showLED(); break; case ('s'): leds[S] = CRGB::Orange; showLED(); break; case ('t'): leds[T] = CRGB::Ivory; showLED(); break; case ('u'): leds[U] = CRGB::Red; showLED(); break; case ('v'): leds[V] = CRGB::Blue; showLED(); break; case ('w'): leds[W] = CRGB::Ivory; showLED(); break; case ('x'): leds[X] = CRGB::Lime; showLED(); break; case ('y'): leds[Y] = CRGB::Red; showLED(); break; case ('z'): leds[Z] = CRGB::Ivory; showLED(); break; default: longLoop++; if (longLoop == 301) { longLoop = 0; leds[H] = CRGB::Yellow; /* come in soft H */ flickerLEDHdim(); for (count = 0; count < 6; count++) { /* help me */ leds[helpmeMacroArray[count]] = CRGB::Ivory; fastShowLED(); } leds[E] = CRGB::Yellow; /* flicker E */ flickerLEDEdim(); break; } else if (longLoop % 31 == 0) { /* else if statement using modulo div */ leds[H] = CRGB::Yellow; flickerLEDHdim(); delay (1000); break; } else { delay (1000); } } }
void loop() { for (int i = 0; i < 3; i++){ // make sure it's fairly bright writeNum(currentDrive); } counter++; expire--; if (expire < 0){ currentChar = NULL; } if (keyboard.available()) { // read the next key char c = keyboard.read(); // change current drive if enter pressed if (c == PS2_ENTER) { currentDrive++; if (currentDrive >= noOfDrives){ currentDrive = 0; } resetDrive(currentDrive); // the current drive cannot be looping } if (c == PS2_DELETE){ currentDrive = 0; for (int i = 0; i < noOfDrives; i++){ resetDrive(i); } } if (c == PS2_TAB) { drives[currentDrive].recording = true; drives[currentDrive].loopCap = 200; // default } if (c == PS2_ESC) { // end loop if (drives[currentDrive].recording == true){ drives[currentDrive].loopCap = drives[currentDrive].currentNote; } } // a char has been pressed! if (c != NULL){ expire = 120; currentChar = c; } } int freq; // get frequency of next note switch(currentChar){ case 'a': freq = 2; break; case 's': freq = 3; break; case 'd': freq = 4; break; case 'f': freq = 5; break; case 'g': freq = 6; break; case 'h': freq = 7; break; case 'j': freq = 8; break; case 'k': freq = 9; break; case 'l': freq = 10; break; case '1': currentDrive = 0; resetDrive(0); break; case '2': currentDrive = 1; resetDrive(1); break; case '3': currentDrive = 2; resetDrive(2); break; case '4': currentDrive = 3; resetDrive(3); break; default: freq = 0; } if (freq != 0){ frame(drives[currentDrive].data, freq); } // recording if (drives[currentDrive].recording){ if (counter % 50 == 0){ // read every 120ms //Serial.print(freq); drives[currentDrive].notes[drives[currentDrive].currentNote] = freq; drives[currentDrive].currentNote++; if (drives[currentDrive].currentNote >= drives[currentDrive].loopCap){ drives[currentDrive].recording = false; // turn recording off drives[currentDrive].currentNote = 0; // reset currentNote drives[currentDrive].looping = true; //Serial.println(); currentDrive++; // increment drive id if (currentDrive >= noOfDrives){ currentDrive = 0; } resetDrive(currentDrive); // the current drive cannot be looping } } } // looping for (int i = 0; i < noOfDrives; i++){ if (drives[i].looping){ // this drive is in loop cycle int driveFreq = drives[i].notes[drives[i].currentNote]; //Serial.println(driveFreq); frame(drives[i].data, driveFreq); if (counter % 50 == 0){ // change note every 120ms drives[i].currentNote++; if (drives[i].currentNote >= drives[i].loopCap){ drives[i].currentNote = 0; // restart loop! } } } } delay(1.8); // 1ms delay for step motor for (int i = 0; i < 7; i++){ // refresh 7 sgement pinMode(segments[i], OUTPUT); digitalWrite(segments[i], 1); } }