-1

I am not too experienced about the working of arduino but I know that it involves data in computer language ( 0 and 1)

I have an array of 8 switches plus a few extra. As I am unable to (due to some reasons) program it through my pc, I wanted to know if it is possible to manually use switches to send data and program it? (complexity doesn't matter).

If yes, then could you tell me how I could do it (taking into consideration my limited knowledge).

If no then why?

  • Welcome. I'm not understanding your question. What is 'it' you want to program? For programming an Arduino you need a PC. You can use switches without an Arduino, but I also don't understand what you mean with 'send data' (to what?). – Michel Keijzers Oct 23 at 13:17
  • Ok, that sparks the question, why you cannot use a computer. As you are able to get an Arduino, I guess you could also buy other electronic components. If a PC is just too expensive, you could go with a Single Board Computer like the Raspberry Pi. Depending on which Pi board you buy, it costs 10 or 35$. 1 standard USB charger (with over 1.5A), an SD card (which can be bought with an OS on them), cheap USB Keyboard/Mouse combination and any HDMI capable display. And a USB cable for the Arduino of course. Then you are good to go. It is like a full fletched PC, just smaller and not that fast. – chrisl Oct 23 at 18:26
  • @chris Thanks for the suggestion!Well I have been having serious problems with my pc currently such that it won't compile nor interpret any code. That's why I had been looking for an alternative – Vamsi Krishna Oct 24 at 6:01
3

Short answer: If you are unable to program your Arduino using a computer, you are unable to program your Arduino at all.

The Arudino is built to be programmed using a serial interface (usually USB) that interacts with the bootloader, plus an IDE on the other end of the cable. It is not set up to be programmed with switches.

You could conceivably build an Arduino programmer that would let you enter a program using 8 switches plus an enter button. Such a programmer would collect the program into a memory buffer, and then load it into the Arduino using the USB interface but it would take WEEKS of working constantly to enter the simplest of programs, and the odds that you could do it without multiple errors is pretty much zero. Plus, it would probably cost several hundred dollars to build such a programmer. It would be a pointless exercise in masochism.

(Not to mention the fact that you would have to somehow compile your Arduino program into machine code, and convert that into binary in order to enter it.)

Some of the earliest computers required that the operator enter the first few instructions via switches as you describe, and then the computer would read and begin executing the rest of its program from a tape drive. Those computers only had a few thousand bytes of memory, and even then, the instructions the operator had to enter were just enough to start the machine booting from tape.

| improve this answer | |
  • The First Arduino had a "serial" port and the more recent have a serial USB interface. So to be correct, the Arduino is programmed with a serial interface. – Mats Karlsson Oct 23 at 16:32
  • 1
    @MatsKarlsson, thanks for the correction. I edited my answer accordingly. – Duncan C Oct 23 at 17:11
2

While not physically impossible it would be a really silly thing to attempt.

However, if I were to attempt it I'd probably use just 3 switches (or rather 2 switches and one button though you could use a switch instead of the button).

I'd wire it up so that the RESET, MISO and SCK pins were all connected to the switches in such a way that I could hold the whole board in RESET for extended periods (i.e., switch between RESET and GND), set a HIGH or a LOW as needed on the MISO pin, and toggle the SCK pin HIGH and LOW (I'm not sure off hand if you need to idle LOW or HIGH with the clock - the datasheet will tell you).

Then I'd become extremely intimate with the ICSP protocol of the ATMega328P.

That would then allow me, extremely slowly, to act like a hardware programmer and instruct the ATMega328P to program itself with data I sent.

You might also like to attach a shift register to the MOSI and SCK pins with 8 LEDs on it so you can monitor the responses from the Arduino while programming.

It would take forever to upload even the simplest of programs, and the error rate would be far to high, but it could be done if you were really desperate and had nothing else to do (including eat or sleep) for a number of days.

| improve this answer | |
  • Oh..thanks a lot!Atleast now I am getting to know the internal workings of the arduino a bit...But of course I won't attempt it – Vamsi Krishna Oct 23 at 14:52
  • Oh wow. That's going really primitive. You'd need debounced switches though. I wonder how many KB of data you'd need to send through the serial interface in order to enter a trivial program like "blink"? Not to mention the work to hand-compile the code, and then map the program into the data-stream needed to program it. – Duncan C Oct 23 at 14:57
  • @DuncanC Yep. Physically possible. Emotionally possible? Nah. You would need to be really really desperate for something to occupy your time, plus a coffee IV and colostomy bag... – Majenko Oct 23 at 14:59
  • 1
    @DuncanC: You can write “blink” in assembly in less than ten 16-bit instructions. It wouldn't take too long to assemble it by hand. But then, the overhead of the ICSP protocol may be a lot larger than the program itself... – Edgar Bonet Oct 23 at 15:34
  • 1
    but if you construct a punch card reader to switch the switches ... :-) – Juraj Oct 23 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.