This gist was automatically pasted at the request of the code author or one of the discord server helpers. If you have any suggestions or bugs to report, you can do so on our GitHub repository, or in our discord server. This project is run by volunteers so feel free to fork and commit your changes then open a pull request!
Created
January 6, 2021 05:18
-
-
Save ArduinoDiscordBot/8250a25d86f152912aa4157396f3a0b4 to your computer and use it in GitHub Desktop.
Code by Jaewon#0001 - Wed Jan 06 2021 05:18:58 GMT+0000 (Coordinated Universal Time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(9600); //initialize the serial transmition | |
Scanner.begin(9600); // set the data rate for the SoftwareSerial port | |
//pins as output | |
pinMode(led1Pin, OUTPUT); | |
pinMode(led2Pin, OUTPUT); | |
pinMode(led3Pin, OUTPUT); | |
pinMode(led4Pin, OUTPUT); | |
} | |
void loop() { | |
//=======Read the gm65 scanner========================== | |
while (Scanner.available() > 0) { | |
scanBuffer[i] = char(Scanner.read()); | |
Serial.print(scanBuffer[i]); | |
if(scanBuffer[i]==barCode1[i]) correct[0]++; //compare with the barcodes | |
if(scanBuffer[i]==barCode2[i]) correct[1]++; | |
if(scanBuffer[i]==barCode3[i]) correct[2]++; | |
if(scanBuffer[i]==barCode4[i]) correct[3]++; | |
i++; | |
} | |
if(i==BUFFER_LEN){ | |
Serial.println(" "); | |
Serial.print("BUFFER_LEN= "); Serial.println(i); | |
if(correct[0]==BUFFER_LEN){ | |
Serial.println("Barcode 1 read"); | |
digitalWrite(led1Pin, HIGH); | |
digitalWrite(led2Pin, LOW); | |
digitalWrite(led3Pin, LOW); | |
digitalWrite(led4Pin, LOW); | |
} | |
else if(correct[1]==BUFFER_LEN){ | |
Serial.println("Barcode 2 read"); | |
digitalWrite(led2Pin, HIGH); | |
digitalWrite(led1Pin, LOW); | |
digitalWrite(led3Pin, LOW); | |
digitalWrite(led4Pin, LOW); | |
} | |
else if(correct[2]==BUFFER_LEN){ | |
Serial.println("Barcode 3 read"); | |
digitalWrite(led3Pin, HIGH); | |
digitalWrite(led2Pin, LOW); | |
digitalWrite(led1Pin, LOW); | |
digitalWrite(led4Pin, LOW); | |
} | |
else if(correct[3]==BUFFER_LEN){ | |
Serial.println("Barcode 4 read"); | |
digitalWrite(led4Pin, HIGH); | |
digitalWrite(led2Pin, LOW); | |
digitalWrite(led3Pin, LOW); | |
digitalWrite(led1Pin, LOW); | |
} | |
resetAll(); | |
} | |
if(i>0){ | |
Serial.println(" "); | |
Serial.print("BUFFER_LEN= "); Serial.println(i); | |
resetAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment