Communicating with USB w/ Uno

I’ve been trying to get my UNO to communicate with my Windows 10 device using open source code for a Braille Display device that originally worked with an Arduino device:

#ifndef SerialCommunication_h
#define SerialCommunication_h

#define Bluetooth_PIN 6

void serialEvent();
uint8_t CheckSerialCommunication();
void SetupSerial();



char inputString[StringBufferSize];         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

// set this to the hardware serial port you wish to use
#define HWSERIAL Serial1

void SerialWriteLine(String);
void SerialReadLine(char *);

void SetupSerial()
{
  Serial.begin(9600);
  //while(!Serial);
  //BT
  pinMode(Bluetooth_PIN, OUTPUT);
  digitalWrite(Bluetooth_PIN, LOW);
  Serial1.begin(9600);
  stringComplete = false;
}

uint8_t CheckSerialCommunication()
{
  SerialReadLine(inputString); 
  if (stringComplete) 
  {
    stringComplete = false;
    return 1;
  }
  return 0;
}

void SerialReadLine(char * buffer)
{
  uint8_t idx = 0;
  char c;

    while (Serial.available() && (idx < StringBufferSize-1))
    {
      c = Serial.read();
      if ((c == '\n')||(c =='\r')) {
        stringComplete = true;
      }
      else
      {
          buffer[idx++] = c;  
      }
      
    }
    buffer[idx] = 0;
}

void SerialWriteLine(String line)
{
    delay(10);
    Serial.println(line);
    delay(10);
    Serial1.println(line);
  
}

void SerialWriteLog(String line)
{
   delay(10);
   Serial.println(line);
   delay(10);
   Serial1.println(line);
  
}

#endif

Unfortunately I’m not with my device but I got an error basically saying that ‘Serial1’ was never declared. I think it could be a placeholder but I’m not too sure. Do I need to change that to my exact USB port name?

Justin

Serial1 is the name of the second hardware serial port. But your Uno only has one hardware serial port, Serial, thus the error. You could use Serial instead, but that port is used for communication with your computer, which includes Serial Monitor and uploads. Connecting anything to the Serial pins (0 and 1) can cause you to no longer be able to upload sketches to your Uno. Serial is also already being used in your sketch, so that is unlikely to be an option.

The alternative is to use the SoftwareSerial library to create a serial port on any pins of your Uno:

Ok, that mightn’t be a problem since one of the hardware ports are used for keyboards which I won’t be using in my project. Could I just remove the Serial1 parts of the code (and obviously in other files where it is referenced) and move on?

I haven't looked closely at the sketch, but if you're not using Serial1 then you could definitely remove that code.

FYI, examples of the Arduino boards that do have Serial1 are the Mega, Leonardo, Micro, Pro Micro, MKR boards. If you were compiling for one of those boards you would not get that error.

Thanks very much for that. I was looking this up for ages and couldn’t get a straight answer anywhere! Just to clarify, is ‘Serial’ the two dedicated pins? Would I be able to use my USB to communicate?

It would be actually more helpful if you linked to whatever it is your are trying to duplicate.

.

Sorry, I thought I had done that already.

https://hackaday.io/project/26331-development-of-a-refreshable-braille-display

The Arduino he uses isn’t similar to mine and could be modified so that could be a problem.

I can't tell where an Arduino of any kind is being used.

Poorly documented. A master thesis project.
SMH.
I still can't find a schematic.
I give up.

I know, it is really badly documented. The reason I’m almost sure it’s an Arduino is because the file extension is .ino.

If I may ask one more question, does the USB on the Uno allow for serial communication?

Under "Files" there schematics and board layouts.
Looks like it uses a Teensy 28 pin board plugged onto the main board as the controller.

Microcontroller
The main controlling unit of the braille device is a microcontroller board based on a 32 bit ARM Cortex-M0+ chip. It features a processor speed of 48 MHz and implements 62KByte Flash, 8KByte RAM, 12 analogue input and output ports, hardware Serial, Serial Peripheral Interface (SPI), I2C and a total of 27 I/O pins. [20]
The Teensy LC is a development board housing the ARM Cortex-M0+ processor chip with all required communication ports and power supply. Therefore this board can be attached through header pins as the main processing unit on the mainboard of the braille display device [21]. As every single dot of the braille display requires an extra port in order to activate it, port expander chips are necessary. Therefore the MCP23017 offers 16 output ports which can be triggered through a two-wire interface via the microcontroller. The current of the outputs and inputs is limited to 25mA. Therefore combining two ports parallel are enough to drive the required motors. [22]

I think it is well documented, with 4 zip files containing a wealth of info, including 4 sets of Eagles files for the electronic boards, and a Thesis describing it all. Including CAD files that I don't have the right software to open.

I didn’t even see that, thanks!
But, the more I look into this, the more I feel this is out of my reach. Custom PCB boards, detailed schematics, and I’m trying to tweak the code to work on my bare Uno. Do you think it is somewhat possible or is it something I may have to give up on?

I would like to see a schematic for the entire thing.
Is that too much to ask????

It seems as if one has to get the PCBs made with the files provided and go on faith that the whole thing works together.

.

justcunn:
I didn’t even see that, thanks!
But, the more I look into this, the more I feel this is out of my reach. Custom PCB boards, detailed schematics, and I’m trying to tweak the code to work on my bare Uno. Do you think it is somewhat possible or is it something I may have to give up on?

My belief is that you need to get exactly what he used and hope it works when you have all the parts made and put together.

To the average person, I can't tell what this device is supposed to do.
I know what he says it is, but I don't work in that field.
So it seems to be more for someone who is more acquainted with devices for the blind or hard of seeing.

"I would like to see a schematic for the entire thing."
They are all there, in the Electronics.zip file.
You will need Eagle from here, try the Free version

[EAGLE | PCB Design And Electrical Schematic Software | Autodesk](http://"EAGLE | PCB Design And Electrical Schematic Software | Autodesk" software|pmt|e|pdv|c|slid|0ruuq7nm|pgrid|37821440599|ptaid|kwd-769821644|&intent="EAGLE+Brand&utm_medium=cpc&utm_source=google&utm_campaign=GGL_EAGLE_US_BR_SEM_EXACT&utm_term=eagle" software&utm_content=s17DN4qBm|pcrid|294276762702|pkw|eagle software|pmt|e|pdv|c|slid|0ruuq7nm|pgrid|37821440599|ptaid|kwd-769821644|&addisttype="g&s_kwcid=AL!8131199977!3!294276762702!e!!g!!eagle" software&gclid="EAIaIQobChMInIWv08Ou5gIVQIFaBR3g4AbpEAAYASABEgJBQ_D_BwE&gclsrc=aw.ds")

Yes, it appears this could be out of my reach for now, which is definitely a bit disappointing as we were to be entering this into a competition, and I’m not too proficient in programming myself.

Sorry, I’m dragging this out, but in what way are hardware and software linked. In the code, it doesn’t seem to be too reliant on hardware and on the surface, looks quite easy to tweak around. I know this probably isn’t the case.

I understand this isn’t your field but I appreciate your help nonetheless.

Yeah, I may have to scrap this, I’m not really proficient in programming completely from scratch.

Sorry for dragging this out again, but would the layout of a PCB affect the software (obviously it does for certain things like port/pin numbers)? The code on the surface looks very adaptable. I also wouldn’t be using half the features in that project.

I understand this isn’t your field, but I appreciate your help nonetheless.

Sorry for the double reply, it wouldn’t show up for me at first.

I wish I can help.
Not something I know much about.

I am not sure entering a competition something that someone else did as a master's thesis would be ethical to do.

justcunn:
is ‘Serial’ the two dedicated pins?

The ATmega328P which is the primary microcontroller on your Uno has one hardware serial port. That serial port is connected to Arduino pins 0 and 1 on the Uno. It is also connected to the USB to TTL serial adapter chip on the Uno, which is in turn connected to the Uno's USB socket.

justcunn:
Would I be able to use my USB to communicate?

I don't know what you mean by that.

justcunn:
If I may ask one more question, does the USB on the Uno allow for serial communication?

The communication between the USB to TTL serial adapter chip on the Uno and the computer is USB communication. However, a virtual serial port is created on the computer, which makes it seem like it is serial communication between the Uno and the computer.