Searching for paid help on Teensy CDS cell

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;
}

moderator: moved to the right section

Hi Martin:

Do you have the photocell already connected? If not, I suggest connecting your photocell between ground and Analog0 and a resistor (a good value is around 47k, but it's not critical) between Analog0 and VRef.

Since the photocell readings will jump around a bit, I added a threshold value. When the difference between the last reading and the threshold is exceeded, then printing to LCD stops.

When do you want the initial reading done? i.e., do you want sending keystokes to stop after it changes from an initial value that's read at startup? Or some other way?

Hi,

Thanks for your quick reaction. The photocell I want to use have the following when it’s light the resistant is about 10 to 20Kohm when it’s dark it’s around the 180 to 200Kohm. If the reading before sending the keystrokes is > then 150Kohm and after sending the keystrokes < then 50Kohm (so there is a big significant in readings) I want the script to stop sending keystrokes and freeze the LCD display to show the number between those readings. Or if it’s more easy to do a reading at the beginning of the script and check the readings after each input for values then it’s okay also. like I said earlier I am not a programmer so I hope I say it correctly.

If you agree to rewrite the code for me can you email me what amount you want for it.

Sorry for my bad English but I hope it’s clear.