This is a recreation of my code im currently unable to access my actual code.
Barcode Reader shield http://arduino.com.au/Arduino-Shields-store.html
const int BeeperPin = 11; // piezo beeper pin
byte serialin; // Serial data read in
byte linefeed=0; // for appending a linfeed so each barcode is on a new line
int Activate = 8;
void setup() // standard arduino setup initializing loop
{
pinMode(BeeperPin, OUTPUT); // initialize Beeper output
Serial.begin(9600); // initialize the serial communication to 9600 baud
Serial.println("Barcode Shield for Arduino v1.01"); // startup title
Serial.println("www.arduino.com.au"); // website address
}
// Note that the barcode is aimed and triggered by a hardware switch
// this hardware switch has been connected to digital pin 8 to activate via code
void loop() // standard arduino loop
{
if (Serial.available()) //signal from PC, problem is it does not register this due to the barcode shield. Works when the shield is disconnected
{
Serial.print("No Signal");
Serial.print("\n\r");
Serial.flush;
digitalWrite(Activate, LOW); //activates the barcode scanner
while (Serial.available()) { // check for data from barcode scanner
serialin = Serial.read(); // read in barcode character at 9600 baud
Serial.write(serialin);
delay(1); // allow 1ms delay for next barcode character to be scanned in
linefeed = 1; // set so that whole barcode has a linefeed appended
}
if (linefeed>0) { // barcode has been full received
linefeed = 0;
tone(BeeperPin,2500,20); // beep at 2.5kHz for 20ms
Serial.print("\n\r"); // send out a linefeed to separate barcodes
}
}
else
{
Serial.print("No Signal");
Serial.print("\n\r");
}
}