Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Sending serial commands to arduino with existing shield using the RX line on: April 04, 2013, 05:46:40 pm
It was doing it for both, which is why I was asking if it was possible, and if there is a in code method that can be implemented to do receive from both the barcode reader and the PC.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Sending serial commands to arduino with existing shield using the RX line on: April 03, 2013, 03:53:43 pm
This is the actual code that im using for this the previous was just a quick recreation i made as i did not have the code on hand.
This code has been adapted from code provided by the suppliers of the barcode scanner shield

Code:
const int BeeperPin = 11;      // piezo beeper pin
byte serialin; // Serial data read in
byte linefeed=0; // for appending a linfeed so each barcode is on a new line
int Activate = 8;  //Used to activate scanner programically, Active LOW
int pos = 0;
int Trigger = 10;
int ManTrig = 12;
byte Run = 0;


void setup() // standard arduino setup initializing loop
{
  pinMode(Activate,OUTPUT);
  digitalWrite(Activate, HIGH);
  pinMode(Trigger,INPUT);
  pinMode(ManTrig,INPUT);
  pinMode(BeeperPin, OUTPUT);   // initialize Beeper output
  tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms    
  delay(100);
  tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms    
  Serial.begin(9600); // initialize the serial communication to 9600 baud
  Serial.println("Barcode Shield for Arduino v1.02"); // startup title
  Serial.println("www.arduino.com.au"); // website address
  
}

// Note that the barcode is aimed and triggered by a hardware switch
// this hardware switch has been connected to digital pin 8 to activate via code
void loop() // standard arduino loop
{
  if (Serial.available())    // checking for input from PC
  {
    Run = 1;
    Serial.write("Serial Signal");  //sent to PC
    Serial.print("\n\r");
    serialin = Serial.read(); //clears the PC input
  }
  else if (digitalRead(Trigger) == HIGH)
  {
    Run = 1;
    Serial.write("Trigger Signal");  //sent to PC
    Serial.print("\n\r");
  }
  else if (digitalRead(ManTrig) == HIGH)
  {
    Run = 1;
    Serial.write("Manual Signal");  //sent to PC
    Serial.print("\n\r");
    tone(BeeperPin,2000,20); // beep at 2.5kHz for 20ms  
  }
  else
  {
    Run = 0;
  }
  if (Run == 1)
  {


    digitalWrite(Activate, LOW);   //activate scanner
    delay(2000);
    digitalWrite(Activate, HIGH);   //deactivate scanner

    while (Serial.available()) {   // check for data from barcode scanner
      serialin = Serial.read(); // read in barcode character at 9600 baud
      Serial.write(serialin);  //sent to PC
      delay(10); // allow 1ms delay for next barcode character to be scanned in
      linefeed = 1; // set so that whole barcode has a linefeed appended
    }

    if (linefeed>0) { // barcode has been full received
      linefeed = 0;
      tone(BeeperPin,2000,20); // beep at 2.5kHz for 20ms    
      Serial.print("\n\r"); // send out a linefeed to separate barcodes
    }
    delay(1000);
  
}
else
{
Serial.write("No Signal");
Serial.print("\n\r");
}
delay(1000);
}
3  Using Arduino / Interfacing w/ Software on the Computer / Re: Sending serial commands to arduino with existing shield using the RX line on: April 02, 2013, 06:21:54 pm
This is a recreation of my code im currently unable to access my actual code.

Barcode Reader shield     http://arduino.com.au/Arduino-Shields-store.html

Code:
const int BeeperPin = 11;      // piezo beeper pin
byte serialin; // Serial data read in
byte linefeed=0; // for appending a linfeed so each barcode is on a new line
int Activate = 8;
 
void setup() // standard arduino setup initializing loop
{
  pinMode(BeeperPin, OUTPUT);   // initialize Beeper output
  Serial.begin(9600); // initialize the serial communication to 9600 baud
  Serial.println("Barcode Shield for Arduino v1.01"); // startup title
  Serial.println("www.arduino.com.au"); // website address
}

// Note that the barcode is aimed and triggered by a hardware switch
// this hardware switch has been connected to digital pin 8 to activate via code
void loop() // standard arduino loop
{
  if (Serial.available()) //signal from PC, problem is it does not register this due to the barcode shield. Works when the shield is disconnected
  {
    Serial.print("No Signal");
  Serial.print("\n\r");
  Serial.flush;
  digitalWrite(Activate, LOW);  //activates the barcode scanner
 
  while (Serial.available()) {   // check for data from barcode scanner
    serialin = Serial.read(); // read in barcode character at 9600 baud
    Serial.write(serialin);
    delay(1); // allow 1ms delay for next barcode character to be scanned in
    linefeed = 1; // set so that whole barcode has a linefeed appended
  }
 
  if (linefeed>0) { // barcode has been full received
    linefeed = 0;
    tone(BeeperPin,2500,20); // beep at 2.5kHz for 20ms   
    Serial.print("\n\r"); // send out a linefeed to separate barcodes
  }
  }
  else
  {
    Serial.print("No Signal");
  Serial.print("\n\r");
  }
}
4  Using Arduino / Interfacing w/ Software on the Computer / Sending serial commands to arduino with existing shield using the RX line on: April 01, 2013, 10:00:22 pm
Hi guys/girls

For the last few days Ive been trying to interface my Arduino with attached barcode reader shield to my computer. I'm trying to get it to activate the barcode reader remotely via the vb.net program that i have written.
I can receive the data scanned from the barcode reader plus any extra info that i want to send using Serial.write() but when i try to send data to the arduino either using my program or the serial monitor it does not receive it. It does how ever receive the data if the shield is disconnected.

Is there something that disconnects the RX line from the computer when the shield is plugged in and is there some was i can get around this in code?
Or will i have to come up with a physical system which is not a problem to do but I dont want to do this if it is not necessary.

Code waits for a Serial.available() i.e. input from the PC before starting.
Pages: [1]