text:
What is the lowest resistance pot that is useful with an analog input?
Background
I've dabbled in electronics since my parents gave me a 150-in-1 kit in the 1970's but never had formal training. My dad repaired Honeywell mainframes so taught me to solder when I was 8. I have a decent set of equipment like irons, parts, meters, etc. and realize I know enough to be dangerous, which is why I avoid mains-powered stuff.  I'm not a newbie but am all too aware of the many holes in my knowledge.  I'm doing this for fun and in a way that allows for failures to be expected, cheap, and educational.
Project
I have a WS2812b LED strip connected to an Arduino Uno and am using various animation libraries to drive it. The goal is to move to a pro mini once the hardware is more settled and use it for creative lighting inside my house or garage.  I started with just the strip and let it display different animations in a sequence based on time but then wanted to attach a button which would advance to the next animation.  After implementing debouncing it worked fine and I moved on to adding a potentiometer to select the speed of the current animation; increasing or decreasing the delay between each 'frame'.  Of interest here is I was using old pots (panel mount not for typical board use - hence I had to solder wires to them just to use them in any configuration) and not doing any ohms law calculations, just hooking up the hardware and tuning the values for mapping the detected voltage to the desired delay by checking printed output from the serial monitor.
I'm happy with the general setup when using a breadboard but when I went to solder something more permanent on perfboard I ran into a problem; the speed control wouldn't work.  I'm sure the first pot I used was 10k but when I checked it with the meter it registered as completely open so I figured I had blown it. Thinking that I needed to control the current I read posts like this one and this one about limiting current I felt better and proceeded to replace the pot with a 25 ohm version thinking that the only difference would be in calibrating the values for mapping the detected voltage to the desired delay.  The behavior I got was randomly fluctuating values for the delay and when I hooked up the prototype using USB to my laptop I could see that the analogread() values were fluctuating wildly within a range even when I wasn't manipulating the pot yet nothing I did could get it to be consistent.  My first thought was that there was a problem with ground so I rechecked the connections but they all tested fine, including still reading 25 ohms along the outside terminals and varying values on the wiper consistent with rotating it along its path from end to end.  When I gave up on my protoboard and returned the circuit back to the breadboard I replaced the full size pot with a 10k small one meant for breadboards and the speed control works again.  This leads to my question.
Question
Is there a minimum value for a potentiometer connected to an analog input of an arduino, or is it more likely that there was an issue with my soldering job on the protoboard?  I don't have a picture of the board because I've already desoldered components from it but I can tell you that it was my first attempt at perfboard soldering and it would not win any prizes, sort of the 'face only a mother could love' sort of thing. If it matters, I was using analog input A2.

if you have all 3 legs connected (vcc, gnd, a2) anything above 100r should work within the current limits of the MCU, though 10k is probably ideal in terms of accuracy and low current draw. 5v into 25r is 200ma; 10X what the MCU wants to provide.

Assuming you wired it correctly (ie. you put the wiper to the analog input) your first setup looked like this:

Your big problem here is the current flow through the pot. Using Ohms Law the current would be:
I = V / R
I = 5 / 25
I = 0.2A  (200 mA)

That is too much to be drawing from the 5V pin and it could easily drag down the voltage to the rest of the board. Also the power would be:
W = I * V
W = 0.2 * 5
W = 1W

One watt is a lot to put through a pot, and you may well have burned the track inside it.

So, if I included a 10k resistor on either side of the pot that should address the current issue but it leaves the question of whether the remaining 25-ohm range is too small for the ADC to register distinct values, ...

The 10k resistor will stop the current problem, but now the range in the voltage divider will be ridiculously small. The setup will now look like this:

Unfortunately the range you are going to read with the analog input is going to be (voltage divider formula):
Vout = Vin * (R2 / (R1 + R2))

With the wiper at one end R1 will be 10000 and R2 will be 10025 and with the wiper at the other end it will be vice-versa. So the voltage you get will be:
Vout = 5 * (10000 / (10025 + 10000))
Vout = 5 * 0.499
Vout = 2.497

Or:
Vout = 5 * (10025 / (10025 + 10000))
Vout = 5 * 0.501
Vout = 2.503

In other words you will always be reading about 2.5V and therefore your analog read will always return around 512, which won't be much use to you.

I'm going with a larger value pot (10k or 25k) ...

That sounds like a sensible value. A 10k pot will only draw:
I = V / R
I = 5 / 10000
I = 0.5 mA

That is a reasonable current draw and the analog input will still read it fine.

As Majenko points out in his answer you don't want a whole lot more than that resistance because of the optimal input impedance of the ADC converter (10k). A very high resistance would mean only a small current would flow into the analog input pin.

How to use your 25 ohm pots
If you want to use your existing 25 ohms pots because of their physical appearance, then a  small resistor in series could reduce the current to a reasonable amount and still give a good reading range. For example, 330 ohms on the "high" side (and nothing between the low side and ground).
Vout = 5 * (330 / (355 + 330))
Vout = 5 * 0.193
Vout = 0.963

Or:
Vout = 5 * (355 / (355 + 330))
Vout = 5 * 0.581
Vout = 2.591

That is now going to give you a reading between 0.96V and 2.59V which, whilst not the full range of 0V to 5V should give you reasonable differentiation as you turn the pot. And the current through it would be:
I = V / R
I = 5 / 355
I = 0.014A (14 mA)

Thus the power would be:
W = I * V
W = 0.014 * 5
W = 0.070 (70 mW)

References

Voltage Dividers tutorial
Ohms Law

That is a such a good and thorough answer @Nick Gammon. Thanks for taking the time!

Most potentiometers take the form of a 3-terminal device, where the two outside terminals are a fixed resistor and the middle terminal adjusts the tap from one extreme to the other.

simulate this circuit – Schematic created using CircuitLab
In this configuration, you end up creating a simple voltage divider. You should pick the potentiometer's voltage such that the fixed portion does not draw more current than necessary, regardless of the tap position. (The arduino's analog input itself does not draw any significant current really.)
If you use a 1k pot, then the current always flowing from 5V to ground is 5mA, which should not tax the Arduino's voltage regulator too much. If you used a 100 ohm pot, then the current would be 50mA -- not likely to damage things, but certainly more than is necessary just to operate a voltage divider.
If you use a 1M-ohm pot, then you are working with 5 micro-Amps, and at that low current, noise from the power supply starts to interfere with your analog readings.
As for your actual setup, it really depends on how you had it wired, etc.

There is no lower limit on the value of a potentiometer that you can use with the Arduino, however the lower the resistance the more current it will pull from the power supply and, if it's too low a resistance and isn't rated for a high enough power, could burn out and catch on fire.
There is, however, an upper limit on the resistance of a potentiometer that you can use.
As a general rule of thumb the output impedance of what you connect to an ADC should be no more than around a tenth of the input impedance of the ADC.  On the Arduino the ADC has around a 1MΩ input impedance, so you shouldn't connect anything with more than around 100kΩ output impedance.
For a potentiometer (well, for any voltage divider) the output impedance is the value of the two halves of the resistance in parallel.  For a 10K potentiometer with the wiper set right in the middle that's 5K for each half, so the formula is:
     R1 * R2   5000 * 5000
Ro = ------- = ----------- = 2500Ω
     R1 + R2   5000 + 5000

As you can imagine that's the maximum output impedance at that point. For example, if you adjust it so it's 9000Ω and 1000Ω it works out as:
     R1 * R2   1000 * 9000
Ro = ------- = ----------- = 900Ω
     R1 + R2   9000 + 9000

So from that you can interpolate that the maximum value potentiometer you can reliably use would have an output impedance of 100kΩ, which is (100000/2500) 40 times more than the 10kΩ one, so 400kΩ is really the maximum you can use.
The main reason for this limit is that the ADC's front-end is a capacitor, and that capacitor has to charge up to the voltage of the input. That charge time is limited by the current available to flow into the pin, and with too high an output impedance the current available is too low and the capacitor can't charge to the right voltage in the limited acquisition time of the ADC.
The datasheet itself speaks of the output impedance limit:

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible.

So they don't recommend anything more than 10kΩ, which equates to a maximum of 40kΩ for the potentiometer's resistance.

The Analog Digital Converter (ADC aka analog input) has only a small capacitance, which has to be loaded to do a measurement. This is normally no problem, even with high resistance potentiometers. Also - if you are using the potentiometer correctly - it is very unlikely, that you have blown it (with 5V supply voltage there is only a current flow of 0.5mA through a 10k potentiometer). The current that flows in the ADC is also very small.
The point in using a potentiometer for providing analog input is, that the total resitance is always the same, regardless of the position. See this schematic:

simulate this circuit – Schematic created using CircuitLab
Both voltage dividers have the same total resistance (10kOhm). If you set the position of the potentiometer to the middle, they have exactly the same output: 2.5V. Moving the slider of the potentiometer is the same as taking some of the resistance from one of the resistors on the right and adding it to the other. So a potentiometer is a variable voltage divider. Normally you want the current, that flows through this voltage divider to be small, because it would be only wasted to heat the resistor strip. If you are using a potentiometer with 25 Ohm total resistance while having a 5V power supply, the current trough it would be 200mA, which is pretty much. And if your power supply cannot give you that much, your application will get really instable.
So I see 2 possible problems:

You used the potentiometer the wrong way, or
You made a soldering mistake

EDIT:
From your comment I read, that you are not familiar enough with the rules, how a voltage divider really works. So I will try to explain a bit more.
A potentiometer looks like this on the inside. It consists of one strip of a resistive material. Each side of the strip is connected to one of the outer pins. The full length of the strip has a constant resistance, say 10kOhm for now. The knob of the potentiometer is connected to a contact, that slides over this resistive strip, making electrical contact with it. When you measure the resistance between one of the outer pins and this middle contact, you get a resistance that is dependent on the position of the contact.
Let's say, we want to measure the resistance between the left contact and the middle contact (the slider). If the slider is very close to the left pin, the resistance we measure is very small, since there is only very few resistive material between the contacts. As we move farer away from the left side of the strip, the measured resistance gets bigger.
At the same time (when we are moving away from the left side of the strip) we are moving towards the right side of the strip, essentially decreasing the resistance between the middle contact and the right side of the strip.
Now we have to do some maths: Ohm's Law states that voltage is resistance multiplied by current
U = R * I

We connect the outer pins of the potentiometer to our 5V power supply and to ground. So U = 5V. And we know the total resistance between these pins: 10 kOhm. To get the current, that flows through our potentiometer, we reform the above formula to
I = U / R

Using the above values we calculate the current through the potentiometer to be 0.5mA. The current through the first part of the resistor strip (say from left to the middle contact) is the same as in the second part (from middle contact to right), as the current has nowhere else to go.
Now we position the middle contact exactly in the middle of the resistive strip. This means that you have half of the total resistance on each side: 5 kOhm. In electrical circuits the voltage is always measured in reference to ground. So here only the ground side matters for the rest of the calculation. We again need Ohm's Law:
U = R * I = 5kOhm * 0.5mA = 2.5V

As we want to read this with an Arduino (which uses a 10 bit ADC --> values in the range of 0 to 1023) we get about 512. (This may vary a bit because of fluctuations and distortion)
When we position the middle contact at the ground end of the resistive strip, we have a ground-side resistance of about 0 Ohm. So we get 0V at the middle pin and a ADC value of about 0.
When we position the middle contact at the 5V end of the resistive strip, we have a ground-side resistance of about 10 kOhm. Using Ohm's Law we get 5V at the middle pin, which translates to an ADC value of about 1023.
Changing the position also changes the ratio of the resistance on ground-side and 5V-side of the strip. But when you (as said in your comment) just add big resistors to both sides of the 25 Ohm potentiometer, you will only we able to control this really small part of the total resistance. So this will not work.
Note: Not every potentiometer has a linear changing resistive strip. Some have a logarithmic or exponential changing strip.

So, if I included a 10k resistor on either side of the pot that should address the current issue but it leaves the question of whether the remaining 25-ohm range is too small for the ADC to register distinct values, or is the ADC still sensitive enough?  I'm going with a larger value pot (10k or 25k) anyway but I'm still interested in understanding what happened when I used the 25r one.


text:
Generating Sinusoid Signal of 40khz
I would like to generate a sinusoidal signal of 40kHz using Arduino Uno.
Maximum I could generate was 1kHz, using bit banging, fast PWM. Do you have ideas of how to boost it to 40kHz?
I used "Advanced Arduino Sound Synthesis" for inspiration. https://makezine.com/projects/make-35/advanced-arduino-sound-synthesis/

What kind of resolution (both amplitude an time resolution) are you wanting?

Sorry, not sure what do you mean by the time resolution, but I am planning to feed the signal into a transmitter and receive it on the other end. I use speakers that work at 40kHz frequency as both transmitter and receiver.

Time resolution: how many samples per second (or samples per sinewave period) do you want?

i mean, based on Nyquist rate, I guess it should be 2*40khz at least. But otherwise, no preference

That would give you a square wave. It depends on what quality you want. Anything less than say 128 samples per period would end up in something more like a triangle wave.

Draw a single period of a sinewave on a piece of paper. Split it into sections by drawing vertical lines. Each line is one sample. How many do you need to draw (subdivide each segment each time) before the points where the lines cross the sinewave look like a sinewave.

i would try to find an opamp-based sine wave generator circuit, then use a digital pot to adjust that. or use an ESP32's DAC...

The purpose of my project now is to develop a lock-in amplifier essentially using only arduino. Thus, I'm trying to stay away from the external hardware

if you don't need to adjust the frequency, a tuned capacitor can turn a square wave into a sine wave.

I tried adding a band pass filter after generating a square wave using arduino and the output seems pretty noisy. Any advice on how to get rid of the noise?

If you don't need to adjust the frequency there are far simpler ways of generating a signal than waveform synthesis.  But before you get too worried about the generation, consider the lock-in itself: are you going to do that in the analog domain?  To do it digitally, you probably want an MCU with a better ADC.

you could use this as a peripheral to the arduino ... https://www.digikey.com/product-detail/en/cypress-semiconductor-corp/CY8CKIT-059/428-3390-ND/5184557 .... here is a tone generator app note ... http://www.cypress.com/documentation/application-notes/an69133-psoc-3-psoc-5lp-easy-waveform-generation-wavedac8-component

@ChrisStratton what MCU would you recommend for that purpose? And what are the simpler ways. Essentially, for my project I need to use as much of Arduino's own hardware as possible, but I can choose any arduino on the market.

You can't really pick a platform without a complete performance requirement.  Sure, if it has to say "Arduino" in soldermask, you could see if the specs of a Due are better in the areas you need - but you won't really know what you need without detailed examination of the requirement.

@Chris Stratton, for this project the only requirement I have is to make use of Arduino as much as possible to essentially assemble a lock-in amplifier. Thus generating a 40khz sinusoid is the first step I have to make. Why 40 kHz? Because I need to use 40kHz speakers(receiver and transmitter) that operate at that frequency

Voting to close as the asker has refused multiple requests to provide any performance specification which could be used to determine if a given method will yield satisfactory results.

Let's first do some maths.

You want 40,000 cycles per second.
Each cycle needs splitting up into samples. For example, let's use 128 samples.
Assume you want an 8-bit amplitude resolution.

Each second of signal would need 40,000 cycles * 128 samples. That's 5120000 samples per second.
If using PWM to generate the audio that's 256 clock cycles (28) per sample. That means 5120000 * 256 = 1,310,720,000.
That means a "carrier frequency" of over 1.3GHz.  There's no way an Arduino can do that.
If instead you used a simple DAC (e.g., an R-2R ladder) connected to the 8 pins of port D (that's pins 0-7 on the Uno) you don't need the 256 clock cycles per sample. That means that you have to output a new sample to PORTD 5,120,000 times per second. That's outputting at over 5MHz.
With some well crafted assembly code that might be possible.  The Arduino certainly won't be able to do anything else at all at the same time.
You would be much better off using a chip that has audio capabilities and DMA. Maybe a Teensy 3.x would be a better choice for your project.

That seems reasonable, I'll research into that. Thanks a lot

You don't need anywhere near 128 samples per cycle; in fact you only need 2. Using so many just makes the analog cleanup filter simpler.

With 2 samples you can only generate a square wave. Yes, you can then add extra circuitry to remove the higher frequency components, but as you say it's more complex. The question is about generating a sinusoid, not generating a square wave and converting it to something close-ish to a sinusoid.

If let's say you decide to take 10 samples per period instead of 180, the sinusoid is still supposed to look decent. But that gives you 1040,000256 = 102MHz clock, but Arduino only has 16MHz clock.

Any number of samples is kind of ludicrous on such a small MCU.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Traffic light light system with sensors
I'm trying to make a traffic light system with a ultrasonic range sensor as well as a light dependant resistor. I'm trying to make it so that the default setting is 2 seconds red light 1 second yellow 2 seconds green then 1 second yellow, this will then repeat until something else happens - I've got this working fine.
Then I want 2 different states.
One where if something comes with 10cm of the sensor then the buzzer will beep and the yellow light must blink on and off 10x with intervals of 0.1ms. When the object moves away it must then return to the default setting.
Secondly I want it when the LDR detects that the light has dropped below a level the red light will turn on and stay on until a object approaches the sensor. When an object is near the sensor it must then turn the red light off and turn the Green light on.
Here is all the code i have so far and i cant figure out why its not working.
Any help would be appreciated
Thanks
    #define ECHOPIN 3
    #define TRIGPIN 2
    float distance;
    long distancecm;

    int RED = 13;
    int YELLOW = 12;
    int GREEN = 11;

    int piezoPin = 8;

    int sensorpin = A0;
    int sensorvalue = 0;

    void setup() {
      pinMode(RED, OUTPUT);
      pinMode(YELLOW, OUTPUT);
      pinMode(GREEN, OUTPUT);
      Serial.begin(9600);
      pinMode(ECHOPIN, INPUT);
      pinMode(TRIGPIN, OUTPUT);
      }

    void distancesensor()
      {
      digitalWrite(TRIGPIN, LOW);
      delayMicroseconds(2);
      digitalWrite(TRIGPIN,HIGH);
      delayMicroseconds(10);
      digitalWrite(TRIGPIN,LOW);
      distance = pulseIn(ECHOPIN, HIGH);
      distancecm = distance/29.1/2;
      if (distancecm <=10);
        for (int j=1; j<=5; j=j+1)
        {
         tone(piezoPin, 1, 500);
         digitalWrite(YELLOW, HIGH);
         delay(100);
         break;
         }
    }

    void lightsensor()
      {
      sensorvalue = analogRead(sensorpin);
      if (sensorvalue > 500)
        digitalWrite(RED,HIGH);
        digitalWrite(TRIGPIN, LOW);
        delayMicroseconds(2);
        digitalWrite(TRIGPIN,HIGH);
        delayMicroseconds(10);
        digitalWrite(TRIGPIN,LOW);
        distance = pulseIn(ECHOPIN, HIGH);
        distance = distance/58;
        while (distance >10)
          digitalWrite(RED,LOW);
          digitalWrite(GREEN,HIGH);
          digitalWrite(TRIGPIN, LOW);
          delayMicroseconds(2);
          digitalWrite(TRIGPIN,HIGH);
          delayMicroseconds(10);
          digitalWrite(TRIGPIN,LOW);
          distance = pulseIn(ECHOPIN, HIGH);
          distance = distance/58;

       }

    void loop() {
      distancesensor;
      lightsensor;
      digitalWrite(RED, HIGH);          //RED ON
      delay(2000);                      //WAIT 2 SECONDS
      digitalWrite(RED, LOW);           //RED OFF
      delay(200);
      distancesensor;
      lightsensor;
      digitalWrite(YELLOW, HIGH);       //YELLOW ON
      delay(1000);                      //WAIT 1 SECOND
      digitalWrite(YELLOW, LOW);        //YELLOW OFF
      delay(200);
      distancesensor;
      lightsensor;
      digitalWrite(GREEN, HIGH);        //GREEN ON
      delay(2000);                      //WAIT 2 SECONDS
      digitalWrite(GREEN, LOW);         //GREEN OFF
      delay(200);
      distancesensor;
      lightsensor;
      digitalWrite(YELLOW, HIGH);       //YELLOW ON
      delay(1000);                      //WAIT 1 SECOND
      digitalWrite(YELLOW, LOW);        //YELLOW OFF
      delay(200);
      distancesensor;
      lightsensor;
      //REPEAT
      }

How is it not working? Describe the problem further? Is it not reacting on your sensors? Do you get a compile error?

Try not to use delay for other things than really simple test code. Instead use non-blocking code like in the BlinkWithoutDelay example of the Arduino IDE. And this kind of project I would program it as a state machine, which also would make things simpler when using non-blocking code

this exact question has been asked before, and i think that it was a different OP,  which tells me that this may be a school assignment. .... is it a school assignment? .... did you write the code?

STATE ALGORITHMS! You need state algorithms!

Chrisl, The problem is that the sensors don't seem to be reacting to anything. i don't get any compile errors.

jsotola ill have a look then. thanks, its a uni project and yes i wrote all the code myself.

Kingduken i don't understand what you mean?

It is likely, that the circuit doesn't seem to react, because the code is busy waiting in the delay function. You have up to 2,8 s delay between the measurements. Show us your schematic/wiring, so that we can check that the delays are really the problem

Chrisl ive updated the post with the picture of what the wiring looks like.

The photo of your circuit doesn't really show, how all the components are wired. For this you should either draw a schematic (which you can do with the schematic tool directly in the question editor) or provide a good visible wiring diagram like from Fritzing (though a proper schematic would be better).
For now I cannot see any wrong wiring, though you definitely should recheck it and add a proper diagram to your question.
For your code I will shortly sketch the functionality of non-blocking code and a state machine:

Non-blocking code: Task, that require a long amount of time (this means long for a microcontoller; seconds are long in this context), you should not use code, which blocks the whole program execution, until the task is completed. Instead you should only shortly check, if there is an action to be taken. If not, quickly proceed with other code. This enables you to do, which seems to be multitasking. For timed sequences you can use the millis() function. It returns the number of milliseconds since the program has started and overflows after 50 days. The following code saves the timestamp, when the LED was toggled the last time and checks, if enough milliseconds have passed since the last time. This way you can do something else in the meantime (like checking the state of your sensors). Also refer to the BlinkWithoutDelay example of the Arduino IDE.

unsigned long timestamp = 0;
unsigned long interval = 500;
...
void loop(){
  if(millis() - timestamp > interval){
    digitalWrite(led_pin, !digitalRead(led_pin));
    timestamp = millis();
  }
}

State machine: A state machine is code, that holds it's current state in a variable, thats mostly numeric. This variable is read at every loop cycle and used to determine, which piece of code is to be executed. In your case you would have states for "red light on", "yellow light on", "green light on", "distance lower than 10cm" and "LDR reports low light condition". Each on this gets it's own number. For convenience you should use an enum. Now on every loop cycle we use a switch case to go to the right code depending on the state. For your case you would set the state code with non-blocking behavior as described above. Then you only need transitions between the states, by setting the state variable.

enum STATE {STATE1, STATE2, STATE3};
STATE state = STATE1;
...
void loop(){
  switch(state){
    case STATE1:
      digitalWrite(led1_pin, HIGH);
      if(millis() - timestamp > interval){
        digitalWrite(led1_pin, LOW);
        state = STATE2;
      }
      break;
    case STATE2:
      // doing whatever this state needs to do and then do transition with setting state variable
      break;
    case STATE3:
      // doing whatever this state needs to do and then do transition with setting state variable
  }
}

For designing the states and transitions it sometimes makes sense to sketch them on paper. A bubble with a names is a state and then you connect these states with arrows.
Since you want to check the sensors in every state, you should do this outside of the switch statement. The measurement functions then do nothing else but the measurement and setting the state variable accordingly (so no digitalWrite() or delay() in there).

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
I2C EEPROM "hangs" on endTransmission()
I am working on the 24LC256 EEPROM, wired as such, except 3.3v to the EEPROM, with 'scope clamped on SDA and SCL. I'm using an address scanner script with a few tweaks, 57600 baud, 10kOhm pullups, 100000 I2C clock, and some serial prints for snooping:
for(address = 1; address < 127; address++ ) {
    Serial.printf("\n%02x", address);
    Wire.beginTransmission(address);
    Serial.printf(",");
    error = Wire.endTransmission();
    Serial.printf(".");
    Serial.flush();
    if (error == 0) {
      Serial.printf("I2C device found at address 0x%02x", address);
      Serial.println("  !");
      nDevices++;
    }
    ...

When the loop hits the address corresponding to the jumpers (pins 1, 2, 3 correspond to address 0b01010abc, aka 0x5?, where ? = binary encoding of those pins), it just sorta hangs:
4c,.
4d,.
4e,.
4f,.
50,

(here I have 1, 2, 3 all low, so the chip responds to addr 0x50). Since it's hitting , but not ., I know it's hanging at Wire.endTransmission(). It always hangs at endTransmission at the address encoded by the jumpers.  SCL is low and SDA is high.
Scope trace looks fine counting through the addresses.
Trace of address not found.
Trace of hanging at address.
gif of cycling through last few addresses.
I'm on an Adafruit Feather nrf52 BLE, if that matters.

Can you check, which circuit is holding SCL low? (The feather or the EEPROM) SCL can be hold low by the slave for slowing down the master, if the slave is not ready or needs some time to process previous data.

@chrisl how can I check that? I tried sticking my scope on a shunt resistor on SCL, that just pulled everything low (probably b/c of the scope ground). I think I need an inamp or something.

Then you most likely connected it wrong. The scope has a high impedance, it should not pull anything down. Measure the voltage with the scope between the SCL pin of the feather and ground of feather

How does that tell me whether master or slave is pulling it low though?

Sorry, should have described it. Attach the scope to feather SCL. When SCL is low, unconnect your slave and check the voltage again. If it goes up the slave was holding it low

@DeusXMachina Looks like they have recently fixed this bug: https://github.com/adafruit/Adafruit_nRF52_Arduino/commit/38047231b1a577f3b7821374ded98efc3463268c

@DeusXMachina You could try to add a write of a single byte.

Because of the way that the I2C library works, the only place it can hang is on the endTransmission. The other calls just buffer stuff up in memory.
There is probably some electrical issue. For example, the pull-up resistors might be better as 4.7k.
There is another library which handles transmission a bit differently which might resolve the hanging.
However if it is hanging there are probably other issues (cable lengths, pull-up resistors, noise) that are the underlying issue.
The standard library waits in a tight loop for certain interrupts to arrive, and if they don't arrive it hangs indefinitely.

except 3.3v to the EEPROM

You may well need a level-shifter. It's all very well only sending out 3.3V to the EEPROM, but the rest of the circuit is dealing in 5V not 3.3V. You can get suitable level shifters quite cheaply.
Why are you using 3.3V anyway? That chip can handle 5V. I have a post about that exact chip which works fine there.

Hi Nick, I'm using 3.3 because the NRF52's logic pins are all 3.3. I should have made that more obvious. The Feather nRF52 is 3.3, so the whole layout is on 3.3. The source image I used shows an UNO. The EEPROM should handle 1.8-5.5V. But I think you are right about the pull up resistors. I've been reading that I2C is very touchy when it comes to capacitance of the system and the rate of those pull ups.


text:
How do I correctly choose components for my current project?
Previously I asked a question that was a bit to broad so I'm narrowing the focus to a single component board of my design.
I have a set of 3 luckylight R/G bar graphs
(datasheet here: https://cdn-shop.adafruit.com/datasheets/KWL-R1230XDUGB.pdf)
A 5.1 V 2A power source
(recycled ac/dc converter voltage tested datasheet here: http://pdf1.alldatasheet.com/datasheet-pdf/view/322359/BOTHHAND/M1-10S05.html)
a series of 5 SN74HC595 (for controlling the LED multiplexing)
and an Arduino Nano.
The purpose of the bar graphs is to show the player how much of his available system energy he/she is using.
The first three bars of the graph are set to Red, the next 5 are yellow, and the final 4 are green.
As various components are switched on, or other activities drain the power of the engine core, a program level command will switch the multiplexing array to have them shut off.
The problem I'm having is getting enough power to each of the LEDs of the bar graph without overloading the IC pins on the Arduino or shift registers and making the colors appear correctly.
I know I could use Darlington arrays, or a bunch of transistors to keep the power going to the LEDs on a line independent of the ICs, but i'm not sure the right way to go about this. I have a few ULN2803 Darlingtons and a lot of 2n2222a transistors.
(Also my current Arduino code only has, at max, 8 LEDs from each register on at the same time, with a forward voltage of 2.4 volts and 20mA per LED. There are three cycles to my code because the bar graphs have three shared cathode pins that run three 2x4 matrices.)
Additionally I don't know precisely how to calculate the resistor values I would need for this arrangement to maintain the same voltage being applied to the 24 simultaneously running LEDs and get their brightness to be equivalent. Currently i'm noticing LEDs that are farther down the 595 logic chain are receiving less power and appearing weaker. (yes i have been running them off the power coming from the Arduino thus far)
Hopefully this is a narrow enough question.

LOL, you don't seem to be having much luck asking questions here. Your earlier one was closed  by community voting (not by me) as too broad, and now this one as not about the Arduino. Maybe you should have mentioned Arduino in the question. I stand by my answer, but if the question isn't re-opened try asking on Electrical Engineering Stack Exchange. Make sure you put the word "Arduino" in the question, and they will quickly close it and migrate it back here. :)

As for the people that voted to close this, you know perfectly well that if the word Arduino was mentioned it wouldn't last 10 minutes on EE Stack Exchange, and would be sent back here.

I guess I didn't word something right, but i also understand this question could have been about another microprocessor environment. Either way it is an Arduino question, but about best practices when using higher output currents than the Arduino can source directly.

According to this datasheet the 595 can drive up to 6 mA per output pin with a maximum of 20 mA for the input to the chip (so, 2.5 mA if you are driving all outputs).
Since your LEDs are quoting a forward current of 25 mA it seems that you will fall somewhat short of providing the 25 mA per LED.
There are higher power shift registers, eg. the TPIC6B595.
You might want to consider a multiplexing LED driver such as the MAX7219. I have a post about using that chip.
Your LEDs sound similar to the things that the MAX7219 is designed to drive. It also has inbuilt current-limiting with the current selected by a single resistor.
It isn't clear from your question whether you have the common anode or common cathode device, but you need a common cathode for the MAX7219.

The MAX7219 is not that expensive if you buy it from eBay. For example search for "MAX7219 kit". I found hits for 4 x MAX7219 for $US 9.75 including boards, capacitors and LEDs. Just discard the LEDs (8 x 8 dot matrix) and run the wires to your bargraph.

As they are designed to run 7 segment displays how would I connect it to transfer from my current 16 bit binary shift setup ...

They can run in a couple of modes (see the Decode Mode register) and one is to send arbitrary bits. Since you can program in any combination of bits (in my link above there is an array which does a CP437 font) you can therefore make up any combination of bars on and off. I would get one as an experiment (buy one of those kits from eBay) and try the idea out. It will be a lot less mucking around than 595 chips, transistors, current-limiting resistors, and so on.
There are various kits around, some are pre-soldered (which you won't want), some come with SMD chips and some with through-hole chips. Choose SMD or through-hole depending on your confidence with soldering SMD parts.

I know on my shift registers pins 1-8 go to the LED anodes and Pins 9-11 go to transistors that run the cathodes. Can you help me understand the pin connections to get the MAX to run this?

Looking at your bar graph specs:

You have 3 rather than 8 cathodes (pins 14, 9 and 8 are duplicates of 1, 6 and 7). So, you would run the cathode wiring (1, 6, 7) to the first 3 "digit" pins (2, 11 and 6) on the MAX7219. The other 8 wires (marked anodes) would go to the 8 anodes (2, 3, 4, 5, 10, 11, 12, 13).
As you have only used 3 cathode pins you could wire up a second bargraph using another 3 cathode pins (and run the anodes in parallel). That way a single MAX7219 can drive two bargraphs, giving you a total of 24 bars, each of which can show red, green, or yellow at one time.

Example wiring and code
I ordered a couple of the LED modules and worked out a schematic for them:

One MAX7219 can drive two of the modules.
Example of wiring:

Example code:
#include <SPI.h>

 // define max7219 registers
const byte MAX7219_REG_NOOP        = 0x0;
const byte MAX7219_REG_DIGIT0      = 0x1;
const byte MAX7219_REG_DIGIT1      = 0x2;
const byte MAX7219_REG_DIGIT2      = 0x3;
const byte MAX7219_REG_DIGIT3      = 0x4;
const byte MAX7219_REG_DIGIT4      = 0x5;
const byte MAX7219_REG_DIGIT5      = 0x6;
const byte MAX7219_REG_DIGIT6      = 0x7;
const byte MAX7219_REG_DIGIT7      = 0x8;
const byte MAX7219_REG_DECODEMODE  = 0x9;
const byte MAX7219_REG_INTENSITY   = 0xA;
const byte MAX7219_REG_SCANLIMIT   = 0xB;
const byte MAX7219_REG_SHUTDOWN    = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;

// which groups of bars we are addressing
const byte BARS_1_4   = MAX7219_REG_DIGIT0;
const byte BARS_5_8   = MAX7219_REG_DIGIT1;
const byte BARS_9_12  = MAX7219_REG_DIGIT2;
const byte BARS_13_16 = MAX7219_REG_DIGIT3;
const byte BARS_17_20 = MAX7219_REG_DIGIT4;
const byte BARS_21_24 = MAX7219_REG_DIGIT5;

// within a group, which one (from the left)
const byte BAR1_RED = 0x80;
const byte BAR2_RED = 0x20;
const byte BAR3_RED = 0x08;
const byte BAR4_RED = 0x02;

const byte BAR1_GREEN = 0x40;
const byte BAR2_GREEN = 0x10;
const byte BAR3_GREEN = 0x04;
const byte BAR4_GREEN = 0x01;

// yellow is done by adding red and green
const byte BAR1_YELLOW = BAR1_RED + BAR1_GREEN;
const byte BAR2_YELLOW = BAR2_RED + BAR2_GREEN;
const byte BAR3_YELLOW = BAR3_RED + BAR3_GREEN;
const byte BAR4_YELLOW = BAR4_RED + BAR4_GREEN;

void sendByte (const byte reg, const byte data)
  {
  digitalWrite (SS, LOW);
  SPI.transfer (reg);
  SPI.transfer (data);
  digitalWrite (SS, HIGH);
  }  // end of sendByte

void setup () {

  SPI.begin ();

  sendByte (MAX7219_REG_SCANLIMIT, 5);   // show 6 digits
  sendByte (MAX7219_REG_DECODEMODE, 0);  // using an led matrix (not digits)
  sendByte (MAX7219_REG_DISPLAYTEST, 0); // no display test

  // clear display
  for (byte col = 0; col < 8; col++)
    sendByte (col + 1, 0);

  sendByte (MAX7219_REG_INTENSITY, 7);  // character intensity: range: 0 to 15
  sendByte (MAX7219_REG_SHUTDOWN, 1);   // not in shutdown mode (ie. start it up)
}   // end of setup

void loop ()
 {
  // send various test combinations
  sendByte(BARS_1_4, BAR1_RED | BAR2_GREEN | BAR3_RED | BAR4_GREEN);
  sendByte(BARS_5_8, BAR2_RED);
  sendByte(BARS_9_12, BAR2_YELLOW);
  sendByte(BARS_13_16, BAR1_RED | BAR2_GREEN | BAR3_RED | BAR4_GREEN);
  sendByte(BARS_17_20, BAR2_YELLOW);
  sendByte(BARS_21_24, BAR1_RED | BAR2_RED);
 }  // end of loop

This is documented in my page about the MAX7219.

It is common cathode. The MAX7219's are a bit pricey, considering I need 9 bar graphs for the project. I was hoping to use the cheaper 595's and just add a transistor array to increase power, but looks like the 7219 might be the way to go. As they are designed to run 7 segment displays how would I connect it to transfer from my current 16 bit binary shift setup, to the correct pins on the MAX. I know on my shift registers pins 1-8 go to the LED anodes and Pins 9-11 go to transistors that run the cathodes. Can you help me understand the pin connections to get the MAX to run this?

See amended answer.

According to the Adafruit page for that product "Since the display is multiplexed we suggest using 3 NPN transistors to drive the cathodes with microcontroller pins and then a 74HC595 to drive the 8 anodes." So, certainly using transistors and a 595 is a possibility. But for 9 of them I think you will find yourself swamped by wires, transistors and resistors, and that the MAX7219 will simply the process.

Thanks, that was very helpful. Just FYI the common cathodes are each doubled so cathodes 8,9,&14 are not necessary. They just allow you to wire from either side of the display easier. I'll try to find a better deal on the MAX7219's. I was a little nervous buying the cheap kits that came with them rather than buying from manufacturer, simply because of the massive price difference. I'll give that a try though.

So far I haven't had a problem with the eBay ones, and for the price, even if I did, I wouldn't be too concerned. I've ordered a couple of your bar LED displays to see how easy it would be to adapt them to the MAX7219. I suspect it will be fairly easy.

Thanks Nick. I've built the test mode for just 2 with 595's. The wiring is a bit intense. According to my design I will only have at max 4 displays per Arduino board. The setup has 5 different interlinked Arduinos.

@B.Guisgand - I've amended the answer with an example of wiring up the LED modules, and some code.

Thanks this was exactly what I needed. Much Appreciated.


text:
Communicating between two Arduinos wirelessly only works when both are connected to the same computer
The transmitter is an Arduino Mega 2560 (China) that is connected to a computer over Serial, from which it only reads data and sends it using a SYN115 433mhz transmitter.
The receiver is an Arduino Nano (China) that drives an 8x8 * 5 led matrix and it reads data using a SYN480R 433mhz receiver.
Everything works as it should, when both devices are connected to my computer over USB.
If I unplug the receiver, the transmitter now stops responding to Serial data and I have to upload a sketch to make it work again, no resetting or power cycling works. But even after "fixing" the transmitter, if the receiver is not to connected to my computer but an external USB power supply (2A) it never receives any data.
I can then plug the receiver back into the computer and things work again.
Also, if I unplug the transmitter while the receiver is still plugged into the computer, the receiver crashes and resets itself.
Obviously there's some power issue when unplugging USB devices causing feedback, but the real issue is the wireless stops working on external power supply.
Both devices are running, it's easy to confirm since the receiver has some scrolling text, and the transmitter blinks an LED when it receives and sends data.
I read at Serial communication not working between two Arduinos unless connected to computer that both systems need to share ground if connected by wires. Could this affect the wireless signal somehow?
UPDATE: Connecting the receiver to a second computer works! (thanks Chris!! I know it was simple, but one can get stuck in one's own thought process ;))
So this is probably power related... Or can the Nano I have require more than just power over USB? I don't touch the serial device on the receiver side at all btw, all it does is read from PIN 2 and pushes data over HW-SPI to the LED matrix.
UPDATE-2: Added reciever code as suggested, though I doubt it's the problem here as it's very simple.
#include <MD_MAX72xx.h>
#include <RadioHead.h>
#include <RH_ASK.h>

#define RADIO_RX 2
#define RADIO_TX 3 // not used in this scetch but still needed by RH_ASK
#define RADIO_EN 4 // -||-

RH_ASK radio( 1200, RADIO_RX, RADIO_TX, RADIO_EN, true);
MD_MAX72XX mx( SS, 5);

void setup() {
  radio.init();
  mx.begin();
  mx.control(MD_MAX72XX::INTENSITY, 0);
  mx.control(MD_MAX72XX::TEST, 0);
  mx.clear();
}

uint8_t sc_text[128] = "-- No Data --     ";
uint8_t sc_pos;
uint8_t sc_charWidth;
uint8_t sc_charPos;
uint8_t sc_buf[8];

int scrollText() {
  mx.update(MD_MAX72XX::OFF);
  if(sc_text[sc_pos] == '\0') {
    sc_pos = 0;
    return 1;
  }
  if(sc_charPos == 0) sc_charWidth = mx.getChar(sc_text[sc_pos++], sizeof(sc_buf)/sizeof(sc_buf[0]), sc_buf);
  if( sc_charPos < sc_charWidth + 1) {
    mx.transform(MD_MAX72XX::TSL);
    if(sc_charPos < sc_charWidth) mx.setColumn(0, sc_buf[sc_charPos++]);
    else sc_charPos = 0;
  }
  mx.update(MD_MAX72XX::ON);
  delay(100);
  return 0;
}

char desc[64];
int temp1, temp2;
int wind1, wind2;

uint8_t radio_preamble[] = { 0x7d, 0x6f, 0xe4, 0x26, 0xb5 };

struct wttr_packet {
  uint8_t preamble[sizeof(radio_preamble)];
  int8_t temp1, temp2;
  uint8_t wind1, wind2;
  uint8_t desclen;
  char desc[32];
};

bool get_wttr_data() {
  struct wttr_packet packet;
  uint8_t len = sizeof(packet);
  int hasdata = radio.recv( (uint8_t*)&packet, &len);
  if(hasdata && len == sizeof(packet)) {
    if(memcmp( packet.preamble, radio_preamble, sizeof(radio_preamble))) return false
    temp1 = packet.temp1;
    temp2 = packet.temp2;
    wind1 = packet.wind1;
    wind2 = packet.wind2;
    memcpy( desc, packet.desc, packet.desclen);
    desc[packet.desclen] = '\0';
    return true;
  }
  return false;
}

bool hasnewdata = false;

void loop() {
  if(get_wttr_data()) hasnewdata = true;
  if(scrollText() && hasnewdata) {
    if(temp1 == temp2 && wind1 == wind2) sprintf( sc_text, "%s     %d %cC     %d km/h      ", desc, temp1, 0xF7, wind1); // 0xF7 == '°'
    else if(temp1 != temp2) sprintf( sc_text, "%s     %d/%d %cC     %d km/h      ", desc, temp1, temp2, 0xF7, wind1); // 0xF7 == '°'
    else if(wind1 != wind2) sprintf( sc_text, "%s     %d %cC     %d/%d km/h      ", desc, temp1, 0xF7, wind1, wind2); // 0xF7 == '°'
    else sprintf( sc_text, "%s     %d/%d %cC     %d/%d km/h      ", desc, temp1, temp2, 0xF7, wind1, wind2); // 0xF7 == '°'
    hasnewdata = false;
  }
}

UPDATE-3: Turns out this wasn't a power issue after all. I had forgotten about a voltage divider I put on the board for using it as a transmitter! The radio module has 3.3V TTL so this is needed for the transmitter but NOT the receiver!
Why this made it work plugged in to USB and not any other power brick I have no idea.

Can you try them on two different computers?  It's vaguely possible that some fault trigger by unplugging a device is forcing a re-start of the whole USB bus.  And it's also possible that a random power adapter may be too noisy to use for a radio receiver.

you use 5V power adapters connected to barel jack?

Its a 2A USB power adapter, cheap :p though not from china, i think.    About a second PC,  il have to do that when i get home, though it will be an old eee901 netbook, for proximity, those radio modules aren't exactly great ;)

Yep, powering the receiver from another computer works!   Ive tried 3 different USB power adapters now, none of them is able to handle wireless.  Even the charger for my brand new Huawei P10 with super charging doesnt work.

Perhaps there's something about your sketch that requires a computer.  You should probably include the receive code with an edit to your question.

Glad you solved your problem, though that solution is a little weird.  On Stack Exchange sites, if you solve your own problem, rather than editing it into the question, you should post an answer. Then come back in a few days when the self-answer timer has expired and accept it; this is the only way the system will consider your question to be resolved, otherwise it will keep getting churned back up for years.

It is weird indeed, all i did was bypass the divider and it works every time :)   I was also wondering about how stackexchange handles that.. so i will do just that. thanks :)

Turns out I forgot I had put a voltage divider on the data-line from the receiver since I originally build the board for transmission.
This in turn, somehow, caused the signal from the radio receiver to fall short of the TTL signals when powered by anything other than USB.
I bypassed the divider and everything works as it should again :)


text:
LCD Display many numbers?
There is no error in the code it already stored 11 numbers in serial print  but the problem I want to input 11 numbers only in keypad That will display 11 numbers also in LCD. But it display many numbers in LCD. Any idea please?

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial mySerial(6, 5);
int table[] = { 0, 0, 0 };
#include <Keypad.h>
#include <Wire.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {
    { '1', '2', '3' },
    { '4', '5', '6' },
    { '7', '8', '9' },
    { '*', '0', '#' }
};
byte rowPins[ROWS] = { 2, 3, 17, 16 }; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 15, 14, 13 }; //connect to the column pinouts of the keypad
int count = 0;
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
char entryStr[13]; // This can hold up to 4 digits
int i = 0;
//char n1, n2, n3;
//char buf[15]; // i put here***
char n1[11], n2[11], n3[11];
void setup()
{
    Wire.begin();
    Serial.begin(9600);
    Serial.begin(9600);
    lcd.begin(20, 4);
    ask();
}

void loop()
{
    Wire.requestFrom(2, 3); // request 6 bytes from slave device #2 for(int i=0;i<3;i++) {

    int c = Wire.read(); // receive a byte as character
    Serial.print(c);
    table[i] = c;
    Serial.print('\t');
    // print the character } Serial.print('\n'); Serial.print(table[0]); Serial.print('\t'); Serial.print(table1); Serial.print('\t'); Serial.print(table[2]); Serial.print('\n');

    //if(table[0]<=8) //{ //Serial.print("Flame Detected!"); //Serial.println("Level1");
}
void ask()
{

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no1.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    GetNumber(n1, sizeof(n1) - 1);;

    Serial.print(n1);

    delay(1);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no2.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    GetNumber(n2, sizeof(n2) - 1);

    Serial.println(n2);
    delay(1);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no3.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    GetNumber(n3, sizeof(n3) - 1);

    Serial.println(n3);
    delay(1);
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("list of numbers ");
    lcd.setCursor(0, 1);
    lcd.print("will be shown press");
    lcd.setCursor(1, 2);
    lcd.print("reset if wrong");

    delay(7000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Numbers Stored:");
    lcd.setCursor(0, 1);
    lcd.print("no1.:0");
    lcd.print(n1);
    lcd.setCursor(1, 2);
    lcd.print("no2.:0");
    lcd.print(n2);
    lcd.setCursor(2, 3);
    lcd.print("no3.:0");
    lcd.print(n3);
}
void GetNumber(char* result, const int maxLength)
{
    char key = kpd.getKey();
    int i = 0; // how far through buffer we are
    while (key != '#') {
        switch (key) {
        case NO_KEY:
            break;

        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':

            lcd.print(key);
            if (i < maxLength) {
                result[i++] = key;
                result[i] = 0; // terminating null
            }
            break;

        case '*': // backspace
            if (i > 0) {
                i--;
                result[i] = 0; // terminating null
            }

            break;
        }

        key = kpd.getKey();
    }

} // end of GetNumber

what i mean is The number i input in keypad is the same number iin LCD thats right.  But i want only in LCD to display 11 numbers only.

You declared n1 to be 11-char long, which doesn't have room for 11 numbers plus the null terminator. How are you getting 11 correct numbers in the first place is probably random.

Thank you. Can you give me any idea how can i fix it?

If 11 is not enough space for 11 numbers plus a null-terminator, I wonder what would be enough space?


text:
string.indexOf() always returns a non-zero value
I am developing a hardware project which contains a facility to change the stored password by any user, if he/she knows the current password.The new password is stored in arduino eeprom. In the main screen, if the user enters the current password, door is unlocked from inside. . The issue faced here is that the point where current password is entered by user, it works fine, but I want to check that '#' is not entered by user in the new password which is not performed properly.
Because in the main screen, when user presses '#' key, change password function is called up, where user is asked to enter current password.
Here is the screenshot of the circuit prepared from fritzing.

The code snippet for entering new password is as under.
lcd.clear();
lcd.print("New Passkey:");
lcd.setCursor(0, 1);
while (j < 4)
{
  char key = keypad4x4.getKey();

  if (key)
  {
    new_password[j++] = key;
    lcd.print(key);
    tone(buzzer, 1000, 50);

    if (j == 4)
    {
      lcd.print("4 reached");
      delay(1000);
      new_password[5] = '\0';
      String str = String(new_password);
      if (str.indexOf('#'))    /** this condition comes out to be true always i.e. always returns a non-zero value**/
      {
        tone(buzzer, 200, 700);
        lcd.clear();
        lcd.print("Invalid Entry");  /** It is printed everytime on lcd**/
        delay(2000);
        key = 0;
        changePass();
        break;
      }
      else  /** this block is not entered, so new password is not saved in EEPROM **/
      {
        for (int i = 0; i < 4; i++)
        {
          EEPROM.write(i, new_password[i]);
        }
        lcd.print(" Done......");
        delay(1000);
        break;
      }
    }
  }
}

and
new_password[5] is used to store new password entered by user.
Now, I am using a string variable to store this new password.
I am using  string.indexof() function to identify whether this new password contains a '#' character anywhere in it.But it seems that when I put this in an if block in code, it becomes true everytime.I have added comments at respective positions to highlight the problem faced by me. I have tested this code in Proteus simulator, and actual project too.
So, my issue is this one, even if correct password is entered by user,without '#', then also, string.indexOf('#') condition becomes true(returns a non-zero value everytime) and thus even valid password is not saved in EEPROM.
I guess I was able to explain my query accurately, please go through the code, and tell me where I am wrong, because I have gone through it many times and could not find the exact issue. Thanks in advance

did you check the reference? https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/indexof/

should be if (str.indexOf('#')+1)

Yes, I have checked the reference before using indexOf() in my code, but the +1 thing you mentioned in your comment,I didn't quite understand it. What does it do??

The problem here is that indexOf returns the position of the character in the string, or -1 if it's not found.
In C 0 is false and everything else is true. That includes -1.
However, your usage if String here to just check for one character is incredibly wasteful and should be avoided. Instead, use strchr:
if (strchr(new_password, '#') != NULL) {
    ... contains # ...
}

It really worked....@Majenko✌


text:
i586-poky-linux-g++: no such file or directory Error compiling for board Intel® Edison
I'm facing this compilation issue.
Arduino: 1.8.4 (Linux), Board: "Intel® Edison"
fork/exec /home/jimish/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0/i686/sysroots/pokysdk/usr/bin/i586-poky-linux/i586-poky-linux-g++: no such file or directory
Error compiling for board Intel® Edison.
Arduino IDE:

Web IDE:

please remove the two pictures and include the actual output text, so that text searches can be made. .... use the edit button

I've already pasted error there. The pictures are proof, that it's not a fault of my local machine or local ide. @jsotola

@JimishFotariya - Have you tried to access this file from the command line?  Usually its just a path issue.

@code-gorilla No i haven't tried that. But web-editor compiles on their server so I think it is a bug in original source.

This sounds like something you need to pursue with the creators of this non-Arduino toolchain.   Either you have a broken install (does the file even exist?) or (if it is there but won't run) an issue like a 32 bit executable that won't run on a 64 bit system unless you install the optional 32-bit system libraries package.

The problem here is that Intel, in their infinite wisdom* have lots of hard-coded paths to libraries in the binaries (why, heaven only knows) and then a set of scripts that munge those binaries to sort out where the libraries really are.
That script uses an option to find that was deprecated 13 years ago.
Way to keep up with the times, Intel...
So you need to make some fixes to get the toolchain to install properly.
I have created "fix" scripts for both the Edison and the Galileo that you can use to replace your broken toolchain.

https://github.com/majenkotech/IntelFixes

*i.e., sheer incompetence


text:
Arduino RFID tag scanning problems
For a school project, I'm using an Arduino Uno and a Parallax RFID together with some other components, I used a script I got from Instructables for reading my serial input from the RFID (link: http://www.instructables.com/id/Wiring-and-programming-the-Parallax-RFID-Serial-Ca/)
To use this serial data, you need to include an if loop in your loop function to check if the scanned tag equals the previous one. If it doesn't, the tag gets used further in the program. This doesn't allow scanning the same tag twice in a row. But I need that for my project. I have tried to work around it, but I can't seem to get it working, I always create a loop of unlimited scans or some other inregularities. Here's my code:
/* Libraries that need to be manually installed:
Blynk libraries: https://github.com/blynkkk/blynk-library/releases/download/v0.5.1/Blynk_Release_v0.5.1.zip
LiquidCrystal_I2C library: https://cdn.instructables.com/ORIG/FVH/K8OQ/J8UH0B9U/FVHK8OQJ8UH0B9U.zip
 */
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <ESP8266_Lib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
//#include <ThingSpeak.h>

//Setting up the Blynk wifi connection
#define ESP8266_BAUD 9600
char auth[] = "auth";

//Setting up the virtual pins
WidgetTerminal terminal(V1);
BLYNK_WRITE(V1){}
int freeSpots = 5;
BLYNK_READ(V2)
{
  Blynk.virtualWrite(V2, freeSpots);
}

//Setting up the RFID
#define RFIDEnablePin 8
#define RFIDSerialRate 2400
String RFIDTAG=""; //Holds the RFID Code read from a tag
String DisplayTAG = ""; //Holds the last displayed RFID Tag

//Setting up the LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//Setting up the serial connection
SoftwareSerial EspSerial(2, 3);
ESP8266 wifi(&EspSerial);

//Setting up the servo
Servo slagboom;

//Tag database
char tags[7][5] = {"6196", "6753", "5655", "69EC", "9FFC"};
char owners[7][5] = {"per1", "per2", "per3", "per4", "per5"};
int statuses[7] ={0};

//unsigned long channelNumber = 461353;
//const char * APIKey = "IHFFREPE9XUNSN94";

void setup() {
  //Serial communication
  Serial.begin(RFIDSerialRate);
  EspSerial.begin(ESP8266_BAUD);
  //RFID pin setup
  pinMode(RFIDEnablePin,OUTPUT);
  digitalWrite(RFIDEnablePin, LOW);
  //Blynk startup
  Blynk.begin(auth, wifi, "ssid", "pass");
  //LCD startup
  lcd.begin(16,2);//16 kolommen, 2 rijen
  lcd.backlight();
  //Servo startup
  slagboom.attach(10);
  slagboom.write(35);

  //ThingSpeak.begin(client);

  //Blynk terminal printing test
  delay(1000);
  slagboom.detach();
  terminal.println(F("Terminal printing succesfull"));
  terminal.flush();

}

void loop() {
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
  }
  if (DisplayTAG != RFIDTAG)
  {
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
  }
}

//Function for comparing the tag to the database
void tagCompare(String tagToCompare)
{
  char lastTag[5];
  tagToCompare.toCharArray(lastTag, 5);
  int i = 0;
  while (i < 5)
    {
      if (strcmp(tags[i], lastTag) == 0)
        {
          terminal.print(owners[i]);
          if (statuses[i] == 0)
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Welkom, ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 1;
            freeSpots--;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking betreden."));
            terminal.flush();
          }
          else
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Tot ziens ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 0;
            freeSpots++;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking verlaten."));
            terminal.flush();
          }
          //ThingSpeak.writeField(channelNumber, 1, i, APIKey);
          Blynk.run();
        }
      i++;
      }
  i = 0;
}

//Function for reading the tag
void ReadSerial(String &ReadTagString)
{
  int bytesread = 0;
  int val = 0;
  char code[10];
  String TagCode="";

  if(Serial.available() > 0)
  {
    if((val = Serial.read()) == 10)
    {
      bytesread = 0;
      while(bytesread<10) // Reads the tag code
      {
        if( Serial.available() > 0)
        {
          val = Serial.read();
          if((val == 10)||(val == 13)) // If header or stop bytes before the 10 digit reading
          {
            break; // Stop reading
          }
          code[bytesread] = val; // Add the digit
          bytesread++; // Ready to read next digit
        }
      }
      if(bytesread == 10)  // If 10 digit read is complete
      {
        for(int x=6;x<10;x++) //Copy the Chars to a String
        {
          TagCode += code[x];
        }
        ReadTagString = TagCode; //Returns the tag ID
        while(Serial.available() > 0) //Burn off any characters still in the buffer
        {
        Serial.read();
        }

      }
      bytesread = 0;
      TagCode="";
    }
  }
}

Any help would be very much appreciated.
Thanks in advance.
Edit: here's the changes I made to the loop():
void loop() {
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
  }
  unsigned long millisScanned;
  if (DisplayTAG != RFIDTAG)
  {
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
  unsigned long millisReference = millisScanned + 10000;
  if ((DisplayTAG == RFIDTAG) && (millis() >= millisReference))
  {
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
}

Can you describe in more detail what you mean by "I always create a loop of unlimited scans or some other inregularities."? Also, the code you posted as "yours" doesn't seem to have had any changes that would avoid checking the new value against the previous, so what exactly did you modify to try to work around it?

I have tried using the millis function to allow the tagCompare function to be used when DisplayTAG equald RFIDTAG.  I did this using the '&&' modifier but it always seemed to ignore the millis function. I also tried changing  the previously mentioned values but that executed the function twice for every tag scanned.
I left the wrong code out of my question, but I could rewrite it for you if necessary.

Please do put in the code you tried. "using the millis function" doesn't explain how you used it, etc.

@josecanuc, I added the code to the main question.

But I need that for my project. .... what are you talking about here?

@jsotola, I need to be able to scan the same tag twice, but I can't figure it out.

If you wish to allow even for duplicate scans, but only want to check it if the RFID reader returns a new scan string, then you don't even need millis()
void loop() {
  static bool pendingTag = false;
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
    pendingTag = true;   // Indicate that this is a new scan to check
  }
  if (pendingTag)
  {
    tagCompare(RFIDTAG);
    pendingTag = false;  // The tag is checked, no need to check again
    DisplayTAG=RFIDTAG;  // Not even sure if you use this anywhere else.
  }
}

Thanks for the reply! Unfortunately this doesn't quite work. I'm able to scan the same tag twice, but it randomly opens multiple times for each tag scanned. Any way to fix this?

I can't give a fix based on that comment. You have to track down what is triggering that, because it's likely not truly random. The code in the answer says to call tagCompare() if there was data on the serial port, essentially. What else might put data on the serial port?

The only thing connected to the serial port is the RFID-reader and I have tried clearing RFIDTAG after comparing it, this nearly fixes the problem, but occasionally tagCompare() still gets called twice.

So... add some debugging statements to print what comes in on the serial port so you can figure out what's going on. No one here can guess what is happening "randomly" on your hardware setup. You have to dig deep into your setup and figure out what is going on.

I think the RFID holds the tag that was last scanned, so it just keeps on sending the same tag to the serial port, I have no clue on how to fix this, so I'm just going to require another tag to be scanned before the first one can be scanned again. Thanks for your help anyway.


text:
Only one of 4 LEDs are lighting up
Before you ask - I've checked that the LEDs worked before putting them in my circuit. They all work.
I've connected 4 LEDs, shown in the arrangement below, up to my Adruino Lilypad. Pin 9 was used as the + 5V, the "- pin" was used as ground. In the schematic below, the "1" represents pin 9.

simulate this circuit – Schematic created using CircuitLab

When I start my sketch, I set pin 9 to high to check that all the LEDs are working. (this is a PWM pin so I write, analogWrite(9, 255);). At this point, only D5 lights up. If I connect up the two wires connecting R9-D6 and R10-D7, then both D5 and D8 light up... but never D7 or D6?
Doing some basic circuit calcs, the total resistance of the circuit is 100 Ohms (1 / (1 / (100 + 100)) + (1 / (100 + 100))). I'm powering from the usb connection to the computer so power source should be 5 V. Total current draw should therefore be 50 mA? Is that too much? If so, why does only D5 - or D5 and D8 when adjusting the circuit - light up?

you have 200 ohms in series with the LEDs .... remove one of the resistors in each leg

Those LEDs are 3.3V forward voltage. With two in series you need at least 6.6V to light them up.

...omg. So would it work if I put all 4 in parallel? Why did only 1 of 4 light up like that?

Not sure why one lights up. Some oddity maybe. Yes, using them in parallel is what you want to do.

Connecting 4 leds in parallel to a single output isn't advised, as it will exceed the maximum allow current. At most connect 2 leds in parallel to a digital output.

What would happen if I did exceed max current? I mean... I already have connected up in parallel & it's fine and works, but I still wanna be safe...! But no failsafe/fuse has kicked in...

The MOSFET in the GPIO pin will get hot, overheat, and go pop.


text:
256 (8x32) LED Matrix via ESP32-Pico-Kit_V4 possible? (Daft Punk Helmet)
I am currently planning on a Daft Punk Helmet. But the available kits are terribly expensive.
I am looking forward to using a 8x32 LED-Matrix(with 256 separate 5mm LEDs) and having a few different display modes which include static text and also repeating animations like a wave going back and forth, or digital eyes that wink. Also a Bluetooth connection would be nice and of course portability is important.
That's why I was looking at the ESP32-Pico-Kit_V4.
My question now: Is it possible to run such a big LED-Matrix off this ESP or would I need some extra boards/controllers and if so which would be necessary.
Or is this as a whole a much bigger project than I am expecting?
PS: I don't wanna use one of the prewired 8x32 panels because they are not see-through.
-- Arduino rookie needing some help

it is just a 256 LED light string folded 7 times ... research driving RGB LED strip with ESP32-Pico-Kit_V4

I'll need 4 display drivers like the MAX7219 CNG chips.
Thanks anyway.

i was under the impression that you wanted color .... good luck with your project


text:
Arduino memory issue with old HP HDSP-2000 display chips

I'm running into memory issues with an Arduino Nano driving some old HDSP-2000/HDSP-2011 chips.
I cannot seem to get the ASCII 5x7 array into PROGMEM and have it read properly. It's so low on memory that I set up a second Arduino to send char[] strings through I2C to keep the Nano from locking up. This sort of worked to my advantage that I can multi-task and I'll probably keep it that way but it still keeps locking up or spitting gibberish.
The display Arduino is constantly bit-banging the displays - multiplexed with two 14-bit (acts as one 28-bit) Serial in / parallel out shift registers and and 5 column drivers. All displays use 5 common anode + columns, which have to be pulse timed with the registers.
#include <Wire.h>

//*** HDSP2011 Display Demo
//*** ASCII-DEMO
//*** phuinink@gmail.com
//*** Paul Huinink has a webpage on displays www.huinink.info and specifically HDSP200X series displays www.spagmon.com
//*** Modified December-2013 by Patrick Hickey: added HP HDSP single digit display and RGB LED
//*** Patrick Hickey ph@nipht.com

//modified 3/2018 by Brandon McRee - removed support for LED and single digit HDSP DISPLAY

//figure out latch pin

// an array of 5 bytes per ASCII
// 5 bytes cause 5 columns
// 7 bits per column (no LSB)

const byte ascii_5x7[] = {    //when I put this in PROGMEM i get gibberish, without it the SRAM is 87% full...
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0xF2, 0x00, 0x00,// !
    0x00, 0xE0, 0x00, 0xE0, 0x00,// "
    0x28, 0xFE, 0x28, 0xFE, 0x28,// #
    0x24, 0x54, 0xFE, 0x54, 0x48,// $
    0xC4, 0xC8, 0x10, 0x26, 0x46,// %
    0x6C, 0x92, 0xAA, 0x44, 0x0A,// &
    0x00, 0xA0, 0xC0, 0x00, 0x00,// 39
    0x00, 0x38, 0x44, 0x82, 0x00,// 40
    0x00, 0x82, 0x44, 0x38, 0x00,// 41
    0x28, 0x10, 0x7C, 0x10, 0x28,// *
    0x10, 0x10, 0x7C, 0x10, 0x10,
    0x00, 0x0A, 0x0C, 0x00, 0x00,
    0x10, 0x10, 0x10, 0x10, 0x10,
    0x00, 0x06, 0x06, 0x00, 0x00,
    0x04, 0x08, 0x10, 0x20, 0x40,
    0x7C, 0x8A, 0x92, 0xA2, 0x7C,//48 0
    0x00, 0x42, 0xFE, 0x02, 0x00,//49 1
    0x42, 0x86, 0x8A, 0x92, 0x62,//50 2
    0x84, 0x82, 0xA2, 0xD2, 0x8C,
    0x18, 0x28, 0x48, 0xFE, 0x08,
    0xE4, 0xA2, 0xA2, 0xA2, 0x9C,
    0x3C, 0x52, 0x92, 0x92, 0x0C,
    0x80, 0x8E, 0x90, 0xA0, 0xC0,
    0x6C, 0x92, 0x92, 0x92, 0x6C,
    0x60, 0x92, 0x92, 0x94, 0x78,
    0x00, 0x6C, 0x6C, 0x00, 0x00,
    0x00, 0x6A, 0x6C, 0x00, 0x00,
    0x10, 0x28, 0x44, 0x82, 0x00,
    0x28, 0x28, 0x28, 0x28, 0x28,
    0x00, 0x82, 0x44, 0x28, 0x10,
    0x40, 0x80, 0x8A, 0x90, 0x60,
    0x4C, 0x92, 0x9E, 0x82, 0x7C,
    0x7E, 0x88, 0x88, 0x88, 0x7E,//65 A
    0xFE, 0x92, 0x92, 0x92, 0x6C,
    0x7C, 0x82, 0x82, 0x82, 0x44,
    0xFE, 0x82, 0x82, 0x44, 0x38,
    0xFE, 0x92, 0x92, 0x92, 0x82,
    0xFE, 0x90, 0x90, 0x90, 0x80,// 70
    0x7C, 0x82, 0x92, 0x92, 0x5E,
    0xFE, 0x10, 0x10, 0x10, 0xFE,
    0x00, 0x82, 0xFE, 0x82, 0x00,
    0x04, 0x02, 0x82, 0xFC, 0x80,
    0xFE, 0x10, 0x28, 0x44, 0x82,
    0xFE, 0x02, 0x02, 0x02, 0x02,
    0xFE, 0x40, 0x30, 0x40, 0xFE,
    0xFE, 0x20, 0x10, 0x08, 0xFE,
    0x7C, 0x82, 0x82, 0x82, 0x7C,
    0xFE, 0x90, 0x90, 0x90, 0x60,// P
    0x7C, 0x82, 0x8A, 0x84, 0x7A,
    0xFE, 0x90, 0x98, 0x94, 0x62,
    0x62, 0x92, 0x92, 0x92, 0x8C,
    0x80, 0x80, 0xFE, 0x80, 0x80,
    0xFC, 0x02, 0x02, 0x02, 0xFC,
    0xF8, 0x04, 0x02, 0x04, 0xF8,
    0xFC, 0x02, 0x0C, 0x02, 0xFC,
    0xC6, 0x28, 0x10, 0x28, 0xC6,
    0xE0, 0x10, 0x0E, 0x10, 0xE0,
    0x86, 0x8A, 0x92, 0xA2, 0xC2,
    0x00, 0xFE, 0x82, 0x82, 0x00,
    0x40, 0x20, 0x10, 0x08, 0x04,
    0x00, 0x82, 0x82, 0xFE, 0x00,
    0x20, 0x40, 0x80, 0x40, 0x20,
    0x02, 0x02, 0x02, 0x02, 0x02,
    0x00, 0x80, 0x40, 0x20, 0x00,
    0x04, 0x2A, 0x2A, 0x2A, 0x1E,
    0xFE, 0x12, 0x12, 0x12, 0x0C,
    0x1C, 0x22, 0x22, 0x22, 0x22,
    0x0C, 0x12, 0x12, 0x12, 0xFE,// 100 d
    0x1C, 0x2A, 0x2A, 0x2A, 0x1A,// 101 e
    0x00, 0x10, 0x7E, 0x90, 0x40,
    0x12, 0x2A, 0x2A, 0x2A, 0x3C,
    0xFE, 0x10, 0x10, 0x10, 0x0E,
    0x00, 0x00, 0x5E, 0x00, 0x00,
    0x04, 0x02, 0x02, 0xBC, 0x00,
    0x00, 0xFE, 0x08, 0x14, 0x22,
    0x00, 0x82, 0xFE, 0x02, 0x00,
    0x3E, 0x20, 0x1C, 0x20, 0x3E,
    0x3E, 0x10, 0x20, 0x20, 0x1E,
    0x1C, 0x22, 0x22, 0x22, 0x1C,
    0x3E, 0x28, 0x28, 0x28, 0x10,
    0x10, 0x28, 0x28, 0x28, 0x3E,
    0x3E, 0x10, 0x20, 0x20, 0x10,
    0x12, 0x2A, 0x2A, 0x2A, 0x24,
    0x20, 0x20, 0xFC, 0x22, 0x24,
    0x3C, 0x02, 0x02, 0x02, 0x3C,
    0x38, 0x04, 0x02, 0x04, 0x38,
    0x3C, 0x02, 0x0C, 0x02, 0x3C,// x
    0x22, 0x14, 0x08, 0x14, 0x22,// y
    0x20, 0x12, 0x0C, 0x10, 0x20,// z
    0x22, 0x26, 0x2A, 0x32, 0x22,//123 {
    0x00, 0x10, 0x6C, 0x82, 0x82,//124 |
    0x00, 0x00, 0xEE, 0x00, 0x00,//125 }
    0x82, 0x82, 0x6C, 0x10, 0x00,
    0x20, 0x40, 0x40, 0x40, 0x80,
    0xA8, 0x68, 0x3E, 0x68, 0xA8,
    0xBE, 0x2A, 0x2A, 0x2A, 0xA2,
    0x00, 0x20, 0x50, 0xA0, 0x00,
    0x04, 0x22, 0x7C, 0xA0, 0x40,
    0x84, 0xFC, 0x04, 0x00, 0x20,
    0xFE, 0x02, 0x02, 0x12, 0x02,
    0x1C, 0x22, 0x14, 0x08, 0x36,
    0x4E, 0x3E, 0x60, 0x40, 0x40,
    0x0C, 0x12, 0x52, 0xB2, 0x1C,//136 ÃƒÆ’Ã†â€™Ãƒâ€šÃ‚Âª
    0x08, 0x1C, 0x2A, 0x2A, 0x2A,
    0xF8, 0x40, 0x40, 0x3C, 0x02,
    0x7C, 0x92, 0x92, 0x7C, 0x00,
    0x42, 0x44, 0x38, 0x04, 0x02,
    0x20, 0x3E, 0x20, 0x3E, 0x22,
    0x10, 0x20, 0x3C, 0x22, 0x20,
    0x18, 0x24, 0x7E, 0x24, 0x18,
    0x1C, 0x22, 0x0C, 0x22, 0x1C,
    0x82, 0xC6, 0xAA, 0x92, 0x82,
    0x3A, 0x46, 0x40, 0x46, 0x3A,
    0x54, 0x54, 0x54, 0x54, 0x54,
    0x44, 0x28, 0x10, 0x28, 0x44,
    0x10, 0x10, 0x54, 0x10, 0x10,
    0x00, 0x70, 0x88, 0x88, 0x70,
    0x60, 0x90, 0x8A, 0x80, 0x40,
    0xFE, 0xFE, 0x92, 0x92, 0x92,
    0x0A, 0x1A, 0x2A, 0x4A, 0x8A,
    0x8A, 0x4A, 0x2A, 0x1A, 0x0A,
    0x28, 0x2C, 0x38, 0x68, 0x28,
    0x04, 0xFE, 0x80, 0x80, 0x80,
    0x4C, 0x92, 0x92, 0x7C, 0x00,//157 ÃƒÆ’Ã†â€™Ãƒâ€¹Ã…â€œ
    0x04, 0x02, 0x7C, 0x80, 0x40,
    0x38, 0x44, 0x38, 0x44, 0x38,
    0xAA, 0x54, 0xAA, 0x54, 0xAA,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0xBE, 0x00, 0x00,
    0x38, 0x44, 0xFE, 0x44, 0x00,
    0x12, 0x7E, 0x92, 0x92, 0x42,
    0xBA, 0x44, 0x44, 0x44, 0xBA,
    0xA8, 0x68, 0x3E, 0x68, 0xA8,
    0x00, 0x00, 0xEE, 0x00, 0x00,
    0x50, 0xAA, 0xAA, 0xAA, 0x14,
    0x00, 0x80, 0x00, 0x80, 0x00,
    0x7C, 0xBA, 0xAA, 0xAA, 0x7C,
    0x12, 0xAA, 0xAA, 0xAA, 0x7A,
    0x10, 0x28, 0x54, 0xAA, 0x44,
    0x80, 0x80, 0x80, 0x80, 0xC0,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x7C, 0xAA, 0xBA, 0x82, 0x7C,
    0x80, 0x80, 0x80, 0x80, 0x80,
    0x00, 0xE0, 0xA0, 0xE0, 0x00,
    0x22, 0x22, 0xFA, 0x22, 0x22,
    0x00, 0x48, 0x98, 0xA8, 0x48,
    0x00, 0x00, 0xA8, 0xA8, 0x70,
    0x00, 0x00, 0x40, 0x80, 0x00,
    0x04, 0xF8, 0x10, 0x10, 0xE0,
    0x60, 0xFE, 0x80, 0xFE, 0x80,
    0x00, 0x00, 0x10, 0x10, 0x00,
    0x08, 0x00, 0x02, 0x04, 0x00,
    0x00, 0x48, 0xF8, 0x08, 0x00,
    0x00, 0xE8, 0xA8, 0xE8, 0x00,
    0x44, 0xAA, 0x54, 0x28, 0x10,
    0xF0, 0x04, 0x0C, 0x14, 0x2E,
    0xF0, 0x00, 0x12, 0x26, 0x1A,
    0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
    0x0C, 0x12, 0xA2, 0x02, 0x04,
    0x1E, 0xA8, 0x68, 0x28, 0x1E,
    0x1E, 0x28, 0x68, 0xA8, 0x1E,
    0x1E, 0xA8, 0xA8, 0xA8, 0x1E,
    0x9E, 0xA8, 0xA8, 0xA8, 0x9E,
    0x9E, 0x28, 0x28, 0x28, 0x9E,
    0x1E, 0x68, 0xA8, 0x68, 0x1E,
    0x7E, 0x90, 0xFE, 0x92, 0x92,
    0x70, 0x8A, 0x8C, 0x88, 0x88,
    0x3E, 0xAA, 0x6A, 0x2A, 0x22,
    0x3E, 0x2A, 0x6A, 0xAA, 0x22,
    0x3E, 0xAA, 0xAA, 0xAA, 0x22,
    0xBE, 0x2A, 0x2A, 0x2A, 0xA2,
    0x00, 0xA2, 0x7E, 0x22, 0x00,
    0x00, 0x22, 0x7E, 0xA2, 0x00,
    0x00, 0xA2, 0xBE, 0xA2, 0x00,
    0x00, 0xA2, 0x3E, 0xA2, 0x00,
    0x10, 0xFE, 0x92, 0x82, 0x7C,
    0xBE, 0x90, 0x88, 0x84, 0xBE,
    0x1C, 0xA2, 0x62, 0x22, 0x1C,
    0x1C, 0x22, 0x62, 0xA2, 0x1C,
    0x1C, 0xA2, 0xA2, 0xA2, 0x1C,
    0x9C, 0xA2, 0xA2, 0xA2, 0x9C,
    0x9C, 0x22, 0x22, 0x22, 0x9C,
    0x44, 0x28, 0x10, 0x28, 0x44,
    0x3A, 0x4C, 0x54, 0x64, 0xB8,
    0x3C, 0x82, 0x42, 0x02, 0x3C,
    0x3C, 0x02, 0x42, 0x82, 0x3C,
    0x3C, 0x82, 0x82, 0x82, 0x3C,
    0xBC, 0x02, 0x02, 0x02, 0xBC,
    0x60, 0x10, 0x4E, 0x90, 0x60,
    0xFE, 0x44, 0x44, 0x44, 0x38,
    0x7E, 0xA4, 0xA4, 0x58, 0x00,
    0x04, 0xAA, 0x6A, 0x2A, 0x1E,
    0x04, 0x2A, 0x6A, 0xAA, 0x1E,
    0x04, 0xAA, 0xAA, 0xAA, 0x1E,
    0x84, 0xAA, 0xAA, 0xAA, 0x9E,
    0x04, 0xAA, 0x2A, 0xAA, 0x1E,
    0x04, 0x6A, 0xAA, 0x6A, 0x1E,
    0x2E, 0x2A, 0x1C, 0x2A, 0x3A,
    0x30, 0x4A, 0x4C, 0x48, 0x00,
    0x1C, 0xAA, 0x6A, 0x2A, 0x1A,
    0x1C, 0x2A, 0x6A, 0xAA, 0x1A,
    0x1C, 0xAA, 0xAA, 0xAA, 0x1A,
    0x1C, 0xAA, 0x2A, 0xAA, 0x1A,
    0x00, 0x80, 0x5E, 0x00, 0x00,
    0x00, 0x00, 0x5E, 0x80, 0x00,
    0x00, 0x40, 0x5E, 0x40, 0x00,
    0x00, 0x40, 0x1E, 0x40, 0x00,
    0x0C, 0x12, 0x52, 0xB2, 0x1C,
    0xBE, 0x90, 0xA0, 0xA0, 0x9E,
    0x0C, 0x92, 0x52, 0x12, 0x0C,
    0x0C, 0x12, 0x52, 0x92, 0x0C,
    0x0C, 0x52, 0x52, 0x52, 0x0C,
    0x4C, 0x52, 0x52, 0x52, 0x4C,
    0x0C, 0x52, 0x12, 0x52, 0x0C,
    0x10, 0x10, 0x10, 0x54, 0x10,
    0x18, 0x26, 0x3C, 0x64, 0x18,
    0x1C, 0x82, 0x42, 0x02, 0x1C,
    0x1C, 0x02, 0x42, 0x82, 0x1C,
    0x1C, 0x42, 0x42, 0x42, 0x1C,
    0x1C, 0x42, 0x02, 0x42, 0x1C,
    0x20, 0x12, 0x4C, 0x90, 0x20,
    0xFE, 0x48, 0x48, 0x30, 0x00,
    0x20, 0x92, 0x0C, 0x90, 0x20,

};

int column[] = {
    8,7,6,5,4}; // change this to other general input/output arduino-pins as you like d8=pin 1
int data = 2;   // change this to other general input/output arduino-pins as you like
int clock = 3;  // change this to other general input/output arduino-pins as you like

int brightness = 2000; // keep high for max visibility. To high will cause flikkering

const int numberOflDisplays = 4; // change this if total number of HDSP200x's is different.

int tekstDat[numberOflDisplays * 4 * 5]; // this is the array that store's what on the displays. 4 digits per display and 5 columns per digit.

unsigned long tijd; // used to trigger events in one of the examples below

char buf[40];
boolean flagRx = false; //allowed to receive if false

//*****************************************************************setup*************************************************************
void setup(){
    //Serial.begin(9600);

    for (int i = 0; i < 5; i++){
        pinMode(column[i], OUTPUT);
    }
    for (int i = 0; i < 5; i++){
        digitalWrite(column[i], LOW);
    }
    pinMode(data, OUTPUT);
    pinMode(clock, OUTPUT);
    digitalWrite(data, LOW);
    digitalWrite(clock, HIGH);
    tijd = millis();

    Wire.begin(8);                // join i2c bus with address #8  >>important<<
    Wire.onReceive(receiveEvent); // register event

}

//***********************************************************************************end setup******************************************************

void loop(){

    char PROGMEM clr[] = "    ";
    char PROGMEM scroll[]  = "1979 TECH CONTROL PANEL by Brandon McRee";
    char PROGMEM scroll2[] = "Remember Stupid... you have to drive this home :)";

    if(flagRx == false){
        delay(10); //needs this delay to be stable
        scrollText(scroll, 8); //scrolling text, speed : second number is var howslow how slow this is a test of fastdraw text (short strings)
        delay(1000);
        //scrollText(scroll2, 10);
        delay(10);
        flagRx = true; // can now recieve
    }
    else{
        writeText(buf);
        for (int i = 0; i< 50; i++) draw(); //does this continuously - display HDSP2011

    }
    /*
            scrollText(scroll3, 10);
            delay(10);

        //short quick text write
        scrollText(hello, 8);
        scrollText(world, 8);
        delay(500);

            delay(5);
        writeText("TEST") ;                   //letters only? special charachters
        for (int i = 0; i< 100; i++) draw();
                delay(5);
        writeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
        for (int i = 0; i< 70; i++) draw();
                delay(5);
        writeText("1234567890") ;
        for (int i = 0; i< 100; i++) draw();
                delay(5);
        writeText("!@#$%^&*()") ;
        for (int i = 0; i< 50; i++) draw(); //delay??
                delay(5);

        delay(1000);

            */

    writeText(buf);
    for (int i = 0; i< 50; i++) draw(); //does this continuously

}
//****************end of main loop *********************************

void receiveEvent(int howMany) {

    int i;
    for (i=0; i<howMany; i++){
        buf[i] = Wire.read(); //read I2C data (address 8)
    }

    flagRx = true;    // set flag, we received something. will figure out how to clear when

    // while (1 < Wire.available()) { // loop through all but the last

}

//int x = Wire.read();    // receive byte as an integer not used
//Serial.println(x);          // print the integer

void writeDigit(int positie, int ascii){
    for (int i =0; i< 5;i++){
        tekstDat[(numberOflDisplays * 4 - positie) * 5 + i] = ascii_5x7[ascii*5+i];
    }
}

void scrollText(String tekkst, long howSlow){
    int leng = tekkst.length();
    for (int u=-numberOflDisplays*4;u<leng;u++){ // first N digits will be spaces. N = all digits of display. So one screen blank before first character apears.
        for (int v=0; v< numberOflDisplays*4;v++){
            if (( (u+v) >= 0 ) && ((u+v) < leng)){ // separete leading and tailing spaces from actual string
                char oneChar= tekkst.charAt(u+v);
                writeDigit(v+1, oneChar); // write the character of the string
            }
            else{
                writeDigit(v+1, 32); // write ascii-value 32 = a space.
            }
        }
        for (long teller = 0; teller < howSlow; teller++){
            draw();
        }
    }
}

void writeText(String tekst){
    int tl = tekst.length();
    int spacesNeeded = 4 * numberOflDisplays - tl;
    if (spacesNeeded <0){
        tl = 4 * numberOflDisplays;
    }
    else{
        for (int u = 0; u < spacesNeeded; u++){
            tekst.concat(" ");
        }
        tl = 4 * numberOflDisplays;
    }
    char tekst_[tl];
    for (int vv = 0; vv < tl; vv++){
        char tt = tekst.charAt(tl-vv-1);
        for (int i =0; i< 5;i++){
            //tekstDat[vv*5+i] = ascii_5x7[tt*5+i]; //old using SRAM
            //tekstDat[vv*5+i] = (pgm_read_byte(ascii_5x7))[tt*5+i]; //new  try and read from PROGMEM does not compile :/
        }
    }
}

void dot(byte x, byte y, boolean oo){
    if ((x < (numberOflDisplays *4 * 5)) && (y < 7)){
        byte oldByte = tekstDat[x] & (0xFF - (2<<y));
        tekstDat[x] = oldByte | (2<<y);
    }
}

void draw(){
    for (int Kolom = 0; Kolom < 5; Kolom++){ // 5 columns to be strobed
        // pumping in 3 x 4 x 7 bits per one stobe of the column
        for (int displayNo = 0; displayNo < numberOflDisplays; displayNo++){  // number of  displays
            for (int digitNo = 0; digitNo < 4; digitNo++){ // 4 characters per display
                for (int diodeNo = 0; diodeNo < 7; diodeNo++){ // 7 row-elements
                    digitalWrite(clock, HIGH);
                    digitalWrite(data, tekstDat[Kolom + 5*(displayNo*4 + digitNo) ] &(2<<diodeNo)); // magic
                    digitalWrite(clock, LOW);
                }
            }
        }
        digitalWrite(column[Kolom], HIGH);
        delayMicroseconds(brightness);
        digitalWrite(column[Kolom], LOW);
    }
}

“I cannot seem to get the ASCII 5x7 array into PROGMEM and have it read properly.” You should solve this problem, rather than try to work around it. A font definitely belongs to PROGMEM.

Take a look at an ASCII table such as the one here.
You could remove the first 32 ASCII characters which are the control characters and don't show up on the display. That would save 160 bytes. You will just need to make sure your index lines up.
You can then remove the last 127 characters which make up the extended character set. These are rarely used in the English language. This would save you an additional 635 bytes.
Overall that would save you 795 precious bytes.

I rem'd out line 153-281 and it seemed to solve the memory issue, the array wouldn't work without the first 32 charachters for some reason, started spitting gibberish - thanks a ton for the help will keep testing it until the panel is finished :)

There are many decoder devices that would do the job such as DLR1414, DLO1414, DLG1414, etc they even have the display integrated. Another solution is to add external memory such as a 2K by 8 eeprom or whatever. Program it such as it is a character decoder/generator. This will give you a lot more memory without using up the on chip memory.  I use to do this many years ago with 2716's. The address inputs would be the select and the output would be the decoded dot pattern.

@Gil why not turn that comment into an answer. :)

Ran into the same issue. Added the following line to setup():
// The following line is magic needed for pgm_read_byte() to function.
if (millis() > 100000L) Serial.println((uint16_t) font, HEX);

Note the Serial.println() is never executed, but the compiler doesn't know that.
Without this line pgm_read_byte() produces garbage.
With this line added to setup() the code runs fine.
Disassembling the code it looks as if without the Serial.println((uint16_t) font) the compiler optimizes away the begin address of the array, dropping "font" from the symbol table.
Complete sketch at https://github.com/koendv/retroleds

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Upcoming Project
Hey guys I have a project that will require 20 I/O pins with serial communication from a computer to control each of the pins. I would like something as small as possible would a arduino micro or uno work for this project or will i need to go bigger like a mega. I have looked at all the pinouts but am confused to know of which pins I can use as digital I/O or not.
Thanks

rarely do you need 20 IO pins if you play your cards right; i have an LCD, INA219 module, a button and an LED on one ESP-01. Take advantage of i2c, ws2812, charleyplexing, etc, then use expanders or pro-minis if needed.

i would also consider an ESP32. you can disable wifi, and it's still a beast of an arduino; it can do your 20GPIOs, and even a devkit is much smaller than a mega, for about the same price or less. The raw power makes coding easier since higher level instructions run plenty fast enough (String class, double, serialized objects in SPIFFS vs EEPROM structs, etc). And who can complain about hundreds of KB of RAM?

@Cameroony Please see the link above for answers to a pretty similar question. Hopefully you get some answers there. If this is not a duplicate, please edit your question and let us know how your question is different.

If you require 20 I/O pins then use Arduino Mega. If it’s too big then use Nano, Micro or Pro Mini (you need a serial thingy to program the Mini) with I/O expanders like PCF8574P with I2C communication or MCP23S17 with SPI communication.

There are a couple of options

Easiest = Use an Arduino with a greater number of pins (e.g. MEGA2560)
Easy = Use an add-on board (e.g. Teensy)
Harder = Use shift registers (see Is there a way to have more than 14 Output pins on arduino?)

Further discussion on these options here.


text:
Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?
In STM32 microcontrollers it is possible to use a technique that ST calls IAP, or In-Application Programming, in order to write to the Flash memory from your running application. They even have a nice Application Note (ex: AN2594) to describe a really ingenious way to use two Flash memory pages to emulate EEPROM while using "wear-leveling" to reduce Flash memory wear during erase cycles.
I have wondered for years: can AVR do this? Ex: the ATmega328 mcu in the Arduino Uno, Nano, etc--can you write code to store data from your application into Flash memory, thereby increasing non-volatile storage space for data acquisition for instance?
If so, can you please point me to some resources or examples, including example code, reference manuals or datasheets, etc, that might help me implement this? I've done some looking in the datasheet and haven't found anything so far but maybe I'm just not looking hard enough or know well enough what I'm looking for.

The answer is "yes, you can use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage, very similar to an STM32 microcontroller."
One of these days I'm going to write an Arduino library to make this really easy for the beginner. For now, however, I'm going to simply post links to valuable references that contain the full answers and that I still need to thoroughly study myself.
Documentation on how to implement Flash memory reading/writing:
-This is frequently called "self programming" by Atmel (now owned by Microchip).
To find these resources I went to the main ATmega328 reference page then clicked the "Documentation" link, then I searched the web page for the word "flash".
Here's what I found (in order of importance--most pertinent references first):

AVR106: C functions for reading and writing to Flash memory on tinyAVR and megaAVR devices

"Description: This application note provides C functions for accessing the Flash memory using the Self programming Program memory which allows to reprogram the Flash memory during program run."
"Introduction: The Atmel® AVR® devices have a feature called Self programming Program memory. This feature enables an AVR device to reprogram the Flash memory while executing the program. Such a feature is helpful for applications that must self-update firmware or store parameters in Flash. This application note provides the details about the C functions for accessing the Flash memory."
This Application Note contains source code, including with the following ready-to-use C functions:

ReadFlashByte()
ReadFlashPage()
WriteFlashByte()
WriteFlashPage()
RecoverFlash()

AVR105: Power efficient high endurance parameter storage in tinyAVR and megaAVR devices Flash memory
AVR116: Wear Leveling on DataFlash
Atmega328 datasheet

Section 30: Boot Loader Support – Read-While-Write Self-programming (BTLDR), p. 328-344.
As pointed out by user SDF in his answer, especially pay attention to Section 30.8: Self-Programming the Flash, p. 334-342.
Also see Section 12.2: In-System Reprogrammable Flash Program Memory, p36
And Section 31.6: Page Size, p. 349.

Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory.
https://majek.sh/en/writing-to-internal-flash-on-arduino/
The number of times you rewrite a cell are limited.
I'd suggest you are better off with adding a FRAM memory chip.
Get a 5V part with SPI interface. Fast reads, virtually unlimitless writes (trillions)
https://www.digikey.com/products/en/integrated-circuits-ics/memory/774?k=fram+memory&k=&pkeyword=fram+memory&pv276=15&FV=ffe00306%2C1f140000%2C1fec000b&quantity=0&ColumnSort=0&page=1&stock=1&pageSize=25

Take a look at section 30.8 in the datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf
It has all the information to reprogram the bootloader section of the flash during runtime.
The bootloader partition size can be adjusted as well.

I'll take a look. What about the rest of the Flash? STM32 allows you to use any part of the flash to write in during runtime, rather than limiting you to one dedicated  part of Flash.

In STM32 You can even move your program to RAM and then erase the Flash you just copied from, for instance--not that I'd want to do that though, it just demonstrates the versatility I'm seeking to find out about for AVR.


text:
How to keep warm arduino uno board with 12v dc supply
I have an arduino uno board with ESP8266 module and i have done all connection using breadboard.
Now when i run arduino uno with USB cable for long time then its not getting hot ! but when i supply power with 12v dc adapter in black barrele then its getting too much hot (i cant touch with my fingure).
Now when i remove the ESP8266 module power and test it again with 12v dc power supply then its not getting hot !
So what is the problem with ESP8266 module ? Is my wiring creates heat ?

need to show wiring diagram, and give specs on the power supplies. But the esp should not be getting that hot

What is the "it" that is getting hot?

@NickGammon Arduino bottom part of that black barrele.

@ChadG yes its readlly getting hot. ! i have also attchaed 5 v realy

Also asked at: http://forum.arduino.cc/index.php?topic=538176 If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information.

Is the ESP8266 working as expected?

you're not supposed to power the esp01 from an UNO. if you do, at least drop vin down to 7v.

See Can I use arduino's 3.3 V output directly to esp8266?
From that page:

The specs for the Uno say that it does not provide as much current on the 3.3V line as the specs for the ESP8266 requires. You will need to provide another regulator that can supply enough current.

Also, putting 12V into the barrel jack is making work for the on-board voltage regulator (located near the barrel jack) because it has to convert 12V to 5V (making heat in the process). You would be better off putting a lower voltage into the barrel jack, ideally around 7V (but not lower).
Alternatively, just power through the USB port as you have been, and plug the USB cable into a USB charger.

To summarize, both the 5V and 3.3V voltage regulators are probably working very hard, thus getting hot.