Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a serial barcode scanner and Arduino Uno. I need to configuration..one Correct barcode scanning led on.

my code is

void setup ()
{
Serial.begin (9600);
 pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
   pinMode(5, OUTPUT);
}


void loop ()
{


if(Serial.available())
{
String command =Serial.readStringUntil('
');
Serial.println(command);
if(command =="1010007")
{
digitalWrite(3, HIGH);
digitalWrite(4,LOW);}
else
if(command !="1010007")
{digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(3,LOW);}


}}

im scanning barcode 1010007 it showing serial monitor g???? like this how to fix it

plz help

and i try another code it showing correctly barcode,,,,,i scan 1010007 serial monitor also same 1010007

but led not on...code is below,,,

#include <SoftwareSerial.h>

SoftwareSerial barcode = SoftwareSerial(2, 3, true); // RX, TX 
void setup()
{
 Serial.begin(9600);
 pinMode(3, OUTPUT);

 
 barcode.begin(9600);

 delay(1000);
}

void loop()
{
 if(barcode.available())
 {
   
  char data = barcode.read();
   Serial.write(data);
   
   if(data=="101007")
 {
 digitalWrite(3, HIGH);
 }
}}
    

   

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
352 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...