message:
How to fix HC05 burning even after while using voltage regulator?

I'm using two circuits for my wireless head mouse project, one of them is a transmitter circuit with Arduino Pro Micro, HC05 Bluetooth module, Elechouse Voice Recognition Module V3.1, GY-521 module based on the MPU6050 sensor. The receiver circuit (Arduino Pro Micro + HC05 Bluetooth) will receive the sensor readings from the transmitter circuit. Both modules were powered by USB from the laptop initially. They worked fine. To make the transmitter circuit completely detached from the laptop, I used a 9V battery, and a voltage regulator of 5V. The receiver circuit was still c. I should mention that I was using voltage dividers for both of the transmitter, and receiver circuit's HC05 Bluetooth modules.
onnected to the laptop USB.

.
After using the voltage regulator, the module was working fine but suddenly the HC-05 burnt, led stopped working. Transmission failed. HC05 of the receiver module also burnt after 2 minutes. Why did this happen? What's the solution?

Circuit connection:
Hc05 connection same for transmitter & receiver circuit
HC05 Tx -> Arduino Rx
Hc 05 rx -> 2k ohm -> gnd
Hc05 rx -> 1k ohm -> hc05 tx
Hc05 vcc -> arduino 5v
Hc05 gnd -> arduino gnd

Voice Recognition Module tx -> arduino 8
Rx -> Arduino 9
Vcc- 5v
Gnd - gnd

Mpu6050 sda - Arduino 2
 Scl- Arduino 3
Vcc - 5V
Gnd- Gnd

Voltage regulator connection:
The connection was 9V battery +ve to input, -ve to ground, output to Arduino 5V

[![receiver circuit][1]][1]

[![Transmitter Circuit][2]][2]

  [1]: https://i.stack.imgur.com/4R9Fx.png
  [2]: https://i.stack.imgur.com/clZzK.jpg

body:
You said "I should mention that I was using voltage dividers for both of the transmitter, and receiver circuit's HC05 Bluetooth modules."

Voltage dividers are not a good way to lower voltage for power components. The voltage output will vary based on load, and they also dissipate the excess voltage as heat, so you need high current resistors.

Post a schematic of your system with the specific batteries, regulators etc that you are using.


sender: user

sender: assistant

body:
Your voltage divider pins are backwards the HC05 RX pin needs the divider, not the TX pin.   Its tx would be 3.3v out and the arduino pin wouldn't care it would still work.

Most likely while you were testing before the HC05 was probably already slowly dying.

the HC05 has a very basic 3.3v regulator on board but only a little over 5V input can fry things.
I have always put 75-100ohm in series with the 5V in just in case.

Your circuit is basically good but the the RX/TX pins on the HC05 need reversing.
 Analog V. regulators are fairly crude and will vary voltage some.

5.000v accuracy is never dead on. I have seen as high as 5.7V out and that would not be good.

Also the HC05 RX pin is receiving a 5V signal back, sourcing thru the HC05 chip.

Even the Arduino help site warns against 5V if it can be avoided.

from Arduino's site
[https://create.arduino.cc/projecthub/electropeak/getting-started-with-hc-05-bluetooth-module-arduino-e0ca81][1]

    Sending Data to Arduino via Bluetooth
    HC05 module has an internal 3.3v regulator and that is why you can connect it to 5v voltage. But we strongly recommend 3.3V voltage, since the logic of HC05 serial communication pins is 3.3V. Supplying 5V to the module can cause damage to the module.

  [1]: https://create.arduino.cc/projecthub/electropeak/getting-started-with-hc-05-bluetooth-module-arduino-e0ca81


message:
How to connect a LiFePO4 battery directly to an esp32?

If I want to connect a LiFePO4 battery (as the power supply) directly to an esp32 - would this be the correct way: the plus of the battery to the 3.3 volt pin and the minus to a ground pin?

body:
No. Absolutely not.

A LiFePO4 battery is 4.2V when fully charged. The absolute maximum voltage of an ESP32 is 3.6V.

You **will** kill the ESP32.

Instead you need to have a voltage regulator with a very low dropout. Ideally a switching ("buck") regulator with a zero-dropout "pass" mode to give the maximum life from your battery.

Even better is a "buck/boost" battery regulator that will boost the voltage up to a stable 3.3V once the battery voltage drops too low.

If all this is beyond you then you're better off using a powerbank to do the regulation to 5V for you then convert that back down to 3.3V with a simple buck regulator.


body:
I know this question is two years old but it still pops up on research. I just wanted to add something from my experience with this:
If you take an Enerpower HTCFR18650 for example [datasheet][1] you see that the maximum voltage isn't 4.2V but 3.65V +/- 0.05V. While this technically is a little bit above the absolute maximum rating of the ESP32 (3.6V), in a non critical environment you can absolutely use the battery without voltage regulator. Just keep in mind that you also will not have any undervoltage protection in this case.

I'm not a fan of this negativity ("**you will fry**", "*you kill you ESP*", "***Everyone will die***"). An ESP32 costs $1. Just try it and if it works its great (it does) and if it doesn't, don't blame me ;)

  [1]: https://enerpower.de/wp/wp-content/uploads/2019/07/Technical-Specifications-HTCFR18650-1800mAh-3.2V-EN.pdf


message:
cant read json data esp 32 “parseObject() failed”

> **hello  I am just trying to make Youtube Subscribe Counter with led matrix 32*8 and esp 32 and I had this problem when I trying to get
> subscribers to count
>      so what is the problem and how I can fix it? `**

      ```    //########################  YouTube Subscriber Count Display on LED MATRIX  #############################
            // Receives and displays YouTube channel statistics
            //################# LIBRARIES ################
            String version = "v1.0";       // Version of this program

        #include <WiFi.h>
        #include <WiFiClientSecure.h>
        #include <ArduinoJson.h>     // https://github.com/bblanchon/ArduinoJson
        #include <SPI.h>
        #include <Adafruit_GFX.h>
        #include <Max72xxPanel.h>    // https://github.com/markruys/arduino-Max72xxPanel
        #include <time.h>
        //################ VARIABLES ################
        // Use your own API key by signing up for a free Youtube developer account at http://www.youtube.com
        // LED Matrix Pin -> ESP32 Pin
        // Vcc            -> 3v
        // Gnd            -> Gnd
        // DIN            -> MOSI pin use results of print statement 23 maybe
        // CS             -> SS pin   use results of print statement 5 maybe
        // CLK            -> SCK pin  use results of print statement 18 maybe

        const char* channelId = "UCqTSLaEj9c4hiZkU0FfbaJA"; // See your Channel details click on your channel icon at top-right, then Settings, then Advanced
        const char* apiKey    = "A--------------Aw"; // See https://developers.google.com/youtube/v3/getting-started for an API key, you must enable it to make it work!
        const char* host      = "https://www.googleapis.com";
        unsigned long lastConnectionTime = 0;                 // Last time you connected to the server, in milliseconds
        const unsigned long  postingInterval = 10L*60L*1000L; // Delay between updates, in milliseconds, you should limit your YouTube requests per-day maximum

        //################ PROGRAM VARIABLES and OBJECTS ################
        int pinCS = 5; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
        int numberOfHorizontalDisplays = 4;
        int numberOfVerticalDisplays   = 1;
        int wait   = 35; // In milliseconds
        int spacer = 1;
        int width  = 5 + spacer; // The font width is 5 pixels
        int port   = 443;
        String time_str;

        Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);

        struct channelStatistics{
          long viewCount;
          long commentCount;
          long subscriberCount;
          bool hiddenSubscriberCount;
          long videoCount;
        };

        // Change to your WiFi credentials
        const char* ssid     = "SSid";
        const char* password = "PASS";

        channelStatistics channelStats;

        void setup() {
          Serial.begin(115200); // initialize serial communications
          Serial.println("Mosi="+String(MOSI));
          Serial.println("SS="+String(SS));
          Serial.println("SCK="+String(SCK));
          StartWiFi(ssid,password);
          StartTime();

          //----------------------------------------------------------------------
          configTime(0 * 3600, 0, "pool.ntp.org", "time.nist.gov");
          matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
        // Adjust the LED matrix to your own needs
        //  matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
        //  matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
        //  matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
        //  matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
        //  ...
          matrix.setRotation(0, 1);    // The first display is position is rotated
          matrix.setRotation(1, 1);    // The first display is position is rotated
          matrix.setRotation(2, 1);    // The first display is position is rotated
          matrix.setRotation(3, 1);    // The first display is position is rotated
          lastConnectionTime = millis();
          obtain_subscriber_stats();
        }

        void loop() {
          display_message("Subs: " + String(channelStats.subscriberCount));
          time_t now = time(nullptr);
          String time = String(ctime(&now));
          time.trim();
          display_message(" on " + time);
          if (millis() - lastConnectionTime > postingInterval) { // 15-minutes
            obtain_subscriber_stats();
            lastConnectionTime = millis();
          }
        }

        //################ PROGRAM FUNCTIONS ################

        void display_message(String message){ // Scroll the image left
          matrix.fillScreen(LOW);
          for ( int i = 0 ; i < width * message.length() + matrix.width() - 1 - spacer; i++ ) {
            int letter = i / width;
            int x = (matrix.width() - 1) - i % width;
            int y = (matrix.height() - 8) / 2; // center the text vertically
            while ( x + width - spacer >= 0 && letter >= 0 ) {
              if (letter < message.length()) matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH means foreground on, LOW means background off, LOW< HIGH inverts the display
              letter--;
              x -= width;
            }
            matrix.write(); // Send bitmap to display
            delay(wait);
          }
        }

        void obtain_subscriber_stats() {
          String command = "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=" + String(channelId);
          String response = GetRequestFromYoutube(command);
          StaticJsonBuffer <200> jsonBuffer;
          JsonObject& root = jsonBuffer.parseObject(response); // Parse JSON
          if (!root.success()) {
            Serial.println(F("jsonBuffer.parseObject() failed"));
          }
          else
          {

            JsonObject& current                = root["items"][0]["statistics"];
            long subscriberCount               = current["subscriberCount"];
            long viewCount                     = current["viewCount"];
            long commentCount                  = current["commentCount"];
            long hiddenSubscriberCount         = current["hiddenSubscriberCount"];
            long videoCount                    = current["videoCount"];
            channelStats.viewCount             = viewCount;
            channelStats.subscriberCount       = subscriberCount;
            channelStats.commentCount          = commentCount;
            channelStats.hiddenSubscriberCount = hiddenSubscriberCount;
            channelStats.videoCount            = videoCount;

          }
          Serial.println("      View Count = " + String(channelStats.viewCount));
          Serial.println("Subscriber Count = " + String(channelStats.subscriberCount));
            Serial.println(GetRequestFromYoutube(command));
            Serial.println(response);
          //  Serial.println(jsonBuffer.parseObject(response));

        }

        String GetRequestFromYoutube(String request) {
          String headers, body = "";
          bool Headers    = false;
          bool currentLineIsBlank = true;
          int  MessageLength = 1000;
          // Connect with youtube api over ssl
          WiFiClientSecure client;
          if (client.connect(host, port)) {
            Serial.println(".... connected to server");
            char c;
            int ch_count=0;
            request += "&key=" + String(apiKey);
            request = "GET " + request;
            Serial.println(request);
            client.println(request);
            int now   = millis();
            while (millis()-now < 1500) {
              while (client.available()) {
                char c = client.read();
                if(!Headers){
                  if (currentLineIsBlank && c == '\n') {
                    Headers = true;
                  }
                  else{
                    headers = headers + c;
                  }
                } else {
                  if (ch_count < MessageLength)  {
                    body = body+c;
                    ch_count++;
                  }
                }
                if (c == '\n') {
                  currentLineIsBlank = true;
                } else if (c != '\r') {
                  currentLineIsBlank = false;
                }
              }
            }
          }
          return body;
        }

        ////////////// WiFi, Time and Date Functions /////////////////
        int StartWiFi(const char* ssid, const char* password) {
          int connAttempts = 0;
          Serial.print(F("\r\nConnecting to: ")); Serial.println(String(ssid));
          WiFi.begin(ssid, password);
          while (WiFi.status() != WL_CONNECTED ) {
            delay(500); Serial.print(".");
            if (connAttempts > 20) {
              Serial.println("\nFailed to connect to a Wi-Fi network");
              return -5;
            }
            connAttempts++;
          }
          Serial.print(F("WiFi connected at: "));
          Serial.println(WiFi.localIP());
          return 1;
        }

        void StartTime(){
          configTime(0, 0, "0.uk.pool.ntp.org", "time.nist.gov");
          setenv("TZ", "GMT0BST,M3.5.0/01,M10.5.0/02",1); // Change for your location
          UpdateLocalTime();
        }

        void UpdateLocalTime(){
          struct tm timeinfo;
          while (!getLocalTime(&timeinfo)){
            Serial.println("Failed to obtain time");
          }
          //See http://www.cplusplus.com/reference/ctime/strftime/
          Serial.println(&timeinfo, "%a %b %d %Y   %H:%M:%S"); // Displays: Saturday, June 24 2017 14:05:49
          char output[50];
          strftime(output, 50, "%a %d-%b-%y  (%H:%M:%S)", &timeinfo);
          time_str = output;
        }
        ```

body:
The [documentation for ArduinoJson 5](https://arduinojson.org/v5/faq/why-parsing-fails/) lists the reasons why [`parseObject()`](https://arduinojson.org/v5/api/jsonbuffer/parseobject/) may return `false`:

1. The input is not a valid JSON
2. The [`StaticJsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/) is too small
3. The [`StaticJsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/) is too big (stack overflow)
4. The [`DynamicJsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/) fails to allocate memory
5. You called [`parseObject()`](https://arduinojson.org/v5/api/jsonbuffer/parseobject/) instead of [`parseArray()`](https://arduinojson.org/v5/api/jsonbuffer/parsearray/)
6. The nesting limit is too low

A glance at your code suggests that the problem is number 2: the [`StaticJsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/) is too small.
Indeed, I don't know what the input looks like, but 200 bytes is probably too small to store the result.

You can use the [ArduinoJson Assistant](https://arduinojson.org/v5/assistant/) to compute the required capacity for the [`JsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/). Don't forget to switch to a [`DynamicJsonBuffer`](https://arduinojson.org/v5/api/jsonbuffer/) if it becomes bigger than 4 KB.

Lastly, I really recommend that you switch to [ArduinoJson 6](https://arduinojson.org/v6/doc/upgrade/) because it offers more features, better performance, better memory usage, and better error reporting, all with the same code size and portability.


message:
Can Only Upload Arduino Sketch Once to Custom Mega2560 Board

I created a custom Arduino based off the Mega2560 R3. It uses the ATMega16U2 uC as the USB interface between ATMega2560 uC and the PC.

The bootloader on the 2560 is uploaded by using an Arduino Micro via ArduinoISP. I followed this [tutorial from Instructables][1] on uploading the bootloader/firmware for the 16U2 except I modified some parts for the 2560 instead of the UNO. Here is my added section in the /program Files (x86)/Arduino/hardware/arduino/avr/boards.txt

    unorestore.name=MEGA2560 16U2 Restore Firmware
    unorestore.bootloader.tool=arduino:avrdude
    unorestore.bootloader.low_fuses=0xff
    unorestore.bootloader.high_fuses=0xd9
    unorestore.bootloader.extended_fuses=0xf4
    unorestore.bootloader.file=Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex
    unorestore.bootloader.unlock_bits=0x3F
    unorestore.bootloader.lock_bits=0x0F
    unorestore.build.mcu=atmega16u2
    unorestore.build.f_cpu=16000000L
    unorestore.build.board=uno.build.board=AVR_MEGA2560
    unorestore.build.core=arduino:arduino
    unorestore.build.variant=standard

**The problem is** after I upload a sketch (with a size say over 10 kB), I can't upload any new sketch and get this timeout error message instead as shown below. Not even a simple blink sketch. The TX and RX LED connected to the 16U2 uC that flashes during an sketch upload doesn't even blink once.

[![enter image description here][2]][2]

The only way I can get it take another sketch is to "re-flash" the bootloader on the 2560 uC via ArduinoISP. The TX and RX led now flashes during the sketch upload. Of course, this is a huge hassle as I don't want to do "re-flash" the 2560 bootloader every time I want to upload a sketch.

I don't have this problem on my Elegoo Mega2560 R3 clone board so I'm thinking it might be something wrong with my 16U2 firmware/bootloader. Anyone have any idea what else might be causing this?

[![enter image description here][3]][3]

  [1]: https://www.instructables.com/How-to-Restore-the-Arduino-UNO-R3-ATmega16U2-Firmw/
  [2]: https://i.stack.imgur.com/YgM7a.jpg
  [3]: https://i.stack.imgur.com/VhyWH.png

body:
Your RESET circuit is wrong.

* You have no pullup resistor on the RESET pin of the ATMega3560.
* You have an extraneous pulldown resistor on the D7 pin of the 16U2.

That means your 16U2 will not be able to trigger a reset of the ATMega2560 to run the bootloader.

Remove the pulldown on D7 of the 16U2 and add a 10kΩ pullup to the RESET pin of the ATMega2560. Without that pullup:

1. The chip may not run properly as RESET is floating (it may have an internal pullup, I can't recall)
2. The capacitor linking the 16U2 D7 and RESET of the ATMega2560 won't be able to generate a proper reset pulse. This will be exacerbated by the 1kΩ pulldown.

On the Mega2560 reference schematic RN1A is the pullup in question.


message:
Why Can't I Program my Atmega168 Pro Mini?

I'm trying to program a Atmega168 Pro Mini 3.3V/8mhz I bought online. I followed a [tutorial][1] that walks through the steps of how to program a Pro Mini with an Arduino Uno. However, in their example they are uploading code to a Atmega328 Pro Mini though I don't think it matters.

Anyway, I followed the same steps as they did (namely hooking up Uno's ground -> ground, 3v -> Vcc, Reset -> DTR, tx->tx, rx->rx). When I attempted to upload via Arduino IDE I got the message that the programmer was not responding. I also noticed that the transfer led on the Uno was not lighting up. Did I screw up something? Also, are my hookups correct? I would think tx pin should connect to rx pin, but I just followed the instructions. Would appreciate any thoughts

[![enter image description here][2]][2]

  [1]: https://www.instructables.com/How-to-Program-Arduino-Pro-Mini-Using-Arduino-UNO/#discuss
  [2]: https://i.stack.imgur.com/pcBjO.jpg

body:
Your hookup seems to be correct. However check if there is a capacitor on the pro-mini board between DTR and reset pin, some arduino clones don't come with one.
If there isn't any you can simply connect a capacitor like this:
Reset pin (Arduino Uno) -> Capacitor (0.01uF for example) -> DTR (pro mini). The reason for this hookup is exmplined well [here][1]

  [1]: https://forum.arduino.cc/index.php?topic=26877.0


message:
DIY Arduino with USB port

I am planing on making Arduino from scratch. I found many examples on internet, but they all need another Arduino for programming. How can I make Arduino with USB interface for programming and serial data transfer? Would I need something called FTDI? Basically I want same Arduino you can buy, just build it from separate parts.

body:
There are two critical things that make an "Arduino". There is the hardware, and there is the bootloader.

The hardware is nothing special. It's just an MCU and the required minimal support hardware. What really makes it an Arduino is the bootloader which allows it to be programmed over the serial connection (via USB usually).

Without that bootloader the only way to program the MCU is over the hardware programming interface (typically ICSP for an AVR MCU), and for that you need some form of hardware programmer.

And of course that means the only way to put the bootloader onto the chip is to use a hardware programmer.

So you have two options:

1. Program the bootloader into the chip using a hardware programmer (which you can make with an Arduino), or
2. Buy an ATMega328P chip with the bootloader pre-programmed.

Once you have the bootloader installed then yes, you can program the chip over UART (through USB with a USB to UART adaptor such as an FT232).


message:
OLED 'SH1106_WHITE' was not declared in this scope

I was following [FREE Functions to draw graphs on OLED displays][1] on YouTube but mine OLED display doesn't support Adafruit_SSD1306 library,but it works on Adafruit_SH1106.h driver.

  [1]: https://www.youtube.com/watch?v=13PFOwcK3-I

The code that is shared with YouTube video

    /*

      This program provides functions to draw:
      1. horizontal bar graph
      2. vertical bar graph
      3. dial
      4. cartesian graph

      It requires an microcrontrioller Arduino, teensy and a 0.96 dispaly (1306 driver chip)

      display. sources
      https://www.amazon.com/Diymall-Yellow-Arduino-display.-Raspberry/dp/B00O2LLT30/ref=pd_lpo_vtph_147_bs_t_1?_encoding=UTF8&psc=1&refRID=BQAPE07SVJQNDKEVMTQZ
      https://www.amazon.com/dp/B06XRCQZRX/ref=sspa_dk_detail_0?psc=1&pd_rd_i=B06XRCQZRX&pd_rd_wg=aGuhK&pd_rd_r=1WJPXAG68XFSADGDPNZR&pd_rd_w=DAAsB

      Adafruit libraries
      https://github.com/adafruit/Adafruit-GFX-Library/archive/master.zip
      https://github.com/adafruit/Adafruit_SSD1306

      Revisions
      rev     date        author      description
      1       12-5-2017   kasprzak    initial creation

      Pin settings

      Arduino   device
      5V        Vin
      GND       GND
      A0        read an input voltage from a pot across Vcc and Gnd (just for demo purposes)
      A1
      A2
      A3
      A4        SDA on the display. or use dedicated pin on board if provided
      A5        SCL on the display. use dedicated pin on board if provided
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13

    */

    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    #define READ_PIN            A0
    #define OLED_RESET          A4
    #define LOGO16_GLCD_HEIGHT  16
    #define LOGO16_GLCD_WIDTH   16

    // create what ever variables you need
    double volts;
    double bvolts;
    double x, y;

    // these are a required variables for the graphing functions
    bool Redraw1 = true;
    bool Redraw2 = true;
    bool Redraw3 = true;
    bool Redraw4 = true;
    double ox , oy ;

    // create the display object
    Adafruit_SSD1306 display(OLED_RESET);

    void setup() {

      Serial.begin(9600);

      // initialize the display
      // note you may have to change the address
      // the most common are 0X3C and 0X3D

      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
      // if you distribute your code, the adafruit license requires you show their splash screen
      // otherwise clear the video buffer memory then display
      display.display();
      //delay(2000);
      display.clearDisplay();
      display.display();

      // establish whatever pin reads you need
      pinMode(A0, INPUT);

    }

    unsigned long OldTime;
    unsigned long counter;

      void loop(void) {

      // read some values and convert to volts
      bvolts = analogRead(A0);
      volts = (bvolts  / 204.6 ) ;

      // draw any of the following, sorry for the crazy long arguement lists
      // note 0.96 isn't very big, so you can't show many graphs at the same time
      // also colors are hard coded
      // the display i use draws text at the top in yellow--we'll use that for drawing the title

      // call one of these functions
      DrawBarChartV(display, bvolts, 25,  60, 40, 40, 0, 1024 , 256, 0, "A0 (bits)", Redraw1);
      //  DrawBarChartH(display, volts, 10, 45, 100, 20, 0, 5, 1, 0, "A0 (volts)", Redraw2);
      //  DrawDial(display, volts, 65, 50, 25, 0, 5 , 1, 0, 200, "A0 (volts)", Redraw3);

      // for multiple graphs uncomment the next 2 lines
      //  DrawBarChartV(display, bvolts, 5,  60, 10, 40, 0, 1024 , 256, 0, "A0 (bits/volts)", Redraw1);
      //  DrawDial(display, volts, 90, 50, 25, 0, 5 , 1, 0, 200, "A0 (bits/volts)", Redraw3);

      // or show a cartesian style graph to plot values over time (or whatever)

        DrawCGraph(display, x++, bvolts, 30, 50, 75, 30, 0, 100, 25, 0, 1024, 512, 0, "Bits vs Seconds", Redraw4);
        if (x > 100) {
        while (1) {}
        }

      delay(1000);

      }

      /*
      This method will draw a vertical bar graph for single input
      it has a rather large arguement list and is as follows

      &d to pass the display object, mainly used if multiple displays are connected to the MCU
      curval = date to graph (must be between loval and hival)
      x = position of bar graph (lower left of bar)
      y = position of bar (lower left of bar
      w = width of bar graph
      h =  height of bar graph (does not need to be the same as the max scale)
      loval = lower value of the scale (can be negative)
      hival = upper value of the scale
      inc = scale division between loval and hival
      dig = format control to set number of digits to display. (not includeing the decimal)
      label = bottom lable text for the graph
      redraw = flag to redraw display. only on first pass (to reduce flickering)

    */

    void DrawBarChartV(Adafruit_SSD1306 &d, double curval, double x , double y , double w, double h , double loval , double hival , double inc , double dig, String label, bool &Redraw)
    {
      double stepval, my, level, i, data;

      if (Redraw) {
        Redraw = false;
        d.fillRect(0, 0,  127 , 14, SSD1306_WHITE);
        d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
        d.setTextSize(1);
        d.setCursor(2, 4);
        d.println(label);
        // step val basically scales the hival and low val to the height
        // deducting a small value to eliminate round off errors
        // this val may need to be adjusted
        stepval = ( inc) * (double (h) / (double (hival - loval))) - .001;
        for (i = 0; i <= h; i += stepval) {
          my =  y - h + i;
          d.drawFastHLine(x + w + 1, my,  5, SSD1306_WHITE);
          // draw lables
          d.setTextSize(1);
          d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
          d.setCursor(x + w + 12, my - 3 );
          data = hival - ( i * (inc / stepval));
          d.print(data, dig);
        }
      }
      // compute level of bar graph that is scaled to the  height and the hi and low vals
      // this is needed to accompdate for +/- range
      level = (h * (((curval - loval) / (hival - loval))));
      // draw the bar graph
      // write a upper and lower bar to minimize flicker cause by blanking out bar and redraw on update
      d.drawRect(x, y - h, w, h, SSD1306_WHITE);
      d.fillRect(x, y - h, w, h - level,  SSD1306_BLACK);
      d.drawRect(x, y - h, w, h, SSD1306_WHITE);
      d.fillRect(x, y - level, w,  level, SSD1306_WHITE);
      // up until now print sends data to a video buffer NOT the screen
      // this call sends the data to the screen
      d.display();

    }

    /*
      This method will draw a horizontal bar graph for single input
      it has a rather large arguement list and is as follows

      &display to pass the display object, mainly used if multiple displays are connected to the MCU
      x = position of bar graph (upper left of bar)
      curval = date to graph (must be between loval and hival)
      y = position of bar (upper left of bar (add some vale to leave room for label)
      w = width of bar graph (does not need to be the same as the max scale)
      h =  height of bar graph
      loval = lower value of the scale (can be negative)
      hival = upper value of the scale
      inc = scale division between loval and hival
      dig = format control to set number of digits to display. (not includeing the decimal)
      label = bottom lable text for the graph
      redraw = flag to redraw display. only on first pass (to reduce flickering)
    */

    void DrawBarChartH(Adafruit_SSD1306 &d, double curval, double x , double y , double w, double h , double loval , double hival , double inc , double dig, String label, bool &Redraw)
    {
      double stepval, mx, level, i, data;

      if (Redraw) {
        Redraw = false;
        d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
        d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
        d.setTextSize(1);
        d.setCursor(2, 4);
        d.println(label);
        // step val basically scales the hival and low val to the width
        stepval =  inc * (double (w) / (double (hival - loval))) - .00001;
        // draw the text
        for (i = 0; i <= w; i += stepval) {
          d.drawFastVLine(i + x , y ,  5, SSD1306_WHITE);
          // draw lables
          d.setTextSize(1);
          d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
          d.setCursor(i + x , y + 10);
          // addling a small value to eliminate round off errors
          // this val may need to be adjusted
          data =  ( i * (inc / stepval)) + loval + 0.00001;
          d.print(data, dig);
        }
      }
      // compute level of bar graph that is scaled to the width and the hi and low vals
      // this is needed to accompdate for +/- range capability
      // draw the bar graph
      // write a upper and lower bar to minimize flicker cause by blanking out bar and redraw on update
      level = (w * (((curval - loval) / (hival - loval))));
      d.fillRect(x + level, y - h, w - level, h,  SSD1306_BLACK);
      d.drawRect(x, y - h, w,  h, SSD1306_WHITE);
      d.fillRect(x, y - h, level,  h, SSD1306_WHITE);
      // up until now print sends data to a video buffer NOT the screen
      // this call sends the data to the screen
      d.display();

    }

    /*
      This method will draw a dial-type graph for single input
      it has a rather large arguement list and is as follows

      &display to pass the display object, mainly used if multiple displays are connected to the MCU
      curval = date to graph (must be between loval and hival)
      cx = center position of dial
      cy = center position of dial
      r = radius of the dial
      loval = lower value of the scale (can be negative)
      hival = upper value of the scale
      inc = scale division between loval and hival
      sa = sweep angle for the dials scale
      dig = format control to set number of digits to display. (not includeing the decimal)
      label = bottom lable text for the graph
      redraw = flag to redraw display. only on first pass (to reduce flickering)
    */

    void DrawDial(Adafruit_SSD1306 &d, double curval, int cx, int cy, int r, double loval , double hival , double inc, double dig, double sa, String label, bool &Redraw) {

      double ix, iy, ox, oy, tx, ty, lx, rx, ly, ry, i, Offset, stepval, data, angle;
      double degtorad = .0174532778;
      static double px = cx, py = cy, pix = cx, piy = cy, plx = cx, ply = cy, prx = cx, pry = cy;

      if (Redraw) {
        Redraw = false;
        // draw the dial only one time--this will minimize flicker
        d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
        d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
        d.setTextSize(1);
        d.setCursor(2, 4);
        d.println(label);
        // center the scale about the vertical axis--and use this to offset the needle, and scale text
        Offset = (270 +  sa / 2) * degtorad;
        // find hte scale step value based on the hival low val and the scale sweep angle
        // deducting a small value to eliminate round off errors
        // this val may need to be adjusted
        stepval = ( inc) * (double (sa) / (double (hival - loval))) + .00;
        // draw the scale and numbers
        // note draw this each time to repaint where the needle was
        for (i = 0; i <= sa; i += stepval) {
          angle = ( i  * degtorad);
          angle = Offset - angle ;
          ox =  (r - 2) * cos(angle) + cx;
          oy =  (r - 2) * sin(angle) + cy;
          ix =  (r - 10) * cos(angle) + cx;
          iy =  (r - 10) * sin(angle) + cy;
          tx =  (r + 10) * cos(angle) + cx + 8;
          ty =  (r + 10) * sin(angle) + cy;
          d.drawLine(ox, oy, ix, iy, SSD1306_WHITE);
          d.setTextSize(1);
          d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
          d.setCursor(tx - 10, ty );
          data = hival - ( i * (inc / stepval)) ;
          d.println(data, dig);
        }
        for (i = 0; i <= sa; i ++) {
          angle = ( i  * degtorad);
          angle = Offset - angle ;
          ox =  (r - 2) * cos(angle) + cx;
          oy =  (r - 2) * sin(angle) + cy;
          d.drawPixel(ox, oy, SSD1306_WHITE);
        }
      }
      // compute and draw the needle
      angle = (sa * (1 - (((curval - loval) / (hival - loval)))));
      angle = angle * degtorad;
      angle = Offset - angle  ;
      ix =  (r - 10) * cos(angle) + cx;
      iy =  (r - 10) * sin(angle) + cy;
      // draw a triangle for the needle (compute and store 3 vertiticies)
      lx =  2 * cos(angle - 90 * degtorad) + cx;
      ly =  2 * sin(angle - 90 * degtorad) + cy;
      rx =  2 * cos(angle + 90 * degtorad) + cx;
      ry =  2 * sin(angle + 90 * degtorad) + cy;

      // blank out the old needle
      d.fillTriangle (pix, piy, plx, ply, prx, pry, SSD1306_BLACK);

      // then draw the new needle
      d.fillTriangle (ix, iy, lx, ly, rx, ry, SSD1306_WHITE);

      // draw a cute little dial center
      d.fillCircle(cx, cy, 3, SSD1306_WHITE);

      //save all current to old so the previous dial can be hidden
      pix = ix;
      piy = iy;
      plx = lx;
      ply = ly;
      prx = rx;
      pry = ry;
      // up until now print sends data to a video buffer NOT the screen
      // this call sends the data to the screen
      d.display();

    }

    /*

      function to draw a cartesian coordinate system and plot whatever data you want
      just pass x and y and the graph will be drawn huge arguement list

      &display to pass the display object, mainly used if multiple displays are connected to the MCU
      x = x data point
      y = y datapont
      gx = x graph location (lower left)
      gy = y graph location (lower left)
      w = width of graph
      h = height of graph
      xlo = lower bound of x axis
      xhi = upper bound of x asis
      xinc = division of x axis (distance not count)
      ylo = lower bound of y axis
      yhi = upper bound of y asis
      yinc = division of y axis (distance not count)
      title = title of graph
      &redraw = flag to redraw graph on fist call only

    */

    void DrawCGraph(Adafruit_SSD1306 &d, double x, double y, double gx, double gy, double w, double h, double xlo, double xhi, double xinc, double ylo, double yhi, double yinc, double dig, String title, boolean &Redraw) {

      double i;
      double temp;
      int rot, newrot;

      if (Redraw == true) {
        Redraw = false;
        d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
        d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
        d.setTextSize(1);
        d.setCursor(2, 4);
        d.println(title);
        ox = (x - xlo) * ( w) / (xhi - xlo) + gx;
        oy = (y - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
        // draw y scale
        d.setTextSize(1);
        d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
        for ( i = ylo; i <= yhi; i += yinc) {
          // compute the transform
          // note my transform funcition is the same as the map function, except the map uses long and we need doubles
          temp =  (i - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
          if (i == 0) {
            d.drawFastHLine(gx - 3, temp, w + 3, SSD1306_WHITE);
          }
          else {
            d.drawFastHLine(gx - 3, temp, 3, SSD1306_WHITE);
          }
          d.setCursor(gx - 27, temp - 3);
          d.println(i, dig);
        }
        // draw x scale
        for (i = xlo; i <= xhi; i += xinc) {
          // compute the transform
          d.setTextSize(1);
          d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
          temp =  (i - xlo) * ( w) / (xhi - xlo) + gx;
          if (i == 0) {
            d.drawFastVLine(temp, gy - h, h + 3, SSD1306_WHITE);
          }
          else {
            d.drawFastVLine(temp, gy, 3, SSD1306_WHITE);
          }
          d.setCursor(temp, gy + 6);
          d.println(i, dig);
        }
      }

      // graph drawn now plot the data
      // the entire plotting code are these few lines...

      x =  (x - xlo) * ( w) / (xhi - xlo) + gx;
      y =  (y - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
      d.drawLine(ox, oy, x, y, SSD1306_WHITE);
      d.drawLine(ox, oy - 1, x, y - 1, SSD1306_WHITE);
      ox = x;
      oy = y;

      // up until now print sends data to a video buffer NOT the screen
      // this call sends the data to the screen
      d.display();

    }

    /////////////////////////////////////////////////////////

For my purpose of running this project in my OLED I replaced all SSD1306 keyword with SH1106. Except this project every other projects works on this OLED by replacing SSD1306 keyword with SH1106.

Getting this error in Ardunio IDE 'SH1106_WHITE' was not declared in this scope

    Arduino: 1.8.13 Hourly Build 2020/04/21 12:25 (Linux), Board: "Arduino Uno"

    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawBarChartV(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, String, bool&)':
    sketch_oct07a:162:33: error: 'SH1106_WHITE' was not declared in this scope
         d.fillRect(0, 0,  127 , 14, SH1106_WHITE);
                                     ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:162:33: note: suggested alternative: 'SH1106_LCDWIDTH'
         d.fillRect(0, 0,  127 , 14, SH1106_WHITE);
                                     ^~~~~~~~~~~~
                                     SH1106_LCDWIDTH
    sketch_oct07a:163:20: error: 'SH1106_BLACK' was not declared in this scope
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:163:20: note: suggested alternative: 'SH1106_128_64'
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
                        SH1106_128_64
    sketch_oct07a:187:30: error: 'SH1106_WHITE' was not declared in this scope
       d.drawRect(x, y - h, w, h, SH1106_WHITE);
                                  ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:187:30: note: suggested alternative: 'SH1106_LCDWIDTH'
       d.drawRect(x, y - h, w, h, SH1106_WHITE);
                                  ^~~~~~~~~~~~
                                  SH1106_LCDWIDTH
    sketch_oct07a:188:39: error: 'SH1106_BLACK' was not declared in this scope
       d.fillRect(x, y - h, w, h - level,  SH1106_BLACK);
                                           ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:188:39: note: suggested alternative: 'SH1106_128_64'
       d.fillRect(x, y - h, w, h - level,  SH1106_BLACK);
                                           ^~~~~~~~~~~~
                                           SH1106_128_64
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawBarChartH(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, String, bool&)':
    sketch_oct07a:221:33: error: 'SH1106_WHITE' was not declared in this scope
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:221:33: note: suggested alternative: 'SH1106_LCDWIDTH'
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
                                     SH1106_LCDWIDTH
    sketch_oct07a:222:20: error: 'SH1106_BLACK' was not declared in this scope
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:222:20: note: suggested alternative: 'SH1106_128_64'
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
                        SH1106_128_64
    sketch_oct07a:246:47: error: 'SH1106_BLACK' was not declared in this scope
       d.fillRect(x + level, y - h, w - level, h,  SH1106_BLACK);
                                                   ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:246:47: note: suggested alternative: 'SH1106_128_64'
       d.fillRect(x + level, y - h, w - level, h,  SH1106_BLACK);
                                                   ^~~~~~~~~~~~
                                                   SH1106_128_64
    sketch_oct07a:247:31: error: 'SH1106_WHITE' was not declared in this scope
       d.drawRect(x, y - h, w,  h, SH1106_WHITE);
                                   ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:247:31: note: suggested alternative: 'SH1106_LCDWIDTH'
       d.drawRect(x, y - h, w,  h, SH1106_WHITE);
                                   ^~~~~~~~~~~~
                                   SH1106_LCDWIDTH
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawDial(Adafruit_SH1106&, double, int, int, int, double, double, double, double, double, String, bool&)':
    sketch_oct07a:283:33: error: 'SH1106_WHITE' was not declared in this scope
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:283:33: note: suggested alternative: 'SH1106_LCDWIDTH'
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
                                     SH1106_LCDWIDTH
    sketch_oct07a:284:20: error: 'SH1106_BLACK' was not declared in this scope
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:284:20: note: suggested alternative: 'SH1106_128_64'
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
                        SH1106_128_64
    sketch_oct07a:333:49: error: 'SH1106_BLACK' was not declared in this scope
       d.fillTriangle (pix, piy, plx, ply, prx, pry, SH1106_BLACK);
                                                     ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:333:49: note: suggested alternative: 'SH1106_128_64'
       d.fillTriangle (pix, piy, plx, ply, prx, pry, SH1106_BLACK);
                                                     ^~~~~~~~~~~~
                                                     SH1106_128_64
    sketch_oct07a:336:43: error: 'SH1106_WHITE' was not declared in this scope
       d.fillTriangle (ix, iy, lx, ly, rx, ry, SH1106_WHITE);
                                               ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:336:43: note: suggested alternative: 'SH1106_LCDWIDTH'
       d.fillTriangle (ix, iy, lx, ly, rx, ry, SH1106_WHITE);
                                               ^~~~~~~~~~~~
                                               SH1106_LCDWIDTH
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawCGraph(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, double, double, double, double, String, boolean&)':
    sketch_oct07a:388:33: error: 'SH1106_WHITE' was not declared in this scope
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:388:33: note: suggested alternative: 'SH1106_LCDWIDTH'
         d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                     ^~~~~~~~~~~~
                                     SH1106_LCDWIDTH
    sketch_oct07a:389:20: error: 'SH1106_BLACK' was not declared in this scope
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:389:20: note: suggested alternative: 'SH1106_128_64'
         d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                        ^~~~~~~~~~~~
                        SH1106_128_64
    sketch_oct07a:433:28: error: 'SH1106_WHITE' was not declared in this scope
       d.drawLine(ox, oy, x, y, SH1106_WHITE);
                                ^~~~~~~~~~~~
    /tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:433:28: note: suggested alternative: 'SH1106_LCDWIDTH'
       d.drawLine(ox, oy, x, y, SH1106_WHITE);
                                ^~~~~~~~~~~~
                                SH1106_LCDWIDTH
    exit status 1
    'SH1106_WHITE' was not declared in this scope

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

I am new to this field. Any help will be appreciated.

body:
In the Adafruit_SH1106.h header file, `SH1106_WHITE` and `SH1106_BLACK` are defined simply as `WHITE` and `BLACK` respectively.
So instead of writing `SH1106_WHITE` try replacing it `WHITE` and `SH1106_BLACK` as `BLACK` respectively.

Eg:-  `fillRect(0, 0,  127 , 14, WHITE);`


message:
Is this LED Strip Schematic correct?

I am trying to simulate a 12V LED strip as per [this tutorial.][1] However the schematic I tried to make on EasyEDA looks quite different from the images on the website. I wanted to know if what I did is correct.

[![A1, A2, A3 are the pins connected to the Arduino][2]][2]

[![As compared to this...][3]][3]

  [1]: https://learn.adafruit.com/rgb-led-strips/usage
  [2]: https://i.stack.imgur.com/iPMug.png
  [3]: https://i.stack.imgur.com/EZb6x.png

body:
Schematic and wiring diagram are not the same. They seem to use different RGB LEDs. The wiring diagram has **common anode** RGB LEDs, while your schematic uses a **common cathode** RGB LED. The difference is, which side of the LED gets switched.

In the common anode configuration, all anodes (positive lead) of the individual color LEDs are connected together, while the cathodes (negative leads) are brought out, so that you can switch them via the MOSFETs. That means, that the MOSTFETs are connected between the strips color component pins and ground.

In the common cathode configuration, all cathodes (negative lead) of the individual color LEDs are connected together, while the anodes (positive leads) are brought out for you to switch them. In this case, the MOSFETs are connected between the strips color component pins and Vcc.

---

Besides that, you should be careful with providing 12V at Vin of an Arduino Uno. While it is possible, you can very fast get the linear voltage regulator to overheat, when providing 12V. It dissipates the excess voltage (so 7V, to get it to 5V down) as heat. The voltage regulator is not cooled, so you might run into this issue, with the wiring diagram. It depends on your much current you draw from the regulator.


message:
How to find out if HX711(amplifier and 24-bit ADC) is damaged or not?

I'm using this ADC with a load cell for weight measurement, I had 4 strain gauges and mounted them on a cantilever structure that I made out of acrylic sheet, used calibration program from here: https://github.com/olkal/HX711_ADC/blob/master/examples/Calibration/Calibration.ino,

followed the steps but it gave ```calibration factor as 0.00``` and the output was ```NaN``` or ```inf``` . I used another program from here: https://github.com/queuetue/Q2-HX711-Arduino-Library/tree/master/examples/simple_scale and the output was just hovering around ```83868```. So I thought that the mounting was the problem and used a load cell (green label, CZL 601) with the above and found the same results by doing the above.

Then I thought maybe the ADC is at fault , measured the power output from Arduino to the board and it was around 5 V , but when I measured between the ```E+``` and ```E-``` , I got ```0 V```. Since it is the excitation voltage to the bridge, it should be around 5V too right?

Is this the right way of checking the board?

P.S. I measured the four wires of the load cell and connected the opp. ends of the bridge to the E+ , E- , A+ , A- (order doesn't matter here right? connected the pairs that showed the rated resistance to E's and A's separately)

Here's a [pic][1] of the connections

Between White and green wire the Resistance is 350 ohm
Between Bk( connected in the board ) and the red it is 408 ohm
Between White and red it was 263 ohm
Between white and bk it is 320 ohm

Between bk(not connected in the board) and all others it is around 1 MOhm (so ignored that)
  [1]: https://photos.app.goo.gl/4HEmZaN1EwZ7Mjur7

body:
Looking closely at the photo of your setup I can see that you haven't soldered the header to the breakout board. Whilst there are headers available that don't require soldering, and ways of making header connections that don't require soldering, this isn't either of those.

Without solder the connection to the board will be intermittent at best and non-existent in general.


message:
Az Delivery ESP32 DevKitC V2 PIN names/number

i wonder where to find out the PIN names for the Az Delivery ESP32 DevKitC V2.
There is a pin out graphic, but it does not say how the Pin addresses are:
https://cdn.shopify.com/s/files/1/1509/1638/files/ESP_-_32_NodeMCU_Developmentboard_Pinout_Diagram.jpg?4479111012146266271

I thought maybe it's just the number of the GPIOs but that's wrong. In the first example script only PIN 1 was named as the address for the board intern LED.

body:
ESP32 boards don't use "names" for their IO pins. There is a direct 1:1 mapping between the internal "GPIO" number and the pin number.

To do something with pin G21 on the board you use pin number 21. To do something with pin G14 you use pin number 14.

By all accounts that board differs from other ESP32 devkits in that the LED is on GPIO1 rather than the normal GPIO0 that all the other boards use. I suspect that this is the source of your confusion.


message:
Dealing with a Signal Source

The following circuit is a simplified version of a more complex system. For testing purposes, the 555 Timer was added to serve as a test signal source with frequencies set by the resistors in series. Each arbitrary signal is indicated by a push button and the Arduino needs to be able to distinguish what button has been pushed. Unfortunately, there can only be 3 buttons and more cannot be added. This is where the problem occurs. How can you reliably indicate which push button has been pressed without interfering with the arbitrary waveform?

At first, my original thought was to have the Arduino sample the signal based on that sample the Arduino would be able to tell which button is pressed.

When button 1 in the pink is pushed the Arduino receives a takes the following
 sample of the signal.

 [![enter image description here][2]][2]

    843
    848
    849
    849
    849
    849
       // Time 0 when button is pushed
    532
    414
    500
    373
    463
    346
    425
    370
    386
    476
    346
    442
    642
    788
Moving the input
[![enter image description here][3]][3]

        // At t = 0 the Serial Monitor reads zero
        998
        998
        998
        998
        998
        0
        0
        0
        0
        0
        998
        0
        0
        0
        0
        0
        0
        0
        0
        0
        998
        0
        0
        0
        0
        998
        0
        0
        0
        998
        998
        998
        0
        998
        0
        0
        0
        998
        0
        0
        0
        0

Moving the analog input does not make it any easier to distinguish which button was being pushed. Which is why I decided to ask the community on how to deal with this. I have tried using a relay and simply hard coding all of the cases but the result is a system is not very robust and is vulnerable to easily break over time.

  [1]: https://www.tinkercad.com/things/eB13vkkJXJT
  [2]: https://i.stack.imgur.com/DSbgc.png
  [3]: https://i.stack.imgur.com/2eAJa.png
  [4]: http://yaab-arduino.blogspot.com/2015/02/fast-sampling-from-analog-input.html

body:
There's an easy way to achieve reading multiple pushbuttons using single analog input.

All you need to do is create some voltage dividers at different voltages which can be read using analogRead. The last resistor,R6, in the diagram below ensures that the pin reads 0 when no push-button is pressed (i.e pull-down resistor).
In the diagram below, connect Vcc to 5V on the Arduino.

[![enter image description here][1]][1]

Try it out, you should be able to get well spaced out values for different push buttons!

  [1]: https://i.stack.imgur.com/ruJKq.png


body:
After a day or two of working on this problem, I have found that it is best to avoid using the analog pins and stay away from directly interfacing with the 555 Timer. This is a simplified version of a more complex circuit and the 555 Timer represents some arbitrary signal source. For example, on mobile radio, you push a button to send out a certain frequency. That is the concept here only the frequencies cannot be adjusted yet. Now that it has been clarified that the 555 Timer has been placed in the circuit for debugging purposes here is the best solution I have found to this problem. First, I have found that it is doable to read in from the analog pin on the Arduino but not easy. This leaves a lot of room for error being that the waveform is arbitrary with some random frequency. Therefore, I have opted to use the digital pins on the Arduino.
[![Revised Circuit][1]][1]
by using the digital pins I have now only have to worry about whether the button is high or low. Then NPN transistors were used to act as switches once the button is pushed. The diodes then were added to maintain a steady voltage across the base of the transistor. For testing purposes, the LCD was removed and replaced by an LED. As far as the code is concerned it is nothing extraordinary or complex as shown below. Therefore, I believe this may be the best way to go about solving this problem.

    const int D_pin10 = 10;
    const int D_pin9 = 9;
    const int D_pin8 = 8;
    int led = 13;
    void setup()
    {
      pinMode(D_pin10 , INPUT); // pin 10 is an input
      pinMode(D_pin9 , INPUT); // pin 10 is an input
      pinMode(D_pin8, INPUT); // pin 10 is an input
      pinMode(led, OUTPUT);
    }

    void loop()
    {
      int High_Low10 =0;
      int High_Low9 =0;
      int High_Low8 =0;

      High_Low10 = digitalRead(D_pin10);
      High_Low9 = digitalRead(D_pin9);
      High_Low8 = digitalRead(D_pin8);

      if(High_Low10 == HIGH)
      {
        digitalWrite(led, HIGH);
      }
      else if(High_Low9 == HIGH)
      {
        digitalWrite(led, HIGH);
      }
      else if(High_Low8 == HIGH)
      {
        digitalWrite(led, HIGH);
      }
      else
      {
        digitalWrite(led, LOW);
      }
      delay(1000);
    }

  [1]: https://i.stack.imgur.com/ZzNd7.png


message:
Can I use LiFe PO4 batteries in a 18650 battery shield?

Is it safe to use LiFe PO4 batteries in a 18650 Battery Shield (sometimes called Lithium-Battery Shield)?

body:
In my opinion it is NOT SAFE, if your 18650 Battery Shield also charges the battery.
Anyhow some pages state that it is possible to charge LiFePo4 batteries with 4.2V instead of the recommended 3.65V. https://www.powerstream.com/lithium-phosphate-charge-voltage.htm

LiFePo4 batteries have a smaller energy density and therefore capacity. Thus those are not as explosive as Li-Ion batteries. But you are risking damaging the battery and shorten its lifespan.


message:
Can I use The mpu6050 with this?

I am making a project with 3 arduinos (2 slave, 1 master) and I want to know can I use the mpu6050 since it uses the I2c communication.

body: You can but keep the I2C wires less then about 30cm. If they are going to be further apart consider something like RS485 or CAN. Are you sure you need three?


body: Yes, but only from the master. You have one I2C bus with three slave devices on it - two arduinos and one mpu6050.


message:
Digispark uploading not working in KDE Neon (Linux)

I am using KDE Neon and have downloaded the Arduino IDE via the Snap store. It worked well with the ESP8266 and other Arduions. But when I tried to upload a simple sketch or an example sketch to my Digispark, I get an error message. I have selected the right Board and the micronucleus programmer. I have also installed libusb. But I always get the following error message:

/home/myusername/snap/arduino/41/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus: error while loading shared libraries: libusb-0.1.so.4: cannot open shared object file: No such file or directory

body:
I had the same problem when using the snap package of the Arduino IDE. I solved the problem by installing the Arduino IDE from the official web page: [https://www.arduino.cc/en/software][1]

  [1]: https://www.arduino.cc/en/software

You might have to run the Arduino IDE with sudo or better add a custom udev rule in case you now get following assertion error:

> 'micronucleus_connect: Assertion `res >= 4' failed.'

Solving the assertion error is further described in following post: https://digistump.com/board/index.php?topic=106.0


message:
AMIS30543 - Library code | Order of pinDirection and pinOut

This piece of code was taken from AMIS30543- Arduino library,
```c++
void init(uint8_t slaveSelectPin) {
    ssPin = slaveSelectPin;
    digitalWrite(ssPin, HIGH);
    pinMode(ssPin, OUTPUT);
}
```

Facts I know

 - digitalWrite - makes the pin to the corresponding voltage level
 - pinMode - makes the pin either input or output
 - ssPin is active low pin usually.

So I was wondering before setting the pinDirection why the pin is made HIGH, Then immediately after that the pinDirection was declared as OUTPUT

Also I know , if a pin was made HIGH and on the next line if the direction of the same is set as  INPUT will bring the internal pull up resistor in action .

So what am I missing here. More over in Arduino does the order of pinMode/digitalWrite matter.? if So what is the meaning of this particular lines of code [Github link to the library][1]

  [1]: https://github.com/pololu/amis-30543-arduino/blob/master/AMIS30543.h

body:
The library is doing this to make sure, that the pin will never go low during initialization.

Imagine doing it the other way round:

    pinMode(ssPin, OUTPUT);
    digitalWrite(ssPin, HIGH);

If the corresponding PORT bit is set to zero (LOW) previously (which is also the standard after reset/power cycle), the pin will go LOW for a very short time, until `digitalWrite()` sets it HIGH again. That LOW time is short, but it might needlessly activate the slave. If you first use `digitalWrite(ssPin, HIGH)`, you activate the internal pullup (as standard mode after reset/power cycle is INPUT) and set the corresponding PORT bit to 1. Thus, when you now change the pin mode, the pin is HIGH immediately, without ever going to LOW in between.

Internally the Arduino uses 3 SFRs (Special Function Registers), which are directly connected to the IO hardware of the pins. The `DDR` register of each port controls the "pin mode" aka direction of the pin (input or output). The `PORT` register controls the output value (HIGH or LOW; or turning the pullup resistor on or off in input mode). The `PIN` register reflects the current state of the pin (for reading it). In this case the double function of the `PORT` register is important, as it activates the internal pullup resistor, when set while in input mode.


body:
This initialization will work with [spi communication][1] for PIC32 microchip too?

  [1]: https://911electronic.com/spi-communication-how-spi-works/


message:
Using LM70 temperature sensor with Arduino

I am trying to sense the temperature using the LM70 temperature sensor with an Arduino Mega. As you can see in the Datasheet, it uses the SPI protocol. I have made the following connections (VSSOP-8 Package):
- SI/O pin --> Pin 50 Arduino Mega.
- SC pin --> Pin 52 Arduino Mega.
- CS pin --> Pin 53 Arduino Mega.
- V+ pin --> 3.3V Arduino Mega.
- GND pin --> GND Arduino Mega.

My code does not work (it does not print the right temperature), and I think it can be for two reasons:
1. I am not reading correctly the information from the sensor. It sends 16 bits, from which the 11 first bits store the data for the temperature.
2. I am not calculating the temperature in the right way.

This is my code:

    // the sensor communicates using SPI, so include the library:
    #include <SPI.h>

    void setup() {
      pinMode(51,OUTPUT); //MOSI
      pinMode(50,INPUT); //MISO
      pinMode(52,OUTPUT); //CLOCK PIN
      digitalWrite(53,HIGH); //slave select stays high. When we set this to low, the sensor will start to send data.
      SPI.begin();
      Serial.begin(9600);

      //time to set up
      delay(500);
    }

    void loop() {
        //enable Slave
        digitalWrite(A0,LOW); //Enable communication with slave
        delay(500); //wait for conversion

        int val = SPI.transfer(0x00); // read from sensor
        Serial.println(val); //display reading on serial monitor
        int temperature = val * 0.25;
        Serial.println(temperature); //display temperature on serial monitor

        //disable Slave
        digitalWrite(53,HIGH); //set to High again
    }

Please, if you see something wrong in my code, let me know.
Thank you in advance.

body:
There are several things that are not doing correctly. This is not a complete answer but to provide you some directions on how to get it right.

1) `A0` is pin 54, it is not `SS` which is pin 53;

2) On how to use the SPI library properly, I would suggest that you read my blog on [SPI](https://www.e-tinkers.com/2020/03/do-you-know-arduino-spi-and-arduino-spi-library/), it will also help you to get the data out of data sheet that you need for SPI programming. Based on the timing diagram on the data sheet, you will need to configure the SPI as `SPI_MODE2`;

3) LM70 SI/O pin is used as both MOSI and MISO, you will need to connect MOSI to SI/O via a 10k resistor, and connect SI/O direct to MISO, this information is available in the data sheet;

4) LM70's temperature data is in [Two's complement format](https://en.wikipedia.org/wiki/Two's_complement), To convert it, it needs a little bit work. It is then need to shift down/right using [bitshift](https://www.arduino.cc/en/pmwiki.php?n=Reference/Bitshift) operator by 5 bits to get ride of the first 5-bits, before finally multiply by 0.25C as per data sheet.

```
int value = 0x4b1f;  //value from SPI, temp = 125 degree C
int mask = 0x8000;   // mask for MSB
int temp = (-(value & mask) + (value & ~mask)) >> 5;
Serial.print("Temp");
Serial.println(temp*.25);
```
Read all links that I provided to understand the subjects and give it a try. Good luck!


body:
Your problem lies here:

```
    int val = SPI.transfer(0x00); // read from sensor
    Serial.println(val); //display reading on serial monitor
    int temperature = val * 0.25;
```

And it's a twofold problem.

First:

```
int val = SPI.transfer(0x00);
```

That only reads the first 8 bits of the data. To get all 16 bits you have to do two transfers and then combine them together with bitshifting:

```
int bh = SPI.transfer(0x00);
int bl = SPI.transfer(0x00);
int val = (bh << 8) | bl;
```

That then gives you a value that is right-aligned. you then need to shift it to the left the right number of bits and "sign extend" it to keep it negative if needed.  If you're not interested in the fractional part then it's as simple as:

```
val >>= 7;
if (val & 0x0100) {
    val |= 0xFE00;
}
```
Now... what does that all mean?  Well, assume it's currently 25°C. From the datasheet we can see that would give us a reading of `0000 1100 1001 1111` (note there is a typo in the datasheet saying that is 0b9f in hex when in fact it's 0c9f).

Let's do those operations - first the bit shift:

```
Dec   Hex   Bin
3231  0C9F  0000110010011111 >> 7
25    0019  0000000000011001
```

Then we look to see if bit 8 is set or not (bit 8 was the most significant bit). If it is then we OR it with bits 9-15 also set. This "sign extends" it.

Let's take a look at -25°C from the datasheet:

```
Dec   Hex  Bin
-3169 f39f 1111001110011111 >> 7      Shift right 7 bits
487   01e7 0000000111100111 & 0x0100  And with 8th bit
256   0100 0000000100000000           Result is not 0 so is true

"Or" the shifted value with 0xFE00:

487   01e7 0000000111100111 or
65024 fe00 1111111000000000 =
-25   ffe7 1111111111100111
```


message:
Infrared sending not working slight misconfiguration?

Edit: Took some advice from below but it still doesn't work. I think it probably blocking code but please tell me how I could fix it to send a the valid infrared signal, NOTE: I wouldn't actually code it like this I am just trying to learn and understand how to do it and then make it better after:

    uint8_t Status;
    uint8_t Counter;
    const uint32_t Code[] = {4507,4507,573,1694,573,1694,573,1694,573,573,573,573,573,573,573,573,573,573,573,1694,573,1694,573,1694,573,573,573,573,573,573,573,573,573,573,573,573,573,1694,573,573,573,573,573,573,573,573,573,573,573,573,573,1694,573,573,573,1694,573,1694,573,1694,573,1694,573,1694,573,1694,573,46560};

    void setup() {
      pinMode(4, OUTPUT);
    }

    void loop() {
      while(Counter<70) {
        if (Status=1) {
            digitalWrite(4, HIGH);
            Status=3;
            while(Status=3) {
              delayMicroseconds(26);
              digitalWrite(4, HIGH);
              delayMicroseconds(26);
              digitalWrite(4, LOW);
            }
            delayMicroseconds(Code[Counter]);
            Status=2;
            Counter++;
        } else {
          if (Status=2) {
            digitalWrite(4, LOW);
            Status=0;
            while(Status=0) {
              delayMicroseconds(26);
              digitalWrite(4, HIGH);
              delayMicroseconds(26);
              digitalWrite(4, LOW);
            }
            delayMicroseconds(Code[Counter]);
            Status=1;
            Counter++;
          }
        }
      }
    }

body:
There are two basic things wrong here - one with your understanding of the timings, and the other with your understanding of how IR communication works.

First the timings - those are both ON *and* OFF timings. You don't just turn on for a defined length of time - you turn on for a defined length of time *and then turn off for another defined length of time*.

So for the timings in your code `4507,4507,573,1694,573,...etc...` you would:

* Turn on
* Wait 4507us
* Turn off
* Wait 4507us
* Turn on
* Wait 573us
* Turn off
* Wait 1694us
* Turn on
* Wait 573us
* ... etc ...

You have no "off" time in your code, only ever on times.

Secondly is your understanding of IR communications. It does not involve turning an LED on or off for defined times. It's not as simple as that. Instead you are controlling the *modulation* of an LED.  When the LED of an IR remote control is "on" it's not just turned on - it's rapidly turning on and off. The receiver looks for the presence or absence of this rapid turning on and off light. This is the "carrier frequency" of the signal and must match what the receiver is looking for.

Typically this is between 30kHz and 50kHz depending on the receiver.

So you need some way of generating that rapid on-off signal. Normally this is done using PWM by the IR libraries and switching between 0% and 50% duty cycle for the off and on periods of the signal you want to send.

So it's far simpler to just use a library that does all this underlying work for you.


message:
Building RS485 serial to USB adapter with digispark

Is it possible to build an serial-adapter with digispark board?
Like: Embedded System with 2-wire RS-485 Port connect to my digispark board. Digispark Board is connected via USB to my Computer (running Linux tty or Windows COM Putty Interface)

I also own a Raspberry Pi. I'm very new at this thing, so maybe there is a way to convert the RS485 signals to monitoring my devices with my computer?

body: There are some good books available to help. There is the Raspberry Pi cookbook and the Arduino cookbook. These will take you from the very beginning to the point where you can make your own designs and they will work.


body:
I would steer you away from using something that has a chip with neither a USART nor USB hardware for the purposes of making something like that. The ATTiny85 that's on the Digispark has USI (Universal Serial Interface), which is really more of a USART construction kit. The USB support it has is bitbanged and somewhat unreliable.

If you do go in this direction and want a small Arduino type board like Digispark, the "Beetle" ATMega32u4 based boards are a better choice.  It has a native USB interface, and a proper USART to hook to an RS-485 driver.

The chip also has a bootloader section; it is difficult to corrupt your own sketch.  It also has more memory, not that you necessarily need it.


message:
What wireless protocols can be used with arduino?

Before you close this saying it's not related to programming. It is related to programming since i'm using it and asking about libraries.

What are the common types of communication protocols and their libraries? Theres WiFi which uses esp8266 etc. Zigbee which can be used with XBee, Bluetooth which can be used with esp32 and others.
What are a list of wireless protocols and chips and libraries for those wireless communications? (This list will be compiled by multiple people hopefully so its okay if you don't know the library or chip but protocol is good) thank you and hopefully no take down <3

body:
Arduino allows you to connect external peripherals (via I2C, SPI, UART, I/O) and shields.

It'll be impossible to list them all, as you can even make your own; but here an overview of the most common I can think off:

 - WiFi
 - Bluetooth
 - LoRa
 - Zigbee
 - Z-wave
 - RF (433mhz)
 - InfraRed
 - GSM/LTE

It'll be a trade-off between signal range, power usage, delay and bandwidth.

Do note that your question in this way is quite broad. If you want to use this to start your own wireless proejct, you can follow these steps (, but do note that we expect one to do some research/tests himself before posting a question):

 1. Find a tranmission layer applicable for your project based on requirements.
 2. Find Arduino compatible hardware (if none found; make your own or find another transmission layer / adjust requirements)
 3. Find libraries/examples of this hardware being used with Arduino.
 4. Buy the hardware (this is not step 1!)
 5. Use the found sources and make your project reality.


message:
Arduino binary LED 10 bit display

I'm working on a simple ADC project, the goal is to adjust the on/off of the LEDs according to the binary reading (1-on,0-off). I've tried this with 8 bit, and it works as intended. But on 10 bit, two of the LEDs with representation of 2^8 and 2^9 won't turn on even though the reading on the serial monitor is 1023 (should be 1111111111 -all LEDs on). I wonder if there's anything wrong with my code or circuit?
(I'm totally new to arduino, sorry for the noobness)
-I'm using Arduino UNO R3, the details are shown in the image[![enter image description here][1]][1]

    void setup(){
      pinMode(13, OUTPUT);
      pinMode(12, OUTPUT);
      pinMode(11, OUTPUT);
      pinMode(10, OUTPUT);
      pinMode(9, OUTPUT);
      pinMode(8, OUTPUT);
      pinMode(7, OUTPUT);
      pinMode(6, OUTPUT);
      pinMode(5, OUTPUT);
      pinMode(4, OUTPUT);

      Serial.begin(9600);
    }

    void loop(){
      int sensorValue = analogRead(A0);
      Serial.print("Decimal=");
      Serial.print(sensorValue);
      Serial.print("\tBinary=");
      Serial.println(sensorValue,BIN);

      if(sensorValue>=0&&sensorValue<=1023){
        digitalWrite(4,(sensorValue&1));
        digitalWrite(5,(sensorValue&2));
        digitalWrite(6,(sensorValue&4));
        digitalWrite(7,(sensorValue&8));
        digitalWrite(8,(sensorValue&16));
        digitalWrite(9,(sensorValue&32));
        digitalWrite(10,(sensorValue&64));
        digitalWrite(11,(sensorValue&128));
        digitalWrite(12,(sensorValue&256));
        digitalWrite(13,(sensorValue&512));
      }
      delay(20);
    }

  [1]: https://i.stack.imgur.com/DBymY.jpg

body:
Seems, digitalWrite does not take any `int` != 0 as HIGH

Rather consider supplying a boolean (one byte value)

       digitalWrite(12,(sensorValue&256)==256);
       digitalWrite(12,(sensorValue>>8)&1);
or similar


body:
According to [the official documentation][doc], the second parameter of
`digitalWrite()` should be either `HIGH` or `LOW`. Thus, in order to be
compliant with the published API, you are supposed to write:

```c++
digitalWrite(12, sensorValue&256 ? HIGH : LOW);
```

In practice, `digitalWrite()` interprets any non-zero value as `HIGH`.
However, [its prototype][proto] is:

```c++
void digitalWrite(uint8_t pin, uint8_t val);
```

Both parameters have the type `uint8_t`, which means “8-bit unsigned
integer”. If you provide a value that doesn't fit in 8 bits, the
implicit cast to `uint8_t` will reduce it modulo 28. Thus,
both 256 and 512 become zero through the implicit cast.

[doc]: https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/
[proto]: https://github.com/arduino/ArduinoCore-avr/blob/1.8.3/cores/arduino/Arduino.h#L135


message:
Photoresistor help

I'm a newcomer to Arduino, trying to read analog values from a circuit with a photoresistor. I believe I am using a 1-ohm resistor

The problem I am having is that my photoresistor does not seem to be working, or my circuit is wrong. When I run the below code on my Nano, my Serial monitor constantly prints 1023. When I cover the photoresistor completely with my finger, the value dips down to 900-950, but then jumps back up to 1023. It dips down to 900-950 again, and jumps back to 1023. This happens continuously.

Here is my code:

```
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int value = analogRead(A0);
  Serial.println(value);
  delay(20);
}
```

Here is an image of the circuit I am using. In my case, I am using a Nano instead of Uno.

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/A3rDT.png

I ran the above code on the virtual circuit above, and it works as expected. However, on my physical device, the phenomenon I explained above occurs.

Is there something wrong with my circuit? Could it be an issue with my photoresistor?

body:
If you pealed the backing off the bread board you will find that you have plugged in your green, red and photo resistor wires into one piece of metal.  This means they are shorted together and as such do not work as you might expect.

[![enter image description here][1]][1]

Also, be aware that [photo resistor or cadmium sulfide cells][2] are slow to react to changes in light.  Sometimes taking about a second to fully change to a new resistance.  If you need a faster response consider using a photo diode or photo transistor.

  [1]: https://i.stack.imgur.com/yB9UT.jpg
  [2]: https://en.wikipedia.org/wiki/Photoresistor


message:
My code is not uploading to Arduino Uno, Please help!

I am very new to arduino, so new that it is my first board. I keep running into this error

`avrdude: stk500_recv(): programmer is not responding`

`avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00`

I have searched the internet for hours, tried solutions from almost every StackExchange question related to this topic, and even Reddit posts but none of those have been able to help me. All my settings are as they are supposed to be. Both the correct board and serial port are selected but it still keeps giving me this error:

`System wide configuration file is "/home/rahat/Desktop/Arduino/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"`

`User configuration file is "/home/rahat/.avrduderc"`

`User configuration file does not exist or is not a regular file, skipping`

       ` Using Port                    : /dev/ttyS4
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200`
`
avrdude: stk500_recv(): programmer is not responding` <br>`
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00`

Also my operating system is **Ubuntu 20.04 LTS**

body:
First of all find out on which port the Arduino is connected by running the command : ```dmesg | grep tty```. You should get ```[82893.921017] usb 1-1: cp210x converter now attached to ttyXXX``` with the ```ttyXXX``` COM port.
Then check if the port is visible ```Tools->Port```. If the port is not visible then you have a permission issue.


message:
Sequencing air pistons proble - Help please?

I am a beginner trying to activate 2 sets of 3 air pistons sequentially by going through the YouTube Tutorials... Help, please, pretty please?? :-)

There are 3 sets of 2 pistons, each set working in opposition.
So I have P1/P2, P3/P4, and P5/P6, each set working in opposition to squeeze at the center sequentially -
Initial state at turn-on/Reset must be:
```
// Step 1 Run Once:
P1 Down/P2 Up  // Move simultaneously (joining at the center) and HOLD in position -
P2 Up/P3 Down  // Move simultaneously and HOLD -
P5 Up/P6 Down  // Move simultaneously and HOLD -
// Wait for Start button -
```
I need to start/stop the sequencing with a toggle push-button -
I have reed-switch sensors that will give me a set of two TRANSIENT contact closure for each piston moving to the Up and Down positions -

Once started, the sequence needs to be as follows:
```
// Loop until Reset button is pushed -
// STEP 2: -
P1 Down/P2 Up (HOLD) // Old Initial State, unchanged -
P3 Down/P4 Up (MOVE) // Piston 3 moves Down/Piston 4 moves Up and HOLDS -
P5 Up/P6 Down (HOLD) // Still Old Initial State, unchanged -
```
// PROBLEM:  P3 Down AND P4 Sensors only give me a TRANSIENT closure:  These two transients MUST occur to initiate Step 3, but  they are not always exactly synched together, so my initial try by putting them in series fails... -
// I need to use that set of contact closures to trigger the next command: -
```
// Step 3: -
// The transient closures of P3 Down/P4 Up Sensors is the trigger needed for -
P5 Down/P6 Up (MOVE) // P5 moves Down/P6 moves Up and HOLD -
P1 Up/P2 Down (MOVE) // P1 moves Up/P2 moves Down and HOLD -
P3 Down/P4 Up (HOLD)  // P3/P4 HOLD -

// Back to Step 2 until the Reset button is pushed -
```
I can send you my attempt at coding for this, but it does not work unless the two sensors close simultaneously, which only happens in simulation...  ARGH..  :-(

Can someone send me a piece of code that will work for this, please?
I would really, really appreciate that...  Very frustrated right now!
You can email me at XXXXXXX.XXXX@XXXXX.XXX or text/call at (XXX)XXX-XXXX
Thanks either way.
Sincerely,
Michael

PS:  I tried to wire for a separate toggle switching for each sensor, but I run out of pins on my Arduino UNO R3... Looking into it via YouTube https://www.youtube.com/watch?v=cAT07gy4DII "Increase the digital outputs on an Arduino (PART 1 & 2)" but that is way more complex...  Trying to wade my way through that now...

body:
> it does not work unless the two sensors close simultaneously

If I understand correctly, the problem is that when your Arduino detects
the second transient signal, the first one is not active anymore, and
your program doesn't remember it has already seen that first signal.

Your Arduino has memory. Thousands of bits of memory! So it can remember
quite a few things. The solution to your problem is to simply make use
of that memory. When you detect a signal that should be useful for a
future decision, take note, store it in a variable. In order for the
variable to be remembered across calls of the function where you set it,
it has to be global. Or, better yet, `static` local.

Here is how that could look like in code:

```c++
// A `static' variable is a variable that remembers its state across
// calls of the function. A global variable would do the same, but
// code is usually clearer when variables are defined close to where
// they are used. A `bool' (for "boolean") is a variable that can only
// be either `true' or `false'.
static bool P5_is_up, P6_is_down;

// If the sensor tells us that the P5 piston went all the way up, take
// note of the fact and remember it.
if (digitalRead(P5_up_sensor) == LOW)
    P5_is_up = true;

// Same for P6 going down.
if (digitalRead(P6_down_sensor) == LOW)
    P6_is_down = true;

// If both pistons finished their travel, we can move to the next
// step. `&&' means "and".
if (P5_is_up && P6_is_down)
    goto_step_3();
```

You will need to reset those variables to `false` at the appropriate
time. The example code above doesn't show that as it only deals with the
logic for deciding when it is time to start step 3.

You will probably end up with many of these variables, and lots of
repetitive code. So you will need to structure your program in order to
avoid excessive repetition. But that is not your immediate problem. For
now, try to make the logic work for a single step transition. Once you
get the logic right, you can worry about generalizing the logic to any
transition.


message:
Help in personal alarm clock project, cant write time on seven segment display

<!-- language-all: lang-cpp -->

I'm trying to make a type of Arduino alarm clock, which when the time I inputed is equals to the current time, a servo will turn on my lights. It basically consists of a Keypad, an RTC DS1307 and a TM1637 seven segment display. The basic idea is that the RTC module would print time to the display until I decide to write something on the keypad, which would clear the time on the display to let me write the alarm. My problem is that the display manages to both show time on the display and write to the display but this only works on separate code, not together.

The keypad has a '\*' and '#' character, when i decide to write the time i want the lights to turn on, after writing it i press the '\*' character to save that time and then the idea would be to compare the time written and the present time, if i press '#', then all would be canceled and the RTC module would continue to show the time on the display. (i have not manage to advance that much due to my error on not being able to clear the display when i want to write on the keypad)

```
#include "Arduino.h"

// KEYPAD
#include "Keypad.h"

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

char customKey;

byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

// DISPLAY
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"

const byte PIN_CLK = 4;   // define CLK pin (any digital pin)
const byte PIN_DIO = 5;   // define DIO pin (any digital pin)
SevenSegmentExtended      display(PIN_CLK, PIN_DIO);

// RTC

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>

void setup(){
    Serial.begin(9600);         // initializes the Serial connection @ 9600 baud
    display.init();
    display.setBacklight(100);  // set the brightness to 10 %
    display.print("ON");      // display INIT on the display
    delay(1000);                // wait 1000 ms
    display.clear();
}

// OTROS

#define digit 4

byte data_count = 0;
char Data[digit];

void loop(){

    tmElements_t tm; // CLOCK

    display.setColonOn(true);
    customKey = customKeypad.getKey();

    if (RTC.read(tm)) {
        display.printTime(tm.Hour, tm.Minute, true);
    }

    if (customKey) { // ACTIVATE KEYPAD

        display.clear();

        if (customKey == '*') { // IF *
            display.blink();

            if (Data[data_count] < 3) {
                error();
            }

        } else if (customKey == '#') { // IF #
            display.blink();
            display.setColonOn(false);
            display.clear();
            clearData();
        } else { // WRITE ON DISPLAY

            Data[data_count] = customKey;
            display.setCursor(0,data_count);
            display.print(Data[data_count]);

            if (data_count < 4) {
                data_count++;
            } else {
                error();
            }
        } // END DISPLAY WRITE

    } // END KEYPAD IF

} // END LOOP

void error() { // DISPLAY ERROR AND DELETE DATA
    display.clear();
    display.setColonOn(false);
    display.print("ERR");
    delay(1000);
    display.clear();
    clearData();
}

void clearData() { // CLEAR DATA
    while (data_count != 0) {
        Data[data_count--] = 0;
    }
}
```

This are the libraries i'm using if it helps:
https://github.com/bremme/arduino-tm1637,
https://github.com/PaulStoffregen/DS1307RTC and the
Keypad library from Arduino library manager

Hope I made myself clear with my problem, english is not my first language, if you want more clarification then let me know!

That is basically what i've got, i'm sorry if the post is too long, i have been struggling with this problem for two days and i don't know how to proceed. Hope you all can help. Thanks!

body:
I think your problem is here:

> ```c++
> if (RTC.read(tm)) {
>     display.printTime(tm.Hour, tm.Minute, true);
> }
> ```

This code displays the current time, and it runs on every single loop
iteration. This is visibly not what you want. Your project should have
at least two distinct operational modes: “display the current time” and
“allow the user to input data”. You need a variable to remember which is
the current mode, e.g.

```c++
enum { MODE_DISPLAY_TIME, MODE_DATA_INPUT } mode;
```

You need to precisely define the events that make your program switch
modes, and code specific behaviors for each mode. For example:

```c++
if (mode == MODE_DISPLAY_TIME) {
    if (RTC.read(tm)) {
        display.printTime(tm.Hour, tm.Minute, true);
    }
} else if (mode == MODE_DATA_INPUT) {
    // Handle user input.
}
```

This general approach is called a “finite state machine”. You can read
more about it in [this blog article by Majenko][fsm].

[fsm]: https://majenko.co.uk/blog/finite-state-machine


message:
Smallest microcontroller?

I am looking for a microcontroller that is small (like a attiny10) which is the smallest one I could find.
Requirements I need: analogRead on 1 pin, 7 pins for analogWrite to micro leds so in total 10 pins (ground, power, analogRead, analogWrite). It's circuitry has to be basic no adding extra things like a crystal oscillator etc.. This will allow me to send a certain code to the recieving pin and then the microcontroller decide which led to turn on.

body:
I don't know whether it's really the smallest you can find but... The
[ATtiny84][] has an ADC, more digital pins than you need, and is
available in 3 mm packages (UFBGA and VQFN). There is also an
[Arduino-compatible core][core] available for it.

[ATtiny84]: https://www.microchip.com/wwwproducts/en/ATtiny84
[core]: https://github.com/SpenceKonde/ATTinyCore


body:
I made a Arduino develop board with [ATtiny3217](https://www.e-tinkers.com/2020/07/arduino-compatible-development-board-with-attiny3217/), it has a 24-pin VQFN form factor, but as powerful as ATmega328p, with no external crystal and capable running at 20MHz.

If this is not suitable for you, look into the new [tinyAVR family](https://www.microchip.com/design-centers/8-bit/avr-mcus/device-selection), they are the new generation of ATtiny with more functionalities than the older ATtiny family with the smaller footprint.


message:
TPIC6B595 Output Unable to Allow Supplied Power to 7-segment Display

We have an Arduino Nano connected to 4 small (0.5") common-anode 7-segment displays and 2 large (3") common-anode 7-segment displays. We are trying to multiplex the displays. The larger one requires more power than the smaller one (9V) which the shift register cannot supply.

Therefore, we have supplied 9V to the open drain outputs of the shift register that are connected to the larger displays with a pull-up resistor (390ohm). However, more power (7.5V) goes to the resistor than the display (1.5V).

They are connected like in the [ShiftDisplay library's schematic][1], with a pull-up resistor added according to [this link on open drain][2].

How do we use the open drain outputs logic to supply power to the display?

The data sheet of the big 7-segment display can be [found here][3]. Each display requires 160mA of continuous current.

  [1]: https://github.com/MiguelPynto/ShiftDisplay
  [2]: https://forum.digikey.com/t/what-does-open-drain-mean/716
  [3]: https://cdn.reignofcomputer.com/images/1637378503422487352_5cab8653-2a2f-4dfb-8d5a-1ee1585e736e.png

body:
You are getting confused. The pullup resistor is only needed on open drain when you are using it to generate logic levels. It turns the OD output into an RTL output.

You don't want that.

Instead you want your open drain outputs to act like a low-side switch transistor - which is infact what they are.

You can do that by simply placing your LEDs in *series* with your "pullup" resistor, thus:

<!-- Begin schematic: In order to preserve an editable schematic, please
     don't edit this section directly.
     Click the "edit" link below the image in the preview instead. -->

![schematic](https://i.stack.imgur.com/gVu8N.png)

<!-- End schematic -->

I have only shown two elements there (everything inside the dashed box is inside the shift register), but you can see now how when an output is "on" the transistor conducts, and the current flows through the LED, through the resistor, through the transistor, and down to ground.

Your resistor value is then calculated as simply

        9 - Vfled
    R = ---------
          Iled

For 20mA and a 2V forward voltage that comes out as 350Ω - so your 390Ω resistors are perfectly fine.


body: Can you use different resistors for each display group? If so that will solve your problem along with what Majenko said.


message:
TinyGPS++ Question about gps.encode(ss.read())

I am trying to make an oled gps display, however when looking at multiple examples and other people's code, I am seeing that people are using different methods. I see some code that has `gps.encode(ss.read());` and other people use `if gps.encode(ss.read())`. I am confused on why this is. Also, people either use `.isUpdated`, or `.isValid`, when checking for location/speed, etc. On the TinyGPS++ page it talks about these, but does not say what should be used for certain applications.

body:
From http://arduiniana.org/libraries/tinygpsplus/

**Validity, Update status, and Age**
You can examine an object’s value at any time, but unless TinyGPS++ has recently been fed from the GPS, it should not be considered valid and up-to-date. The **isValid()** method will tell you whether the object contains any valid data and is safe to query.

Similarly, **isUpdated()** indicates whether the object’s value has been updated (not necessarily changed) since the last time you queried it.

Lastly, if you want to know how stale an object’s data is, call its **age()** method, which returns the number of milliseconds since its last update. If this returns a value greater than 1500 or so, it may be a sign of a problem like a lost fix.


message:
How to use correctly a microstepping driver with a lower voltage stepper motor

I want to use a microstepping driver like [Haitronic's HS2215](http://www.haitronic.cn/index.php?route=product/product&product_id=3743) with a NEMA 17 stepper motor with rated voltage of 4.2V and rated current 1.5A.

The input voltage range of the microstepping driver is 9-40VDC.

From what I understand,  I can use the switches to set the maximum current. In this particular case I would use SW4=On, SW5=On, SW6=Off.

[![enter image description here][1]][1]

TB6600 current settings
You can adjust the current that goes to the motor when it is running by setting the dip switches S4, S5, and S6 on or off.

[![enter image description here][2]][2]

I've found this [Maker's Guide](https://www.makerguides.com/tb6600-stepper-motor-driver-arduino-tutorial/) which describes the settings for use with an arduino.
However, I am not certain what voltage (VCC) should I supply to the mircrostepping driver? Should I provide, the minimum of 9VDC, should I provide less? Is this irrelevant?

  [1]: https://i.stack.imgur.com/QpacI.png
  [2]: https://i.stack.imgur.com/SddiV.png

body:
That doesn't matter at all.

The voltage stepper motors are rated for is the voltage that, if applied to the motor coils, would create its rated current.

Stepper motor drivers monitor the *current*, and always use the full voltage available to them (9 - 40V in your case) to drive the stepper motor - using PWM.
The stepper motors coils inductance slows down the change in current, allowing the driver to reach its set current.

Higher drive voltages simply mean that it's easier to overcome that inductance, allowing for faster stepper motor movements.

You'll want to set your driver at 1.0 or 1.5 A, and supply it with as much voltage (up to the rated 40 V) as you can.