texts: ESP8266 won't display data after connecting to wifi

texts:
My esp8266 is now connected to wifi however the datas won't display
Here's the code:
    #include <ESP8266WiFi.h>
    #include <WiFiClient.h>
    #include <ESP8266WebServer.h>
    #include <ESP8266HTTPClient.h>
    int Led_OnBoard = 2;                  // Initialize the Led_OnBoard
    const char* ssid = "";           // Your wifi Name
    const char* password = "";          // Your wifi Password
    const char *host = "***.***.*.*"; //Your pc or server (database) IP, example : 192.168.0.0 , if you are a windows os user, open cmd, then type ipconfig then look at IPv4 Address.

    void setup() {
        // put your setup code here, to run once:
        delay(1000);
        pinMode(Led_OnBoard, OUTPUT);       // Initialize the Led_OnBoard pin as an output
        Serial.begin(115200);
        WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)
        delay(1000);
         WiFi.mode(WIFI_STA);        //This line hides the viewing of ESP as wifi hotspot
        WiFi.begin(ssid, password);     //Connect to your WiFi router
        Serial.println("");
        Serial.print("Connecting");
        // Wait for connection
        while (WiFi.status() != WL_CONNECTED) {
            digitalWrite(Led_OnBoard, LOW);
            delay(250);
            Serial.print(".");
            digitalWrite(Led_OnBoard, HIGH);
            delay(250);
        }

        digitalWrite(Led_OnBoard, HIGH);
        //If connection successful show IP address in serial monitor
        Serial.println("");
        Serial.println("Connected to Network/SSID");
        Serial.print("IP address: ");
        Serial.println(WiFi.localIP());  //IP address assigned to your ESP
    }

    void loop() {
        // put your main code here, to run repeatedly:
        HTTPClient http;    //Declare object of class HTTPClient
        String PirValueSend, postData;
        int pirvalue=analogRead(A0);  //Read Analog value of PIR
        PirValueSend = String(pirvalue);   //String to interger conversion
        //Post Data
        postData = "pirvalue=" + PirValueSend;
        http.begin("http://***.***.*.*/thesis/database/database.php");     //Specify request destination
        http.addHeader("Content-Type", "application/x-www-form-urlencoded");    //Specify content-type header
        int httpCode = http.POST(postData);   //Send the request
        String payload = http.getString();    //Get the response payload

        if(pirvalue > 0 )
        {
            Serial.println(httpCode);   //Print HTTP return code
            Serial.println(payload);    //Print request response payload
            Serial.println(postData);
            Serial.println("Pir Value=" + PirValueSend);
        }
         else
        {
            Serial.println("No motion.");
        }
        http.end();  //Close connection
        // delay(4000);  //Here there is 4 seconds delay plus 1 second delay below, so Post Data at every 5 seconds
        digitalWrite(Led_OnBoard, LOW);
        delay(1000);
        digitalWrite(Led_OnBoard, HIGH);
    }


texts: Measuring voltage on an analog pin - What do I need to know about amperage?

texts:
I'd like to measure the voltage at a test point on a stepper motor driver chip with an arduino. The voltage at this point controls the amperages to the phase coils and is adjusted to trim the driver.

I have a common ground with the driver already, I'd like to wire the drivers v-ref point to an analog input to drive an LCD showing the output amp number so I can adjust the driver.

The issue I am worried about is that with the hardware I have to test with a properly trimmed driver is pushing 0.84A.

Is this safe to do without killing the arduino board?


texts: What’s the most stable digital communication protocol for sewable electronics?

texts:
I’ve spent the past few days trying researching communication protocols and I have a few issues. With sewable electronics, you need to work with cables with a fairly high resistance that are constantly moving. That means unreliable and noisy communication. Furthermore relying on multiple data lanes increases the needed number of stitches and the chances of failure.
Adafruit Neopixels use a good system that allows them to only use 1 data pin for a large number of individually controlled addressed devices with a total of 3 connections between each device. Disconnecting the devices while in use doesn’t cause them to crash most of the time, and there’s a lot of expandability. Best of all, the circuit design is incredibly simple because most of the hardware is on board the IC. The problem is that the communication type they use seems to be specifically designed for use on those circuits only, and to my knowledge there is no version of the logic circuit that isn’t coupled with the SMD RGB LED component, and even if there was there’s no way to directly adapt it to other components.
I’ve looked into I2C, SPI, UART, FTDI, USB, CAN-bus, and a bit of DMX and I’m still fairly certain none would work. All I need is to exchange bytes of data between two microcontrollers without them constantly crashing. I’m willing to try the most exotic solutions imaginable.


texts: Why is my pushbutton always reading LOW?

texts:
I know this is ridiculously simple task but I spent the last two hours trying to get this to work and it is not working.  I don't have an Arduino but I have an ESP8266 Huzzah Feather which is programmable via the Arduino IDE.  So, I don't think I can provide a Fritz diagram but in any case, I'm just trying to hook up a pushbutton and be able to read a HIGH or LOW (via my Serial monitor).  Currently, everything is 0.

As best I can describe it is:

5V from Feather into resistor into one terminal of the pushbutton.  Out the other terminal of the pushbutton is a wire connecting to pin 12 of the Feather, and also a wire leading to ground.  Feather is also grounded.

My code is:

void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT);
}

void loop()
{
  int button_val = digitalRead(12);
  Serial.println(button_val);
}

It shouldn't be this hard for me.  Whenever I open and run the serial monitor, it reads 0s.  What am I missing?

Oh, an issue that I faced is determining which 2 out of the 4 terminals of the pushbutton to use.  Some resources I find say that it is the same side as the terminal the voltage is flowing into; other resources say it is the terminal opposite to the side the voltage is flowing into.  I currently have it opposite.


texts: Suggestions for a program for drawing simple schematics

texts: I'm wondering if there are free programs or web sites that let you draw simple schematics similar to this example:


texts:
This is my first time working with a rotary encoder and interrupts.  I am using a Pro Micro which has interrupt pins at pin0 and pin1.  The code below works as expected.

My question: do I need to use an interrupt pin for PinB as well, or can I use any digital pin?

It does not seem to work when I choose PinB = 9, for example.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

// Used for generating interrupts using CLK signal
const int PinA = 0;

// Used for reading DT signal
const int PinB = 1;

// Used for the push button switch
const int PinSW = 8;

// Keep track of last rotary value
int lastCount = 50;

// Updated by the ISR (Interrupt Service Routine)
volatile int virtualPosition = 50;

// ------------------------------------------------------------------
// INTERRUPT     INTERRUPT     INTERRUPT     INTERRUPT     INTERRUPT
// ------------------------------------------------------------------

void isr ()  {
  static unsigned long lastInterruptTime = 0;
  unsigned long interruptTime = millis();

  // If interrupts come faster than 5ms, assume it's a bounce and ignore
  if (interruptTime - lastInterruptTime > 5) {
    if (digitalRead(PinB) == LOW)
    {
      virtualPosition-- ; // Could be -5 or -10
    }
    else {
      virtualPosition++ ; // Could be +5 or +10
    }

    // Restrict value from 0 to +100
    //virtualPosition = min(100, max(0, virtualPosition));

  }
  // Keep track of when we were here last (no more than every 5ms)
  lastInterruptTime = interruptTime;
}

// ------------------------------------------------------------------
// SETUP    SETUP    SETUP    SETUP    SETUP    SETUP    SETUP
// ------------------------------------------------------------------
void setup() {
  // Just whilst we debug, view output on serial monitor
  //  Serial.begin(9600);

  lcd.init();                      // initialize the lcd

  lcd.backlight();

  // Rotary pulses are INPUTs
  pinMode(PinA, INPUT);
  pinMode(PinB, INPUT);

  // Switch is floating so use the in-built PULLUP so we don't need a resistor
  pinMode(PinSW, INPUT_PULLUP);

  // Attach the routine to service the interrupts
  attachInterrupt(digitalPinToInterrupt(PinA), isr, LOW);

}

// ------------------------------------------------------------------
// MAIN LOOP     MAIN LOOP     MAIN LOOP     MAIN LOOP     MAIN LOOP
// ------------------------------------------------------------------
void loop() {

  // Is someone pressing the rotary switch?
  if ((!digitalRead(PinSW))) {
    virtualPosition = 50;
    while (!digitalRead(PinSW))
      delay(10);
    //    Serial.println("Reset");
  }

  // If the current rotary switch position has changed then update everything
  if (virtualPosition != lastCount) {

    lcd.clear();
    lcd.print(virtualPosition);

    // Keep track of this new value
    lastCount = virtualPosition ;
  }

  //delay(100);
}


texts: How do I supply either (1) dual voltage or (2) negative voltage?

texts:
Sorry in advance if this question already exists--I tried to search but my keyword knowledge is shaky. I have created a Colpitts oscillator on breadboard using AA batteries as the power supplies. I want to implement this oscillator with an Arduino. (Once it's set up, I want to use its voltage to do some things, but that isn't part of this question.)

In the image below, I have two voltages, Vcc (positive voltage) and Vee (negative voltage). My simulations indicate I can run the oscillator either with a dual voltage (+5V and -5V), or with one negative voltage (-5V) and the other set to ground. Either provides a 100 kHz oscillation from about -5 to 2 V. So:

Is there a way to provide a dual voltage supply from the Arduino Uno?
Is there a way to provide a single negative voltage supply from the Arduino Uno?

Thanks!


texts: Error compile board LOLIN(WEMOS) D1 R2 & mini

texts:
I have a wemos d1 mini and a mpu 6060 sensor. I am trying to send the data from the sensor to Firebase. However i have come across a hurdle which i cant seem to solve. This is my error, can you help me out with this issue?

Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

In file included from C:\Users\Zakaria\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:30:0,

                 from C:\Users\Zakaria\Desktop\WORKING_ACCELERAMETOR_BACKUP\WORKING_ACCELERAMETOR_BACKUP.ino:4:

C:\Users\Zakaria\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:109:11: error: StaticJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6

     std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

           ^

In file included from C:\Users\Zakaria\Desktop\WORKING_ACCELERAMETOR_BACKUP\WORKING_ACCELERAMETOR_BACKUP.ino:4:0:

C:\Users\Zakaria\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:86:11: error: StaticJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6

   std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

           ^

Using library FirebaseJson at version 2.3.3 in folder: C:\Users\Zakaria\Documents\Arduino\libraries\FirebaseJson
Using library firebase-arduino-master at version 0.1 in folder: C:\Users\Zakaria\Documents\Arduino\libraries\firebase-arduino-master
Using library ArduinoJson at version 6.15.0 in folder: C:\Users\Zakaria\Documents\Arduino\libraries\ArduinoJson
Using library ESP8266HTTPClient at version 1.2 in folder: C:\Users\Zakaria\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266HTTPClient
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\Zakaria\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi
Using library Wire at version 1.0 in folder: C:\Users\Zakaria\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\Wire
exit status 1
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.


texts: Power servo with external power using a hacked USB cable

texts:
I want to use a servo motor and control it by an Arduino Duemilanove (or a Leonardo). It seems to work fine when I connect it directly to Arduino's VCC, GND and an PWM pin. But I am a bit worried if this is a good idea. The multimeter shows that it draws up to 0.6A which is about 10 times of what I'd expect that the Arduino can provide. Is this correct or does this apply only to the digital out pins? Would it be better to power the servo using an external power supply?

I thought it would be a nice and easy solution to power the Arduino using a USB power supply and to cut the USB cable and connect the servo directly to the +5V of the USB. But is there even a difference in powering the Arduino via USB and connecting the servo to the VCC of the Arduino? Is it a problem to connect GND and UGND?

(After first tests, I think that the Arduino led is pulsating less using the hacked USB cable, but still a pulsating LED shows that the servo is drawing a lot of power from the board.)

Bonus question: does your answer apply to all Arduino models? (I am interested especially in Leonardo and Duemilanove.)

Similar discussion:
http://forum.arduino.cc/index.php/topic,22132.0.html


texts: ESP8266 with RTC DS1307 shield - WS2818B shield won't blink - I2C issue?

texts:
Dear Ladies and Gentlemen,
I'd like to let a LED blink base on the time of the day. So I took Wemos D1 mini and a WS2818B shield and a RTC DS107 Shield for the before mentioned ESP8266 model.
Based on my observation, I can let the LED blink on its own without starting the initialization of the RTC. As soon as I initialize the communication with the DS1307 shield, the LED shield won't translate any commands toward the desired behavior (e.g. the LED won't blink anymore).
What am I doing wrong?
I'm using the Ardunio IDE to program the D1 mini.
I stacked the shields and kept an eye on the pins to be sure I did wire everything the right way.
Libraries in use:
RTC: https://github.com/Makuna/Rtc
LED: Adafruit NeoPixel
Code:
// WIFI
#include <ESP8266WiFi.h>

// RTC
#include <RtcDateTime.h>
#include <RtcUtility.h>
#include <Wire.h> // must be included here so that Arduino library object file references work
#include <RtcDS1307.h>
RtcDS1307<TwoWire> Rtc(Wire);

// LED
#include <Adafruit_NeoPixel.h>
#define PIN        D2
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ400);

int DELAYVAL = 1000; // Time (in milliseconds) to pause between pixels

void setup() {

  Serial.begin(57600);
  Serial.println();
  Serial.flush();

  setupLed();

  setupWifiConnection();

  setupRtc();

}

void loop() {

  pixels.clear(); // Set all pixel colors to 'off'
  pixels.show();   // Send the updated pixel colors to the hardware.
  delay(DELAYVAL); // Pause before next pass through loop

  pixels.setPixelColor(0, pixels.Color(0, 150, 0));
  pixels.show();   // Send the updated pixel colors to the hardware.
  delay(DELAYVAL); // Pause before next pass

}

void setupRtc () {

  Rtc.Begin();

  RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
  Serial.println();

  if (!Rtc.IsDateTimeValid())
  {
      if (Rtc.LastError() != 0)
      {
          // we have a communications error
          // see https://www.arduino.cc/en/Reference/WireEndTransmission for
          // what the number means
          Serial.print("RTC communications error = ");
          Serial.println(Rtc.LastError());
      }
      else
      {
          // Common Causes:
          //    1) first time you ran and the device wasn't running yet
          //    2) the battery on the device is low or even missing

          Serial.println("RTC lost confidence in the DateTime!");
          // following line sets the RTC to the date & time this sketch was compiled
          // it will also reset the valid flag internally unless the Rtc device is
          // having an issue

          Rtc.SetDateTime(compiled);
      }
  }

  if (!Rtc.GetIsRunning())
  {
      Serial.println("RTC was not actively running, starting now");
      Rtc.SetIsRunning(true);
  }

  RtcDateTime now = Rtc.GetDateTime();
  if (now < compiled)
  {
      Serial.println("RTC is older than compile time!  (Updating DateTime)");
      Rtc.SetDateTime(compiled);
  }
  else if (now > compiled)
  {
      Serial.println("RTC is newer than compile time. (this is expected)");
  }
  else if (now == compiled)
  {
      Serial.println("RTC is the same as compile time! (not expected but all is fine)");
  }

  // never assume the Rtc was last configured by you, so
  // just clear them to your needed state
  Rtc.SetSquareWavePin(DS1307SquareWaveOut_Low);
}

void setupLed () {

  pixels.begin();

  pixels.clear();
  pixels.show();
}

void setupWifiConnection () {

  WiFi.begin("some ap", "some password");

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
}


texts: It might be a stupid question but, I am currently using Arduino Uno with the 16MHz processor, what is maximum sampling rate of data available to me if I want to read data of a sensors such as accelerometer?


texts: SPI - Apparently Random pulses on CS/SS line

texts:
I'm trying to figure out why my SPI device isn't responding as expected. So I hooked up my logic analyzer and am a bit confused by the results.

I'm seeing what appears to be random pulses on the chip select/slave select line (CS in the images below). The pulses happen in random locations with random counts. Always matching either a falling edge or rising edge in the CLK line.

The code I'm running is part of a library, but I've pulled it all out for a minimum functional example:

#include <SPI.h>

#define DC_PIN          9
#define CS_PIN          10
#define BUSY_PIN        7

int IfInit(void) {
    pinMode(CS_PIN, OUTPUT);
    SPI.begin();
    SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
    return 0;
}

void SpiTransfer(unsigned char data) {
    digitalWrite(CS_PIN, LOW);
    SPI.transfer(data);
    digitalWrite(CS_PIN, HIGH);
}

int Init() {

    if (IfInit() != 0) {
        return -1;
    }

    SendCommand(0x01); //POWER_SETTING
    SendData(0x03);                  // VDS_EN, VDG_EN
    SendData(0x00);                  // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
    SendData(0x2b);                  // VDH
    SendData(0x2b);                  // VDL
    SendData(0xff);                  // VDHR
    SendCommand(0x06); //BOOSTER_SOFT_START
    SendData(0x17);
    SendData(0x17);
    SendData(0x17);                  //07 0f 17 1f 27 2F 37 2f
    SendCommand(0x04); //POWER_ON
    WaitUntilIdle();
    SendCommand(0x00); //PANEL_SETTING
    SendData(0xbf);    // KW-BF   KWR-AF  BWROTP 0f
    SendData(0x0b);
    SendCommand(0x30); //PLL_CONTROL
    SendData(0x3c);        // 3A 100HZ   29 150Hz 39 200HZ  31 171HZ

    return 0;
}

void SendCommand(unsigned char command) {
//    digitalWrite(DC_PIN, LOW);
    SpiTransfer(command);
}

void SendData(unsigned char data) {
//    digitalWrite(DC_PIN, HIGH);
    SpiTransfer(data);
}

void WaitUntilIdle(void) {
    while(digitalRead(BUSY_PIN) == 0) {      //0: busy, 1: idle
        delay(100);
    }
}

void setup() {

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

  Serial.begin(9600);
  Serial.println("Start");

  if (Init() != 0) {
    Serial.println("init failed");
    return;
  }

  Serial.print("init success");

}

void loop() {

}

I've tried on two different ATMEGA chips (same Arduino Uno board), same results. I've also tried with the device disconnected. Again same results. I've also tried changing the pin used for the CS, still didn't change anything.

Anyone have some insight as to what might be causing this, and/or what can be done to stop it?


texts: AccelStepper Library: How do I go to a position without decelerating?

texts: When I make the motor move at a certain distance with setMaxSpeed(), setAcceleration(), and moveTo(), it always accelerates and decelerates. Is there a way to disable the deceleration?


texts:
I have the following situation.
    I would like to develop a bracelet prototype that identifies when a person is on the go and also issue a question to the person for that bracelet and get an answer, depending on the status of the response by sending a notification to a mobile app. I am interested in what Arduino technologies to use.


texts:
I am trying to use Arduino platform.txt to run some extra pre-processing on my Arduino codes.

As far as I can understand the best way to do that is to use prebuild hooks as mentioned below
https://github.com/arduino/arduino/wiki/arduino-ide-1.5-3rd-party-hardware-specification

I am using the hooks as follows

recipe.hooks.sketch.prebuild.1.pattern=echo {source_file} sketch pret;
recipe.hooks.sketch.prebuild.2.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

This is the output I get for the hooks

echo "{source_file}" sketch pret;
{source_file} sketch pret;
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10804 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   {includes} "{source_file}" -o "{object_file}"
avr-gcc: error: {includes}: No such file or directory
avr-gcc: error: {source_file}: No such file or directory
avr-gcc: fatal error: no input files
compilation terminated.

The {source_file} variable is used in a compilation reciep as follows

recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

and the recipe runs as follows

"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10804 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Users/vinayakjoshi/Library/Arduino15/packages/boltiot/hardware/avr/1.0.0/variants/boltduino" "-I/Users/vinayakjoshi/Documents/Arduino/libraries/boltiot-arduino-helper-update-dev/src" "-I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/src" "/var/folders/kp/9gnp402j7_nfb1qpqpdkxgcr0000gn/T/arduino_build_658970/sketch/CommandHandler.ino.cpp" -o "/var/folders/kp/9gnp402j7_nfb1qpqpdkxgcr0000gn/T/arduino_build_658970/sketch/CommandHandler.ino.cpp.o"

As you can see, in a standard recipe, the variable {source_file} and other such definitions are correctly replaced. But in the hooks, this is not happening.

I want to know whether it is possible to get the value of the {source_file} variable to be used with the hooks, so that I can do some extra pre-processing with it. And if it is, how can I do it.

P.S. IDK what tag has to be used. I couldn't find platform.txt or 3rd party cores. I used the Arduino-IDE tag, as this question definitely asks how the IDE works.


texts:
What is the ideal power supply for this module? What do you use that works ok?

Will the AMS1117 work?


texts: How to wire a three-pin on-off-on switch for reading input?

texts:
I would like to read the output of an on-off-on switch with my Leonardo board, but I have very little knowledge of electronics and don't know how to wire it up.
This is the switch in question: E-Switch 200MSP4T1B1M1QE
The switch has three pins. Generic three-pin SPDT wiring diagrams I've found suggest that the two outer pins should be connected to separate lights and the middle pin should be connected to the power source. Those lights also have a ground connection.
I don't want to power anything in a literal sense, I only want to have the Leonardo read the output of the switch. The end goal is to have the two ON positions read as separate button presses (eventually using a joystick library, in case that changes how the switch needs to be wired).
My questions are:

Is the above wiring example correct for my use case?
Is the output of the switch considered digital or analog?
Is a wire from the switch to GND not required?

One final note - I'm not using a breadboard, but connecting the wires directly from the switch to the board.


texts: Tiny RTC module doesn't work properly when connected to an Arduino Uno together with 16x2 LCD

texts: I am trying to make a digital clock using a tiny RTC, 16x2 LCD, and Arduino Uno. The RTC module works fine if 16x2 LCD is not connected to the Arduino. Both RTC and LCD are I2C modules and hence are using the same A4 and A5 pins of the Arduino. I have been informed that the I2C devices if connected in parallel should work. But, in this case, the clock doesn't show the time properly.


texts:
Can somebody please tell me what is the operating voltage of ESP8266?

What is the A0 voltage range?

I am powering it up from USB (5v) and have a sensor that comes back with Analog value, to calculate it correctly I am asked to provide "Logical Voltage" value that is either 3300 or 5000 (3.3v or 5v). Sensor is connected to 3.3V port as there is no 5v port on the board.

What do I choose here 3300 or 5000 for NodeMCU V3?

Thank you.


texts: Can someone help me figure out why only one wheel is spinning?

texts:
I am attempting to use a code which I have posted below for two wheels. However, when connected to power, only one wheel spins. I am using a 9V battery which is what was suggested so I am not sure why only one wheel spins. When both wheels are connected, the wheel that was originally working stopped spinning.
#include <SPI.h>      //SPI library for communication with the nRF24L01+
#include "RF24.h"  //The main library of the nRF24L01+
#include "Wire.h"

RF24 radio (8, 9); // CE,CSN

//Create a pipe addresses for  communication
const uint64_t pipe = 0xE8E8F0F0E1LL;

struct package
{
  int X = 1;
  int Y = 1;
};

typedef struct package Package;
Package pos;

int buttonState;
int spinnerState = false ;
int motora_1 = 3;
int motora_2 = 4;
int motorb_1 = 5;
int motorb_2 = 6;
int spinner = 2;

void setup()
{
  Serial.begin(9600);
  radio.begin();                    //Start the nRF24 communicate
  radio.openReadingPipe(1, pipe);   //Sets the address of the transmitter to which the program will receive data.
  radio.startListening();
  pinMode(motora_1, OUTPUT);
  pinMode(motora_2, OUTPUT);
  pinMode(motorb_1, OUTPUT);
  pinMode(motorb_2, OUTPUT);
  pinMode(spinner, OUTPUT);
  digitalWrite(spinner, LOW);
  delay(100);
}

void loop()
{

  if (radio.available()) {
    radio.read(&pos, sizeof(pos));
    radio.read(&buttonState, sizeof(buttonState));
    Serial.print("X:");
    Serial.print(pos.X);
    Serial.print("      Y");
    Serial.print(pos.Y);
    Serial.print("      buttonState");
    Serial.println(buttonState);
  }

  int xAxis = pos.X;
  int yAxis = pos.Y;
  int forward = map(yAxis, 570, 1024, 0, 255);
  int backward = map(yAxis, 480, 0, 0, 255);
  int right = map(xAxis, 570, 1024, 0, 255);
  int left = map(xAxis, 480, 0, 0, 255);

  if (yAxis > 570) {          // Move Forward
    // Set Motor A forward
    analogWrite(motora_1, forward);
    analogWrite(motora_2, 0);
    // Set Motor B forward
    analogWrite(motorb_1, forward);
    analogWrite(motorb_2, 0);
  } else if (yAxis < 480) {                     //Move Backward
    // Set Motor A backward
    analogWrite(motora_1, 0);
    analogWrite(motora_2, backward);
    // Set Motor B backward
    analogWrite(motorb_1, 0);
    analogWrite(motorb_2, backward);
  } else if (xAxis > 570) {                     // Move Right
    // Set Motor A forward
    analogWrite(motora_1, right);
    analogWrite(motora_2, 0);
    // Set Motor B stop
    analogWrite(motorb_1, 0);
    analogWrite(motorb_2, 0);
  } else if (xAxis < 480) {                     // Move Left
    // Set Motor A stop
    analogWrite(motora_1, 0);
    analogWrite(motora_2, 0);
    // Set Motor B foward
    analogWrite(motorb_1, left);
    analogWrite(motorb_2, 0);
  } else  {     //stop
    // Set Motor A stop
    analogWrite(motora_1, 0);
    analogWrite(motora_2, 0);
    // Set Motor B stop
    analogWrite(motorb_1, 0);
    analogWrite(motorb_2, 0);
  }

  if (buttonState == 0 ) {
    spinnerState = ! spinnerState;
    delay(50);
  }

  if (spinnerState == true) {
    digitalWrite(spinner, HIGH);    //turn On spinner
    delay(100);
  } else {
    digitalWrite(spinner, LOW);      //turn Off spinner
    delay(100);
  }

}


texts:
Ultimately I will move to a generic smart phone for this project.
I'm trying to read 4 analog inputs from my arduino with a fixed 1kHz sampling frequency. I managed to set it to read at 1kHz as you can see from this link. The issue is that after running several times, I kept testing the frequency by logging the time vector (produced by arduino to the serial terminal) into Excel and calculating the frequency using the equation:
f=1/(t2-t1)

I did this to the entire column and I noticed that I got a changing frequency. The difference is very big as it ranges from 780 to 1kHz. I need a fixed sampling rate because we will be applying some digital signal processing on the obtained results which obviously requires a sampling frequency. My code to send the data is the following:

#define INTERVAL_LENGTH_US 1000UL

unsigned long previousMicros;
#define FASTADC 1
int recValue;
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
double t = 0;

void setup() {
  int start ;
  int i ;

#if FASTADC
  // set prescale to 16
  sbi(ADCSRA, ADPS2) ;
  cbi(ADCSRA, ADPS1) ;
  cbi(ADCSRA, ADPS0) ;
#endif

  Serial.begin(115200) ;
}

void loop()
{
  unsigned long currentMicros = micros();

  if ((currentMicros - previousMicros) >= INTERVAL_LENGTH_US)
  {
    previousMicros += INTERVAL_LENGTH_US;

    int val_a0 = analogRead(A0);
    int val_a1 = analogRead(A1);
    int val_a2 = analogRead(A2);
    int val_a3 = analogRead(A3);

    Serial.print(((double)currentMicros) / 1000000UL, 5 ); // 1 is the number of decimals to print
    Serial.print('\t');

    Serial.print(val_a0);
    Serial.print(',');

    Serial.print(val_a1);
    Serial.print(',');

    Serial.print(val_a2);
    Serial.print(',');

    Serial.println(val_a3);

  }
}

Ps. I'm using Arduino Leonardo,
What's the right way to achieve this?

EDIT: Thank you all for responding, As you wanted to see my data, here is a screenshot of the results after I applied Jwpat7's suggestion:

The yello shaded column is the frequency calculated, the first and 2nd columns represent T1 and T1 (T2 is just T1 shifted upward for easier calculation). You may notice the Matlab section, this is because I'm trying to plot the data in Matlab and use it to do the digital signal processing after transmission. The plotting will be real time (I'll the data in txt files for later processing). the bottom potion of the figure shows the frequency after a while....as you can see it's decreasing!

Thanks


texts: Gratuitious instantiation of `Serial`, why?

texts:
Let's take a very simple sketch, any simple one-.ino sketch. Say, just a led blinker like this

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
}

void loop()
{
  static bool on;
  digitalWrite(LED_BUILTIN, (on = !on) ? HIGH : LOW);
  delay(1000);
}

Once compiled in Arduino IDE, compiler reports using 10 bytes for global variables. This is perfect for our purposes.

Now let's add an extra .cpp file to it. Let's call it foo.cpp. The file looks like follows

#include <Arduino.h>

int foo()
{
  return Serial.available();
}

Compile it all together. Now the compiler reports using 185 bytes for globals. But why?!

Clearly, this extra global memory usage is Serial. It is brought in by the fact that global object Serial is referenced from foo. In the original sketch Serial is not instantiated (or discarded) by the linker as an unreferenced symbol. In this case it is referenced from foo, so the linker keeps it.

But... But GCC linker is usually smarter than this. I'd expect it to see that symbol foo is not referenced anywhere, so the reference to Serial inside foo also "doesn't count" and should not require an instance of Serial in final code.

In fact, if I tried using my own "heavy" class, my own global variable of that class and reference it in foo (instead of Serial), GCC would work as expected: regardless of how "heavy" my global variable is, GCC linker would discard my global variable from the final code and report the same 10 bytes for globals, as expected. The global memory usage would remain at 10 until I'd actually reference foo from somewhere.

But Serial is somehow special. Even an "unused" mention of Serial causes it to appear in global memory. What is so special about it? What makes it behave that way?


texts: Can't figure out how to send Motor Values over Bluetooth, Arduino Bluetooth-controller robot

texts:
I was trying to make an Arduino Robot that is Bluetooth controlled but I've some problems!

I can't figure out how to parse strings in Arduino like c++/java/python!
I tried this, If the first letter is L, set the next value to left motor, same for R

but for example "L255" is received as L - 2 - 5 - 5 and it sets L to 2 and ignores 5 - 5.

Any ideas on what I should do?

EDIT: Thought of something else, Sending L or R will toggle the motors! but that's just terrible, it'll be my last option

Update: This is how it works now:
L(0-5) means Left motor speed 5 * 51, 6-9 are backwards! its go backwards at (L(6-9) -5 * 51)


texts:
Can I connect a DS3231 and an MPU6050 by an Arduino Mega 2560? I have connect it:

MPU 6050               Arduino Mega 2560
SDA           =        SDA
SCL           =        SCL
GND           =        GND
VCC           =        5V

And I have connected DS3231 to SDA and SCL beside AREF pin:

DS3231               Arduino Mega 2560
SDA           =        SDA
SCL           =        SCL
GND           =        GND
VCC           =        5V

The problem is when I connect both of them MPU6050 prints nan, after opening the DS3231 pin from the arduino, MPU6050 prints the correct angles.
Can someone please help me?

Code:

#include "MPU6050.h"
#include "Wire.h"
#include <DS3231.h>
MPU6050 accelgyro;
int16_t ax, ay, az, gx, gy, gz;

DS3231 rtc(SDA, SCL);

double timeStep, time, timePrev;
double arx, ary, arz, grx, gry, grz, gsx, gsy, gsz, rx, ry, rz;

int i;
double gyroScale = 131;

void setup() {
  Wire.begin();
  accelgyro.initialize();
  Serial.begin(9600);
  rtc.begin();
}

void loop() {
  timePrev = time;
  time = millis();
  timeStep = (time - timePrev) / 1000;
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  gsx = gx/gyroScale;   gsy = gy/gyroScale;   gsz = gz/gyroScale;
  arx = (180/3.141592) * atan(ax / sqrt(square(ay) + square(az)));
  ary = (180/3.141592) * atan(ay / sqrt(square(ax) + square(az)));
  arz = (180/3.141592) * atan(sqrt(square(ay) + square(ax)) / az);
  if (i == 1) {
    grx = arx;
    gry = ary;
    grz = arz;
  }
  else{
    grx = grx + (timeStep * gsx);
    gry = gry + (timeStep * gsy);
    grz = grz + (timeStep * gsz);
  }
  rx = (0.1 * arx) + (0.9 * grx);
  ry = (0.1 * ary) + (0.9 * gry);
  rz = (0.1 * arz) + (0.9 * grz);
  Serial.print("X axis == ");
  Serial.println(arx);
  Serial.print("Y axis == ");
  Serial.println(ary);
  Serial.print("Z axis == ");
  Serial.println(arz);
  Serial.println(rtc.getTimeStr());
  i = i + 1;
  delay(1000);
}


texts: How to fix when i shorted 5v to gnd accidentally (Arduino Nano)

texts: I connected 5V to GND accidentally (connect directly, no LED, no motor). Now the LED on the board doesn't light up and power LED lights up but it is not bright. The 5V output pin is only around 1.98V. I'm using clone version from Alibaba. I ordered two, one is still working but the shorted one doesn't work. May I know how to fix them?


texts: Where to connect shield in USB power supply for Arduino?

texts:
I'm making a 5 volt portable regulated power supply (using LM7805 regulator IC) for Arduino UNO. I'm planning to use a USB connector as its output socket, this way I can just plug it into the Arduino to power it.

My problem is where do I connect the USB sockets's shield? (Not an Arduino shield - I am talking about the USB cable's shield).

As far as I know it should be connected to the ground if it is a host device - can we consider the power supply as a host device?


texts:
I stumbled upon the following unexpected behaviour and am curious about its cause.

header.h:

#include <Time.h>
[...]

main.ino:

#include "header.h"
#include <Time.h>
[...]

My code is working correctly with this setup. However, if I comment out the Time.h library in my main.ino, my code is working not correctly anymore:

#include "header.h"
//#include <Time.h>
[...]

I can still access the functions of Time.h, but they are returning garbage time.

Why do I have to include the library in my *.ino, although I am already including it in my header file?
Is there a best practice, on where to include libraries? Shall I simply always include all libraries in my *.h and *.ino file?


texts: Wifi server to control led on and off from local webpage.. - ..if statement doesnt work...

texts:
Im a newbie on this arduino thing and I would like to build a curtain remotecontrolled from a local webpage with 2 buttons... a up an a down...

I got the connection via my phone the the local page with the buttons. :D

My problem on this one is that the buttons' if statement (command == on); doesnt work or in other words the client.println(command); get the "on" command and write it on the page... but it dont do the function in the if statement (the button)...

Can anybody help me...? it should be simple..:D

    #include <Bridge.h>
    #include <YunServer.h>
    #include <YunClient.h>

    int LEDPIN = 3; // your LED PIN
    YunServer server;

    String readString;

    void setup() {
  // Start our connection
  Serial.begin(9600);
  pinMode(LEDPIN,OUTPUT);
  digitalWrite(LEDPIN,HIGH); // turn on Led while connecting
  Bridge.begin();

  // Show a fancy flash pattern once connected
  digitalWrite(LEDPIN,LOW);
  delay(150);
  digitalWrite(LEDPIN,HIGH);
  delay(150);
  digitalWrite(LEDPIN,LOW);
  delay(150);
  digitalWrite(LEDPIN,HIGH);
  delay(150);
  digitalWrite(LEDPIN,LOW);
  delay(150);

  // Disable for some connections:
  // Start listening for connections

  // server.listenOnLocalhost();
  server.begin();

}

/* ------------------------------------------------*/
/* --------------- End WIFI connection ------------*/
/* ------------------------------------------------*/

void loop() {
  YunClient client = server.accept();
  if (client) {
      process(client);
    client.stop();
  }
  delay(50);
}

void process(YunClient client) {
  String command = client.readStringUntil('\\');

  client.println("Status: 200");
  client.println("Content-type: text/html");
  client.println();
  client.println("

");
  client.println("ON

");
  client.println("OFF

");
  client.print("Command: ");
  client.println(command);
  client.println("");

/* ------------------------------------------------*/
/* ------------------- Buttons --------------------*/
/* ------------------------------------------------*/

  if (command == "on") {
    digitalWrite(LEDPIN,HIGH);
    digitalWrite(13,HIGH);
  }

  if (command == "off") {
    digitalWrite(LEDPIN,LOW);
     digitalWrite(13,LOW);
  }
}


texts:
I have a simple project for my arduino : light some leds when i send a certain frequency from my smartphone through the jack output . For example ,
 I play a simple audio file generated with a frequency generator (it generates sinwaves, sawtooth, quadrate waves...) at 1kHz --> a red led turns on
I play another frequency (5kHz) --> a green led turns on.
I read similar questions , but they needed a precise reading of the signal frequency, so they had to convert from AC to DC and from 700mV to 2,5V, is it necessary in my case ? I can also prepare a track with a program called audacity with the current remaining always positive but oscillating between 0 and 0,7 mV.
How can i realize my project in the simplest way possible ?

Thank you


texts: I am new to Arduino. Can I combine Arduino UNO and MEGA in 1 project? Arduino UNO is for audio output and MEGA for LCD display. If I am wrong, is there any ideas how do combine both LCD display and audio output in one microcontroller?


texts: ESP8266 Webserver ESP8266WebServer variable html page (not as one const char)

texts:
The aim is to display a non-static html page depending on some variable condition.

The code I created hast the problem, that the esp8266 is ressetting in the moment I request the page.

const char htmlIndexHeader[] PROGMEM = R"=====(

    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test</title>

Hello World

)=====";

const char htmlIndexProgress1[] PROGMEM = R"=====(

lorem

)=====";

const char htmlIndexProgress2[] PROGMEM = R"=====(

ipsum

)=====";

const char htmlIndexFooter[] PROGMEM = R"=====(

)=====";

char htmlIndexAll[2000];

void handleRoot()
{
  Serial.println("GET /");

   strcpy(htmlIndexAll, htmlIndexHeader);

   if(var1==true)
   {
     strcat(htmlIndexAll, htmlIndexProgress1);
   }

   if(var2==true)
   {
     strcat(htmlIndexAll, htmlIndexProgress2);
   }

   strcat(htmlIndexAll, htmlIndexFooter);

  server.send(200, "text/html", htmlIndexAll);
}

If I display a static page the esp8266 does not restart at page request.


texts: What's the most efficient implementation of map(x,0,1023,50,250)?

texts:
I recently noticed how the map() function in Arduino was bulky in both terms of flash space used and time taken to execute, largely because it deals with long and involves a division and multiplication.

Many times you can replace maps with more basic functions i.e.

output = map(input,0,1023,0,255);

can become

output = input >> 2;

or

output = map(input,0,1023,1023,0);

can become

output = 1023 - input;

I have one line in some code that says:

backlight = map(LDRreading,0,1023,50,250);

How could this be simplified so that it is both space and time efficient?

I'll allow slight differences in output values if it results in a much better solution.


texts:
I have a 2-wire brushed DC motor in a servo housing which either pushes left or right (and "center" when unplugged).

To push to one side I connect a wire to 5V and the other to GND, to push to the other side I just need to swap the wires.

How can I achieve this with the arduino without any physical rewiring?


texts: Using usb port to communicate with standalone atmega328p circuit

texts:
noob here

So I managed to get my circuit to be a standalone circuit (as pictured below). I want to use this circuit as an input to a game on my computer. What I want to know is could this micro-usb breakout board https://www.diyelectronics.co.za/store/breakout-boards/2414-micro-usb-power-switch-breakout-module.html
 be used to communicate with the computer. Where would the data pins (d+/d-) connect to the atmega328?

Any help will be most appreciated


texts: Controlling the Serial Monitor for 10 seconds

texts:
I am an amateur with Arduino and coding and I am learning in my lab class. My project consists of using a photoresistor to measure the brightness of a white LED. I have the following circuit built.

I am having problems with the code because I need the serial monitor to print every 1/10 of a second for 10 seconds. My professor started talking about the micros() function but never showed an example. I have an idea as to how I can utilize this function to control how long the Serial Monitor prints for but I have been unsuccessful. I know that setting a delay is good enough for reading every 1/10 of a second but how can I make the serial monitor print values for only 10 seconds?

I believe it should be a total of 100 readings.

This is my current code:

unsigned long start, finished, elapsed, total;
int analogInPin = A0;
int LEDreading;           // analog reading
int LEDpin = 9;           // LED on pin 9

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

void loop() {
  analogWrite(LEDpin,255);  // LED brightness
  start = millis();
  LEDreading = analogRead(analogInPin);
  Serial.println(LEDreading);
  delay(100);
  finished = millis();
  elapsed = finished - start;
  total = elapsed*100;

  if (total >= 10000){
    Serial.end();
}


texts: is it possible to convert a 328 design to use a 32U4?

texts:
I have several projects that use simple 328 based arduinos that I built myself, similar to the familiar "arduino on a breadboard" projects that I'm sure everybody has seen. They have just the bare minimum, no ftdi, etc.

Is it possible to drop in the 32U4 without modifying the circuits, or would I have to do a bunch of work to the circuits to get them to work with the 32U4 chips, and if so what are the general steps?


texts: How to package a 16 bit integer to send it with serial.write?

texts:
I am trying to display the values i get from reading a potentiometer (0-1023) in the program called 'processing'.

when I just use Serial.write(integer) and display the value on a line graph in 'processing' the line will max out at 256 and loop back around to 0 as i vary the potentiometer.

I understand that this is because the serial.write can only write in bytes(8 bits) so I would need to package the 16 bit integer into 2 bytes.

i was considering using a union but as you can probably guess i am very new to arduino so i haven't been able to make that work.

here is the code i have tried:

union Data{  uint16_t now; } data;

void setup() {   // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(A1, INPUT);

}

void loop() {   // put your main code here, to run repeatedly:
    uint16_t sensorVal = analogRead(A1);
     union Data data;

    data.now = sensorVal;

    Serial.println(data.now);

    //Serial.write(sensorVal);
    delay(10); }


texts:
i'm trying to remove all the data i've in an array.
Example:
I've arr[5,3,2] and i want to clear the array totally and finish with an array like this arr[], ready to add new values. How can i do that? Thanks in advance.


texts: Arduino: how can I stop while() when bluetooth send a data?

texts:
I have learned Arduino for a month, and I want to bulid a car with 2 modes,
Remote and Auto. Auto mode needs to have while() loop, so it can receive data from sensors. When I choose Auto mode via bluetooth, it keeps looping and it won't stop when I choose the Remote mode. Here's the part code:

char mode;

void loop()
{
    while(serial1.available())
    {
        char control = serial.read();
        if(control == 'r') mode = 'r';     // r stand for Remote Mode
        if(control == 'a') mode = 'a';     // a stand for Auto Mode

        if(mode == 'r') remoteMode(control);

        while(mode = 'a')
        {
            int IR = analogRead(A10);
            float U1cmMsec,U2cmMsec;
            long U1microsec = u1.timing();
            long U2microsec = u2.timing();
            U1cmMsec = u1.convert(U1microsec, Ultrasonic::CM);
            U2cmMsec = u2.convert(U2microsec, Ultrasonic::CM);

            robot(U1cmMsec, U2cmMsec,IR);

            /*
            Here is the code to stop while() that I don't know how
            to program.
            I have tried:

            if(serial1.read() != 'a') break;

            But it will stop while(), because it will waits for
            bluetooth send data to arduino board.
            And if I take this line off, it will keeps while() and
            nothing can stop it.
            So, what am I supposed to do?
            */
        }
    }
}


texts: avrdude fuse error when programming ATMEGA328 without crystal

texts:
I built several boards with an ATMEGA328 and no crystal a couple of years ago. I programmed them successfully with a bootloader using usbasp, and with a sketch using the Arduino serial interface. I have now made some more, but I get an error message from AVRDUDE when I try to burn the bootloader:

***failed;
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first).

I followed the instructions here and I am using the hardware configuration archive referenced on that page: breadboard-1-6-x.zip.
If I reprogram the bootloader on a device that does have a crystal, it works if I select Arduino Pro/Pro Mini (3.3V, 8MHz), but fails with the message above if I select the breadboard specified in the boards.txt from  breadboard-1-6-x.zip.
There are no other error messages, but... if I turn on verbose, it works.. turn verbose off and it stops working again. Maybe verbose mode modifies the timing enough to make it work.
I know that you can use the -B option to slow down avrdude when you run it from the command line: is there a way of doing the same thing from within the Arduino environment?


texts: Esp32 sending a wav file to API via POST

texts:
I'm trying to send a .wav file to an API with an ESP32 using a HTTP Post request with a multipart/Form-data content type.
I can already send the API Key as it is a plain key and get a return from the server, but I fail on how to add the .wav file into the post request.
I am currently reading the wav file from an sd card, it's 5 secs long 16 bit,11025Hz. and about 400 kb.
If anyone have experience with this, your help would be greatly appreciated!

This is the code snippet where I send the key and where the data should come;
I tried putting the code into a buffer as and concatting the data but I'm not sure if this is the right way to do it
char buf[1024];

 if (https.begin(client, host, port, path)) {

   //https.addHeader("Content-Type", "multipart/Form-data");
   //int httpsCode = https.POST("apikey = XXX");
Serial.println(WavFile);
     https.addHeader("content-type", "multipart/form-data; boundary=----123");
    String HTTPSPost ="------123\r\nContent-Disposition: form-data;
`

----------

name=\"apikey\"\r\n\r\XXX\r\n------123--\r\nContent-Disposition: form-data; name=\"wav\"; filename=\"test444.wav\"\r\nContent-Type: audio/x-wav\r\n\r\n\r\n";
  `
    //wav recording Comes here
    String WavData ;
   // for (int i = 0; i < 1024; i++) WavData.concat(buf[i]);; // Tried to put Wav file in a buffer
  // Serial.println(WavData);

    String End = "------123--";
    String full = HTTPSPost + WavData + End;
    int httpsCode = https.POST(full );
        if (httpsCode > 0) {
              if (httpsCode == HTTP_CODE_OK) {
                res =  https.getString();
                JsonObject& obj = jb.parseObject(res);

                String token = obj["error"];
                if (obj.success()) {

                } else {
                    res = "failed to parse json";
                }
              }
        } else {
            res = "failed to Post";
        }
   } else {
    res = "failed to connect to server";
   }
https.end();
return res;
}
`

better code because httpclient can't do sd cards, but wificlient can;

File file = SD.open("/xxx.wav");

if (!client.connect("XXX", 443)) {
  Serial.println("Connected FAILED!");
  return;
}

Serial.println("Connected ok!");

client.println("POST  HTTP/1.1");
client.println("Host: ");
client.println("Cache-Control: no-cache");
client.println("Content-Type: multipart/form-data; boundary=----123");
client.println();
client.println("------123");
client.println("Content-Disposition: form-data; name=\"grant_type\"");
client.println();
client.println("client_credentials");
client.println("------123");
client.println("Content-Disposition: form-data; name=\"apikey\"");
client.println();
client.println("XXX");
client.println("------123");
client.println("Content-Disposition: form-data; name=\"wav\"; filename=\"xxx.wav\"");
client.println("Content-Type: audio/wav");
client.println("");
client.print("Content-Length: ");
client.println(file.size());
//client.println();
//while (file.available()){
//      client.write(file.read());
//}
client.write(file);
client.println("------123--");
Serial.println(">>><<<");
if (client.available())
    {
      String serverRes = client.readStringUntil('}');
      Serial.println(serverRes);
    }


texts: Where do avrdude parameters get defined in the Arduino IDE?

texts:
I am interested in learning how the Arduino IDE handles parameters in order to correctly upload hex files with avrdude.

I found this in boards.txt:

uno.name=Arduino/Genuino Uno

uno.vid.0=0x2341
uno.pid.0=0x0043
uno.vid.1=0x2341
uno.pid.1=0x0001
uno.vid.2=0x2A03
uno.pid.2=0x0043
uno.vid.3=0x2341
uno.pid.3=0x0243

uno.upload.tool=avrdude
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.maximum_data_size=2048
uno.upload.speed=115200

uno.bootloader.tool=avrdude
uno.bootloader.low_fuses=0xFF
uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0x05
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.bootloader.file=optiboot/optiboot_atmega328.hex

uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.board=AVR_UNO
uno.build.core=arduino
uno.build.variant=standard

There is this in platform.txt:

# AVR Uploader/Programmers tools
# ------------------------------

tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd.path={path}/bin/avrdude
tools.avrdude.config.path={path}/etc/avrdude.conf

tools.avrdude.upload.params.verbose=-v
tools.avrdude.upload.params.quiet=-q -q
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdude.program.params.verbose=-v
tools.avrdude.program.params.quiet=-q -q
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdude.erase.params.verbose=-v
tools.avrdude.erase.params.quiet=-q -q
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m

tools.avrdude.bootloader.params.verbose=-v
tools.avrdude.bootloader.params.quiet=-q -q
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m

This line is particularly interesting:

tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

It seems like these variables are corresponding:

{cmd.path} --> tools.avrdude.cmd.path
{config.path} --> tools.avrdude.config.path
{upload.verbose} --> tools.avrdude.upload.params.verbose
{build.mcu} --> uno.build.mcu
{upload.protocol} --> uno.upload.protocol
{serial.port} --> ?
{upload.speed} --> uno.upload.speed
{build.path} --> ?
{build.project_name} --> ?

It seems these are likely used in the Java code for the IDE. There are obviously a few I am unsure of. I would guess these are considered user inputs in the IDE. Though I am by no means a Java or JavaScript programmer.

Where are these variables explicitly defined in the Arduino library? (e.g. {runtime.tools.avrdude.path}, {path}, {cmd.path} ....) Or how do they get defined by IDE?


texts: Arduino with WS2812 using Adafruit NeoPixel library fade in/out different patterns

texts:
Hey all I have been trying to figure out a way to random set patterns for my fade in/ out code below:

int PIN = 3;
int totalLEDs = 11;
int ledFadeTime = 5;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(totalLEDs, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  rgbFadeInAndOut(0, 0, 255, ledFadeTime); // Blue
}

void rgbFadeInAndOut(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {
  for(uint8_t b = 0; b <255; b++) {
     for(uint8_t i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }

     strip.show();
     delay(wait);
  };

  for(uint8_t b=255; b > 0; b--) {
     for(uint8_t i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }
     strip.show();
     delay(wait);
  };
};

The code above works great. Fades the blue in and out infinity times. However, I am wanting random LEDs to be off or have a lighter/darker shade of the color I choose (in the above it's blue).

Example:

[off][blue][blue][off][off][dark blue][blue][off][dark blue][dark blue][off]
[blue][blue][blue][dark blue][off][blue][dark blue][blue][dark blue][off][off]
etc etc...

Would anyone happen to have code already like this?

Any help would be great! Thanks!


texts: Accessing 2 dimensional array in PROGMEM inside loop

texts:
I am unable to access elements of a 2D PROGMEM array from inside a loop. Please see the following example:

const byte a1[] PROGMEM = {'a', 'b', 'c', 'd'};
const byte a2[] PROGMEM = {'e', 'f', 'g', 'h', 'i'};
const byte a3[] PROGMEM = {'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'};
const byte a4[] PROGMEM = {'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

const byte * const arr[] PROGMEM = {a1, a2, a3, a4};

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

  Serial.println(pgm_read_byte(&(arr[0][0])));
  Serial.println(pgm_read_byte(&(arr[1][0])));
  Serial.println(pgm_read_byte(&(arr[2][0])));
  Serial.println(pgm_read_byte(&(arr[3][0])));
  for (int i = 0; i < 4; i++) {
    Serial.print(i);
    Serial.print(":");
    Serial.println(pgm_read_byte(&(arr[i][0])));
  }
  int j = 0;
  Serial.println(pgm_read_byte(&(arr[j][0])));
  j = 1;
  Serial.println(pgm_read_byte(&(arr[j][0])));
  j = 2;
  Serial.println(pgm_read_byte(&(arr[j][0])));
  j = 3;
  Serial.println(pgm_read_byte(&(arr[j][0])));
}

void loop() {

}

The output is:

97
101
106
114
0:12
1:174
2:12
3:148
97
101
106
114

I verified and re-verified the syntax so many times. could not find anyone facing similar issue. I am at my wits end why it would not print correct values inside the loop. Any ideas?

EDIT: expected output is:

97
101
106
114
0:97
1:101
2:106
3:114
97
101
106
114


texts:
I bought a batch of ESP8266-01 and DHT11 on ebay.

The sensors give data, but the datasheet say +/- 2 degrees. Who can live with that? Well, they claim the repeatability is 0.2 degrees, so I guess they could be calibrated.

But thet are not stable. They start a few degrees over room temperature, but gradually the reading is up to 33 degrees, more than 10 degrees too high.

Could it be the proximity of the ESP8266 giving off heat? Or are the sensors themselves heating up when reading at one read every two seconds?


texts:
ok, im having problems with my bh1750, here is all info i got:

board: esp32s nodeMCU v. 1.1

Pins:

Wiring: (the 2 reds go to pin 21 and 22)

code:

#include <BH1750.h>
#include <Wire.h>

BH1750 lightMeter;

void setup(){

Wire.begin();
Serial.begin(115200);
lightMeter.begin();
if (lightMeter.begin()) {
Serial.println(F("BH1750 initialised"));
}
else {
Serial.println(F("Error initialising BH1750"));
}
}

void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.println(lux);
delay(500);
}

Sorry for bad formating

Serial output:

13:01:41.926 -> [BH1750] ERROR: received NACK on transmit of address

13:01:41.926 -> [BH1750] ERROR: received NACK on transmit of address

13:01:41.926 -> Error initialising BH1750

13:01:41.926 -> [BH1750] Device is not configured!

13:01:41.926 -> 65534

13:01:42.430 -> [BH1750] Device is not configured!

13:01:42.430 -> 65534

13:01:42.932 -> [BH1750] Device is not configured!

13:01:42.932 -> 65534

and that goes on forever

Hope someone got an answer :D


texts: I'm trying to control the ESC using remotexy, esp8266 and arduino mega but I think there is a problem with the PWM signal in the slider. Please help

texts:
{

define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT

include

// RemoteXY connection settings

define REMOTEXY_SERIAL Serial3

define REMOTEXY_SERIAL_SPEED 115200

define REMOTEXY_WIFI_SSID "RemoteXY"

define REMOTEXY_WIFI_PASSWORD "12345678"

define REMOTEXY_SERVER_PORT 6377

// RemoteXY configurate

pragma pack(push, 1)

uint8_t RemoteXY_CONF[] =
  { 255,4,0,0,0,37,0,10,24,0,
  4,0,-7,-46,16,122,25,16,5,32,
  71,4,53,53,24,25,31,2,0,16,
  52,26,7,2,26,31,31,79,78,0,
  79,70,70,0 };
   {
  int8_t slider_left;
  int8_t joystick_1_x;
  int8_t joystick_1_y;
  uint8_t switch_1;

uint8_t connect_flag;

} RemoteXY;

pragma pack(pop)

include

Servo ESC;

include

Servo left_servo;
Servo right_servo;

define swtch 53

void setup()
{
  RemoteXY_Init ();

ESC.attach(2);
  left_servo.attach(9);
  right_servo.attach(10);
  RemoteXY.slider_left=50;
  RemoteXY.joystick_1_x=50;
  RemoteXY.joystick_1_y=50;
  pinMode (swtch, OUTPUT);

}

void loop()
{
  RemoteXY_Handler ();

ESC.writeMicroseconds(RemoteXY.slider_left*20 + 500);
  left_servo.writeMicroseconds(RemoteXY.joystick_1_x*10 + 1500);
  right_servo.writeMicroseconds(RemoteXY.joystick_1_y*10 + 1500);
  digitalWrite(swtch, (RemoteXY.switch_1==0)?LOW:HIGH);
}
}


texts: Sketch does not work without delay() or other complex functions like digitalWrite()

texts:
I have a simple sketch here that should just blink a led once a second or so (approximately):

boolean onOff=true;
int count=0;

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

void loop() {
    count++;
    delay(1);

    if (count == 316) {
    onOff=!onOff;
    digitalWrite(13, onOff);
    count=0;
    }
}

So, if count is 316 it changes the state of led. It works right now, but it does not without delay() function or some other complex ones like digitalWrite() being in the loop() too. If i am deleting delay(), than led is just always on. I can feel it is smth about interrupts, but i am not sure.

What am i trying to do here is to make an alternative to delay() and millis() for my other project. One of the most needed thing for me is to make ASAP (as soon as possible) "timer", so that some code could run every 2(3-4...) iterations of loop(). delay() is bad always, and millis() uses long variable (which is bad for cpu time and ram), and while having problems with ram and cpu time in my project, i want smth lighter for ASAP and other not very precise timing.  So, the questions are:

Why does my sketch works only with delay(), but does not work
without it?
Why does blinking sketches work with millis(), while they do not use any delay() just like my sketch.
Am i a bad person for trying to make smth like an ASAP timer?:)  Is saved ram and cpu time worth of it?  Any other possible problems?
Can this sketch be workable without delay() or other complex or ram and cpu costly functions?

Thank you.

So, the sketch up there works indeed, but here is the version that you can can observe with your eyes:

boolean onOff=1;
unsigned int counter=0;
unsigned long time=0;

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(57600);
}

void loop() {
   if (counter==0)  time=micros();
    counter++;
    if (counter == 0) {
        onOff= !onOff;
    digitalWrite(13, onOff);
    Serial.println(micros()-time);
    }
}

With Serial i was checking delay between blinks, and it is 140164 mcs = 140 ms = 0.14s. But to be honest it feels slower, so please correct me if i can benchmark it in a better way.


texts: need help regarding modification of arduino code

texts:
https://youtu.be/a7cO0Zcwmvw).Can Anyone help me to remove the LED DISPLAY 16*2 code from the given below code(I just need the TM1637 LED DISPLAY code)
CODE:-
https://drive.google.com/file/d/1hJycJ3VA24xxR94xC54HCzciLk4g_uWx/view?usp=sharing


texts: How to keep track of if data is outdated

texts: I have a large set of data and it is refreshed every 30 seconds or so. However, not all data is refreshed every time. It is possible that no new data for a particular calculation isn't received for even a few hours. For this reason I need to track what data is possibly outdated, but hasn't been updated (maybe due to technical malfunctions or a sensor is down). I was thinking about creating an additional (large) 2d array to do this, and increment some sort of counter. This way if a particular spot is at 1000 this means it is old. When new data is received it can be reset to 0. However, this seems like a slow, ineffective way to do this. How could I keep track of data more efficiently?


texts: I'm trying to setup home automation system controlled with webpage stored in SD card of Arduino, I was thinking if it was possible to set a login page, only combination of correct user id & password will be able to access the control page.


texts: Why does the ADC overflow when using an external Aref?

texts:
I'm using an LM35 temperature sensor, and it outputs 190 mV (which agrees with 19°C). I'm using an external reference voltage which I measure as 417mV. (This is set by the pin "aRefCntrl"). So I should have a reading around 467, but I get 1023, i.e. the ADC overflows. When I use the internal 1.1V reference I get a correct reading. Any ideas?

This is my code (Arduino waits for a request from the PC to send the data):

#define lm35 A0
#define aRefCtrl 10

void setup() {
  pinMode(aRefCtrl, OUTPUT);
  digitalWrite(aRefCtrl, 0);
  analogReference(EXTERNAL);
  analogRead(lm35); // dummy read
  Serial.begin(9600);
}

void loop() {
  if ( Serial.available() ) {
    Serial.read(); // PC's request is a single byte
    int temperature = analogRead(lm35);
    Serial.println(temperature);
  }
}

follow-up on Ignacio's comment: would a decoupling capacitor do? (I can't test for the moment, I have to order some)


texts: Beginners code, loop doesn't detect unplugged pin

texts:
I'm learning on an Arduno UNO board, and im trying to turn a LED on three times when I connect pin 10 to ground and then turn it off. Then when I unplug the pin number 10 it should NOT blink again... yet it does and I can't find the issue.
this is the entire code:
bool ledBlinked = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(7, OUTPUT);
  pinMode(10, INPUT_PULLUP);
}

//Turns on and off a digital pin, a number of times, with a certain delay
void blinkLed(int pin, int times, int del){
  // activates a pin a number of times
  for (int i=0; i<=times; i++){
    digitalWrite(pin, HIGH);
    delay(del);
    digitalWrite(pin, LOW);
    delay(del);
  }
}

//Checks if passed pin number is connected to ground
bool pinIsGround(int pin){
  return (digitalRead(10) == LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(pinIsGround(10) && !ledBlinked){ //if pin is connected to ground and the LED hasn't blinked
    blinkLed(7,3, 100); //blink pin 7, 3 times, with a delay of 100ms
    ledBlinked = true; //LED has blinked already
  }
  if (!pinIsGround(10) && ledBlinked){ //if pin is not connected to ground and the LED hasn blinked
    digitalWrite(7, LOW); //turn LED off (unnecesary?)
    ledBlinked = false; //LED hasn't blinked yet
  }

}


texts: Returning to parent directory with the SD library

texts: I have a File variable called dir and i'm building a simple file explorer for my device. Is there a way to get a reference to dir's parent directory?


texts: How to use Timer1 (AT328Mega) to measure the time between rising edges of two input signals

texts: I'd like to use Timer1 to measure the time between rising edges of two input signals.  Specifically, use Tn to start the timer counter and IPCn to latch the elapsed time since the rising edge of the Tn input signal.  The goal is to measure the time between the rising edges of two input signals.   Is there a Timer1 library out there that alread does this?  Code suggestions welcomed.


texts:
I'm trying to convert a String to a float but I'm running into issues with precision, even with the Arduino's own String example I'm getting bad results.

Example 0:
Input string: 1.234567  After conversion to float: 1.2345669

Example 1:
Input string: 60.123456 After conversion to float: 60.1234512

Example 2:
Input string: 9.876543  After conversion to float:9.8765430

Why is this happening and how do I get rid of this?


texts: Sample code for using adafruit servo shield?

texts:
I would like to control 16 motors with a servo shield, however, I have found scant to nothing sample code online. The one I was able to find is...strange to say the least

https://github.com/kachok/arduino-libraries/blob/master/Adafruit_PWMServoDriver/examples/servo/servo.pde

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)

uint8_t servonum = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel Servo test!");

  pwm.begin();

  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
}

void loop() {
  // Drive each servo one at a time
  Serial.println(servonum);
  for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
    pwm.setPWM(servonum, 0, pulselen);
  }
  delay(500);
  for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
    pwm.setPWM(servonum, 0, pulselen);
  }
  delay(500);

  servonum ++;
  if (servonum > 15) servonum = 0;
}

Im used to controlling motors using servo.write, but with the shield, it doesn't seem very intuitive as to how I should control the motors. How does Servomin and Servomax map to 0 degree and 180 degree?

Someone please elucidate!


texts: expected primary-expression before ',' token

texts:
EDIT: have solved the problem. It was missing the quotation marks around each letter. Thanks for your help, st2000!

I am very new to Arduino and C++ (coding in general!). Have copied an example code, only modifying the notes to make my own tune. But when I click 'verify', I am getting the error above, and I can't for the life of me, work out what is wrong! I've searched and read several forums and FAQs, but am just coming up blank. This is the code I have, where the error is occuring:

  int melody[]={
    a,C,D,
    a,a,C,D,D,C,
    C,C,D,D,C,
    C,D,E,F,E,D,C};

Any help would be greatly appreciated!


texts:
I have a project where I read 2 sensors using an esp32 and also have an web server. I can connect using mobile phone and display the page where I see info about the sensors (using web sockets to update the info on the page very quickly ) and also send some commands back to esp32. Is working fine, just the issue that when I am connected to esp I don t have internet on my phone anymore (which is a normal thing:) ).
My question is if I can achieve same but using bluetooth instead wifi ? Is there any way to have a "web page" using bluetooth ?
Thank you


texts:
. I used      the inbuilt basic example of measuring the distance to test my ultrasonic sensor. the object is kept at 10 - 15 cm. form the ultrasonic sensor but still the readings show 135 cm only

#include <Ultrasonic.h>
int trigPin = 5;
int echoPin = 6;
#include <Servo.h>   //servo library
Servo servo;
int servoPin = 7;
long duration, dist, average;
long aver[3];   //array for average

void setup() {
    Serial.begin(9600);
    servo.attach(servoPin);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    servo.write(0);         //close cap on power on
    delay(100);
    servo.detach();
}

void measure() {
 digitalWrite(100,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(100);
digitalWrite(trigPin, HIGH);
delayMicroseconds(150);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2.0) / 29.1;    //obtain distance
}
void loop() {
  for (int i=0;i<=2;i++) {   //average distance
    measure();
   aver[i]=dist;
    delay(100);              //delay between measurements
  }
 dist=(aver[0]+aver[1]+aver[2])/3;

if ( dist<15 ) {
//Change distance as per your need
 servo.attach(servoPin);
  delay(1);
 servo.write(0);
 delay(2500);
 servo.write(100);
 delay(500);
 servo.detach();
}
Serial.print(dist);
}

#include <Ultrasonic.h>
int trigPin = 5;
int echoPin = 6;
#include <Servo.h>   //servo library
Servo servo;
int servoPin = 7;
long duration, dist, average;
long aver[3];   //array for average

void setup() {
    Serial.begin(9600);
    servo.attach(servoPin);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    servo.write(0);         //close cap on power on
    delay(100);
    servo.detach();
}

void measure() {
    digitalWrite(100,HIGH);
    digitalWrite(trigPin, LOW);
    delayMicroseconds(100);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(150);
    digitalWrite(trigPin, LOW);
    pinMode(echoPin, INPUT);
    duration = pulseIn(echoPin, HIGH);
    dist = (duration/2.0) / 29.1;    //obtain distance
}

void loop() {
  for (int i=0;i<=2;i++) {   //average distance
    measure();
   aver[i]=dist;
    delay(100);              //delay between measurements
  }
  dist=(aver[0]+aver[1]+aver[2])/3;

  if ( dist<15 ) {
    //Change distance as per your need
    servo.attach(servoPin);
    delay(1);
    servo.write(0);
    delay(2500);
    servo.write(100);
    delay(500);
    servo.detach();
  }
  Serial.print(dist);
}


texts: RF transmitter with external 8-12v power not working properly

texts:
So I have this pair of transmitter and receiver

RPI is powered by USB from laptop
Transmitter is connected to Attiny85 being interfaced from RPI at 3v3
Receiver is connected to Arduino at 5v

If I have transmitter VCC connected to RPI 5v, data pin to Attiny85 running at 3.3v and all of them having same ground - all works fine, but obviously range is not great.
At this point same ground connects: transmitter, Attiny, RPI.

So I've tried using external power supply for transmitter.

I have power brick with DC output running at 12v

DC output positive goes to VCC, negative to common ground.
At this point same ground connects: transmitter, Attiny, RPI, power brick.
This doesn't work at all, receive nothing.

I have YwRobot breadboard power, which is broken and now supplies 8v on 5v pins

I've connected same power brick DC output to YwRobot DC in, positive 5v from board (actually pushing 8v) goes to VCC, negative from board goes to common ground.
At this point same ground connects: transmitter, Attiny, RPI, YwRobot.
This setup transmits data some times, still worse results than connecting VCC to RPI 5v.

Am I missing something? Does external power supply has to be something specific? I've thought as long as grounds are connected any power supply can be used on transmitter.

Update:
This 433MHz transmitter with PCB integrated antenna from my thermostat (powered by 2xAA) has no problem penetrating 3 walls and floor in my house. Sorry for my ignorance, but I need to achieve similar form factor and performance. 2.4GHz modules also require a lot of pins limiting what else can be done with Attiny85.

Update:
Attiny is using manchester and software serial (part of Arduino IDE) on attiny core.
RPI is using serial, not sure which version, installed using sudo apt-get install python-serial


texts: How to create objects with their own variables?

texts:
So i created a class and when i created objects and use them, they seem to share their variables between each other ( the currentReading, previousReading and the time variable). how can i create objects that have their own variables so that type of conflict cant happen?

code : ( read the buttons and print them in the lcd screen)

#include <LiquidCrystal.h>

LiquidCrystal lcd(6, 5, 3, 2, 1, 0);

class button {
  public:
    void SetupButton(int pino);
    int Read();

  private:
    int _pin;
};

void button::SetupButton(int pin) {
  pinMode(pin, INPUT_PULLUP);
  _pin = pin;

}

int button::Read() {
  static boolean currentReading, previousReading = 1;
  static unsigned long time;

  currentReading = digitalRead(_pin);// reading
  if (previousReading - currentReading  == 1) { // when reading gos from 1 to 0
    time = millis();
  }

  if (currentReading - previousReading == 1 && (50 < (millis() - time) < 500)) {     // when reading gos back to 1 before 500ms
    previousReading = currentReading;
    return 1;
  }

  if (3000 > (millis() - time) && (millis() - time) > 500 && !currentReading) { // when reading keeps in 0 after 500ms
    previousReading = currentReading;
    return 2;
  }

  if ((millis() - time) > 3000 && !currentReading) { // // when reading keeps in 0 after 3000ms
    previousReading = currentReading;
    return  3;
  }

  previousReading = currentReading; // current reading becomes the previous

  return 0;
}

button up;
button down;

void setup() {
  lcd.begin(16, 2);
  up.SetupButton(A0);
  down.SetupButton(A1);

}
void loop() {

  lcd.setCursor(0, 0);
  lcd.print(up.Read());
  lcd.print(down.Read());

}

ps :  i already know how to do this without using classes but doing it with classes makes the code much cleaner so i am trying to achieve this


texts: How can I fix this error "invalid operands of types 'const char [17]' and 'float' to binary 'operator+'"?

texts:
#include <Wire.h>

long aX,aY,aZ,gX,gY,gZ;
float rtX,rtY,rtZ,gfX,gfY,gfZ;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  setupMPU ();
}

void loop()
{
  recordAccelregisters();
  recordGyroregisters();
  printData();
  delay(100);
}

void setupMPU()
{

  Wire.beginTransmission(0b1101000);
  Wire.write(0x6B);
  Wire.write(0b00000000);
  Wire.endTransmission();
  Wire.beginTransmission(0b1101000);
  Wire.write(0x1B);
  Wire.write(0b00000000);
  Wire.endTransmission();
  Wire.beginTransmission(0b1101000);
  Wire.write(0x1C);
  Wire.write(0b00000000);
  Wire.endTransmission();
}

void recordAccelregisters()
{
  Wire.beginTransmission(0b1101000);
  Wire.write(0x3B);
  Wire.endTransmission();
  Wire.requestFrom(0b1101000,6);
  while(Wire.available()<6)
  {
    aX = Wire.read()<<8|Wire.read();
    aY= Wire.read()<<8|Wire.read();
    aZ = Wire.read()<<8|Wire.read();
    processAData();
  }
}

void processAData()
{
  gfX= aX/16384.0;
  gfY = aY/16384.0;
  gfZ = aZ/16384.0;
}

void recordGyroregisters()
{
  Wire.beginTransmission(0b1101000);
  Wire.write(0x43);
  Wire.endTransmission();
  Wire.requestFrom(0b110100,6);
  while(Wire.available()>6)
  {
    gX = Wire.read()<<8|Wire.read();
    gY = Wire.read()<<8|Wire.read();
    gZ = Wire.read()<<8|Wire.read();
    processGdata();
  }

}

void processGdata()
{
  rtX= gX/131.0;
  rtY = gY/131.0;
  rtZ= gZ /131.0;
}

void printData()
{
  Serial.print("Gyro degree(x)= "+ rtX + " ");// this line shows error mentioned above in the question
  Serial.print("Gyro degree(y)= "+ rtY + " ");// this line shows error mentioned above in the question
  Serial.print("Gyro degree(z)= "+ rtZ + " ");// this line shows error mentioned above in the question
  Serial.print("Accel Gforce(x)= "+ gfX + " ");// this line shows error mentioned above in the question
  Serial.print("Accel Gforce(y)= "+ gfY + " ");// this line shows error mentioned above in the question
  Serial.print("Accel Gforce(z)= "+ gfZ + " ");// this line shows error mentioned above in the question
}

this is a code of mpu6050.  Why am I getting this error and How Can I resolve it?


texts:
I've got an ArduiMU V3+ and would like to connect an ordinary push button to it.
How would I connect it to it.


texts: How to make 12V flashing LEDs using an Arduino Uno?

texts:
I have 3 LEDs powered by an Arduino; each LED has its own flash rate.

Now I want it to be powered by an external 12V power source and still have the flashing function of the Arduino?


texts: Segmentation fault and huge SRAM need for Serial.println

texts:
I have written my own 'assert' since I want to use it for both Windows and Arduino. The class is called from many files (about 10).

AssertUtils.h:

#pragma once

#define assert(expr) AssertUtils::Assert2((expr), (__func__), (__FILE__), (__LINE__));

class AssertUtils
{
public:
    static void Assert2(bool expression, const char* funcName, const char* fileName, int line);
};

AssertUtils.cpp:

#include "AssertUtils.h"
#include "Arduino.h"

/* static */ void AssertUtils::Assert2(bool expression, const char* funcName, const char* fileName, int line)
{
    if (!expression)
    {
        Serial.println(funcName);
        Serial.println(fileName);
        Serial.println(line, DEC);
        Serial.flush();

        // Abort program execution.
        abort();
    }
}

When I compile this, the SRAM usage is 1469 bytes (together with the rest of my sketch and classes).

When I comment the line below, I get a segmentation fault in a random assert call (when I comment out that call, I get it in the next, etc.).

    //Serial.println(funcName);

When I also comment out the second print statement, the compiler reports only 1137 bytes SRAM usage (which I expect since this was about equal until before I added the Assert class).

    //Serial.println(funcName);
    //Serial.println(fileName);

Questions:

How can I get rid of the segmentation fault?
How can it be that about 332 bytes are used for one two additional print statements? (maybe related to the const char* buffering (?)


texts: int array passed through function has wrong values only after multiple passes

texts:
I have this code:
for(int i = 0; i < its; i++) {
    x1 = random(0,4);
    y1 = random(0,4);
    multiLamp(new int[2] {3,1}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    multiLamp(new int[2] {2,0}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    x2 = random(0,4);
    y2 = random(0,4);
    multiLamp(new int[2] {1,3}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    multiLamp(new int[2] {0,2}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
}

which calls the function "multiLamp" and passes 3 int arrays with 2 values each. Here is the function:
void multiLamp(int epos[], int xpos[], int ypos[], int del, int len) {
  for(int it = 0; it < del; it++) {
    for(int i = 0; i < len; i++) {
      lamp(epos[i],xpos[i],ypos[i],2);
    }
  }
}

This function is supposed to call some function "lamp" with a few integers from the arrays. In the beginning this works fine but after more than 50 calls of the "multiLamp" function the values in the arrays become {0,128,128} and {3,3,3} or something similar even though the values passed into it from my main code are equally valid as before (they are somehow changed after being passed to the "multiLamp" function).
I can't seem to find the issue here. Any help is appreciated!
UPDATE:
Here is the full code, although I don't know if it will be of any use because I wrote it to control some LEDs and if you don't have the setup it's difficult to see if the code is working or not.
int e[] = {12,13,11,10};
int xy[] = {2,3,4,9,6,7,8,5,1,A0,A1,0,A3,A4,A5,A2};

void setup() {
  for(int a=0;a < 4;a++){
         pinMode(e[a], OUTPUT);
         digitalWrite(e[a], LOW);
  }
  for(int b=0;b < 16;b++){
         pinMode(xy[b], OUTPUT);
         digitalWrite(xy[b], HIGH);
  }
}

void loop() {
  bigCubes(100);
  rain(20, 30);
  miniCubes(15);
  every(80);
}

void lamp(int epos, int xpos, int ypos, int del) {
  int xypos = 4*xpos+ypos;
  digitalWrite(e[epos], HIGH);
  digitalWrite(xy[xypos], LOW);
  delay(del);
  digitalWrite(e[epos], LOW);
  digitalWrite(xy[xypos], HIGH);
}

void multiLamp(int epos[], int xpos[], int ypos[], int del, int len) {
  for(int it = 0; it < del; it++) {
    for(int i = 0; i < len; i++) {
      lamp(epos[i],xpos[i],ypos[i],1);
    }
  }
}

void every(int wait) {
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 4; j++) {
      for(int k = 0; k < 4; k++) {
        lamp(i,j,k,wait);
      }
    }
  }
}

void miniCubes(int wait) {
  int cube[8][3] = {{0,0,0},{0,0,1},{0,1,1},{0,1,0},{1,1,0},{1,1,1},{1,0,1},{1,0,0}};
  for(int c = 0; c < 8; c++) {
    for(int it = 0; it < wait; it++) {
      for(int i = 0; i < 8; i++) {
        lamp(cube[i][0]+2*cube[c][0],cube[i][1]+2*cube[c][1],cube[i][2]+2*cube[c][2],2);
      }
    }
  }
}

void bigCubes(int wait) {
  multiLamp(new int[32] {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3}, new int[32] {0,0,0,0,1,1,2,2,3,3,3,3,0,0,3,3,0,0,3,3,0,0,0,0,1,1,2,2,3,3,3,3}, new int[32] {0,1,2,3,0,3,0,3,0,1,2,3,0,3,0,3,0,3,0,3,0,1,2,3,0,3,0,3,0,1,2,3}, wait, 32);
}

void rain(int its, int wait) {
  int x2 = random(0,4);
  int y2 = random(0,4);
  int x1;
  int y1;
  for(int i = 0; i < its; i++) {
    x1 = random(0,4);
    y1 = random(0,4);
    multiLamp(new int[2] {3,1}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    multiLamp(new int[2] {2,0}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    x2 = random(0,4);
    y2 = random(0,4);
    multiLamp(new int[2] {1,3}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
    multiLamp(new int[2] {0,2}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
  }
}


texts: Possible configure ESP8266 as wifi shield for Arduino?

texts:
I know there's sketch to make ESP8266 becoming a simple web server. ESP8266 is cheap, small and consume less power compared to a Arduino Wifi shield.

Due to a more complex functionality requirement, I wish to place the web server code inside the Arduino itself (UNO, Nano or Pro Mini maybe). Is it possible to do this by configuring ESP8266 as a wifi bridge/shield to the Arduino? Or some mechanism methods which can route network traffics from ESP8266 to/from Arduino?

Updated
It connected to 4 relays & one I2C RTC DS1307.
It needs to sync RTC time with NTP server, and implement a web server which allows on-demand turn on/off each individual relay or by scheduling (e.g: turn on/off different relay at particular time of day). If RAM spaces allows, would like to implement a password access scheme for the web server as well


texts: What are the traditional ways to optimize program memory usage?

texts:
While doing big projects using Arduino boards (Uno, Atmega328P MCU). I used to get warnings like this
Sketch uses 13764 bytes (44%) of program storage space. Maximum is 30720 bytes.
Global variables use 1681 bytes (82%) of dynamic memory, leaving 367 bytes for local variables. Maximum is 2048 bytes.

Low memory available, stability problems may occur.

What are the generally practiced methods for the optimization program memory usage?
Is there any difference in memory usage if the variable is declared globally or locally.
Will it matter what the control statement/selection statements are (like if, switch )
Usage of Serial monitor. Serial.print()
......

Low memory available, stability problems may occur.

How bad are these warnings?
Before marking it duplicate, I have referred the following. But it wasn't satisfactory
Most memory efficient way to program
What are safe memory usage limits?


texts: Send data before raising edge of a Clock

texts:
I'm trying to control a LED strip that has a custom protocol (developed above of I2C).

But in my tests i was successful figuring out how it works :

You set Clk to zero , you send a bit in the data line , then you set Clk to high. Based on the pixels number , i should send 16bits for each color (Red Green Blue).

I was able to generate a Clock signal at 8MHz with this code :

const byte Clock = 9;
const byte Data = 10;

void setup ()
{
 pinMode (Clock, OUTPUT);
 pinMode (Data, OUTPUT);
 digitalWrite(Data, HIGH);
 TCCR1A = bit (COM1A0);
 TCCR1B = bit (WGM12) | bit (CS10);
 OCR1A =  0;
 }

 void loop ()
 {
 ...
 }

My questions :
How could i send data at that specific time when the clock is at zero ?

Note that using digitalWrite() function was not working due to the frequency limitation of that function.

Thanks for any helpful information.


texts:
dear member.
I have 4 ESP-12 averything OK but one chip behave weird.
always return 1024 on analogRead(A0);
once use ADC_MODE(ADC_VCC) and reflash using ADC_MODE(ADC_TOUT); and never back to normal, is my Chip Error..?
FM 4MB
ArduinoIDE 1.8.13
BR 115200
PS 80MHz
int iVal = 0;
void setup() {
  Serial.begin(115200);
  delay(999);
  pinMode(A0,INPUT) ;
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  iVal=analogRead(A0);
  Serial.println(iVal);

  if (iVal > 900) digitalWrite(LED_BUILTIN,HIGH);
  else   digitalWrite(LED_BUILTIN,LOW);
  delay(720);
}


texts: Arduino can't write MPU6050 data to SD card

texts:
I hope my MPU6050 sensor can write data to my SD card, it compiled OK, but to open the serial monitor I got error message:

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful
filename :acc_0.txt
0, ax: -85, ay: 227, az: 3997
filename :acc_0.txt
error: opening att_0.txt for write failed
SD errorCode: 0X13,0XE5

Here is my code:

// Based on I2Cdevlib, MPU6050_raw
// Experiments to verify if any data loss when writing MPU6050 outputs to SD card

#include "I2Cdev.h"
#include "MPU6050.h"
#include <SdFat.h>

// SD card read/write
// MOSI - pin 11
// MISO - pin 12
// CLK  - pin 13
// CS   - pin 4
const int chipSelect = 4;

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;

SdFat sd;
SdFile myFile;

int count = 0;
int idx = 0;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

    // initialize device
    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // change accel sensitivity to 8g
    accelgyro.setFullScaleAccelRange(MPU6050_ACCEL_FS_8);

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

    // Initialize SdFat or print a detailed error message and halt
    // Use half speed like the native library.
    // change to SPI_FULL_SPEED for more performance.
    if (!sd.begin(chipSelect, SPI_HALF_SPEED))
        sd.initErrorHalt();
}

void loop()
{
    // read raw accel/gyro measurements from device
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    // dynamic create a file
    if (count == 0)
    {
        // dynamic filename
        char filename[11];
        sprintf(filename, "acc_%d.txt", idx);
        Serial.print("filename :");
        Serial.println(filename);

        // open the file for write at end like the Native SD library
        if (!myFile.open(filename, O_RDWR | O_CREAT | O_AT_END))
            sd.errorHalt("opening att_0.txt for write failed");
    }

    // write data to file
    Serial.print(count); myFile.print(count); myFile.print(", ");
    Serial.print(", ax: "); Serial.print(ax); myFile.print(ax); myFile.print(", ");
    Serial.print(", ay: "); Serial.print(ay); myFile.print(ay); myFile.print(", ");
    Serial.print(", az: "); Serial.println(az); myFile.println(az);

    // close file when every 1,000 records
    if (count > 1000)
    {
        myFile.close();
        Serial.println("Finish.");
        count = -1;
        idx  ;
    }

    count  ;
}


texts: I have an SD card have a very big file (1M character). i try to load it into memory in terms of 4K character array ( The maximum I could do using Arduino Mega). but this take almost 250 call to the server. And this is too much. Is there any way better to do it. I am using firebase as my server and i am touching the limit and this is inacceptable to the stability of the program


texts:
i want to make a phisycal keylogger from an arduino board that means to every computer the arduino is connected to the arduino will capture any keypress on keyboard and save it in sd card module or something else
is there a way of doing so?


texts: To update GPS after every 30seconds using NeoGPS and NeoSWSerial Libray

texts:
I am using Adafruit Ulitimate Breakout GPS module and NeoGPS and NeoSWSerial Library. Now I want the GPS to update in 30seconds once (1time in 30seconds).After it is updated I want to check the location if new location is equal to old location then it should be updated in 60seconds once(1time in 60seconds).If not the location should be new location. It should display the location every 60seconds.
I tried this flow on Adafruit GPS Library, which works but I want to use NeoGPS library and do the same.
Below is my adafruit library code:

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(11, 10);
Adafruit_GPS GPS(&mySerial);

#define GPSECHO  true
uint32_t timer = millis();
float old_lat,old_lon,new_lat,new_lon;

void setup()
{

  Serial.begin(9600);
  delay(1000);
  Serial.println("Adafruit GPS library basic test!");
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand("$PMTK220,30000*1F");
  mySerial.println(PMTK_Q_RELEASE);
}

void loop()                     // run over and over again
{
  char c = GPS.read();
  if (GPS.newNMEAreceived()) {
    //Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived() flag to false
    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another
  }

if (GPS.fix) {

      old_lat = GPS.latitudeDegrees;
      old_lon = GPS.longitudeDegrees;
      if (timer > millis())  timer = millis();
      if (millis() - timer > 60000) {
        timer = millis();
          Serial.println("Location 1 minute:");
          displaytime();
          new_lat = GPS.latitudeDegrees;
          new_lon = GPS.longitudeDegrees;

          if (new_lat == old_lat){
            new_lat = old_lat;
          }
          else{
            new_lat = GPS.latitudeDegrees;
          }
          Serial.print("Final Latitude: ");
          Serial.println(new_lat,6);

          if (new_lon == old_lon){
            new_lon = old_lon;
          }
          else{
            new_lon = GPS.longitudeDegrees;
          }
          Serial.print("Final Longitude: ");
          Serial.println(new_lon,6);

}
}
}

void displaytime(){
    Serial.print("\nTime: ");
    if (GPS.hour < 10) { Serial.print('0'); }
    Serial.print(GPS.hour, DEC); Serial.print(':');
    if (GPS.minute < 10) { Serial.print('0'); }
    Serial.print(GPS.minute, DEC); Serial.print(':');
    if (GPS.seconds < 10) { Serial.print('0'); }
    Serial.print(GPS.seconds, DEC); Serial.print('.');
    if (GPS.milliseconds < 10) {
      Serial.print("00");
    } else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
      Serial.print("0");
    }
    Serial.println(GPS.milliseconds);
}

This is my NeoGPS Library code in which I am using NeoSWSerial:

#include <NMEAGPS.h>
#include <NeoSWSerial.h>// import the serial library

NeoSWSerial gpsPort(11, 10); // RX is 11 (to GPS tx), TX is 10 (to GPS rx)
NMEAGPS gps; // the parser
gps_fix fix; // the struct with all the parsed values

void setup() {

  gpsPort.begin(9600);
  Serial.begin(9600);
  Serial.println("GPS Start");
}

void loop() {

  if (gps.available( gpsPort)) {
      fix = gps.read();
      Serial.println("Latitude:");
      Serial.println( fix.latitude(), 6);
      Serial.println("Longitude:");
      Serial.println( fix.longitude(), 6);

    }
 }


texts: ESP01 to DC Motor powered via Battery with Power Regulator

texts: Hi I'm wanting to control a dc motor through esp-01 and to have it powered by batteries. To keep my esp-01 safe, I have found the esp-01 adapter to regulate voltage. I am wondering if anyone could provide a simple schematic of the wiring? I'm wanting to keep the design small so no breadboard if possible.


texts: Arduino Uno not including two header files at the same time

texts:
I have an Arduino Uno and I am trying to control a stepper motor with it. I also have an RF transmitter and receiver (433MHZ). I need to transmit data about motor status.

For RF I am following this page. Individually both are working great. I am able to send data from one Arduino (TX) to another (RX). And also I am able to control the motor. But when I am merging these projects, their header files are giving an error.

For RF, I need to include #include <RH_ASK.h> and for the motor I need include #include <Servo.h>. When I am including these headers files, they are giving me this error:

Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Uno"

libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin): In function `RH_ASK::maxMessageLength()':

(.text+0x0): multiple definition of `__vector_11'

libraries\Servo\avr\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

I do not know what's wrong here. Can anyone please help me?


texts: ESP32 USB HID/MIDI library (not the BLE one)

texts:
I couldn't find any library to use an "old" ESP32 (not the new ESP32-S2) as an HID connected physicaly to the Usb port (not over BLE pairing) to send keystrokes to the PC ...
Is there any solution? Any code example, so far?
Thanks in advance!