I'm a bit of a noob with Arduino's and hoping I can get some advice, please.
I'm wanting to use an Arduino Uno to monitor some logic levels (0 - 5v) of another microcontroller. To keep things simple, I thought I'd be able to use the digital inputs on the Arduino board rather than the analog inputs.
As a test, on the Arduino board I have a wire connected to Digital Input 2 and another wire connected to Ground in the Power section of pins.
Using the code below, I can get the onboard LED to light up on the Arduino whenever the two wires are connected together. When I connect the two wires up to the controller that I want to monitor the logic of, it works perfectly for about 30 seconds until it stops and the ATmega328P gets very hot. If I disconnect everything and let it cool down for a minute, then it will work again correctly until the same thing happens once again.
Obviously I'm doing something wrong here. I've Googled as many terms that I can think of however, I can't see anything relevant. Is my assumption that the digital inputs can handle voltage up to 5v wrong and I have to use the analog inputs instead?
I don't have access to the other microcontroller right at the moment, so I have just been using 3 x AA batteries in series (measured at 4.8 volts) with a switch to simulate the logic behaviour. This configuration is providing the exact same behaviour as when it is connected to the other microcontroller e.g. it works for a little while, lighting up the on-board LED when the switch is pressed / held, before it then stops and the ATmega328P is very hot to the touch.
If I reverse the polarity of the battery pack, then the LED does not light up at all.
Why don't you use the Arduino 5V for input level? Most probably your batteries provide more voltage than your USB connection and the batteries heat the controller. By reversing the battery polarity you may have damaged your controller already. Consider to buy replacement controllers if your board has a socketed controller.
You only provide one signal level to the input pin. Most probably the input level remains high for some time even after the switch goes off. For proper operation the pin also must be dragged low actively, never should be left open. At least add a pulldown resistor (10k) to GND.
Hi,
Why are you putting a negative potential on Pin2 of the UNO?
If you want to simulate a 0 to 5V input pulse, put the switch between gnd and Pin2, forget the battery.
The INPUT_PULLUP in your code will pull Pin2 HIGH when the switch is open and the pin will go LOW when the switch is closed.
You are putting -4V8 on the input, which will overload and probably damage the input protection diodes, and possibly the rest of the chip. That explains the heating. At no point are you putting 0V on the input, so it won't work as you want.
Are you able to suggest how this should be wired using the digital inputs, please? Perhaps it can't be and I need to use the analogue inputs instead?
Using digital inputs is correct. Tom George's reply #6 is the answer you need, I was just explaining the problem more clearly (I hope!). The output of another microcontroller running on 5V would be correct.