Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can you help me? I am a beginner, I have a small project that I want to realize.
the idea is to be able to connect a barcode reader to Arduino and when I make a scan on a barcode, this code should be displayed on a LCD screen and at the same time should be displayed in a textbox of an application C # on my PC.
When the code is displayed in the textbox it must automatically generates an action to Arduino to open a door.
I do not want to send this code by clicking a button, I want it to be sent automatically when it displayed in textbox.
i want to have an idea about the mechanism how this can be realized. how to communniicate between the PC and the LCD connected to Arduino and how to get the information displayed on this LCD to display it in the textbox? and what kind of data I need to send and receive? Is the communication in real time or i have to program Arduino away from my c# application.
And thank you very much

Where to start....

It sounds like you've never touched an Arduino before. Is this correct?/

First thing you need to do is get a LCD display working with an Arduino. YES, you're going to have to write code for the Arduino to do this. There are examples all over the web that show various ways of doing this. NO, you cannot use C# to do that.

Next, get a solenoid working with the Arduino. Again, you're going to have to write Arduino code to control it. Again, there are examples on the web on how to do this in a variety of ways. Again, you cannot use C# to do this.

The next thing you have to do is get a barcode reader to work with an Arduino. Again, you're going to have to write Arduino code to do this. Again, you cannot use C# to do it.

Then you need to write code for both the Arduino and the PC to talk to each other over a serial connection. This is actually kind of easy. There are tons of examples to do this all over the web.

Once you have all those pieces working, the rest is easy. Your C# code on the PC is just accepting messages from the Arduino, processing the data and sending a command back to the Arduino to tell it to fire the solenoid to "unlock the door".

The command structure is up to you. You define the commands and options and write your code to support those commands.

Now, if you replaced the Arduino with something that DOES run the .NET Microframework, like a Netduino, then you can write C# code for the microcontroller.
Share this answer
In addition to Dave's answer:
0) The desired interaction between your periferals, the arduiono and the PC progam are not clearly definied in your post.
1) The arduino boards are based on Atmel microcontrollers. The arduino project provides you a neat development platform, which you can program in a C++ like language - no hexa :). Based on what you wrote, if you have some C and C# knowledge, it will be not hard to program the arduino. Please note, that arduinos have no hard disk, no operating system, just a bootloader "burned" into the microcontroller. During development you connect the arduino with the PC using a regular USB cable. This provides power to the device, and the program you wrote is simply uploaded to the microcontroller using the same connection from within the IDE.
2) If you buy proper LCD, you will have a library to include in your project and you will have it working in notime. But please note, that the LCD will be a peripheral of the arduino, not of your PC.
3) The barcode scanner can be problematic. There is USB host shild[^]. But you can use the integrated UARTs to communicate with a serial barcode reader. Still, you will need to dig a little bit lower to get it working. Google first in this topic before you buy the scanner. There are also camera based barcode scanner approaches for arduino.
4) The communication between the arduino and your PC is serial. Actually you will see your the arduino on the PC as an additional serial port - both in development and in "production" state.
5) First draft an interaction diagram between your periferals, tha arduino and your pc program. Please remember, that you can't communicate directly with the periferals from the PC just via the arduino. You can implement in c# and in arduino a serial event listener model, where both sides can initiate events (send commands), and can react to events from the other party. You can easily find samples for borth arduino and c#.
Share this answer
Member 10466735 15-Feb-15 4:55am    
Thank you very much for your replay which helped me very much to clarify some ambiguities.
i googled it but i found so much informations which made me confused.
- About the communication between c# and arduino with serial port, i use only com ports which are available on my system device?
- The barcode displayed on LCD can be displayed at the same time in my textbox?
- Can you tell me which is the appropriate barcode reader for this project? can i use the usb barcode which used in supermarkets?
Zoltán Zörgő 15-Feb-15 6:46am    
1) No, as you connect with an USB port to the arduino, you don't need a physical serial port. But you will see it under your devices as a serial port.
2) Of course. If you program your arduino to send it to your program too.
3) No, I can't. There are many suitable. But I suggest you pick one which was already used by somebody and for which you can find connection and programming information on the web.
Member 10466735 15-Feb-15 10:03am    
Zoltán Zörgő , thank you very much for this clarification.
Zoltán Zörgő 15-Feb-15 10:49am    
You are welcome. If you find an answer of real use, feel free to upvote and even accept it.

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