I'm coding for Arduino barcord scanner

I’m on project to operate the barcode scanner.
my problem might be simple or super hard.
I don’t know why this error comment appear.
this comment says that the problme is in the library in my PS3BT.cpp but it is possible that i open that cpp file, modify the wrong point and save? I’m not sure the meaning of the comment.
looking for someone to help me.

C:\Program Files (x86)\Arduino\libraries\USB_Host_Shield_2.0-master\PS3BT.cpp: In member function ‘float PS3BT::getAngle(AngleEnum)’:
C:\Program Files (x86)\Arduino\libraries\USB_Host_Shield_2.0-master\PS3BT.cpp:107: error: ‘atan2f’ was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\USB_Host_Shield_2.0-master\PS3BT.cpp:109: error: ‘atan2f’ was not declared in this scope

My current code is:


Portable barcode scanner. Uses USB HID barcode scanner, Arduino Board, USB Host Shield and HD44780-compatible LCD display

The circuit:

  • LCD RS pin to digital pin 7
  • LCD Enable pin to digital pin 6
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • 10K resistor:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)

#include <hid.h>
#include <hiduniversal.h>

#include <LiquidCrystal.h>
#include <avr/pgmspace.h>

//#include <avrpins.h>
//#include <max3421e.h>
//#include <usbhost.h>
//#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
//#include <address.h>
#include <hidboot.h>
#include <SPI.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);
HIDUniversal Hid(&Usb);

class KbdRptParser : public KeyboardReportParser
void PrintKey(uint8_t mod, uint8_t key);
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)

/* 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 ) {
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 );

Serial.println( (char)key );
lcd.print( (char)key );

KbdRptParser Prs;

void setup()
Serial.begin( 115200 );

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

delay( 200 );

Hid.SetReportParser(0, (HIDReportParser*)&Prs);
// set up the LCD’s number of columns and rows:
lcd.begin(DISPLAY_WIDTH, 2);
delay( 200 );

void loop()

I'm not sure the meaning of the comment.

It says that a call is being made to a function called atan2f() which is not a function that the compiler knows anything about.

but it is possible that i open that cpp file, modify the wrong point and save?

You haven't told us why you edited the cpp file or what changes you made, so I'll agree that it is possible that you did something wrong.

From math.h which is included from Arduino.h:

    The atan2() function computes the principal value of the arc tangent
    of <em>__y / __x</em>, using the signs of both arguments to determine
    the quadrant of the return value.  The returned value is in the range
    [-pi, +pi] radians.
extern double atan2(double __y, double __x) __ATTR_CONST__;
#define atan2f	atan2		/**< The alias for atan2().	*/

Maybe the library was supposed to include Arduino.h or math.h and didn’t.

What barcode scanner are you using?

I’ve used several HID type barcode scanners with a microcontroller.

The barcode scanners I’ve purchased have a cable with a USB connector on one end (to connect with PC) and the end which connects to the scanner looks like a RJ45 connector but it has 10 pins instead of 8.

The connector on my scanners will accept normal 8-pin RJ45 connectors. Used a piece of Cat5 cable with an RJ45 connector to make my own cable to use the scanners with a microcontroller.

I posted some instructions in the comments of the scanner sold by SparkFun.

I’m not sure if making your own cable will be easier than figuring out how to get the scanner to work with the USB shield or not but if anyone is thinking of using a barcode scanner with an Arduino, making their own cable would save them the price of purchasing a USB shield.