5

Wouldn't this be simpler? Note: amended answer increases R1 to 10 k. The 10 k resistor limits current to 0.17 mA. The 3.3 V zener diode clamps the input voltage to 3.3 V (I measured 2.3 V on mine so that is well within spec). The other end of the zener diode goes to the Arduino ground pin. I originally had R1 as 1 k however if you had a high voltage input ...


5

You need: A timer A board that is capable of running fast enough to do what you want. The Nano fits the first criteria, but not the second. At 16MHz you get a clock period of 63ns. That means you get a mere 8 clock ticks (actually gives you 504ns) per interruption from the timer. That's at most 8 assembly instructions that can be executed within that ...


5

LVTTL is Low Voltage Transistor-Transistor Logic. In general, the term "TTL" is used for a digital signal. The "Low Voltage" part is special, the ATmega32U4 switches from low to high (and vice versa) at low voltages. Just as it is written. For example, when the ATmega32U4 runs at 5V, then: VILmax = 0.2 * 5 - 0.1 = 0.9 V. VIHmin = 0.2 * 5 + 0.9 = 1.9 V. ...


4

You're over-stressing the MCU and causing all sorts of horrible things to happen with the power rails. Of course nasty things are going to happen. The only way to fix it is to change the circuitry. Something as simple as adding a 1kΩ resistor in series with each of the input connections could be enough to sort it out.


4

There is no difference between a switch and a "pin" for input. All are either HIGH or LOW. You tie it HIGH with the pullup, and then try giving it a HIGH with +5V (Caution: The Due is a 3.3V device, not 5V!). At no point do you ever give it a LOW signal (connect the input to GND), so how can it ever read LOW?


3

Note: this is an attempt to answer the question as asked. This answer is unlikely to be of any use to the original poster, who presumably asked the wrong question. I am writing this only as a way to explore the limits on how fast a modest AVR can sample a port. For an answer that genuinely attempts to address the OP’s problem, see Majenko’s answer. I read ...


3

It read a port just like it reads memory (to which it's mapped.) So speed is how fast an instruction can read memory. EEPROM is a different animal. Might get it a little faster by replacing buttonState = digitalRead(buttonPin); with buttonState = PORTB & _BV(buttonPin); Assuming it's PORTB that you are using. This will alleviate at least one ...


3

When I get time, I will provide more definitive answers. I did follow through with this, and the result is here, towards the end of the page: https://dannyelectronics.wordpress.com/2016/05/01/the-price-of-avr-arduino/ the short answer is: digitalRead() takes 4.9us to execute on a 16MIPS Arduino Uno, or 79 ticks (=instructions). the fastest you can read ...


3

Some good results you can get with optocouplers. It's electrically disconnects one part of your circuit from another. For example, here is my IoT-ish device, which is detects water leaks in my bathroom: I use the transformer (T1), which have two separate output windings, so, that windings does not connected electrically, only magnetically. The block in ...


3

After seeing your schematic, I think the general problem here is that you need to more closely read and follow the datasheet for this part. A lot of times, when you are hobbling a project together at a small scale there are a lot of things you can ignore and get away with, but as you scale up, all the rounded corners start to add up. In this case, you can ...


3

No, the ATmegaXXX0 has no analog pins without GPIO capability. Additionally, the ATmegaXX8PB adds GPIO capability to the other analog pins plus a couple of the supply pins, so if you can convince someone to slip one of those on instead then you will gain two GPIOs (a respin will be required to access the ones on supply pins). Note that the core will also ...


2

On https://www.arduino.cc/en/Main/ArduinoBoardNano it says: Analog pins 6 and 7 cannot be used as digital pins. There is no such corresponding statement on https://www.arduino.cc/en/Main/ArduinoBoardMega2560 and judging by the datasheet all of the analog pins can be used as digital pins.


2

Considering an ATMEGA with a 5V VCC we have: LOW = < 0.3*VCC = 0,3*5V = 1.5 V HIGH = > 0.5*VCC = 0,5*5V = 2.5 V You can connect directly to the Arduino if the output of your sensor is higher than 2.5 volts whether current is present or below 1.5 volts if not. This would translate to HIGH or LOW output from digitalRead() function respectively. You ...


2

The logic of your second attempt is perfectly correct. If you put resistors in series with the LEDs you may get more joy out of it. Having two LEDs in parallel without resistors often results in one LED lighting and the other not.


2

You can't put 12 volts into a Uno input pin in any case. You could run it into a voltage divider and divide it down to somewhere on the range 0 to 5 V, and then do an analogRead to see exactly (or almost exactly) what the resulting voltage is. I don't really see where comparators come into it in this particular case. I mean, you could use a comparator to ...


2

When you output HIGH you connect the pin to +5V. When you output LOW you connect the pin to ground. It's called a push-pull interface, and looks like this: When it's set HIGH the p-FET is turned on and the n-FET is turned off. That connects the output direct to VDD. When it's set LOW the p-FET is turned off and the n-FET is turned off. That connects the ...


2

That depends on the frequency your Arduino runs at. It's basically once per iteration of the loop, and that depends on everything that is happening in the loop. You can examine the assembly language output of the compiler (disassemble the .elf file using avr-objdump -h -S <elf file>) and count the number of clock cycles per iteration (the datasheet ...


2

The code shown in my answer to question 18183, “Read RC receiver channels using Interrupt instead of PulseIn”. That answer has code to read four channels of RC PWM. It can easily be adapted to work with eight channels. It has an ISR that runs when selected pins change. It sorts out which channel(s) changed, and stores the value of micros() at each change. ...


2

If you would like to read multiple inputs, you can access port register directly. For 8 bit AVR: DDRA = 0; // set pins A0-A7 as input, modeInpit() in Arduino uint8_t data = PINA; // read all A0-A7 inputs (8 bits) To read more than 8 bits, you need 32 bit ARM based MCU/board like Arduino Due, other Atmel SAM, STM32Fxxx MCU etc. For STM32, there ...


2

Without knowing the encoder in question (which you seem extremely reluctant to disclose for some reason that I have trouble understanding) it is hard to give a good answer. However ... The 8-bit AVR processors can only read 8 bits atomically. This is indeed called a port. The Atmega328P (used in the Uno) organizes its I/O ports as ports B, C and D (I don't ...


2

For this, almost any diode will work. Searching, it turns out that the 1N4148 is a popular ubiquitous choice. But don't go out of your way to obtain this particular diode. Maximum rated forward current has to be higher than whatever current a single pin of the 74HC595 produces. You should turn your thinking around. Consider the nominal high voltage ...


2

You could use a GPIO expander (MCP23017 or similar) which could give you 14 extra pins (16-2 for I2C bus), but this is putting extra load on the microprocessor. (you haven't said which one by the way). Or another option might be to revisit you design and see if you can split it out to multiple processors. This is effectively the same as a GPIO Expander, ...


2

What you are trying to do is perfectly safe. In fact, you reading PINC will have no effect whatsoever on the input circuitry. You are just reading an I/O register and, whether you read it or not, this register is updated on every clock cycle from a set of comparators that monitor the pin voltages. Just for completeness, I should mention that it is possible ...


2

One common misconceptions is that the current limit of a GPIO pin applies to inputs. It does not. The 40mA "maximum sink" is only applicable when the pin is set to OUTPUT and is driven LOW - at which point the pin is connected to ground through a MOSFET. Read: What Exactly is a GPIO Pin? However, when the pin is in INPUT mode it is high impedance. This ...


2

Any time you have the same sequence of code repeated over and over with slight variations, that is a "code smell" (an indication that you may be using the wrong approach.) You should use arrays of pin numbers as you have in the first couple of commented-out lines, and write code that loops through those arrays, as well as functions that take ...


1

I expect the problem is in the circuit. To be sure, put a serial print statement directly after reading the inputs, to be sure the input values are read correctly. See the remark of using INPUT or INPUT_PULLUP from Jot below. The following is just a more compact way of writing your loop (and does not fix your problem): void process(int pin, char* text) { ...


1

In general, most embedded processors multiplex external pins into specialized internal circuits. Circuits which check standard fixed threshold crossings (digital inputs), circuits which check variable threshold crossings (comparators) and circuit which combine comparators with a variable settable reference (analog to digital converter) to name only three. ...


1

From the official Arduino site, See DigitalWrite : If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. The exact definitions can be found here for reading a signal: Constants When reading or writing to a digital pin there are only two ...


1

When the function blinkLED() is triggered, there is this delay,.. does the whole loop()-function wait, too? Yes, when you call a function it doesn't return until it is done, and delay is blocking. You can rewrite a bit like this: int ledPin = 13; int pin[] = {A0, A1, A2, A3}; int cc[] = {20, 21, 22, 23}; int potiValues[] = {...


Only top voted, non community-wiki answers of a minimum length are eligible