Go Down

Topic: USB Sensor data hacking (Read 646 times) previous topic - next topic

James_OS

Hi all,

I am new to the forums and I hope I am posting in the right place. I am trying to access the data from a USB sensor I am trying to have the data from the device be displayed in a LCD instead of having the device connected to a pc, which means replace the pc with an Arduino, I have the proper commands and through the pc's serial console it works fine but when I have the Arduino send the same command nothing happens, I thought it was because the UNO does not work as a usb host so I got a Due but the same result.

This is my code for the UNO:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int Resetbutton = 13;     // the number of the input pin for resetbutton
int buttonstate = 0;      // the current state of the resetbutton
int response = 0;

void setup()
{
 Serial.begin(9600);
 lcd.begin(16, 2);
 pinMode(9, OUTPUT);
 pinMode(Resetbutton, INPUT);
 digitalWrite(8, HIGH); //Pin 8 for reset need to set it HIGH immediately on boot
 pinMode(8,OUTPUT);
 lcd.setCursor(0,0);
 lcd.print("Starting...");
}

void loop()
{
if(Serial.available())
 {
 digitalWrite(9, HIGH);
 Serial.println("GET");
 delay(1000);
 lcd.clear();
 response = Serial.read();
 lcd.setCursor(0,1);
 lcd.print(response);
 delay(1500);
 lcd.setCursor(0,0);
 lcd.print(response);
 }
else
 {
 lcd.clear();
 lcd.print("Error No Serial");
 }
}

The due uses the same code except that I replace the Serial for SerialUSB, I ended up with the Error no Serial custom message which makes me wonder if the serial is actually being properly opened, the command is sent on a Loop indefinitely to constantly refresh the LCD screen, I tried connecting the UNO to the DUE by having the UNO send the word "TEST" anytime a Serial connection (via usb connection not the TX/RX) is present to test if the problem was with the usb device but still no results, any idea is appreciated. BTW I am using the native usb port on the due.

Go Up