Click here to Skip to main content
15,894,182 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
XML
we use barcode reader with usb. Connectig it with aduino(UNO).
 All we want to realizing is next.
 At first, scanning a barcode and its information is save in variable A.
 and send it to the second computer with bluetooth.
 Doing this process several times, and fnally,
 displaying all information in second computer.


 For this, we made two programs.
 One is for senging information with BT, and the other is reading barcode numbers with scanner.

 we wanted to intergrate it, but it is too hard for us.

 please help...!!

 This is specific code..!

 BARCODE SCANNING
#include <liquidcrystal.h>
#include 
 
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <usb.h>
#include <usbhub.h>
#include 
#include <address.h>
#include <hidboot.h>
 
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
 
#define DISPLAY_WIDTH 16
 
// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
 
USB     Usb;
//USBHub     Hub(&Usb);
HIDBoot<hid_protocol_keyboard>    Keyboard(&Usb);
 
class KbdRptParser : public KeyboardReportParser
{
 
protected:
 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) 
{
static uint32_t next_time = 0;      //watchdog
static uint8_t current_cursor = 0;  //tracks current cursor position  
 
    if( millis() > next_time ) {
      lcd.clear();
      current_cursor = 0;
      delay( 5 );  //LCD-specific 
      lcd.setCursor( 0,0 );
    }//if( millis() > next_time ...
 
    next_time = millis() + 200;  //reset watchdog
 
    if( current_cursor++ == ( DISPLAY_WIDTH + 1 )) {  //switch to second line if cursor outside the screen
      lcd.setCursor( 0,1 );
    }
 
    if( (key != 19) && (key != 106))
    {      
      Serial.println( key - 48 );
      lcd.print( key - 48 );
    }
};
 
KbdRptParser Prs;
 
void setup()
{
    Serial.begin( 9600 );
    Serial.println("Start");
 
    if (Usb.Init() == -1) {
        Serial.println("OSC did not start.");
    }
 
    delay( 200 );
 
    Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
    // set up the LCD's number of columns and rows: 
    lcd.begin(DISPLAY_WIDTH, 2);
    lcd.clear();
    lcd.noAutoscroll();
    lcd.print("Ready");
    delay( 200 );
}
 
void loop()
{
  Usb.Task();
}</hid_protocol_keyboard></parsetools.h></hexdump.h></message.h></printhex.h></hidboot.h></address.h></usbhub.h></usb.h></usb_ch9.h></usbhost.h></max3421e.h></avrpins.h></liquidcrystal.h>
Posted
Comments
Sergey Alexandrovich Kryukov 21-Oct-13 0:12am    
Any links to the libraries you are using?
—SA
Member 10348350 21-Oct-13 0:27am    
Thank you for your attention..!!
Member 10348350 21-Oct-13 0:28am    
oh..! library link - Host shield 2.0!!!!!!!!!!!!!!!!!
felis.github.io/USB_Host_Shield_2.0/
Member 10348350 21-Oct-13 0:14am    
and BT communication code is here.
블루투스



#include <softwareserial.h>

SoftwareSerial BTSerial(2, 3 ); //Connect HC-06 TX,RX()
void setup()
{
Serial.begin(9600);
BTSerial.begin(9600);
}
void loop()
{
if (Serial.available())
BTSerial.write(Serial.read());
}

How can I intergrate those two codes...!
Member 10348350 21-Oct-13 0:16am    
if( millis() > next_time ) {
lcd.clear();
current_cursor = 0;
delay( 5 ); //LCD-specific
lcd.setCursor( 0,0 );
}//if( millis() > next_time ...

next_time = millis() + 200; //reset watchdog

if( current_cursor++ == ( DISPLAY_WIDTH + 1 )) { //switch to second line if cursor outside the screen
lcd.setCursor( 0,1 );
}

if( (key != 19) && (key != 106))
{
Serial.println( key - 48 );
lcd.print( key - 48 );
}
};

KbdRptParser Prs;

void setup()
{
Serial.begin( 9600 );
Serial.println("Start");

if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}

delay( 200 );

Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
// set up the LCD's number of columns and rows:
lcd.begin(DISPLAY_WIDTH, 2);
lcd.clear();
lcd.noAutoscroll();
lcd.print("Ready");
delay( 200 );
}

void loop()
{
Usb.Task();
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900