# How to establish communication between microcontroller on a bread board and laptop using usb cable?

I want to learn about microcontrollers and use them in some projects. But I do not want to buy an Arduino, although that is what would be easy for doing projects. This creates a problem in programming the microcontroller. Although a programmer can be used, I noticed that many microcontrollers have an SPI. I thought I could use this along with a USB to programming it serially. I may also read the data serially (using shift registers) into the computer. This way, I think, I can establish communication of some sort between the two. But I am not sure if my computer will allow me to write to a USB port without any identifiable device being connected.

I am aware I would have to write some code to make this smooth since, both the microcontroller and the computer have different clock speeds.

• But I do not want to buy an Arduino Why? It is one of the easiest ways to get started. Once you master Arduino you can always switch to something else or make your own setup. In my opinion you're only making your life harder with more chance of failure and giving up. It is much easier to go from something that just works (Arduino) to your own custom solution which needs to have all the details right, details you do not know about yet. Nov 29 '19 at 10:54
• Usually hobbysts use USB-SerialTTL cable with microcontroller and a serial terminal in PC Nov 29 '19 at 10:54
• "This creates a problem in programming the microcontroller." Are you asking about how to flash the MCU or how to establish a MCU -> PC communication as part of the application? Those are very different things. Nov 29 '19 at 12:01
• @VishalDalwadi UART/RS-232 is the simplest way to communicate between MCU and PC. But you really don't want to upload code that way. It is possible through skunky bootloaders but that's needlessly painful and not something I'd recommend anyone to do, least of all beginners. Modern MCUs have in-circuit debuggers for that, from USB to SWD/JTAG. Nov 29 '19 at 12:41
• I started with Arduino because it is fun and quickly develops in us interest and curiosity towards embedded electronics. Which I think is important for a beginner to learn further things 😊 Nov 29 '19 at 13:52

An eg basic Arduino Nano clone from Asia for under $US3 incl shipping gives you a few basic ICs a voltage regulator, a USB to serial interface and some support firmware to allow bootloading from USB. You gain nothing by not starting with a few parts on a board and the bootloader and free environment. Once running you can pursue whatever purist directions that seem good. Struggling with months to achieve what can be done in hours in setting up an Arduino will teach you much, but there are far far far better ways to use the same learning time. I built my first microcontroller system on strip board about 45 years ago!!! Based on a Nat Semi SC/MP. NO O/S, Binary toggle switch program and data input. (No keyboard or keypad initially). LED I/O (yes, we had LEDs :-) ). No assembler (let alone an HLL). Later we graduated to using Baudot code teleprinetrs - that we wrote our own code for. So, yes, I know what you can learn the hard way. Buy an Arduino to start :-). You can learn far far far more quickly by starting with an Arduino and working DOWN once you have it running. Arduino use in no way misses out on ANY computer architecture aspects. You are doing yourself a massively large disservice by not starting with Arduino. Arduino Bootloader: What it does and why use it, & How to turn any appropriate AVR microcontroller IC into an Arduino. An Arduino-less Arduino here and Adding a bootloader with ICSP here and here and here Stack Exchange discussion here What it is and what it does here • I really agree that Arduinos are great. But I also want to somehow want to communicate with it. This medium can then also be used to send the program to and receive output from it. Nov 29 '19 at 12:33 • Why would a newbie want a bootloader for? They are cumbersome and painful to troubleshoot. Just flash the MCU with your favourite ICD, you'll need one for meaningful debugging anyhow. Nov 29 '19 at 12:44 • @VishalDalwadi Why not start off making maximal use of your learning experience and then progress to adding frustration, difficulty and pointless troubleshooting in due course ? :-). | A bootloader is an integral part of most Arduino systems. It is not essential to use An Arduino in that manner BUT it is highly "newbie friendly" & invisible to beginners.See eg here re loading the bootloader from scratch if needs must. Thereafter or with commercially supplied units it operates seamlessly invisibly. Nov 29 '19 at 14:11 • @RussellMcMahon I guess, I will just get an Arduino. Nov 29 '19 at 14:41 • @VishalDalwadi My son did computer science 101. They had him accessing web based data bases in no time. They taught him no fundamentals. I was appalled. Once he saw what he could achieve they drilled down. I was impressed. I did it the hard hard hard way. Don't. Start wity an Arduino. Then burrow ijto the system. As long as you are not one of the generation who has no clues what goes on underneath, and deson't care (and you obviously are not). You will learn faster this way. || For interest, where are you located? I'm in NZ. Nov 29 '19 at 15:02 USB and SPI are completely different and you cannot communicate between your computer and your microcontroller using SPI directly. However in most (to not say all) of the current microcontroller eval boards you will be provided with an UART-to-USB converter, and thus you will be able to communicate with your PC using an UART. • I never said it was impossible but you cannot do it directly without additionnal material. Serial port and USB are differents btw. I don't see in any way how you could bit-bang from SPI to USB. Nov 29 '19 at 11:10 • I think I can use a shift register to make it work. Nov 29 '19 at 12:28 • No, you cannot. Please spend some time understanding these things by working with an existing system of the same purpose. Nov 29 '19 at 13:35 Answer is simple: Serial. Get yourself a UART-USB converter like this, write some code in whatever language you please in order to use a COM port for communication. Done. Don't you worry about clock speeds and bit banging. No need to reivent the wheel. • This amounts to trying to design an Arduino alternative from scratch with no experience of using a correctly built and working one first. Nov 29 '19 at 13:22 • @ChrisStratton sure, but that's what the OP said he wanted to do. " I do not want to buy an Arduino, although that is what would be easy... Nov 29 '19 at 18:16 I noticed that many microcontrollers have an SPI. I thought I could use this along with a USB to programming it serially. These are wildly different protocols, and building your own adapter between them is definitely a project for after you've learned a lot about microcontrollers. On the other hand, you can just buy one: The other approach is to use the dedicated programming interface on the microcontroller, which may be "JTAG" or something like "ST-LINK" for "SWD" parts. That lets you do all sorts of convenient things in a debugger, such as set breakpoints and inspect variables. • Thank you. I guess I start off from here. Nov 29 '19 at 14:43 You need to avoid confusing Arduino the software environment and Arduino hardware. There is nothing unique about the Arduino hardware and they are a very cost-effective way to obtain all the hardware for what you are requesting. You don't have to build any hardware if you don't wish to. I often use Arduino hardware (either Nano or Uno for ~3$) but write the program using AVR-GCC and program the processor using Avrdude and the Arduino boot-loader.