PaulS:
if (input == '764025613224')Single quotes are for single characters. Please post a picture of your keyboard, with the ONE key that you pressed to get that single character circled.
Thanks for the info. I'm scanning a barcode, so the "key being pressed" is actually the values of the barcode. I also printed out my own barcodes to make for easier numbers to use. I printed out a barcod numbered 0001, and now in my serial monitor it is output as:
48
48
48
49
19
While the 48 and 49 correspond to the 0 and 1, respectively, I did some research and the 19 at the end is for device control 3, which is a software flow control for transmit off.
When I scan a barcode now, I can see the those numbers on my serial monitor, but then the output pin does not go high. This is what I have now...
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <Usb.h>
#include <hidboot.h>
int pinout1 = 2;
int pinout2 = 5;
int pinout3 = 7;
char* key[40];
USB Usb;
//USBHub Hub(&Usb);
HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);
class KbdRptParser : public KeyboardReportParser
{
virtual void OnKeyDown (uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key);
};
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
uint8_t c = OemToAscii(mod, key);
if (c)
OnKeyPressed(c);
}
/* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key)
{
Serial.println( key );
}
KbdRptParser Prs;
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}
delay( 200 );
Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
delay( 200 );
pinMode(pinout1, OUTPUT); //sets pinout1 = 2 as an output
}
void loop()
{
Usb.Task();
if (key[30] == "4848484919")
{
digitalWrite(pinout1, HIGH);
delay (1000);
digitalWrite(pinout1, LOW);
}
}