texts:
When I send an SMS like this:

Tilt:090
Azimuth:120

First time an SMS is read, the servo rotates to the correct position, but after they change a small angle, it's like noise.
I do following things to stop that change:

First try with motor driver

Capacitor circuit use

Here is my code:
#include <AFMotor.h>
#include <Sim800l.h>
#include <SoftwareSerial.h>
#include <Servo.h>

Sim800l Sim800l; //to declare the library
Servo Tilt;
Servo Azimuth;

String text; // to storage the text of the sms
uint8_t index; // to indicate the message to read.
int t, pos, old_pos, pos1, old_pos1; // to indicate the int value.

void setup()
{
    Tilt.attach(9); // attaches the servo on pin 5 to the servoH object
    Azimuth.attach(10); // attaches the servo on pin 6 to the servoV object
    Serial.begin(9600); // only for debug the results .
    Sim800l.begin(); // initializate the library.
    index = 1; //  position in the prefered memory storage.
}

void Tilt_servo()
{
    if (old_pos > pos) {
        for (int q = old_pos; q > pos; q--) {
            Tilt.write(q);
            delay(20);
            Serial.println("position dicreasing");
        }
    }
    else if (old_pos < pos) {
        for (int q = old_pos; q < pos; q++) {
            Tilt.write(q);
            delay(20);
            Serial.println("position increasing");
        }
    }
    else {
        Tilt.write(pos);
    }
}

void Azimuth_servo()
{
    if (old_pos1 > pos1) {
        for (int d = old_pos1; d > pos1; d--) {
            Azimuth.write(d);
            delay(20);
            Serial.println("position1 dicreasing");
        }
    }
    else if (old_pos < pos) {
        for (int d = old_pos1; d < pos1; d++) {
            Azimuth.write(d);
            delay(20);
            Serial.println("position1 increasing");
        }
    }
    else {
        Azimuth.write(pos1);
    }
}

void loop()
{
    delay(1000);

    Serial.println("---------------------------------------------------------------------------");
    old_pos = pos;
    old_pos1 = pos1;

    Serial.println("old_pos:");
    Serial.println(old_pos);
    Serial.println("old_pos1:");
    Serial.println(old_pos1);

    text = Sim800l.readSms(index);
    Serial.println(text);
    String W = text.substring(33, 45); // filter phone number...
    Serial.println(W);
    String y = text.substring(20, 30); // filter REC UNREAD
    Serial.println(y);

    if (y == "REC UNREAD") {

        String s = text.substring(74, 79); // filter the "Tilt:"
        Serial.println(s);
        String p = text.substring(79, 82); // filter the position
        int t = p.toInt(); // convert position as int value
        Serial.println(t);
        pos = t;

        String v = text.substring(83, 91); // filter the "Azimuth:" letter
        Serial.println(v);
        String u = text.substring(91, 94); // filter the position as string
        int b = u.toInt(); // convert position as int value
        Serial.println(b);
        pos1 = b;

        if (s == "Tilt:" && v == "Azimuth:") {

            Tilt_servo();
            delay(1000);
            Serial.println("done....Tilt...");
            Serial.println(pos);
            Azimuth_servo();
            delay(1000);
            Serial.println("done....Azimuth...");
            Serial.println(pos1);
        }
        //Sim800l.delAllSms();
        //delay(5000);
    }

    else {
        Tilt.write(pos);
        Azimuth.write(pos1);
    }

    delay(1000);
    Sim800l.delAllSms();
    delay(5000);
    Serial.println("---------------------------------------------------------------------------");
}


texts: I only currently have 2 arduinos and I find that any project I build I feel bad because I have to rip it apart to get the arduino because I want to build something else. Is there a way to get arduinos for cheap? (I'm new to arduino)


texts: I made a project based on calling with gsm module and arduino and  now i want to transmit to voice wirelessly to my bluetooth earphone which module should i use for this purpose.


texts:
I am planning to buy a Arduino board. I am also considering Arduino clones, too. My requirements are that the board should inbuilt communication modes like Ethernet, WiFi and a SD card slot, too. Also the board should have a decent amount of memory and the processor must be a a little more powerful than the Uno. The board must be capable of running a OS if possible!

I was looking at the Yun and Due. The Yun has all the communication modes but runs on a low end processor. The Due on the other hand runs on a ARM processor but has none of the communication modes. So now I am in a fix.

Which board should I choose?


texts:
i'm making a project and i came across the follwing error.
Whan i'm trying to compile and upload the code i'm getting those errors:

ShiftRegisterTest1.ino:In function 'int* return_pins(int)'
displays.ino:9: error: expected primary-expression before '{' token
displays.ino:9: error: expected `;' before '{' token
displays.ino:12: error: expected primary-expression before '{' token
displays.ino:12: error: expected `;' before '{' token
displays.ino:15: error: expected primary-expression before '{' token
displays.ino:15: error: expected `;' before '{' token
displays.ino:18: error: expected primary-expression before '{' token
displays.ino:18: error: expected `;' before '{' token
displays.ino:21: error: expected primary-expression before '{' token
displays.ino:21: error: expected `;' before '{' token
displays.ino:24: error: expected primary-expression before '{' token
displays.ino:24: error: expected `;' before '{' token
displays.ino:27: error: expected primary-expression before '{' token
displays.ino:27: error: expected `;' before '{' token
displays.ino:30: error: expected primary-expression before '{' token
displays.ino:30: error: expected `;' before '{' token
displays.ino:33: error: expected primary-expression before '{' token
displays.ino:33: error: expected `;' before '{' token
displays.ino:36: error: expected primary-expression before '{' token
displays.ino:36: error: expected `;' before '{' token
displays.ino:39: error: expected primary-expression before '{' token
displays.ino:39: error: expected `;' before '{' token
displays.ino:42: error: expected primary-expression before '{' token
displays.ino:42: error: expected `;' before '{' token
displays.ino:45: error: expected primary-expression before '{' token
displays.ino:45: error: expected `;' before '{' token
displays.ino:48: error: expected primary-expression before '{' token
displays.ino:48: error: expected `;' before '{' token
displays.ino:51: error: expected primary-expression before '{' token
displays.ino:51: error: expected `;' before '{' token
displays.ino:56: error: expected primary-expression before '{' token
displays.ino:56: error: expected `;' before '{' token
Error compiling

I don't really understand why since the code (see below) should be working.

int * return_pins(int get_number)
{
static int rp[8];
switch(get_number)
{
            //DP, A, B, C, D, E, F, G
    case 48: //0
        rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};
        break;
    case 49: //1
        rp[8] = {0, 0, 1, 1, 0, 0, 0, 0};
        break;
    case 50: //2
        rp[8] = {0, 1, 1, 0, 1, 1, 0, 1};
        break;
    case 51: //3
        rp[8] = {0, 1, 1, 1, 1, 0, 0, 1};
        break;
    case 52: //4
        rp[8] = {0, 0, 1, 1, 0, 0, 1, 1};
        break;
    case 53: //5
        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};
        break;
    case 54: //6
        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};
        break;
    case 55: //7
        rp[8] = {0, 1, 1, 1, 0, 0, 0, 0};
        break;
    case 56: //8
        rp[8] = {0, 1, 1, 1, 1, 1, 1, 1};
        break;
    case 57: //9
        rp[8] = {0, 1, 1, 1, 1, 0, 1, 1};
        break;
    case 65: //A
        rp[8] = {0, 1, 1, 1, 0, 1, 1, 1};
        break;
    case 70: //F
        rp[8] = {0, 1, 0, 0, 0, 1, 1, 1};
        break;
    case 69: //E
        rp[8] = {0, 1, 0, 0, 1, 1, 1, 1};
        break;
    case 80: //P
        rp[8] = {0, 1, 1, 0, 0, 1, 1, 1};
        break;
    case 72: //H
        rp[8] = {0, 0, 1, 1, 0, 1, 1, 0};
        break;
            //DP, A, B, C, D, E, F, G
    case 45: //-
    default:
    rp[8] = {0, 0, 0, 0, 0, 0, 0, 1};
    break;
}
return rp;
}

What this code does is to basicaly get an int ad input and based on this number it returns an int array. It's a very simple code which is called inside the loop() method which is located on an other file.

Also i'm using Atmel Studio 6 instead of the original Arduino IDE but i dont think it has to do something with the problem :/


texts:
I am trying to stop servo motor from rotating when I enter 0 in serial. The code is below. Can someone please help?

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards
int state;
int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin (9600);
}

void loop()
{
  if (Serial.available () > 0)
  {
    state = Serial.read ();
    if (state == '1')
    {
      for (pos = 0; pos <= 180; pos += 1)
      {
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);
      }
      for (pos = 180; pos >= 0; pos -= 1)
      {
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);      // waits 15ms for the servo to reach the position
      }
      if (Serial.available () > 0)
      {
        state = Serial.read ();
        if (state == '0')
        {
          myservo.write ('90');
          delay (300);
        }
      }
    }
  }
}


texts: How to move a servo quickly and without delay function

texts:
Im trying to move a servo from one place to another while using the typical for loop you find in the servo's library example.
int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 <= lightON; pos1 += 1) {
  servo1.write(pos1);
  delay(15);
}

for (pos1 = lightON; pos1 >= lightOFF; pos1 -= 1) {
  servo1.write(pos1);
  delay(15);
}

The thing is that while this does work, I want to be able to move the servo a little quicker but I cant use the delay function because of some connectivity issues with another library named BLYNK. How could i move the servo from lightOFF to lightON the quickest way possible without the delay function? Sorry for my grammar i'm not a native english speaker. Thank you!


texts: Powering Arduino Mega 2560 from a Raspberry Pi Usb

texts:
I have a Raspberry Pi B+ running 7x24. I have to connect an Arduino Mega 2560 to its USB. The Arduino has only one nRF24L01-PA-LNA powered from its 3V3.
Can I power the Arduino from the Pi's USB?


texts: How to create a simple TCP server with the analogRead value on Wemos D1 mini?

texts:
I want to create a TCP server on the Wemos that serves the analogRead value of the connected potentiometer.

The code below is based on this example.
The Wemos connects to the Wi-Fi and i'm able to ping it,
but the problem is that I can't connect to the server.
Also I don't really understand why the length of the data has to be passed with the data (serverClients[i].write(sbuf, len);). Why can't the library figure that out?

#include <ESP8266WiFi.h>

//how many clients should be able to telnet to this ESP8266
#define MAX_SRV_CLIENTS 2
const char* ssid = "myWifi";
const char* password = "myPassword";

WiFiServer server(23);
WiFiClient serverClients[MAX_SRV_CLIENTS];

unsigned long previousMillis = 0;
const long interval = 200;
void setup() {
  Serial.begin(115200);
  Serial.print("\nConnecting to "); Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
  if (i == 21) {
    Serial.print("Could not connect to"); Serial.println(ssid);
    while (1) delay(500);
  }
  server.setNoDelay(true);
  Serial.print(WiFi.localIP());
}

void loop() {
  unsigned long currentMillis = millis();
  uint8_t i;
  //check if there are any new clients
  if (server.hasClient()) {
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      //find free/disconnected spot
      if (!serverClients[i] || !serverClients[i].connected()) {
        if (serverClients[i]) serverClients[i].stop();
        serverClients[i] = server.available();
        continue;
      }
    }
    //no free/disconnected spot so reject
    WiFiClient serverClient = server.available();
    serverClient.stop();
  }

  //do every 200ms
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    int isensorValue = analogRead(A0); //analog read
    String sSensorValue = String(isensorValue); //int to string
    size_t len = sSensorValue.length();
    uint8_t sbuf[len];
    sSensorValue.getBytes(sbuf, len);
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      if (serverClients[i] && serverClients[i].connected()) {
        serverClients[i].write(sbuf, len);
        delay(1);
      }
    }

  }
}


texts: Anyone have the Maplin N97DG bluetooth shield working?

texts:
I went & impulse-bought a Maplin Bluetooth shield yesterday.

It comes with a little tiny book containing examples, and uses the softwareserial library in these; I can load them, and get the Arduino <-> PC communication going OK, however there appears not to be a response from the bluetooth part of the device. The LED lights much as the booklet says it should. I did see it return some odd characters one time, just the once..

Given that the system appears to be alive, I don't want to give up & take it back; however the output from Google is not promising, and my trial to date isn't either - so I'm looking for positive news that this product does actually work for someone somewhere?

I'm using the built-in serial in the IDE to talk to it, not X-CTU as they suggest (as they don't do a Linux version).


texts: I'm planning on building an LED clock, but I want it to be lit only when I press the POWER button on my remote control. Using an IR receiver, which Arduino sleep mode should I use to reduce the current consumption but still be able to receive this interrupt?


texts: Arduino Nano joystick x2 / potentiometer

texts:
will i be able to connect up all these parts to an arduino Nano
i noticed i will need to connect to the nanos v5 to the 2 joysticks and potentiometer slider if i share the voltage will it still function as intended

Parts

x1 = USB Arduino Nano V3.0 ATMEGA328P CH340G 5V 16M Micro-Controller Arduino

x2 = 3D Analog Joystick for Sony PSP 1000 Consol
+5v (possible 10kOhm resistance)

x1 = Electronic slider 10K potentiometer Slider Module for Arduino
Voltage: 3.3V or 5V / Resistance: 10K


texts: Concatenation of non constant character array with a string

texts:
I have an Arduino Duemilanove.

I read this page on string concatenation. Yet, it didn't include my case.

I have a non constant character array, that later gets a value.

char clat[11];
dtostrf(gps.location.lat(), 11, 6, clat);

I want to output this:

Latitude: 20.653425

So basically I want a final string that contains: "Latitude:" + the value of the nonconstant array.

Is it possible?


texts: is it necessary to include libraries that are specified in the header file already?

texts:
I am using the Adafruit BME280 library in my sketch. In the example sketches, they have included the Wire, SPI and the Adafruit_Sensor library. However, I see that in the Adafruit_BME280 library header file, these libraries are already included. So I tried commenting out them in my sketch and it still works. So I wonder if there are still cases or any specific reason to include them twice?
Additionally, if a library is included/referenced twice like mentioned above, wouldn't it increase the size of the sketch unnecessarily?

Example Sketch that comes with the library
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Serial.begin(9600);
    while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;

    // default settings
    status = bme.begin();
    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }

    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}

void loop() {
    printValues();
    delay(delayTime);
}

void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}


texts: 3 input (on/off/off with delay) to control 1device using ESP8266 as Web Server

texts:
I want to control one device in three ways : turn on / turn off / turn off with delay.
To do that i use an ESP8266 web server + android phone app.
The problem is that turn off with delay wont work.
It works with delay() but i dont want to use delay() as it stops other functions.
I would be grateful if you could help me.
here is my code :
#include <ESP8266WiFi.h>
const int device1 = 14;
unsigned long previousMillis = 0;
const long interval = 5000;
const char* ssid     = "****";
const char* password = "****";
#include <Arduino.h>
WiFiServer server(80);
String data = "";

void setup() {
 pinMode(device1, OUTPUT);
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
WiFi.begin(ssid, password);
IPAddress ip(*,*,*,*);
IPAddress gateway(*,*,*,*);
IPAddress subnet(*,*,*,*);
WiFi.config(ip, gateway, subnet);
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");

 server.begin();

 Serial.println(WiFi.localIP());
 }

void loop() {
    unsigned long currentMillis = millis();

  WiFiClient client = server.available();
 if (!client) {
   return;
 }

 while(!client.available()){
 }

 String req = client.readStringUntil('\r');
 client.flush();
 if (req.indexOf("/on") != -1)
   { digitalWrite(device1, HIGH);}
 if (req.indexOf("/off") != -1)
   { digitalWrite(device1, LOW);}

 if (req.indexOf("/delay") != -1)
 {
  unsigned long currentMillis = millis();
  unsigned long previousMillis = millis();
if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    digitalWrite(device1, LOW);

}
}


texts:
I need to separate numbers from the text where my string of numbers will always be of length 8:

string text = "77953505HELLO THIS IS A MESSAGE"; //my string of numbers will always be of length 8

My result

string number = "77953505"; //my string of numbers will always be of length 8
string message = "HELLO THIS IS A MESSAGE";

What operation should I use?

this is the job I'm doing

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

void loop() {
  if (Serial.available() > 0) {

    String Texto = String(Serial.read());

    String number = Texto.substring(0, 7);
    String message = Texto.substring(8);

    Serial.write(number);
    Serial.write(message);
  }
}

help me!


texts: What's the difference between DDRB and pinMode?

texts:
It's my understanding that the following lines are equivalent. They seem to be interchangeable in my sketch:

DDRB = 1<<DDB0;

and

pinMode(0, OUTPUT);

Is the first form (DDRB...) setting a micro-controller address directly? Is that assembler?

And is the second form (pinMode) using an included library? Maybe the avr/io.h library?

On a Digispark ATTiny85.


texts:
I know this isnt specific but could you suggest some causes for the following issue:

Mega2560 sends values to Raspi 3 and Raspi 3 receives prints them accordingly (arduino also prints out the values it sends). However, at every occasional instances, garbage data is printed on Raspi terminal while the right data is still printed on the serial monitor for Arduino for a baudrate of 115200 for both.

Any helpful suggestions would be appreciated


texts: Efficient algorithm/data structure to calculate moving averages

texts:
Currently I am developing a graphic LCD system to display temperatures, flows, voltages, power and energy in a heat pump system. The use of a graphic LCD means that half of my SRAM and ~75% of my flash have been used up by a screen buffer and strings.

I am currently displaying min/max/average figures for energy At midnight when the daily figure resets, the system checks if the consumption for the day is above or below the previous minimum or maximum, and stores the value. The average is calculated by dividing the cumulative energy consumption by the number of days.

I would like to display the daily average over the last week and month (4 weeks for simplicity) i.e. a rolling average. Currently this involves maintaining an array of values for the last 28 days and calculating an average over the whole array for monthly and last 7 days for weekly.

Initially I was doing this using an array of floats (as the energy is in the form "12.12kWh"), but this was using 28 * 4 bytes = 112 bytes (5.4% of SRAM). I don't mind having only a single decimal point of resolution, so I changed to using uint16_t and multiplying the figure by 100. This means that 12.12 is represented as 1212, and I divide by 100 for display purposes.

The size of the array is now down to 56 bytes (much better!).

There is no trivial way to reduce the figure down to a uint8_t that I can see. I could tolerate the loss of a decimal place ("12.1kWh" instead of "12.12kWh"), but consumption is frequently higher than 25.5kWh (255 being the highest value represented by a 8-bit unsigned integer). Consumption has never been below 10.0kWh or above 35.0kWh, so conceivably I could subtract 10 from the stored figures, but I know that one day we will exceed these limits.

I then tested code to pack 9-bit values into an array. This gives a range of 0-51.2kWh and uses 32 bytes in total. However, accessing an array like this is pretty slow, especially when you have to iterate over all values to calculate an average.

So my question is - is there a more efficient way of calculating a moving average with three windows - lifetime, 28 days and 7 days? Efficiency means smaller in terms of SRAM usage, but without the penalty of huge code. Can I avoid storing all values?


texts: How do I get more than 64 characters of message from serial

texts:
I am trying to make a moving message board using an Arduino Uno, HC-05 Bluetooth module and DMD board.
Sending message to the DMD through the Bluetooth module can only give a not more than 62 character message.
I need help in what to do to get up to 200 or more. Thanks.


texts:
My code:

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

bool buttonState = 0;         // variable for reading the pushbutton status
bool ledState = 0;
void setup() {
  pinMode(ledPin, OUTPUT);   // initialize the LED pin as an output:
  pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:
}
void loop() {
  buttonState = digitalRead(buttonPin);// read the state of the pushbutton value:
  if (buttonState == HIGH)
 {
  ledState = !ledState;
 }
  if (ledState == HIGH)
 {
   digitalWrite(ledPin, HIGH); // turn LED on:
 }
   else
 {
    digitalWrite(ledPin, LOW); // turn LED off:
 }
}

So this is supposed to toggle a led's light on and off. currently it does do that but its not always the case. Currently, if the button is pressed on the arduino board, it has a 50-50 chance of changing its state. What part of the code is leading to this outcome?


texts:
How does the Serial.print() transmit the data? Can you please explain this with respect to TX buffers?

Also, What would happen if i try to output the data that is greater than 64 bytes? How is this transmitted?

And please explain the difference with Serial.write()

Thanks!


texts: Uploading to atmega328 over serial with arduino bootloader running at 2MHz

texts:
I want to run an atmega328 on a breadboard at 2MHz and upload to it via the serial pins (pins 2 and 3). So I am setting the clock divide by 8 fuse bit to enable this, meaning the atmega runs at 2MHz eith the 16MHz crystal. But I can't upload, probably because the bootloader is not expecting the clock to be running at 2MHz. The baud rates are probably mismatched by 8 times, the IDE is trying to upload at 57600 but since the bootloader code is not aware its being clocked at 2MHz, its probably running 8 times too slow. I've messed around a bit with the arduino conf files changing baud rates but had no joy. I was wondering if anyone knows how to do this off the top of their head.

Thanks, Pete


texts: Ethernet Shield - Multiple simultaneous connections cause TCP reset

texts:
I have a very inconvenient problem with a web server I'm writing for a Arduino Mega 2560 with a W5100 Ethernet Shield (with the "official" Ethernet lib). I wrote the server code and it works like a charm, BUT there is a condition, when the server won't accept all the TCP handshakes and resets the TCP connections:
When I load a big webpage, the browser (Firefox and Chrome too) asks for the .htm first, then collects the links in the file and request them all simultaneously and that's when I got the problem:

The server gets multiple TCP connections but it only accepts the first, then dumps all the others (by TCP reset). After that the client sends them again and the problem starts again: the server accepts the first and drops the others. And so on, for example if the browser needs 3 files, it will take ~9 seconds, because of the retransmission delay. (3 + 6 seconds) Eventually the webpage will load, but a 10 second delay is not acceptable.
Is there any way to cache the requests on the Ethernet Shield or to tell the browser to wait a bit between requests or any other way, to wait a bit for the Arduino to finish the previous request?

Snippet for the server, Wireshark and Chrome network data: https://gist.github.com/anonymous/181f359b70d69e4470931204c4ec175c

Thanks for the help!

G.


texts: 7 Key Educational Piano with Capacitive Sensor

texts:
I am working on a project for grade 10 computer science.  I am supposed to make a piano that has 7 keys using a capacitive sensor, and the piano is supposed to teach you songs like Twinkle Twinkle Little Star by illuminating the LED corresponding with that key and then playing that tone on the speaker.  There is also a "random scales" part where you are timed and have to press the keys as fast as you can as they light up.  Unfortunately, I have come into a few problems.

I ran out of outputs and have to use a shift register. I have no idea on how to control each of the outputs.
When the game starts I want there to be 2 options a song and a random scales using randomSeed however I have NOT found a way for them to pick which option. I think I can do user input by typing or by them just pressing a key but I am not sure.
I am pretty new on Arduino so anything helps.

Finally I am using the Arduino Uno and that is why I am short pins because I have 1 gnd 1 speaker and the rest key inputs.


texts:
Please I'm new to Arduino and I need assistance. I'm working on a project which makes use of the ultrasonic sensor to make a certain pin high if a certain distance is attained. When I used the USB port to power it up it worked fine. When I use external power(tried two different 9V microphone battery) it's not giving desired result. Now I want to try using just the Atmega328P on the board externally(separately from the Arduino).

Questions

What could be the cause of the malfunction when I use external 9V battery
what voltage should I connect to the VCC of the Atmega cos I'm scared of damaging it.
Am I going to power the ultrasonic sensor with an entirely different source from the VCC or I can tap from that same VCC source.
Any other information I need to know using the ATmega on its own


texts: Connecting Function Generator to Arduino

texts:
I want to send a function generator's signal to an Arduino UNO Analog pin. Can I use an Oscilloscope probe connected to the function generator output BNC, set to 1x to connect to the Arduino headers using jumper wires? I did read through the manuals of the function generator, but couldn't find a solution.

The function generator available is Tenma 72-14110.


texts: Sending Arduino data to MySQL using phpMyAdmin and XAMPP using Windows10

texts:
I want to send my Arduino's sensor data to a MySQL database, using XAMPP and phpMyAdmin. I have been using an ESP8266 for the wifi connection. But I am unable to send the value. And actually I have to send four values, but for the time being I am sending only one value. So also please tell how to send multiple values. I have written the PHP file and saved in to Apache's htdocs.

#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspUdp.h>
#include <SoftwareSerial.h>
#include <PubSubClient.h>
#include <SPI.h>
IPAddress ip(192,168,8,1);
char ssid[] = "ZONG MBB-E8372-B67D"; // your network SSID (name)
char pass[] = "08522547"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
int photocellPin = 4; // Analog input pin on Arduino we connected the SIG pin from sensor
int photocellReading; // Here we will place our reading
char server[] =  "192.168.8.1";
// Initialize the Ethernet client object
WiFiEspClient espclient;
SoftwareSerial soft(2,3); // RX, TX

void setup() {
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  soft.begin(115200);
  // initialize ESP module
  WiFi.init(&soft);
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }
  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }
  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
}

void loop() {
  photocellReading = analogRead(photocellPin);
  // Fill the sensorReading with the information from sensor
  // Connect to the server (your computer or web page)
  if (espclient.connect(server, 80)) {
    espclient.println("GET /write_data7.php?"); // This
    espclient.println("value="); // This
    espclient.println(photocellReading);
    // And this is what we did in the testing section above.
    // We are making a GET request just like we would from our browser
    // but now with live data from the sensor
    espclient.println(" HTTP/1.1"); // Part of the GET request
    espclient.println("Host: 192.168.8.1");
    // IMPORTANT: If you are using XAMPP you will have
    //to find out the IP address of your computer and put it here
    // (it is explained in previous article). If you have a web page,
    // enter its address (ie.Host: "www.yourwebpage.com")
    espclient.println("Connection: close");
    // Part of the GET request telling the server
    // that we are over transmitting the message
    espclient.println(); // Empty line
    espclient.println(); // Empty line
    espclient.stop();    // Closing connection to server
  } else {
    // If Arduino can't connect to the server (your computer or web page)
    Serial.println("--> connection failed\n");
  }

  // Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.
  delay(10000);
}

Following is the PHP code:

<?php
//connecting to the database
define('DB_HOST', 'localhost');
define('DB_NAME', 'connected_car_1');
define('DB_USER','Maryam1');
define('DB_PASSWORD','telecom1213');

$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());

$sql = "INSERT INTO connected_car_1.sensor (value) VALUES ('".$_GET["value"]."')";
// Execute SQL statement
mysql_query($sql,$con);
mysql_close($con);
?>

And this is my serial monitor output:

I am very new to coding in Arduino as well as PHP and databases. So kindly tell me what I am doing wrong. And do I have to provide the IP address of the server, ie. 127.0.0.1? If yes, then where?


texts: I am not able to compile,libraries missing

texts:
this was the error  message
Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 1,068 bytes (3%) of program storage space. Maximum is 32,256 bytes.
Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.
avrdude: ser_open(): can't open device "\.\COM17": The semaphore timeout period has expired.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\leddelay: C:\Users\nehal\Documents\Arduino\libraries\leddelay
Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c: C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c
Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\leddelay: C:\Users\nehal\Documents\Arduino\libraries\leddelay
Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c: C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c

This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 What should I do?


texts: How can I measure the point of contact between two wires?

texts:
I'm not sure the best way to ask this question, so I'll try to explain what I'm looking for, and roughly what I think is involved.

I want to measure the point of contact between two wires. This seems like it could be a resistance measurement, but I wasn't sure if that was the best way to go as it seems like the amount of change would be too small to measure.

Specifically I have two wires (more likely some sort of conductive ribbon) on a glove. One wire runs along the index finger, and the other is at the tip of the thumb. When someone touches their thumb to their finger, I want a value that indicates approximately where they touched.

For example, if they touch the tip of their finger to their thumb the value would be 1. If they touched their thumb to their first knuckle, then the value would be 0.75. And so forth. With a touch between two "points" producing a value in between.

Ideally someone could slide their thumb down their finger and produce a slowly changing value from 1 to 0.

Is resistance the way to go for this? It seems like there could a lot of other variables (surface area of contract, humidity, etc) that could dramatically change the resistance. Is there a better method?

Update: Because of some overzealous votes to close and confusion, this will be using the Arduino platform (maybe an ESP32, if that matters) once I figure out what sort of sensors and systems to work with.


texts:
I want have 2 74HC595N shift registers in series.

I built this schematic

When I send a value to the first register, it is sent to the second one. I have same value on both. I change them (master/slave) but the result is the same.

I connected pin 9 on the first SR first with pin 14 on the second. I am using Johnny Five on Galileo Gen 1 with shiftRegister.send(25) to send the data.

What am I doing wrong because several days ago I made it and it worked?


texts: Is Arduino IDE enough to program with C or C++?

texts:
I am using Arduino IDE to program my ATmegas with bootloaders. I can directly manipulate ports, use timers, interrupts, PWM pins and timers, etc. Everything is working.

But this question arises: Does the Arduino IDE differ from AVR Studio in terms of using C or C++ on an ATmega chip?

I know AVR Studio has some features or something. My question is not about that. My question is that I am coding everything, not using extra libraries, features etc.


texts: Programming Pro Micro over ISP, but keep bootloader

texts: I want to program a Pro Micro over ISP from a hex file using avrdude, but I also want to have the bootloader after it is programmed so that I can program it over USB. Is this possible?


texts: Will this be possible to do before I even get started. I want to automate my house window

texts:
I will have 2 buttons.
Using Adafruit DC Motor Driver
https://www.adafruit.com/product/3190
Top button is a function, bottom button is mode.
The top button functions.
Window 1:
Single press will turn on motor 1 to open blinds until the top limit switch is pressed to signal the blinds have reach their max open and turn motor 1 off.
(In Mode) Windows 1-3:
Single press will turn on motors 1,3,5 to open blinds until each windows top limit switch is pressed to signal the blinds have reach their max to open and turn motors 1,3,5 off.
Window 1:
Double press will turn on motor 2 to raise the blinds until the top limit switch is pressed to signal the blinds can't be raised anymore.
(In Mode) Windows 1-3:
Double press will turn on motor 2,4,6 to raise the blinds until all top limit switches are pressed to signal the blinds can't be raised anymore.
Window 1:
Single press and hold will reverse motor 1 to return the blinds back to the closed position and stop motor 1 when the bottom limit switch is pressed.
Double press and hold will reverse motor 2 to lower the blinds back to the closed position and stop motor 2 when the bottom limit switch is pressed.
(In Mode) Windows 1-3:
Single press and hold will reverse motors 1,3,5 to return the blinds back to the closed position and stop motors 1,3,5 when the bottom limit switches are pressed.
Double press and hold will reverse motors 2,4,6 to lower blinds to return the blinds back to the complete closed position and turn off motors when motors 2,4,6's limit switches are pressed.
Bottom button is mode---------------------------------------------------------------------------------------------------------------------------------
Mode toggles between my middle den window and all 3 den windows and give the same controls from above to all 3 windows.
Now my most important question is.
If window 1's blinds are raised and I press mode and want all 3 window blinds to raise will the fact that limit switch on window 1 already being triggered for the blinds being raised already do nothing while windows 2 and 3 raise and vise versa?


texts:
Hello. I have begun working with an ESP8266 and an Arduino Uno. The connection I used is shown below, except I am using an Arduino Uno. The rest of the connection is the same.
The code I'm using is:
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX

void setup() {
  Serial.begin(9600);
  ESPserial.begin(9600);
  Serial.println("");
  Serial.println("Remember to to set Both NL & CR in the serial monitor.");
  Serial.println("Ready");
  Serial.println("");
}

void loop() {
  if (ESPserial.available()) {
    Serial.write( ESPserial.read() );
  }
  if (Serial.available()) {
    ESPserial.write(Serial.read());
  }
}

But the serial monitor is only printing:

Remember to to set Both NL & CR in the serial monitor.
Ready

What to do?


texts: Is it possible for ESP8266WiFi client to request the number of clients currently connected to Access Point?

texts:
My system consists of several ESP8266 based 'stations', which are synchronised in a way that all of them go into deep sleep and wake up on the same schedule. All stations are WiFi clients. All stations run on batteries and energy saving is critical.

One of the stations is a Master. It contains a modem/router that serves as AP to all stations.   The AP is switched OFF during the sleep phase. When a Master wakes up it switches on the AP and thus starts a communication session available to all stations. When all stations have their data sessions completed and disconnect from AP, the Master switches off the modem/router and goes to sleep.

My question is about the Master being informed that there are no other clients actively connected to the AP. My current solution is WAN based - each station reports to the Web Service on the start and end of their connection. Is it possible to achieve the same result locally - by a request from the WiFi client to the Access Point?


texts: ATMEL SAMD11 SPI (Slave) With Arduino (Master)

texts:
I am trying to get my Atmel SAMD11 XPLAINED PRO and arduino to talk to each other using SPI. I have set up the arduino as the master, with the SAMD11 as the slave. On the ATMEL, I have the following code:

http://asf.atmel.com/docs/latest/samd21/html/asfdoc_sam0_sercom_spi_slave_callback_use.html

Essentially, it waits until the master sends data, compares the data with what it expects, and updates an LED accordingly. On the arduino side, I have the following:

#include <SPI.h>

#define BUF_LENGTH 20
int slave_select = 10;

void setup (void)
{
  // Initialize serial for DEBUG.
  Serial.begin(9600);
  pinMode (slave_select, OUTPUT);
  digitalWrite(slave_select, HIGH);  // ensure SS stays high for now
  // Put SCK, MOSI, SS pins into output mode
  // also put SCK, MOSI into LOW state, and SS into HIGH state.
  // Then put SPI hardware into Master mode and turn SPI on
  SPI.beginTransaction (SPISettings (4000000, MSBFIRST, SPI_MODE0));  // 4 MHz clock, MSB first, mode 0
  // Master initialized.
  Serial.println("Master Initialized");
}  // end of setup

void loop (void)
{
  static uint8_t buffer_expect[BUF_LENGTH] = {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
     0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
  };
  // enable Slave Select
  digitalWrite(slave_select, LOW);    // SS is pin 10

  //write the 20 bytes
  for (int I=0;I<20;I++)
  {
    SPI.transfer(buffer_expect[I]); //write data byte
    delay(20);
  }

  // disable Slave Select
  digitalWrite(slave_select, HIGH);

  delay (1000);  // 1 seconds delay
}  // end of loop

When I run the code, the LED on the SAMD11 isn't updated, which means that it is waiting for data to be sent, and hasn't received any, despite what the arduino code writes. On the hardware side, I have GND connected on both boards, VCC on the SAM to 5V on the arduino, and SPI_SS_A, MOSI, MISO and SCK connected to pins 10,11,12 and 13 on the arduino respectively.


texts:
I am using two HG-C 1100 measurement sensor for measuring the width of the metal. In the top of the sensor I will be having the measurement value. The sensor is capable of measuring the dimensions from -35mm to 35mm.
So I am using the formula:
int First_sample = analogRead(6);
int Second_sample = analogRead(7);
float First_sensor = (map(First_sample, 1023, 0, -3500, 3500) / 100.0);
float Second_sensor = (map(Second_sample, 0, 1023, -3500, 3500) / 100.0);
Serial.print("First_sensor:");
Serial.println(First_sensor, 3);
Serial.print("Second_sensor:");
Serial.println(Second_sensor, 3);
Final_sensor = (First_sensor - Second_sensor);
Serial.println(Final_sensor, 4);

If I use this code, I will get the proper width of the metal. But when I place the metal in between the sensor, I am getting the exact width in the serial monitor. But at the top of the sensors the values are different.
I don't why the analog values are different on the serial monitor and the top of the sensors. But the output of the sensor is perfect in the serial monitor.
Can anyone help me with this?


texts: I Can't Connect to my MQTT server via arduino

texts:
I have mosquitto MQTT installed on my VPS server which I can subscribe and publish to it using paho client thorugh websockets. However when I tried to connect to it through Arduino, I get the following error:
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

I uploaded the following code to arduino:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.

const char* ssid = "IOT";
const char* password = "11112222";
const char* mqtt_server = "burooq.com";

WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

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

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is active low on the ESP-01)
  } else {
    digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
  }

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str())) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("test", "hello world");
      // ... and resubscribe
      client.subscribe("test");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  unsigned long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    ++value;
    snprintf (msg, MSG_BUFFER_SIZE, "hello world #%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish("test", msg);
  }
}

i checked my server mosquitto ports which shows
mosquitto 10436       mosquitto    4u  IPv4   46043      0t0  TCP 127.0.0.1:1883 (LISTEN)

I checked my conf file and it has
listener 1883 localhost

so how what's wrong within my code or settings that prevents me from connecting to my server?`


texts: L298N beeps and malfunctions when receiving certain analogWrite values

texts:
I created a simple circuit with an UNO, L298N and a single motor.
Wrote the following code to test controlling the speed of the motor.
Tested motor with digitalWrite() function and it works fine.
Tested motor with analogWrite() function and from 255 down to around 70 motor works at various speeds.

Q: But from around 70 and below, the L298N starts to beep and the motor stop spinning. Any thoughts?

int enr = 9;
int inr1 = 8;
int inr2 = 7;

void setup() {
 pinMode(enr, OUTPUT);
 pinMode(inr1, OUTPUT);
 pinMode(inr2, OUTPUT);
}

void loop() {
  analogWrite(enr, 71);
  digitalWrite(inr1, HIGH);
  digitalWrite(inr2, LOW);
}


texts:
I'm trying to create a function that will take a String as an input, and at every 20 characters, it will instert "\n" so that the string doesn't go off the side of my screen (I'm using an oled with the SSD1306Ascii library).
This is my code so far, but when I run it nothing appears on the screen (I have another part of the code which passes the string to the funtion):
String message = "";
String newMessage = "";

void printMessage(String message) {
  oled.clear();
  if(message.length() > 20) {
    current = 20;
    while(current < message.length()) {
      newMessage = message.substring(current-20, current) + "\n";
      newMessage = newMessage + message.substring(current+1);
      current+20;
    }
    oled.println(newMessage);
  }
  else {
    oled.println(message);
  }
}


texts: Simplifying code, getting invalid conversion from 'const char*' to 'char*'

texts:
I have a program that does 4 times the same thing with different parapmeters; and was trying to simplify my code to take one parameter as a variable.

Example (what was):

const char MQTT_PUB_IRRIGATION_TANK_VALVE[]      = "ArgyleCourt/Property/Hub/IrrigationTank/Valve";
const char MQTT_PUB_HOUSE_BOREWATER_TANK_VALVE[] = "ArgyleCourt/Property/Hub/HouseBoreWaterTank/Valve";

publishTankValveStatusIrrigation(false);

void publishTankValveStatusIrrigation(bool demandStatus) {
  if (demandStatus) {
    mqttClient.publish(MQTT_PUB_IRRIGATION_TANK_VALVE, "ON");
  } else {
    mqttClient.publish(MQTT_PUB_IRRIGATION_TANK_VALVE, "OFF");
  }
}

publishTankValveStatusHouse(false);

void publishTankValveStatusHouse(bool demandStatus) {
  if (demandStatus) {
    mqttClient.publish(MQTT_PUB_HOUSE_BOREWATER_TANK_VALVE, "ON");
  } else {
    mqttClient.publish(MQTT_PUB_HOUSE_BOREWATER_TANK_VALVE, "OFF");
  }
}

to one function now passing the topic also inot the function, thus needing only one function:

publishTankValveStatus(false, MQTT_PUB_IRRIGATION_TANK_VALVE);
publishTankValveStatus(false, MQTT_PUB_HOUSE_BOREWATER_TANK_VALVE);

void publishTankValveStatus(bool demandStatus, char topicToPublishTo) {
  if (demandStatus) {
    mqttClient.publish(topicToPublishTo, "ON");
  } else {
    mqttClient.publish(topicToPublishTo, "OFF");
  }
}

when I compile the simplified function, I get "warning: invalid conversion from 'const char*' to 'char' [-fpermissive]", but do neither understand why or how to fix it.


texts: How can I adjust my code so that the value that I print with my BLE device does not get chopped up when I receive it on an app?

texts:
I am using a BLE device (https://www.adafruit.com/product/1697) that I use to print data to an app. I can successfully connect the BLE to the app and receive the data but the result however gets chopped up.

What I am sending is a lat, lng value (that I gather with a library called TinyGPS++ http://arduiniana.org/libraries/tinygpsplus/) and the code looks like this:

BTLEserial.Print::print(gps.location.lat(), 8);
BTLEserial.print (", ");
BTLEserial.Print::print(gps.location.lng(), 8);

So for example if the latitude is: 32.12345678, it comes like this to the app: 3, new row, 2, new row etc.

So my question is, how can I adjust my code to make sure it does not send the result chopped up but instead sends it's complete value?


texts: Comparing orientation data obtained using gyroscope and accelerometer

texts:
Recently, I have been playing around with a gyroscope and accelerometer in the hopes of building a quadcopter. I have plotted some of the data the two sensors and I am noticing that the pitch from the accelerator lags significantly behind the gyroscopic pitch.

From some research, I understand that these two are not going to equivalent values due to the mechanisms of measurement, however is it common to have such large discrepancies (i.e a difference of 20 degrees or higher) between the two sensors or is this an issue with my conversion?

I have listed the graph and source code here. Any help would be appreciated!

Sincerely,
Anand


texts: In tutorial - https://www.arduino.cc/en/Main/Standalone , they have used voltage regulator. Can we able to do without Voltage regulator ?(to compact the circuit), If so what should the voltage & current value in Atmega328?


texts:
I am trying to convert byte* value to int here is how I have it.

void mqttCallback(char* topic, byte* payload, unsigned int length) {

  String topicStr = topic;
  int* payload_value;
  int updates_cal;

    payload_value = (int*)payload;
    //updates_cal = *payload_value;

    Serial.print((int)payload_value);

  delay(1);

  Serial.println();
  Serial.println("-----------------------");

}

I am getting MQTT payload as Integer value. Which I want to receive in my NodeMCU (ESP8266).

Is there any way to do this?

Thank you!


texts: Arduino to check if digital connected to analog

texts:
Is it possible to check if a Analog pin is touching a digital?
I have an Arduino Uno, and I want to have a small matrix, A0 A1 A2 A3 (all have rows of 6 buttons)
All the 6 buttons are connected to the digital pins
This is how I want it to work

Digital (1,2,3,4,5,6)
(A0)1,2,3,4,5,6
(A1)1,2,3,4,5,6
(A2)1,2,3,4,5,6
(A3)1,2,3,4,5,6

I've tried writing code but for each key pressed it gives the same value for each row i.e it's not detecting different sections.


texts: Fading from color to color using for-loop FastLEDs

texts:
I'm attempting to fade a strip of ws2812 7 pixels in length. Below I am using a for loop to increment the color red. I can fade it to red (from blue) but it will do it one pixel at a time or it just stays blue, depending where I move my r for-loop to. I need it to fade from color to color all 7 LEDs at once.

I get no errors.

I don't understand the process of getting NUM_LEDS leds all into x then proceeding with my color changing. Seems like I'm grabbing one pixel, fading it to red, then another...

fastLeds 3.03 library, arduino 1.0.6

#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 7

#define BRIGHTNESS 45
#define COLOR_ORDER GRB
#define g 50
#define b 100
int r;
CRGB leds[NUM_LEDS];

void setup(){
  FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
}

void loop(){
  for(int x = 0; x < NUM_LEDS; x++){
    delay(10);
    leds[x] = CRGB(r,g,b);
  }
  FastLED.show();
  delay(10);

  //-------------------------

  for(int x = 0; x < NUM_LEDS; x++){
    for(int r = 0; r < 254; r++) {

if NUM_LEDS is holding the number 7 why can't I just do it like this below: leds[NUM_LEDS]?

      leds[x] = CRGB(r,g,b);
      FastLED.show();
      delay(100);
    }
  }
}


texts: Is there any working analogue to the pair std::function and std::bind in Arduino?

texts:
Both ArduinoSTL and StandardCplusplus don't support them. They implement the version that is compatible with c++03 (not c++11).

This functionality is handy when you design libraries that work with callbacks. And you do need them, if your Arduino does more than one thing simultaneously.

I tried also several other options, but none was enough. Most complete thing I found, Passing capturing lambda as function pointer, does not support plain function pointers and does not allow me to hold the function object as a member of the structure, because the type of the object depends on the lambda (not only its signature, like in std::function).

In particular, I need a functor that

can store both capturing lambdas and plain function wrappers
has a type that depends only on the signature of the function, so I can store it as a class member.


texts: So I have 3 ground pins, but I need 4 motors on my Arduino. Can I connect multiple motors to the same ground pin?


texts: analogRead() inside a loop always returns 0

texts:
I wrote Arduino code to receive analog input from different voltage dividers connected to four pins (A0 to A4) and analog input from a temperature sensor (LM35) to A5. analogRead inside the for loop always returns zero whereas analogRead outside the for loop returns correct values.

What has to be changed to get correct values?

int time=0,y=0;
float volt;
String str;
int countParallel=0;
float voltage[]={0,0,0,0};
float temperature=0;
int sensors_pin[]={A1,A2,A3,A4,A5};
String x="";

// the setup rouontine runs once when you press reset;
void setup() {
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  Serial.begin(9600);
  Serial.setTimeout(50);
}

// the loop routine runs over and over again forever;
void loop() {
  Serial.println(analogRead(A5)*500/1023);
  delay(1000);
  while (Serial.available() > 0) {
    int inChar = Serial.read();
    if (isDigit(inChar)) {
      x += (char)inChar;
    }
  }
  // Parallel Disharging
  //  Serial.println(x);
  if(x.toInt()==1) {
    digitalWrite(13,HIGH);
    if(countParallel<1) {
      digitalWrite(6, HIGH);
      digitalWrite(7, HIGH);
      countParallel++;
    }
   for(int i=1,x=14;i<=5;i++,x++) {
    if(i<4) {
      Serial.println(analogRead(x)*(5/1023));
      delay(100);
    } else if(i==5) {
      Serial.println(analogRead(x) * p(500/1023));
      delay(100);
    }
    if(volt<2.8){
     digitalWrite(i+1,HIGH);
   } else if(temperature>40) {
     digitalWrite(2,HIGH);
     digitalWrite(3,HIGH);
     digitalWrite(4,HIGH);
     digitalWrite(5,HIGH);
    }
  }
}

// Series Discharge
if(x.toInt()==2){
    for(int i=A0;i<=A4;i++){
      if(i<A4) {
        voltage[i] = analogRead(sensors_pin[i]) * (5/1023);
        Serial.println(10);
        delay(100);
      } else if(i==A4) {
        temperature = analogRead(sensors_pin[i])*(500/1023);
        Serial.println(9);
        delay(100);
      }
      if(volt<2.8) {
        digitalWrite(i, HIGH);
        delay(100);
      } else if(temperature>40) {
        digitalWrite(2,HIGH);
        digitalWrite(3,HIGH);
        digitalWrite(4,HIGH);
        digitalWrite(5,HIGH);
      }
     }
  }
}


texts: What does serial monitor send with 'Both NL & CR'

texts:
There is something I don't understand about serial monitor.

As far as I know the Newline option is \n.

The Carriage return option is \r\n.

But does that make the Both NL & CR option \n\r\n?


texts: Arduino MKR1000 and DHT11 not giving correct output for temperature and humidity

texts:
I've been trying to follow this tutorial to wire my Arduino MKR1000 to a DHT11 temperature and humidity sensor, but my output consists of either 0's or 255's for both values. I've tried several different arrangements of wires, but none seem to work. Here's my current setup:

And here's my code:

// Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN A0     // what digital pin we're connected to; MAY BE PROBLEM

// Uncomment whatever type you're using!
#define DHTTYPE DHT11
//#define DHTTYPE DHT22
//#define DHTTYPE DHT21

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs. DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(9600);
    Serial.println("DHTxx test!");

    dht.begin();
}

void loop() {
    // Wait a few seconds between measurements.
    delay(2000);

    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    float h = dht.readHumidity();
    // Read temperature as Celsius (the default)
    float t = dht.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)
    float f = dht.readTemperature(true);

    // Check if any reads failed and exit early (to try again).
    if (isnan(h) || isnan(t) || isnan(f)) {
        Serial.println("Failed to read from DHT sensor!");
        return;
    }

    // Compute heat index in Fahrenheit (the default)
    float hif = dht.computeHeatIndex(f, h);
    // Compute heat index in Celsius (isFahreheit = false)
    float hic = dht.computeHeatIndex(t, h, false);

    Serial.print("Humidity: ");   Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.print(" *C ");
    Serial.print(f);
    Serial.print(" *F\t");
    Serial.print("Heat index: ");
    Serial.print(hic);
    Serial.print(" *C ");
    Serial.print(hif);
    Serial.println(" *F");
}

And here's the diagram of an Arduino MKR1000:

This is my first time using a micro controller, so any help is much appreciated.

UPDATE: Here's my setup with 2 10k resistors in parallel added:


texts: problems with Blue Pill (stm32f103c8t6) direct register manipulation

texts:
I'm trying to access registers but I keep getting the "was not declared in this scope" error message.
I'm currently using the STM32F1xx boards from http://dan.drown.org/stm32duino/package_STM32duino_index.json
The board package does not seam to recognize any of the registers from the reference manual, mostly trying to access the ADC registers such as 'ADC_CR2'. Does anyone know where I can find the register names which works in the Arduino IDE?


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

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


texts: Can I safely connect my A6 GPRS module to this 5V 2A phone adapter

texts:
I have an A6 GPRS module, and my Samsung phone power adapter has output of 5V and 2A. But it also says 9V and 1.6A

My Phone's Adapter
So would it damage my A6 GPRS Module if I plug this to it via the micro usb power port? (especially because it also says 9V)?

My A6 GPRS module


texts:
Arduino Uno

I'm currently working on a project which will involve entering a sequence on a 12V keypad. The keypad and its documentation can be found here: https://www.jaycar.com.au/digital-keypad-with-rfid-access-control/p/LA5353

They keypad wants 9-18V AC/12~24V DC. I'll be using the keypad to output 26 bit Wiegand to the Arduino. I'm just wondering the best way to power this system. The schematics included with the keypad show that the keypad and the controller  (Arduino) should be sharing a power source. See image attached.

How can I power the 12-24V keypad through the arduino without frying it?


texts:
So I wondered what the difference between the nano and the nano every is and why the nano every is so much cheaper than the nano.

I'm new to the microcontroller business and I would like to know what would be better for what situation.


texts:
I want to light an LED in a sketch and then have it fade out.
I tried to use analogWrite and have it decrease from a value of 255 to 0 using a for() loop, but I can't seem to get it to work.
Using digitalWrite I can turn it on and off but cant get it to fade out.
Can anyone help please.

const int ledPin1 = 2;
const int ledPin2 = 3;
const int ledPin3 = 9;
int j = 0;

void setup() {
    pinMode(ledPin1, OUTPUT);
    pinMode(ledPin2, OUTPUT);
    pinMode(ledPin3, OUTPUT);
}

void loop() {
    j = 255;
    delay(1000);
    if (j >= 5);
    {
        analogWrite(ledPin3,j);
        delay(10);
        j = j - 5;
    }
    delay(1000);
}


texts:
Here is the schematic I followed:

Here also the link: https://www.circuito.io/app?components=10167,11021,12083,13678,13959

#include "DHT.h"
#include "NewPing.h"
#include <SoftwareSerial.h>
#define DEBUG true

SoftwareSerial esp8266(11,10);

#define DHTPIN 2       // DHT-11 Output Pin connection
#define DHTTYPE DHT11   // DHT Type is DHT 11 (AM2302)
#define TRIGGER_PIN 4
#define ECHO_PIN 3
#define MAX_DISTANCE 400

NewPing sonar(TRIGGER_PIN,ECHO_PIN,MAX_DISTANCE);

float hum;
float temp;

DHT dht(DHTPIN, DHTTYPE);

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

  pinMode(TRIGGER_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);

  sendData("AT+RST\r\n",2000,DEBUG);
  sendData("AT+CWMODE=2\r\n",1000,DEBUG);
  sendData("AT+CIFSR\r\n",1000,DEBUG);
  sendData("AT+CIPMUX=1\r\n",1000,DEBUG);
  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG);
}

void loop()
{
  delay(2000);  // Delay so DHT-11 sensor can stabalize

  hum = dht.readHumidity();  // Get Humidity value
  temp= dht.readTemperature();  // Get Temperature value

  digitalWrite(TRIGGER_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIGGER_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGER_PIN, LOW);

  long duration,distance;
  duration = pulseIn(ECHO_PIN,HIGH);

  distance = duration/58.2;

  Serial.print("Humid: ");
  Serial.print(hum);
  Serial.print(" %, Temp: ");
  Serial.print(temp);
  Serial.print(" C, ");
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(50);

  if(esp8266.available())
  is sending a message
  {
    if(esp8266.find("+IPD,"))
    {
      delay(1000);
      int connectionId = esp8266.read()-48;
      /* We are subtracting 48 from the
         output because the read() function returns
         the ASCII decimal value and the
         first decimal number which is 0 starts at 48 */
      String webpage = "
IOT Garbage Monitoring System
";
      webpage += "

";
      if (distance<5)
      {
        webpage+= " Trash can is Full";
      }
      else{
        webpage+= " Trash can is Empty";
      }
      webpage += "

";
      String cipSend = "AT+CIPSEND=";
      cipSend += connectionId;
      cipSend += ",";
      cipSend +=webpage.length();
      cipSend +="\r\n";

      sendData(cipSend,1000,DEBUG);
      sendData(webpage,1000,DEBUG);
      String closeCommand = "AT+CIPCLOSE=";
      closeCommand+=connectionId;
      closeCommand+="\r\n";
      sendData(closeCommand,3000,DEBUG);
    }
  }
}

String sendData(String command, const int timeout, boolean debug)
{
  String response = "";
  esp8266.print(command);
  long int time = millis();
  while( (time+timeout) > millis())
  {
    while(esp8266.available())
    {
      char c = esp8266.read();
      response+=c;
    }
  }
  if(debug)
  {
    Serial.print(response);
  }
  return response;
}

I've been trying to solve this problem for almost a week.


texts: Is it common that Uno clones misbehave when connected to 12v on VIN?

texts:
Edit: this was completely my mistake. See end.

My official Uno worked fine when powered by 12v on VIN, but my Uno clone acted really funny--it read random noise from an input when a simple wire was attached, but not with no wire. It was solved with a pulldown resistor. The worse problem was that the PWM didn't turn off when I called analogWrite(pin, 0). More worrying, it seemed to be outputting by power rather than duty cycle, since my small LED strip seemed to be doing higher duty than my big LED strip (both powered by transistors), though both were being set with analogWrite(pin, 0). I measured the 5v pin at 5.9v. The input voltage may have actually been up to 12.5 v, but clean. I disconnected VIN and hooked back up to USB, and everything worked fine.

I assume the solution is to either use a linear regulator wired to VIN, or a battery?

I did get the linear regulator, which didn't help. I finally checked all my voltages, and found there was a 0.8 volt difference between different grounds!  It turned out my breadboard was wired to the Arduino pin next to ground, instead of ground itself. I feel very lucky not to have ruined the board, and my only complaint is that the pins aren't labeled clearly as they are on my official Arduino. On the other hand, I wouldn't have been able to debug this as easily on the official Arduino, since the clone has lovely solder holes at each pin which are a great spot to stick a voltmeter probe.


texts:
My arduino is meisuring the tempature and gives values like: 28.58 Degrees Celcius. I would like to round this up to one decimal. I could make the variable one shorter by cutting the "8" off which would desplay 28.5.
Yet this feels a bit like cheating as it mathimatical not correct. Does anyone know how to round up/down. Which would show my tempature as 28.6.

Extra advice needed. I am sending the tempature by Serial to my RPi which has a python code running. Would you suggest doing the rounding in the Arduino code or in The Python code.

Thanks in Advance!


texts: Arduino sketch- How to add Time Stamp for outgoing MQTT

texts:
I'm writing a sketch in order to upload to a Sonoff device ( Remote relay, based ESP8266 ).

All is working great, but I wish my MQTT pubs to contain following format:

[ DATE & TIME ] msg

ESP8266 is connected to the internet.
I;m looking for a way doing it (including periodic time updates ) without running all 1MB memory, meaning: a code that
1) get time from external source (LAN or WAN )
2) update it every 24h
3) Lite code ?

Thanks


texts:
I'm programming an arduino uno with attached screen to be a clock and have the code below. It counts up from zero the milliseconds, seconds, minutes and hours and when it hits 24 hours it starts again from zero.
Does anyone know how I can set the start time that it automatically starts at when it is reset? It will be a one off thing and I don't want it to interfere with the clock resetting to 0 hours after it hits 24. Thanks

#include <Wire.h>
#include <LiquidCrystal.h>

#define MILLIS_OVERFLOW 34359738

/**
 * Clock Variables
 */
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
    lcd.begin( 16, 2 );

}

void loop()
{
    setClock();
    /**
     * After set clock now you have 3 int variables with the current time
     */
     //seconds
     //minutes
     //hours
     lcd.setCursor ( 0, 1);
     lcd.print(hours);
     lcd.print(":");
     lcd.print(minutes);
     lcd.print(":");
     lcd.print(seconds);
     lcd.print(":");
     lcd.print(elapsedMillis);

}

void setClock()
{
    currentMillis = millis();
    /**
     * The only moment when currentMillis will be smaller than previousMillis
 * will be when millis() oveflows
 */
if (currentMillis < previousMillis){
    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;
} else {
    elapsedMillis += currentMillis - previousMillis;
}

/**
 * If we use equals 1000 its possible that because of the mentioned loop limitation
 * you check the difference when its value is (999) and on the next loop its value is (1001)
 */
if (elapsedMillis > 999){
    seconds++;
    elapsedMillis = elapsedMillis - 1000;
}

if (seconds == 60){
    minutes++;
    seconds = 0;
}
if (minutes == 60){
    hours++;
    minutes = 0;
}
if (hours == 24){
    hours = 0;
}

previousMillis = currentMillis;
}


texts: Value of uninitialized EEPROM in ESP8266?

texts:
In my limited testing it appears that the EEPROM in the Wemos D1 is not initialized to 255 like the specs say is the case for AtMega based Arduinos. In fact, the values look to be more-or-less random. Presumably this is because the ESP8266 doesn't actually contain EEPROM, but instead emulates it using flash. Is there a way to initialize the EEPROM region when flashing?

(This is pretty much the same question as here, which has not been answered.) Since I need only a few bytes of data, I'd prefer not to have to use the SPIFS.

Update:

Use case: I'm using the WiFiManager library to select the network to connect a Wemos D1 mini to the web to upload data to Thingspeak. I'd like to use WiFiManager to request the api-key and channel id from the user. However, once the user has entered these, I'd prefer not to make them enter the values again. (The api key is 16 random looking chars and difficult to enter correctly.) This means that the device has to store the values persistently between boots - the main use case for EEPROM. But how do you tell that the values in EEPROM (actually flash on an ESP device) are uninitialized crap, not the previous value? As suggested in the comments, setting flag values in a number of vars make it statistically unlikely to the random values from uninitialized memory. On an AtMega device, unless previously used, the values will be 255 in each byte.


texts: Arduino MPU6050 AD0 Tricks with offset setting gives corrupted data

texts:
I am currently experimenting with two MPU6050 which the AD0 is connected via PIN 7 and PIN 8 respectively, and if this is working, I plan to add another 2 more MPU6050 to it.
I am using i2cdevlib's MPU6050 library and what I did in a flow is:

Initialize one MPU6050 object
Set MPU6050 Object as 0x68 (LOW AD0)
Set all to HIGH, but one to LOW (to select the MPU6050)
Calculate offset and calibrate, store everything in array. (offsets and etc)
Repeat steps 3 to 4 unless all are calibrated.
Start to loop between two MPU, setting everything to HIGH and the one to be used as low.
Write the LOW's (current selected) MPU with offset that is stored in array, then getMotion6 (Raw data).
Write selected MPU to high, repeat from step 6 to step 7.

Everything is working, however when I am having a loop to collect data, it gives me corrupted data, the problem I find is in this function
void loop{
    for (int i = 7; i <= 8; i++) {
      pinMode(i, OUTPUT);

      digitalWrite( i, LOW);
      //      Serial.print("\nWriting pin: ");
      //      Serial.print(i);
      //      Serial.println(" to LOW");
      delay(2);
      int index = i - 7;
      Serial.print("Offsets:\t");
      Serial.print(ax_offset[index]);
      Serial.print("\t");
      Serial.print(ay_offset[index]);
      Serial.print("\t");
      Serial.print(az_offset[index]);
      Serial.print("\t");
      Serial.print(gx_offset[index]);
      Serial.print("\t");
      Serial.print(gy_offset[index]);
      Serial.print("\t");
      Serial.println(gz_offset[index]);

      accelgyro.setXAccelOffset(ax_offset[index]);
      accelgyro.setYAccelOffset(ay_offset[index]);
      accelgyro.setZAccelOffset(az_offset[index]);
      accelgyro.setXGyroOffset(gx_offset[index]);
      accelgyro.setYGyroOffset(gy_offset[index]);
      accelgyro.setZGyroOffset(gz_offset[index]);

      Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t");
      Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t");
      Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t");
      Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t");
      Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t");
      Serial.print(accelgyro.getZGyroOffset()); Serial.println("\t");

      //      delay(1000);
      //      accelgyro.getMotion6(&ax[index], &ay[index], &az[index], &gx[index], &gy[index], &gz[index]);
      int ax, ay, az, gx, gy, gz;
      accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

      Serial.print("PIN ");
      Serial.print(i);
      Serial.print("'s data is:");
      Serial.print("aX:" ); Serial.print(ax); Serial.print("\t");
      Serial.print("aY:" ); Serial.print(ay); Serial.print("\t");
      Serial.print("aZ:" ); Serial.print(az); Serial.print("\t");

      Serial.print("gX:" ); Serial.print(gx); Serial.print("\t");
      Serial.print("gY:" ); Serial.print(gy); Serial.print("\t");
      Serial.print("gZ:" ); Serial.println(gz);

      pinMode(i, INPUT_PULLUP);
    }
}

The first few loops will return accurate data (as in, all the sensors are close 0 [no motion])
I am suspecting because there is a huge difference between both sensors and the getMotion6 is comparing with the old sensor, can that be the case?
Attached is the output of my sensors reading, untouched.


texts:
When I upload this code LED at pin 13 goes HIGH and that's it. My goal is to make it blink in the order specified in the array. What am I doing wrong?

int Array[] = {1,1,1,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0};
int Data = 13;
int i = 0;

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

void loop() {
    int x = Array[i];
    delay(200);
    digitalWrite(Data, x);
    i = i+1;
    if (i==23) {
        i=0;
    }
}


texts: Schematic for the adafruit motor shield v2.3

texts:
I am trying to locate a schematic for the Adafruit motor shield v2.3. It has many ports and currently I have found little to no explanation of what is on the board. I located this picture which highlights the motor ports, servo ports, and Arduino Pins. But what about everything else?

What are the pin holes above and below the Arduino pins? Are they secondary positions for the pins? What is the PWMs 0,1,14,15? How is the big empty board in the center setup?


texts:
I am currently working on a project that involves steering wheels, and I would like a way for Arduino to wait for a change in value. A potentiometer is used and I would like a program to run (say, like lights blinking ) until there is a change in value of the potentiometer ( like an increase in 300).

Thanks in advance.

EDIT
I realized that I did not give enough information about what I want, so here is the actual task I am trying to achieve :

The lights goes on when :

Button is pressed

The lights goes off when :

The button is pressed again

or

Another button is pressed

or

Potentiometer increases or (only one of it) decreases by 300

Plus I didn't mention that the value of the potentiometer will be constantly changing so the old value for the potentiometer should be the one right after the button press.

Soooo sorry for the inconvenience caused. ( I am really bad at programming)


texts:
I am currently designing a hexapod with a total of 18 servos. I come from a computer science background and know little about electronics, so there is one thing which puzzles me.
Adafruit is selling this servo shield. It can power up to 16 servos while only using two pins. But it's quite expensive as it would cost me ~30€. Add the cost of an Arduino Uno and you are at >50€. At the same time I could just buy an Arduino Mega and power all Servos for a lower price.

I like to think that Adafruit wouldn't sell a uselessly overpriced product, so would there be any advantage to using this shield?

Bonus question: If I'd end up buying the shield, could I just power 16 Servos with the shield and 2 via the Arduino? Would there be any problems with that? Like a delay in the 16 motors or similar issues which could through my kinematics over bord? Would I have to buy two shields (which is not really an option at that price)? Any other suggestions I have not heard of are also very welcome!

If it is of any relevance, I am planning to buy these servos as they are pretty strong and come super cheap in bulk.


texts: How to connect a 5V submersible motor to Node MCU?

texts:
I connected the D1,D2 pins of the the Node MCU to the positive and negative of a 5V submersible motor. I wrote the following code, its getting uploaded without any errors but the motor is not working. I tested the condition of the motor by connecting to a battery,it does work.the code:

void setup() {
  // put your setup code here, to run once:
    pinMode(D1,OUTPUT);
pinMode(D2,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(D1,HIGH);
digitalWrite(D2,HIGH);
}


texts: How to build image with ultrasound sensors HC-SR04

texts:
There is a simple algorithm on Wikipedia: how to build ultrasound image. And I want to build one. Resolution and presision are of no importance, I just want to do this for the case of study - I want to make such an "image 1D+depth slice" of a 20m^2 room. So I may just use these low frequency sensors - 1cm is enough.

So, as stated in the article, I need a phased array (to direct wave). And accidentally I have a couple of Arduino sensors HC-SR04:

Everyone uses them, but I stumbled how to use them. Interface seems to be totally weird, insuffient and unusable. Despite there are (visually) so many logic ICs soldered on the back.. So why is it designed so poorly and how to fix that?

Could you help me - where and what would you solder/desolder to use it for ultrasound imaging? I think that sensors itself could suit for this task.

PS. Basically I need to measure echoes delay (for depth) and echoes streight (for pixel brightness)

It should work on the phased array principles, without rotating, moving, without using any motors. Desired radiation pattern is illustrated by following animations:


texts: Serial communIcation from OS X app to Arduino Mega

texts:
I am new to stack overflow. I have a question regarding using the USB serial communication sending data from an OS X app to the Arduino Mega 2560.

What happens is, when I have the Arduino running with the Serial monitor open, then I run the OS X app to send data, the Arduino does receive the data for a few seconds, then it stops.

This is the simplified Object-C code on the Mac side:

-(IBAction)sendData:(id)sender{
    NSString *toSend=[NSString stringWithFormat:@"echo %f > /dev/tty.usbmodem1a1341" ,vector.x];
    //vector is the continuous data generated by the Mac
    const char *toCSend =[toSend UTF8String];
    //converting to c string
    printf("%s", toCSend);
    popen(toCSend, "r");
}

This is the code on the Arduino side:

// Read Serial input:
void setup() {
  // Open Serial commurial1.beginnications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    // wait for Serial port to connect. Needed for Leonardo only
  }
}

void loop() {
  // Read Serial input:
  while (Serial.available() > 0) {
    int inChar = Serial.read();
    if (inChar != '\n') {
      inString += (char)inChar;
      Serial.read();
    } else {
      // if you get a newline, print the string,
      // then the string's value as a float:
      Serial.println(inString.toFloat(), 6);
      // clear the string for new input:
      inString = "";
    }//end of if else
  }//end of while (Serial.available() > 0)
}

I am not sure what the problem, could it be the OS X app send out too much data to quickly? Or could it be the Arduino serial buffer is overflowed?

I really don't know much about serial communication so I don't know what I am missing. Any help will be greatly appreciated.


texts: How do I add or subtract to a pre-determined value without having it default back to the original value?

texts:
Typical apologies in advance, it's been quite some time since I've tinkered with Arduinos. Using an Arduino Micro Clone (Pro Micro), TF02 LiDAR, and a Adafruit 1.2" 7-segment display, I've been working on a rangefinder that is able to be adjusted up/down by increments of 1. I've hit a wall though. I am unable to adjust the distance value without it returning to the original value. Say the distance is at 6'2". When I push the "up" button, the value is 6'3" but then returns to 6'2". Same applies for the "down" button. Also, when the distance is at, for example, 1'0", and I press the down button, instead of going to 0'11", it displays 0'99". I'm at a wall in terms of what I can do to resolve this.  Any help is appreciated!
*
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_7segment matrix = Adafruit_7segment(); //d pin 2, c pin 3
#include <SoftwareSerial.h>// soft serial port
#include <Wire.h>

//button stuff
int Up_buttonState = 0;
int Dn_buttonState = 0;
int Up_lastButtonState = 0;
int Dn_lastButtonState = 0;
const int  UpPin = 7;
const int  DnPin = 8;

//LiDAR stuff
int dist;// LiDAR actually measured distance value
int strength;// LiDAR signal strength
int check;// check numerical value storage
int i;
int uart[9];// store data measured by LiDAR
const int HEADER=0x59;// data package frame header
long inches, INCH, feet, ftin;

SoftwareSerial mySerial(9,10); //rx tx,

void setup()
{
pinMode(UpPin, INPUT);
pinMode(DnPin, INPUT);
 Serial.begin(9600);

 mySerial.begin(115200);//set the Baud rate of LiDAR and Arduino serial port
  #ifndef __AVR_ATtiny85__

  #endif
  matrix.begin(0x70);
}
void loop()
{

 if (mySerial.available())//check whether the serial port has data input
 {
    if(mySerial.read()==HEADER)// determine data package frame header 0x59
    {

      uart[0]=HEADER;

      if(mySerial.read()==HEADER)//determine data package frame header 0x59
      {
       uart[1]=HEADER;

      for(i=2;i<9;i++)// store data to array
         {
          uart[i]=mySerial.read();
         }
           check=uart[0]+uart[1]+uart[2]+uart[3]+uart[4]+uart[5]+uart[6]+uart[7];
           if(uart[8]==(check&0xff))// check the received data as per protocols //if data received

             { //start equations
               dist=uart[2]+uart[3]*256;// calculate distance value

               //equations for converting mm to ft,in
               inches = (dist * .3937);
               INCH = inches% 12;
               feet = (dist / 2.54) / 12;
               ftin = feet*100 + INCH;

               Up_buttonState = digitalRead(UpPin); // add 1 to ftin
                if (Up_buttonState != Up_lastButtonState)
                {
                  if (Up_buttonState == HIGH)
                  {
                    ftin++;
                  }
                  delay(500);
                }
                Up_lastButtonState = Up_buttonState;

               Dn_buttonState = digitalRead(DnPin); // subtract 1 from ftin
                if (Dn_buttonState != Dn_lastButtonState)
                {
                  if (Dn_buttonState == HIGH)
                  {
                    ftin--;
                  }
                  delay(500);
                }
                Dn_lastButtonState = Dn_buttonState;

               Serial.print(ftin);
               matrix.print( ftin , DEC );
               matrix.writeDisplay();

             }
      }
    }
 }

}


texts: Analog input voltage rises when motor is working

texts:
I'm making automatic water plant system. I'm using:
Arduino Uno
3.3-6V water pump -https://www.amazon.com/Vipe-Micro-Submersible-Motor-Water/dp/B01N0X3CW4
Capacitive soil moisture sensor - https://www.amazon.com/Gikfun-Capacitive-Corrosion-Resistant-Detection/dp/B07H3P1NRM
I've noticed that when motor turns on sensor readings are much higher. First I thought that the problem is in sensor, but when I measured sensor output in both cases (when motor is on and when motor is off) there was no difference, voltage was the same. Then I measured voltage in analog pin A0 that I used, and I saw there is increase in voltage when pump is on (+0.4V), so my guess is that this voltage is added to  sensor output voltage which is giving me higher values in my serial monitor.
For powering my pump I'm using same circuit as in this example:
https://www.devacron.com/arduino-tip120-control-dc-motor/
Just except potentiometer there is my sensor, powered via 3.3V Arduino pin (its GND is connected to Arduino GND). I also tried connecting all grounds together in one point, didn't help. I powered Arduino with usb and with 9V supply, in both cases same problem. Tried powering pump and Arduino with same and with different power supplies, no luck either.
I should also add that there is no change in AREF and 5V pin when pump is working. 4.97V in both cases.
Does anyone have any idea what can be the problem and how to solve it?
Here is how I wired everything:
https://imgur.com/a/I70lRVZ
I also tried with 0.1uF ceramic and 10nF electrolytic capacitors. as suggested, wiring it like this: https://imgur.com/a/jWfkbJG
Didn't make much difference, problem is still there.


texts: If the code used for Arduino can be embedded into a permanent , callable memory, is there a way to create an OS for Arduino that runs on call?

texts:
This thought came into my mind on thinking about smartwatches.
Although those I saw on YouTube are really good, they don't seem to provide a real experience of a real smartwatch - one that has an OS embedded in it. If some code in Arduino C/c++ can be compiled into some binary code that works on being called from the flash memory (where the main program resides), is there a possibility that we will be able to make an OS for Arduino ?


texts: How to get the angle from vertical window blinds

texts:
How can i know the angle of the vertical window blind by placing a small sensor on one of the blind slat

i am trying to make a arduino/esp8266 controlled window blinds, the controlling can be easily achieved in horizontal blinds, but my apartment has a vertical blind which are not interconnected at the bottom

Tried so far:

open and close based on time which it takes to open and close, but it keeps drifting over time
Cannot use light sensor to sense the ambient light, does not give correct information (day and night)
Tried to put a potentiometer on top of one of the blind slat ( no enough room to place things there, potentiometers have more friction)

any suggestions for angle sensor ?