6 #define TIME_COUNTDOWN 600
11 #define PIN_CABLE_CHECK 2
13 #define PIN_KEY_CLK 3 //IRQ!
14 #define PIN_KEY_DATA 4
20 #define PIN_COIL_LO 10
21 #define PIN_COIL_HI 11
23 #define ADDR_DISPLAY 0x70
25 //////////////////////////////////////////////////////////////////
27 #include <PS2Keyboard.h>
29 //#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
30 #include <Adafruit_GFX.h>
31 #include "Adafruit_LEDBackpack.h"
34 Adafruit_7segment display = Adafruit_7segment();
38 Serial.println("Keyboard Test:");
40 keyboard.begin(PIN_KEY_DATA, PIN_KEY_CLK);
42 display.begin(ADDR_DISPLAY);
44 //display.writeDisplay();
46 pinMode(PIN_LED_R, OUTPUT);
47 pinMode(PIN_LED_G, OUTPUT);
48 pinMode(PIN_LED_B, OUTPUT);
49 pinMode(PIN_COIL_LO, OUTPUT);
50 pinMode(PIN_COIL_HI, OUTPUT);
51 pinMode(PIN_CABLE_CHECK, INPUT_PULLUP);
55 if (keyboard.available()) {
58 char c = keyboard.read();
60 // check for some of the special keys
67 if(digitalRead(PIN_CABLE_CHECK)) c+=16;
68 display.print(c, HEX);
69 display.drawColon(c%2);
70 //display.setBrightness(random(0,15));
71 display.setBrightness(0);
73 display.writeDisplay();
77 analogWrite(PIN_LED_R, random(0,255)); // turn the LED on (HIGH is the voltage level)
78 analogWrite(PIN_LED_G, random(0,255)); // turn the LED on (HIGH is the voltage level)
79 analogWrite(PIN_LED_B, random(0,255)); // turn the LED on (HIGH is the voltage level)
80 digitalWrite(PIN_COIL_HI, HIGH); // turn the LED on (HIGH is the voltage level)
82 digitalWrite(PIN_COIL_LO, HIGH); // turn the LED on (HIGH is the voltage level)
83 digitalWrite(PIN_LED_R, LOW); // turn the LED on (HIGH is the voltage level)
84 digitalWrite(PIN_LED_G, LOW); // turn the LED on (HIGH is the voltage level)
85 digitalWrite(PIN_LED_B, LOW); // turn the LED on (HIGH is the voltage level)
87 delay(random(1,15)); // wait for a second
88 digitalWrite(PIN_COIL_LO, LOW); // turn the LED off by making the voltage LOW
89 digitalWrite(PIN_COIL_HI, LOW); // turn the LED off by making the voltage LOW
92 int d = random(100,1000);
93 for(int i = 0; i < 1000; i++) {
95 digitalWrite(PIN_COIL_LO, HIGH); //digitalWrite(11, HIGH);
96 delayMicroseconds(d/2);
97 digitalWrite(PIN_COIL_LO, LOW); //digitalWrite(11, LOW);
98 delayMicroseconds(d/2);