Hello,
I am looking for paid help on the following: I am using a Teensy board to emulate keyboard strokes, once programmed if I put the Teensy in a USB port it sends automatically the numbers 0000 till 9999, this is working fine. Also attached to it is an LCD which displays the what is send at that moment. What I am looking for is attaching a photoresistor CDS cell to the Teensy board that after sending a keystroke checks if the resistance of the cell has changed , once it’s changed the sending of the keystrokes has to stop and the last send number needs to be displayed in the LCD display. Attached the code what I am using right now, this code is downloaded from the internet and copied/pasted into here.
I am not a programmer nor I want to be one so that’s why I am posting this over here.
Martin
USED CODE:
#include <usb_keyboard.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(23, 22, 16, 15, 14, 13);
const int ledPin = 13; // choose the pin for the LED
int counter = 0;
int fakecounter = counter;
char pin = “xxxx”;
void setup() {
lcd.begin(16, 2);
lcd.print(“CODE INPUT”);
pinMode(ledPin, OUTPUT); // declare LED as output
delay(10000);
}
void loop() {
keyboard_modifier_keys = 0;
if (counter <= 9999) {
delay(8000);
digitalWrite(ledPin, LOW);
delay(5500);
digitalWrite(ledPin, HIGH);
sprintf(pin, “%04d”, fakecounter);
//sending first digit
Keyboard.press(pin[0]);
delay(450);
Keyboard.release(pin[0]);
delay(420);
//sending second digit
Keyboard.press(pin[1]);
delay(398);
Keyboard.release(pin[1]);
delay(510);
//sending third digit
Keyboard.press(pin[2]);
delay(421);
Keyboard.release(pin[2]);
delay(423);
//sending forth digit
Keyboard.press(pin[3]);
delay(430);
Keyboard.release(pin[3]);
delay(525);
//sending enter
Keyboard.press(KEY_ENTER);
delay(305);
Keyboard.release(KEY_ENTER);
lcd.setCursor(0, 1);
lcd.print(pin[0]);
lcd.setCursor(1, 1);
lcd.print(pin[1]);
lcd.setCursor(2, 1);
lcd.print(pin[2]);
lcd.setCursor(3, 1);
lcd.print(pin[3]);
}
//reached 4 digit PIN max value
if (counter > 9999) {
for (int blinkies = 0; blinkies < 8; blinkies++) {
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(200);
}
delay(6000);
}
++counter;
fakecounter = counter;
}