texts: Motor driver not able to drive motor in reverse direction

texts:
In my recent project, I'm using DC motor driver 24V 20A[RKI-1340].

Motor Driver

After reading the manual of this I figure out information for this motor driver.
Basically, this motor driver has 5 pins. Each has own functionality.

  (1) 5V : Regulated 5V output from motor driver board (maximum 50mA
  supply)

  (2) BRK : Breaking input to halt the motor in operations when 5V
  (logic high)

  (3) PWM : Pulse Widht Modulation input to control speed of motor
  (recommended freq 20Hz to 400Hz)

  (4) DIR : Pulled down to GND Forward by default and Backward when 5V
  (logic high)

  (5) GND : Connect to GND on controlling board

Now, I connect this motor driver to my Arduino. My connection is like below:

  Motor Driver : Arduino

  5V - No connection with Arduino

  DIR ---> Pin 4

  PWM ---> Pin 5

  BRK ---> Pin 6

  GND - No connection with Arduino

And my code is like below:

const int kPinDIR = 4;
const int kPinPWM = 5;
const int kPinBRK = 6;

void setup()
{
  pinMode(kPinDIR, OUTPUT);
  pinMode(kPinBRK, OUTPUT);
  pinMode(kPinPWM, OUTPUT);
}

void loop()
{
  digitalWrite(kPinDIR, HIGH);   // Case 1
  digitalWrite(kPinBRK, LOW);

//  digitalWrite(kPinDIR, LOW);  // Case 2
//  digitalWrite(kPinBRK, HIGH);
//
//  digitalWrite(kPinDIR, LOW);  // Case 3
//  digitalWrite(kPinBRK, LOW);
//
//  digitalWrite(kPinDIR, HIGH); // Case 4
//  digitalWrite(kPinBRK, HIGH);

  analogWrite(kPinPWM, 255);
}

As you can see that, I tried out 4 different case to run motor. But motor run only for first two case(case 1 & 2) and direction of rotation is same. And in other two case(case 3 & 4) motor is not rotating.

I don't understand that thing why case 1 and case 2 give same output. If I tried out logic according manual description means according manual DIR pin change the direction of motor's rotation. According that If I provide LOW logic(GND) to DIR pin then motor rotating in one direction and but If I provide HIGH logic(5V) to DIR pin then motor is not rotating. I tried every case(already written in my code) but motor is still rotating in same direction.

And here I provide supply to motor driver by regulated power supply. And for Arduino, it take supply through it's cable(cable is connected to LAPTOP).

Actually, I am trying to run Peltier module using this motor driver. I want to change Peltier's polarity using this. So, first I tried out with motor then If I succeed then I tried this one to Peltier. I think I have to connect GND of Motor Driver to Arduino's GND but I think it will my Arduino. I'm not sure about this GND connection between Motor Driver and Arduino. Please suggest me.

EDIT 1: My wiring is look like this.

simulate this circuit – Schematic created using CircuitLab


texts: Serial Communication to Arduino with Node.js

texts:
I ran into some strange problems while trying to send data from my Node.js Server to my Arduino. My goal is to transfer an Int to the Arduino Nano and display it on a LCD. So far I managed to connect the server with the Arduino with the help of the serial library. The Arduino returns all data sent to it via Serial and prints it bytewise to the LCD.

These are the problems:

Node.js always opens the port, but is only able to send and receive data when the Serial Monitor from the Arduino IDE is opened.
The Data Node.js is sending seems to have a special format or gets transformed during the Process. If I send a simple int like 2, the display shows a y and an undecipherable character, and the data returned looks like this:  49 50 49 13 10 48 13 10. I noticed that the amount of 13 corresponds with the int I send (3 send = three 13's come back). When I enter data into Arduinos own Serial Monitor, it is displayed correctly and returned as ASCII (because I am saving the return value of Serial.read() as an Int).

Here's my server (the relevant parts):

http = require('http');
fs = require('fs');
serialport = require('serialport');

port = 3000;
host = '127.0.0.1';
SerialPort = serialport.SerialPort;
arduinoPort = '/dev/ttyUSB2';

var printLog = true;
var playerRoundKills = 0;
var playerTotalKills;
var roundLive = false;

//open port
var myPort = new SerialPort(arduinoPort);
parser: serialport.parsers.raw          //rohdatenparser definieren
serialport.on('open', function(){
  console.log('Serial Port Opend');
  serialport.on('data', function(data){
      console.log(data[0]);
  });
});

//implementation of abstract port functions
myPort.on('open', showPortOpen);
myPort.on('data', sendSerialData);
myPort.on('close', showPortClose);
myPort.on('error', showError);

function showPortOpen() {
   console.log('port open. Data rate: ' + myPort.options.baudRate);
}

//output incoming data
function sendSerialData(data) {
   console.log(data[0]);
if(typeof data[1] !== 'undefined') console.log(data[1]);
}

function showPortClose() {
   console.log('port closed.');
}

function showError(error) {
   console.log('Serial port error: ' + error);
}

myPort.on("open", function () {
  console.log('open');
//send data (3) to arduino
myPort.write(3, function(err, results) {
    if(err != null)console.log('Fehler beim ersten senden: ' + err);
    if(results != null)console.log("Killcount erstmals gesendet: "+results);
  });
});

And my sketch:

#include <LiquidCrystal.h>

//LDCD Display
LiquidCrystal lcd(9, 8, 6, 5, 4, 3);  //Digitale Pins an dem das Display angeschlossen ist
#define LCD_WIDTH 16                    //Anzahl Spalten des Display (16)
#define LCD_HEIGHT 2                    //Anzahl Zeilen des Display (2)

#define DEBUG_MODE true

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

  lcd.begin(LCD_WIDTH, LCD_HEIGHT,1);

  lcd.setCursor(0,0);

}

void loop() {
  // when characters arrive over the serial port...
  if (Serial.available()) {

    //clear display for new killcount
    //lcd.clear();
    // wait a bit for the entire message to arrive
    delay(100);
    // read all the available characters
    while (Serial.available() > 0) {
      // write each character to display as ascii
    int temp = Serial.read();
    lcd.write(temp);
    Serial.println(temp);

    }
    //Serial.flush();
  }
}

I'd appreciate any suggestions! =)


texts: How do I prevent Arduino from running on startup?

texts:
I just uploaded a sketch to my Arduino Leonardo, which presses a key on the keyboard. The code was unfortunately bugged and now as soon as the Arduino is powered on, the key is being pressed.

When I try to upload a new sketch that fixes the issue, I am unable to do so as the Arduino is executing the sketch, preventing the new sketch from being uploaded.

How can I prevent the Arduino from executing the sketch once powered on? Pressing the reset button or wiring it in does not work...


texts: Using micros() to measure analogRead() time varies based on Serial.print location?

texts:
I'm trying to use micros() to measure the time it takes to execute an analogRead() cycle, but am having some issues.  Originally, I just printed out the measured time for the analogRead() right after doing the subtraction, but I wanted to change that to printing out all of the time values for the 100 loops at once.  When I print the start times, end times, and values both in the if statement (right after calculating them) and at the end, the values printed are the same.  I'm not sure if they're accurate because they fluctuate a lot within those 100 tests.  For example, some of these measured times consecutively are 216, 97, 153, 34, 89, 145, 27.  I put the ADC in freerun mode, so I figured it could be normal for that.  However, when I don't print the start times, end times, or values immediately after calculating them and instead try to print them in the else if statement, it gives a stream of values that are all either 407 or 408.  If I print "Test" instead of the values right after calculating them, it still gives the (I'm assuming) correct values that vary a lot, not the 407s.  If, instead of printing them in the if statement, I print them just in the general loop (currently commented out) and the else if statement, they are still the varying maybe-correct values.  I assumed that even if the values aren't being printed, they're still being stored in the array correctly.  I don't understand why printing something unrelated right after storing the values would change them.  Any ideas?

Thanks

    int sensorPin = A1;    // select the input pin for the potentiometer
    int ledPin = 13;      // select the pin for the LED
    int sensorValue[1000];  // variable to store the value coming from the sensor
    int ind = 0;
    int starts[1000];
    int ends[1000];
    int vals[1000];
    int stopprint = 0;
    int i = 0;
    int countto = 100;

    void setup() {
      // declare the ledPin as an OUTPUT:
      Serial.begin(57600);
      analogReadResolution(12);
      pinMode(ledPin, OUTPUT);
      Serial.println("ready to begin");
        analogReadSetup(A1);
      for (i = 0; i < 1000; i++) {
        starts[i] = 0;
        ends[i] = 0;
        vals[i] = 0;
      }
    }

    void loop() {
      // read the value from the sensor:
      if (ind < countto) {
      starts[ind] = micros();
    //  delay(50);
      sensorValue[ind] = analogRead(sensorPin);
      ends[ind] = micros();
      vals[ind] = ends[ind] - starts[ind];
    //  Serial.println("Test");
        Serial.print(ind);
        Serial.print('\t');
        Serial.print(starts[ind]);
        Serial.print('\t');
        Serial.print(ends[ind]);
        Serial.print('\t');
        Serial.print(vals[ind]);
        Serial.print('\t');
        Serial.print('|');
        Serial.print('\t');
      Serial.print('\n');
      Serial.print('\r');
      ind++;
      }
      else if (stopprint == 0) {
        Serial.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
        for (int j = 0; j < countto; j++) {
    //        Serial.println(j);
            Serial.print(starts[j]);
            Serial.print('\t');
            Serial.print(ends[j]);
            Serial.print('\t');
            Serial.print(vals[j]);
            Serial.print('\n');
            Serial.print('\r');
            stopprint = 1;
        }
      }
      else if (stopprint == 1) {
        while(1);
      }
    //  Serial.print(ind-1);
    //  Serial.print('\t');
    //  Serial.print(starts[ind-1]);
    //  Serial.print('\t');
    //  Serial.print(ends[ind-1]);
    //  Serial.print('\t');
    //  Serial.print(vals[ind-1]);
    //  Serial.print('\n');
    //  Serial.print('\r');
   }

Also, I'm using the Arduino Zero if it makes a difference.


texts: Arduino + ultrasonic rangefinder behaving unexpectedly

texts:
I'm using an HC-SR04 ultrasonic rangefinder to control the frequency at which an Arduino pin turns on and off, with the output going via a 1/4" jack plug into my computer's audio interface. (i.e. it's a simple audio oscillator that responds to gestures). This is the code (based on that given here):

#define trigPin 10
#define echoPin 12

void setup() {

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(9, OUTPUT);

}

void loop() {

  float duration, distance;
  digitalWrite(trigPin, LOW); // Sends a 2 µs LOW signal to the trigPin
  delayMicroseconds(30);

  digitalWrite(trigPin, HIGH); // Sends a 10 µs HIGH signal to the trigPin
  delayMicroseconds(30);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH); //Defines the duration variable

  digitalWrite(9, HIGH); //square wave oscillator
  delay(0.1+duration*0.01);
  digitalWrite(9, LOW);
  delay(0.1+duration*0.01);
}

Pin 9 is the output, and sounds roughly as expected, but what's confusing me is that making any kind of gesture other than very slow ones (i.e. if the distance isn't changing very slowly) causes the output to stop completely for a few seconds, then start again, as if something is overloading and then resetting. What am I doing wrong?


texts:
This following error message I am getting while compiling:

Arduino: 1.6.8 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/lwip2/include/lwip/opt.h:51:0,

                 from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/lwip2/include/lwip/init.h:40,

                 from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/IPAddress.h:27,

                 from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:31,

                 from C:\Users\Shree\Documents\Arduino\libraries\firebase-arduino-master\examples\FirebaseDemo_ESP8266\FirebaseDemo_ESP8266.ino:20:

C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/lwip2/include/lwipopts.h:1301:2: error: #error TCP_MSS must be defined

 #error TCP_MSS must be defined

  ^

C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/lwip2/include/lwipopts.h:2381:2: error: #error LWIP_IPV6 must be defined

 #error LWIP_IPV6 must be defined

  ^

C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/lwip2/include/lwipopts.h:3534:2: error: #error LWIP_FEATURES must be defined

 #error LWIP_FEATURES must be defined

  ^

In file included from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.h:29:0,

                 from C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:34,

                 from C:\Users\Shree\Documents\Arduino\libraries\firebase-arduino-master\examples\FirebaseDemo_ESP8266\FirebaseDemo_ESP8266.ino:20:

C:\Users\Shree\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0/tools/sdk/include/user_interface.h:34:2: error: #error LWIP_OPEN_SRC must be defined

 #error LWIP_OPEN_SRC must be defined

  ^

C:\Users\Shree\Documents\Arduino\libraries\firebase-arduino-master\examples\FirebaseDemo_ESP8266\FirebaseDemo_ESP8266.ino:21:29: fatal error: FirebaseArduino.h: No such file or directory

 #include <FirebaseArduino.h>

                             ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

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

please help me out to solve this issue.


texts: Using an Arduino and multiplexer for writing to multiple outputs

texts:
I'm attempting to use the multiplexer setup in this article with my Arduino Uno to control the output of LED's, as a way to fully understand the principles of multiplexing.

I'm working to modify the code in the article to switch from reading potentiometer values to writing voltage values to the LED's.

Below is the modified sketch; the biggest modified change is the loop in the writeMux function:

//Mux control pins
int s0 = 8;
int s1 = 9;
int s2 = 10;
int s3 = 11;

//Mux in "SIG" pin
int SIG_pin = 3;

//Voltage value to write to the LEDs
int testValue = 255;

void setup(){
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(SIG_pin, OUTPUT);

  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
}

void loop(){
  for(int i = 0; i < 9 ; i ++){
    delay(1000);
    writeMux(i);
  }
}

int writeMux(int channel){
  int controlPin[] = {s0, s1, s2, s3};

  int muxChannel[10][4]={
    {0,0,0,0}, //channel 0
    {1,0,0,0}, //channel 1
    {0,1,0,0}, //channel 2
    {1,1,0,0}, //channel 3
    {0,0,1,0}, //channel 4
    {1,0,1,0}, //channel 5
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
//    {0,1,0,1}, //channel 10
//    {1,1,0,1}, //channel 11
//    {0,0,1,1}, //channel 12
//    {1,0,1,1}, //channel 13
//    {0,1,1,1}, //channel 14
//    {1,1,1,1}  //channel 15
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //read the value at the SIG pin
  analogWrite(testValue, SIG_pin);

  //return the value
  return 0;
}

Below is a photo of my circuit:

However, none of the LED's light up.

I'm fairly certain that this is more of a problem with the code rather than the circuit...any advice is appreciated!


texts: Arduino Nano 33 BLE work with its Bluetooth and GPS synchronously?

texts:
I am using Arduino nano 33 Sense BLE in which I want GPS to run and display its location . The GPS module which I am using is Adafruit GPS. I want both Bluetooth and GPS to run synchronously. But only one of them shows output. I have tried Adafruit-GPS library with the Hardware Serial but it shows the GPS location not the Bluetooth working.
I also checked the code individually both are working well.I have used the example of Adafruit-GPS library->GPS_HardwareSerial_Parsing and ArduinoBLE library->LED , these codes both work individually well but when I have combined them and tried to make it run only the GPS shows its location the bluetooth seems to be not working.Below is the combined code:

#include <Adafruit_GPS.h>
#include <ArduinoBLE.h>

// what's the name of the hardware serial port?
#define GPSSerial Serial1
// Connect to the GPS on the hardware port
Adafruit_GPS GPS(&GPSSerial);
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO false
uint32_t timer = millis();

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int ledPin = LED_BUILTIN; // pin to use for the LED

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

 // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate

  pinMode(ledPin, OUTPUT);
  BLE.setLocalName("LED");
  BLE.setAdvertisedService(ledService);
  // add the characteristic to the service
  ledService.addCharacteristic(switchCharacteristic);
  // add service
  BLE.addService(ledService);
  // set the initial value for the characeristic:
  switchCharacteristic.writeValue(0);
  // start advertising
  BLE.advertise();

  delay(1000);
}

void loop()
{
  char c = GPS.read();

  BLEDevice central = BLE.central();

  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 (timer > millis()) timer = millis();

//BLE code to connect to bluetooth

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());
    // while the central is still connected to peripheral:
    while (central.connected()) {
      // if the remote device wrote to the characteristic,
      // use the value to control the LED:
      if (switchCharacteristic.written()) {
        if (switchCharacteristic.value()) {   // any value other than 0
          Serial.println("LED on");
          digitalWrite(ledPin, HIGH);         // will turn the LED on
        } else {                              // a 0 value
          Serial.println(F("LED off"));
          digitalWrite(ledPin, LOW);          // will turn the LED off
        }
      }
    }
    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }

//GPS to print latitude and longitude
  // approximately every 5 seconds or so, print out the current stats
  if (millis() - timer > 5000) {
    timer = millis(); // reset the timer
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", ");
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
    }
  }

}


texts: Measure different Vcc using 1.1V bandgap

texts:
When I power my ATmega328P chip from 5.16V and 3.3V, there doesn't seem to be a single bandgap voltage compensation figure that works for both.

I'm using the following sketch, and I need the following InternalReferenceVoltage values to read the correct voltage from A0:

1255L to correctly output 5.16V.
1358L to correctly output 3.3V.

I have a couple of questions:

Should I be able to use a single InternalReferenceVoltage compensation value whe powering the ATmega328P from different voltages?
Aren't both of these values outside the specced 1.0 to 1.2 range?

The code is from, http://forum.arduino.cc/index.php?topic=56750.msg407897#msg407897, retolefty post @ Mar 28, 2011, 02:27 pm.

#include <SPI.h>

void setup()
{
  delay(5000);

  Serial.begin(115200);
}

void loop(void)
{
  // Determines what actual Vcc is, (X 100), based on known bandgap voltage
  int battVolts = readVcc1();

  Serial.print("Battery Vcc volts =  ");
  Serial.println(battVolts);
  Serial.print("Analog pin 0 voltage = ");
  Serial.println(map(analogRead(0), 0, 1023, 0, battVolts));
  Serial.println();

  delay(1000);
}

// Returns actual value of Vcc (x 100)
int readVcc1()
{
  uint8_t oldADMUX = ADMUX;

  const long InternalReferenceVoltage = 1255L; // Adjust this value to your boards specific internal BG voltage x1000

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  // For mega boards
  // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc reference
  // MUX4 MUX3 MUX2 MUX1 MUX0  --> 11110 1.1V (VBG)         -Selects channel 30, bandgap voltage, to measure
  ADMUX = (0 << REFS1) | (1 << REFS0) | (0 << ADLAR) | (0 << MUX5) | (1 << MUX4) | (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (0 << MUX0);

#else
  // For 168/328 boards
  // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc external reference
  // MUX3 MUX2 MUX1 MUX0  --> 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure
  ADMUX = (0 << REFS1) | (1 << REFS0) | (0 << ADLAR) | (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (0 << MUX0);

#endif
  delay(50); // Let mux settle a little to get a more stable A/D conversion
  // Start a conversion
  ADCSRA |= _BV(ADSC);
  // Wait for it to complete
  while (((ADCSRA & (1 << ADSC)) != 0));

  // Scale the value
  int results = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; // calculates for straight line value

  ADMUX = oldADMUX;

  return results;
}

I have read these other references to try and find a solution:

Measure Vcc using 1.1V bandgap
https://hackingmajenkoblog.wordpress.com/2016/02/01/making-accurate-adc-readings-on-the-arduino/
http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/


texts:
We have two sensor one of them(MPU6050-gyro) is communicating using I2C, the other is via SPI(SD card reader). Now, we need an additional component as a sensor that the barometer which communicates via I2C.

Can we use all three modules without any problem? I wonder if two I2C modules is used in a hassle-free manner? Otherwise, what can be done?


texts:
I've been trying to get a for loop to run 9 times using the below code but can't get the loop to run.

void output() {
  int r;
  r = 1;
  Serial.println("Output");
  digitalWrite(Latch, LOW);
  for (int r=1; r >= 9;  r = r + 1) {
    Serial.println("Test");
    digitalWrite(DataOutput, Q[r]);
    digitalWrite(ClockPin, HIGH);
    digitalWrite(ClockPin, LOW);
  }
  Serial.println("Done For");
  digitalWrite(Latch, HIGH);
  digitalWrite(Latch, LOW);
}


texts: Arduino bluetooth HC-05 data reading problem

texts:
I have a problem with bluetooth module HC-05 and servos. If I type in bluetooth terminal 4,1 I want that servo1 turns 60 degrees 3 times. Briefly servo1 turns 60 degrees and then servo2 goes 180 and turns back and again servo1 turns 60 degrees and so on.

The bluetooth mixes the numbers. If I type "1" it gives me "49" and that's why the system is not working properly. How do I fix this data problem?

#include <Servo.h>
#include <SoftwareSerial.h>

Servo myservo1;
Servo myservo2;
long players, cards;
int pos1 = 0;
int pos2 = 0;
int servo;
int pos = 0;
int deal = 0;

SoftwareSerial BT(2,3);

void setup() {
  Serial.begin(9600);
  BT.begin(9600);
  myservo1.attach(10);
  myservo2.attach(11);
  servo = 90;

}

void loop() {
  if(BT.available()>0) {
    players = BT.read();
    cards = BT.read();

    Serial.println(players);
    Serial.print(cards);

    pos = 180/(players-1);
    for(deal = 0; deal < cards; deal++) {
      for (pos1 = 0; pos1 <= 180 ; pos1 += pos ) {
          delay(20);
          myservo1.write(pos1);

          for (pos2=0; pos2<=180 ; pos2 +=1){
            myservo2.write(pos2);
            delay(10);
          }

          for (pos2=180; pos2>=0 ; pos2 -=1){
            myservo2.write(pos2);
            delay(15);
          }

    }
      for (pos1 <= 180; pos1 >= 0; pos1 -=1 ) {
          pos2=0;
          myservo1.write(pos1);
          delay(10);
      }
    }

  }
}


texts:
Is it possible to get the Gerber files for the Arduino Uno r3 and the WiFi 101?  I've been teaching myself the SW side of this hobby (with much help from SE Arduino) and I'd like to better understand, or at least get some exposure to, the HW side.

Are the Arduino Uno and WiFi 101 Gerber files available to the general public or are they considered IP?  I am under the impression that it is open source but I'm not sure where the OS boundary ends.


texts: esp32-cam mjpg stream to be recorded in an NVR

texts:
I recently purchased an ESP32-CAM. This board is a "AI Thinker Model".
I loaded the code as described here: randomnerdtutorials
I have set it up with static ip and everything works well, meaning that the camera streams images at my browser <cam_ip:81/stream> and so you can use it as a monitoring device.
However I have an NVR (ESCAM PVR208) in the network, that doesn't accept mjpg streaming (or it seems so). Protocols that the nvr accepts are P6S, P1, P2, P5, onvif and zwp2p. None of these can be setup with this esp32-cam.
Can I somehow take the mjpg stream and transform it to something else like rtsp? Can somebody direct me as to what to look for? Or maybe is there some other solution to this?


texts: Writing serial data, just once after read

texts:
I have developed a program and the idea is that when it receives serial data (any single character) it returns a single random number.

I have it working but it returns 3 x random numbers one after another for each read that it does and I can't figure out why.

int led = 13;
char incomingByte = 10;
long randNumber;
// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
 Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {

//  delay(1000);               // wait for a second

   if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();
                // say what you got:
              //  Serial.print("I received: ");

                randNumber = random(1, 2000);
                Serial.println('PL' + randNumber);
                  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
                  delay(1000);               // wait for a second
                  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

}

}


texts:
tl;dr: trying to receive DMX512 (via a RS485 module) on a STM32 and not going well.
I am trying to modify the firmware of a commercial lighting fixture with a STM32F103C8 clone as it's MCU. It basically receives DMX and converts it into a single axis of motion and a lighting fixture with ~24 WS2812B LEDs. Unfortunately, all of the DMX libraries available (DMXSimple2, Conceptinetics) only support avr, and I don't have very much experience with the lower level hardware/library interactions.
I am looking at this tutorial because it seems easier to modify to work with the STM32, but the tutorial says

Now just do a search for "ISR(USARTn_RX_vect)" in HardwareSerial.cpp

which I can't find in the Arduino STM32 core.
Can someone help or point me towards resources about how to modify the existing libraries to work for my application?


texts:
Folks,
I am a beginner to Arduino. I have a sketch that tests a set of INPUTS for HIGH or LOW by using a 'for' loop. When the for loop reaches an INPUT which is kept OPEN (no wires connected to it), the for loop apparently 'skips' that INPUT and move on to the next. However, if I have +5V connected to any INPUTS within the range of the for loop, it works correctly. Any thoughts what's is happening here?


texts: Is it possible to use WiFi and Bluetooth / BLE in the same ESP32 project?

texts:
@Majenko's answer works like a charm. I did have to make some changes as follows:

Per Majenko, you need to change the Tools > Partition scheme.  I used "No OTA (Large APP) as he suggested and it is now working.

However, the Partition Scheme option under Tools was not available for either of my devices (Huzzah32 or NodeMCU-32s).  I changed my board type (Tools > Board) to "ESP32 Dev Module" and several additional options appeared under Tools, including Partition Scheme.

Original Question: I am not able to use both the WiFi.h and BLE libraries at the same time.  Even the most minimal projects run out of memory during compile.  Am I doing something wrong?   I get identical results with both an Adafruit Huzzah32 and a NodeMCU-32S.

Does anyone know of a workaround, or barring that a suggested alternate board? A Raspberry pi zero W seems like overkill and the power consumption is ugly, so I don't want to do that unless I really have to.

#include <WiFi.h>
#include <BLEDevice.h>

void setup() {
  WiFi.mode(WIFI_MODE_STA);             // use a WiFi function
  BLEDevice::init("Minimal BLE WiFi");  // use a BLE function
}

void loop() { }

The error I get is

  Arduino: 1.8.9 (Mac OS X), Board: "NodeMCU-32S, 80MHz, 921600"

  Build options changed, rebuilding all Sketch uses 1443898 bytes (110%)
  of program storage space. Maximum is 1310720 bytes.

  Global variables use 60208 bytes (18%) of dynamic memory, leaving
  267472 bytes for local variables. Maximum is 327680 bytes. Sketch too
  big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips
  on reducing it. Error compiling for board NodeMCU-32S.


texts: arduino PWM temperature inexpected results

texts:
I am making a system which regulates the temperature of a plate.
using the PID library
I programed the system as followed:

/********************************************************
 * PID Basic Example
 * Reading analog input 0 to control analog PWM output 5
 ********************************************************/

#include <PID_v1.h>
#include "math.h"

int val, output2;
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID( &Input, &Output, &Setpoint,0,20,20, DIRECT);

void setup()
{
  //initialize the variables we're linked to
  Setpoint = 37; //temperature a reguler

  //turn the PID on
  pinMode(9, OUTPUT);
  myPID.SetOutputLimits(-100, 100);
  myPID.SetMode(AUTOMATIC);
  Serial.begin(57600);
  while (!Serial);
}

void loop()
{
  // phase haute
  //delay(100-output2);
  val = analogRead(1);
  float mv = ( val/1024.0)*5000;
  Input = mv/10;
  myPID.Compute();
  {   output2 = map(Output, -100, 100, 0, 200);
      Serial.print("output is :");
      Serial.println(output2);
      digitalWrite(9,HIGH);
      delay(output2);
      // phase basse
      digitalWrite(9,LOW);
  }
  //analogWrite(5,Output);
  //Serial.print("input temperature is :");
  //Serial.println(Input);
  // Serial.println(Output);
  // Serial.println(Input);

}

As you can see in the code the output result is between 0 and 100.
the temperature desired in the plate is 37 degre. and the actual temperature is 24 degre. consequently, the program supposes to set the value of the output to the max value to reach to 37 degre.
But the problem is my output is setting to different values as you can see here:

what can be the problem here ? thank you in advance


texts:
I have an Arduino Uno connected to the Adafruit Motorshield v2. I have it hooked up to a stepper motor(27BYJ-48). I am trying to make the motor do one complete revolution. However, the number of steps I specify to the stepper motor(200 in the code) doesn't affect the motor steps. For example, the 2200 step in this code, is roughly one rotation and is completely unaffected by change the steps/revolution specified when instantiating the motor. How do I get the motor to do one exact revolution?

Here is the code on the arduino:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  AFMS.begin();  // create with the default frequency 1.6KHz

  myMotor->setSpeed(2000);  // 10 rpm
}

void loop() {
  Serial.println("Single coil steps");
  myMotor->step(2200, FORWARD, DOUBLE);
  myMotor->step(2200, BACKWARD, DOUBLE);
}

Edit:
Wiring:


texts:
I have uploaded a program to NodeMCU , to print "hello, world" on JHD162A 16x2 LCD module. But the text doesn't appear on the lcd display. Instead just black blocks appear on the first row on the LCD. I assume it's a hardware related issue since the software worked in simulation. I powered the NodeMCU and the LCD using 5V DC from 7805 voltage regulator IC. The 12v input to the IC is provided using a 230V AC  to 12V DC adapter with 2A max current out. I have placed a 680 ohms resistor to the anode of the lcd back led, also a 1K resistor between the Vss and Vee of the LCD to set contrast. I am using D0, D1, D2, D3 pins of the NodeMCU to the D7, D6, D5, D4 data pins of the LCD. The RW is connected to the gnd pin of NodeMCU. The RS and E pins are connected to the D8 and D7 of NodeMCU.

#include<LiquidCrystal.h>

const int RS= D8, EN = D7, d4 = D3, d5= D2, d6 = D1, d7 = D0;

LiquidCrystal lcd(RS, EN, d4, d5, d6, d7);

void setup()
{
lcd.begin(16, 2);
lcd.print("hello, world!");
}

 void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}


texts: Delay() is not working outside of interrupt

texts:
Delay() doesn't work inside ISR routines, but here I have used it in loop and outside interrupt section still Delay is not working, however there isn't any error coming. What is wrong?

int L = 2;
volatile int done0=0;                                //ISR variables
void recordL();                                              //ISR 1

void setup() {
Serial.begin(9600);
Serial.println("Start");

pinMode(L,INPUT);
}

void loop() {

interrupts();
attachInterrupt(0,recordL,RISING);
done0=0;

while(!done0)
{
    Serial.println(millis());
}
noInterrupts();

Serial.println("Detected");
delay(5000);
Serial.println("After Delay");
}

void recordL()
{
  Serial.println("in Interrupt0");
  done0=1;
}


texts: How to read serial data without any blocking using ESP8266

texts:
I'am deconding one electronic device serial protocol and using ESP8266 for this task. Device is sending 202 byte data constantly and I figured out begining and the end.

Whole packet looks like:

71 c8 01 10 56 55 62 49 00 05 00 00 00 00 00 00 00 00 00 00 19 15 11 55 16 5e 55 05 09 00 00 00 00 00 00 00 00 00 80 8f 80 8a b2 71 71 97 99 00 00 00 00 00 00 00 00 00 00 00 80 85 15 8a 85 85 d0 7b 78 1f 7e 1f 1f 79 79 8d 8d 9e 96 71 8f b7 a3 7b 8f 8e 85 80 8f 8a 94 9e 8a 8a 94 9e 82 90 8b 05 65 78 c1 0b 00 00 00 00 00 00 00 00 55 56 55 21 53 15 5a 05 12 12 19 00 00 00 00 00 00 00 00 e2 ce 0d 71 81 72 ce 0c 92 81 b0 00 aa 7c ab b0 32 32 9c b6 32 32 32 80 b7 af cd 9a ac 79 80 77 80 ff 91 01 29 59 00 00 3b 0b 1c 51 59 01 36 79 01 01 c3 02 00 dd 02 00 05 00 00 01 00 00 06 01 01 01 01 01 0a 14 00 00 00 77

Here start "header" is 0x71 and 0xc8   and the last 202 byte is a Checksum value of hole 201 bytes.

Goal is to get valid 202 byte data by checking if start contains 0x71 and 0xc8

My readserial looks like, how it to improve in best way?

void readSerial()
{
  if (Serial.available() > 0) {
    data_length = Serial.readBytes(data, 202);
       while (Serial.available()) {
      delay(2);
      Serial.read();
    }
  }
  else data_length = 0;
}


texts:
I wanted to make a buzzer go off when the distance measured by the ultrasonic sensor becomes more than 100cm. The things used in this project are a 4x4 keypad, an hc-sr04 ultrasonic sensor, and a passive buzzer all connected to a keyestudio mega 2560.
What happens is that the moment I upload the code/turn on the Arduino, the buzzer turns on despite a solid object being within a 100cm range. And the buzzer almost randomly stops for a couple of seconds and continues. It won't turn off, even when I press the appropriate key on the keypad.
This is the code I have written, thanks
    #include <Key.h>
    #include <Keypad.h>

    const int trigPin = 11;    //output to sensor
    const int echoPin = 12;    //input from sensor
    const int buzzPin = 13;    //output to buzzer

    const byte ROWS = 4;
    const byte COLS = 4;

    long duration;    //travel time of sound waves
    int distance;    //distance at which an object is

    char hexaKeys[ROWS][COLS] = {
      {'1', '2', '3', 'A'},
      {'4', '5', '6', 'B'},
      {'7', '8', '9', 'C'},
      {'*', '0', '#', 'D'}
    };

    byte rowPins[ROWS] = {9,8,7,6};
    byte colPins[COLS] = {5,4,3,2};

    Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

    void setup() {
      // put your setup code here, to run once:
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      pinMode(buzzPin, OUTPUT);
      Serial.begin(9600);
    }

    void loop() {
      // put your main code here, to run repeatedly:

      char customKey = customKeypad.getKey(); // gets key values from keypad

      if(customKey) {
        Serial.println(customKey);
       }

      digitalWrite(trigPin, LOW);    //reset the sensor by turning it off for 2 microseconds
      delayMicroseconds(5);

      digitalWrite(trigPin, HIGH);    //generate ultrasound wave by turning it on for 10 microseconds
      delayMicroseconds(50);
      digitalWrite(trigPin, LOW);

      duration = pulseIn(echoPin, HIGH);    //time it takes for sound to get back
      distance = duration*0.034/2;    //plug into formula for distance

      Serial.println(distance);

    if (distance <= 100){
     digitalWrite(buzzPin, LOW);
      }
    if (distance >= 100){
      digitalWrite(buzzPin, HIGH);
      if (customKey != 7){
        digitalWrite(buzzPin, HIGH);
        delay(2000);
        digitalWrite(buzzPin, LOW);
        delay(1000);
      if (customKey == 7){
        digitalWrite(buzzPin, LOW);
}
}
}
 }


texts: My LED toggeling doesn't work the way I want

texts:
I want to do LED toggeling so I wrote this:

int led=13, button=12;

void setup()
{
    // put your setup code here, to run once:
    pinMode(led,OUTPUT);
    pinMode(button,INPUT);
}

void loop()
{
    // put your main code here, to run repeatedly:
    if(digitalRead(button)==HIGH && digitalRead(led)==LOW)
    {
        digitalWrite(led,HIGH);
    }

    if(digitalRead(button)==HIGH && digitalRead(led)==HIGH)
    {
        digitalWrite(led,LOW);
    }
}

But It doesn't work well, sometimes I need to press the button many times in order to turn on or of...and some times with just one press.

I saw this video but I didn't understand it well:
https://www.youtube.com/watch?v=aMato4olzi8&t=415s

Anyway I don't know why my way doesn't work well.


texts: Trying to use a 7 segment display to count 0/9 with a potentiometer

texts:
im trying to switch number on the display using a
    potentiometer, it is just counting from 0/9.
    All help is much appreciated!

int SegmentA = 6;
int SegmentB = 7;
int SegmentC = 8;
int SegmentD = 9;
int SegmentE = 10;
int SegmentF = 11;
int SegmentG = 12;

const int PP = A0;

void setup()
{
  pinMode (SegmentA, OUTPUT);
  pinMode (SegmentB, OUTPUT);
  pinMode (SegmentC, OUTPUT);
  pinMode (SegmentD, OUTPUT);
  pinMode (SegmentE, OUTPUT);
  pinMode (SegmentF, OUTPUT);
  pinMode (SegmentG, OUTPUT);

}

void loop() {

  int POD = analogRead(PP);
  int SM = map(POD, 0, 1023, 0 , 8);
  switch (SM) {

    case 0:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, HIGH);   //0
      digitalWrite (SegmentF, HIGH);
      digitalWrite (SegmentG, LOW);

      delay(1000);

    case 1:
      digitalWrite (SegmentA, LOW);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, LOW);
      digitalWrite (SegmentE, LOW);   //1
      digitalWrite (SegmentF, LOW);
      digitalWrite (SegmentG, LOW);

      delay(1000);

    case 2:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, LOW);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, HIGH);   //2
      digitalWrite (SegmentF, LOW);
      digitalWrite (SegmentG, HIGH);

      delay(1000);

    case 3:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, LOW);   //3
      digitalWrite (SegmentF, LOW);
      digitalWrite (SegmentG, HIGH);

      delay(1000);

    case 4:
      digitalWrite (SegmentA, LOW);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, LOW);
      digitalWrite (SegmentE, LOW);   //4
      digitalWrite (SegmentF, HIGH);
      digitalWrite (SegmentG, HIGH);

      delay(1000);

    case 5:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, LOW);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, LOW);   //5
      digitalWrite (SegmentF, HIGH);
      digitalWrite (SegmentG, HIGH);

      delay(1000);

    case 6:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, LOW);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, HIGH);   //6
      digitalWrite (SegmentF, HIGH);
      digitalWrite (SegmentG, HIGH);

      delay(1000);

    case 7:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, LOW);
      digitalWrite (SegmentE, LOW);   //7
      digitalWrite (SegmentF, LOW);
      digitalWrite (SegmentG, LOW);

      delay(1000);

    case 8:
      digitalWrite (SegmentA, HIGH);
      digitalWrite (SegmentB, HIGH);
      digitalWrite (SegmentC, HIGH);
      digitalWrite (SegmentD, HIGH);
      digitalWrite (SegmentE, HIGH);   //8
      digitalWrite (SegmentF, HIGH);
      digitalWrite (SegmentG, HIGH);

  }

}


texts: Am I able to connect an anti static wrist strap to the ground pin on the Arduino uno?

texts: So you have the pin on the arduino uno which is ground, are you able to use a jumper wire to send the ground source out the other end of the wire to the alligator clip for the antistatic wrist strap?


texts:
I've been using an Arduino Uno Rev. 3 for a few projects and would like to switch to using a bare Atmega328 chip so I can keep everything on the same board. I've seen the Arduino on breadboard tutorial which is fine, but the Arduino board itself has a lot of other components that aren't in the tutorial. I realize I can go look up the actual design itself, but I'm looking for a high level description of what most of the components are used for.

I'm not interested in programming through the Arduino IDE, so I don't need parts for serial programming and such. But I'm wondering if leaving out some other components would leave me at a disadvantage. For example, the datasheet recommends connecting AVCC to VCC with an LC circuit for ADC noise cancellation, but the arduino on breadboard tutorial doesn't mention this and I otherwise never would have known.


texts: How to get arduino to always be connected as /dev/ttyUSB0 and with chmod 0777?

texts:
I've got Debian 10 as OS and for a Project, I need my arduino to always be connected as /dev/ttyUSB0, not any other ttyUSB-number, and I need it to be connected with the 0777 rights for a script to work.
I've read some things about udev, but nothing I tried yet worked.
I tried creating
/etc/udev/rules.d/51-my_usb_device
with the content
SUBSYSTEM=="tty", MODE="0777", KERNELS=="ttyUSB0"
but it does not work, even after reboot (like nothing changed). I must admit though that I do not really understand udev.
How to do this?


texts: Arduino stopped working: avrdude: ser_open(): can't set com-state

texts:
I'm playing with my first Arduino device (Arduino Leonardo). It worked fine but at some point it failed. I'm getting this error:

  avrdude: ser_open(): can't set com-state for "\.\COM6"

  An error occurred while uploading the sketch

The error came out of nowhere because I didn't change the port or cable or anything. Everything seems to be in order: the port, the driver, the IDE, the cable. And everything worked just an hour ago.

1) I've tried to change the port
2) I've reinstalled IDE
3) I've tried different cable

What else can I do?

And another thing: after manual reset of Arduino (with button) device disappears.


texts: Send AT commands to ESP8266 from Arduino Nano serial monitor

texts:
I have an Arduino nano and an ESP8266-01.

The first thing to do seems to be to send AT commands via the serial monitor and see the replies.

ESP connect as follows:

  GND   GND
  GPIO2 not connected
  GPIO0 not connected
  RX    to Arduino RX via level shifter
  TX    to Arduino TX via level shifter
  CHPD  3.3V
  RST   3.3V
  VCC   3.3V

Image of breadboard (imgur rejects)
https://www.dropbox.com/s/aif8afi29amy02h/20180807_135218.jpg?dl=0

When connecting the red light comes on and the blue light flashes quickly (and the Arduino RX light flashes with it) then goes out.

Here is the sketch I'm using. (The ESP8266 must be disconnected from RX+TX for uploading of the sketch to work.)

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

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  delay(3000);
 }

(I like to blink the LED to demonstrate that uploading worked.)

With the serial monitor set to 115200 (NL&CR) I sent AT and nothing happens.

What have I got wrong? I really don't understand! Thanks in advance for any suggestions.

(This is actually my third ESP8266. The first worked fine on 5V but stopped working after I set the baud rate to 9600. I presume 5V killed it but it's strange that it worked for so long. The second, connected as above, when powered up made that power supply red hot and melted the jumpers.)


texts: Is it possible to execute a code in runtime when gets updated over the air (OTA)?

texts:
I would like to build a lib like ArduinoOTA but with no downtime at runtime. To achieve that I am wondering if it is possible to create a simple setup and loop code to

Check for new releases
If we have a new one start download it
As download routine is not finished keep running the current release
When download has finished, swap current release to the new one.
Now the normal routine is running the new release.

I am pretty interested if it is possible to do by myself something like that.

I didn't find any paper or articles similar to this and I don't known if this is a challenge for Arduino scope or C/C++.

Maybe I am saying something bizarre but I have been thinking of save new release into flash memory, point to it and discard the old release from flash memory.


texts: What is the theory behind the Arduino UNO being able to create AM waves at 800 kHz

texts:
I am doing a school project and saw someone use an Arduino and a piece of wire as an antenna here: https://forum.arduino.cc/index.php?topic=88422.0

I've tested this experiment and it works, but I have searched the internet for some time now for some background knowledge or theory on why this works, and how does it?

If anyone knows anything about the arduino creating simple AM waves, could you please let me know about it or redirect me to another source.

For some context, in this school project I've got to explain the theory behind creating basic AM waves and amplitude modulation in general, then prove the theory by conducting this experiment which I prove it correct.


texts:
I would like to introduce myself as a student from Czech Republic. I'm currently I'm working on a Meteostation project.

I've got Arduino set up, with plenty of weather sensors, as well as WH1080 sensors connected.

Right now, I'm only able to read the data via serial port on computer with Arduino IDE or show it on my 20*4 display.

Because of the distance between source of data and recipient of data, wireless data transfer is unsuitable for my application.

I found these MAX 485 modules on eBay for cheap:

I quickly got 2 pieces, as well as 5v-3.3v logic level shifter, as I was concerned about different logics on Raspi. I don't know much about Raspi and their pins, as the only thing I ever used with them was DS3231 real time clock module.

Now, the thing I'm trying to achieve is this - I want to be running a bunch of sensors at roof of our house, and have the Arduino send the data to Raspi over the rs485 (on request? as the sensor loop would be like 10-15min so maybe communicate on interrupt?)

What I'm planning to do with the data on the raspi would be running a software like WeeWx or wfrog to process them and possibly render a local website, that I could make public as port forwarding (I have public IP).

However, there are few questions I have, hopefully its not too much to ask

How would the wiring look like? I was unable to find any dumb-proof tutorial online, as I don't know whether or how to use the logic level shifter.
If I can read the data over serial port, would it be just a plain text (as shown on PC in Arduino ide serial monitor), or has each value its address that I could then easily accessing to a variable then being used to process the weather data?
If I'm completely wrong in something, or there's some completely different way how these things are being done by more experienced people, I'd love to hear some suggestions.

Thanks in advance for any kind of response, as this is at the moment causing me headaches, as I'm unable to do this on my own. I don't expect anyone to do all the work for me, maybe just point me in the right direction.


texts: Once I have a working project that I want to commercialize - how do I proceed?

texts:
I am working on a small Arduino project that once successful I think about commercializing (in my case, its a smart tag, but asking in general).
The question is - what is the next step? how do I get a chip that can be more cost effective, and smaller (I don't need all the Arduino abilities for a smart tag)?
Is there an online website, service, or do I must approach a professional (and who?)
Thanks in advance,


texts: The topic is quite self-describing. Is there some full color ink printer head module for arduino? If there isn't, what are the alternatives?


texts: Is RX1 and TX0 the same thing as TX and RX? Will there be a difference in the way I program it?

texts:
I have an Arduino.

I'm not sure if RX1 and TX0 the same thing as TX and RX? Will there be a difference in the way I program it?

For example, do I treat RX1 and TX0 as RX and TX in the Arduino IDE when coding?

This is the chip I have. On the chip it says "ProMini R160JAC6v" and when I program it, it programs under 5V 16MHz with ATmega 328. Notice RST RX1 and TX0 are on the top left corner.


texts: Arduino wont start up and it wasnt succesfully booted in any time it was downloaded

texts:
I know the title sounds stupid but I never found a question like mine so I wanted to be specific because I downloaded the Arduino IDE to start my first project and I never managed to boot it because nothing happens when I try and I also tried every kind of thing to make it work I could think of. I reinstalled it, downloaded from another link like the zip version and also tried the windows repairtool. I also tried to boot it as admin several times but nothing changed anything. I did all of that yesterday and today when I started the Pc and retried I atleast saw something of a bootingscreen of the app so I thought I just had to restart but then it just went off again and the pain from yesterday began once again.

´´
I own windows 7 64 bit
´´
and tried every download except the one for windows 8.1 and 10

I saw a question about Arduino IDE not starting but this person atleast got any response from the program and the tipp they suggested with the folder in

´´
AppData/Lokal where you delete broken data to reinstall doesnt work too because the arduino folder doesnt even excist in the whole appdata section.
´´

´´
Windows repair tool said the program is not compatible, only in Windows xp (service pack 2) version but in compatibility mode nothing changes
´´

Ok thew this question is really long but I gave my best to explain everything I could about my problem so I really hope somebody could help me on my problem so I didnt waste my 45 Euro and time on tech stuff that I cant use

one thing to meantion I have left is that i bought my stuff from a teacher (Erik Verbene) on the internet

but that doesnt matter because it is your program that is not working so
yeah
hope somebody can help me out on this dilemma


texts: Optical mouse sensor M116504386 arduino libary

texts: I am doing project and I used optical mouse IC sensor M116504386 with 16 pins and I don't know how to get this sensor libraries to interface it with arduino uno.


texts: How to send an email via Arduino without an email account?

texts:
Assuming I have all the necessary hardware...
I want to develop a system where you type in an email address and the Arduino will send hourly updates on attached sensors to the provided email address.

I can only get this to work if I enter my email account's username and password and send the email from the authenticated account. There's tons of examples online of this. However, I want to share it with others and I do not want my email authentication to be accessible or be attached with sending the emails.
For example, I want the email to be from a generic service like email@web-mail.com that no one can sign into and not my personal email or a Gmail account I made for the project.

Anonymous email senders have the right method, but they require human interaction to bypass Captcha or similar.

Does anyone have an idea of how to do this? Or should I make a separate webserver that handles the requests made by the Arduino and send emails through a Gmail account I made for the project?


texts:
I am following this page (among others similar) about creating a portable Arduino IDE.
Though the steps are declared as easy...

Downloading the v.1.8.13 Windows ZIP file for non admin install,
Creating the portable folder,
Executing the arduino.exe file.

...I got stuck with this error:

This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted

I uninstalled v.1.8.13, then installed v.1.6.0, and never had any problems with JRE, until now.
What I am missing?


texts: Reading digital port with pullup via Firmata

texts:
I've got a weird issue, probably something I'm missing but have no clue what.

Got some simple float sensors connected to D2 - D5 on a Nano. Need internal pull-up to eliminate a floating value. Wrote this little sketch to test things:

pinMode(2, INPUT_PULLUP);
int sensorVal = digitalRead(2);
Serial.println(sensorVal);

pinMode(3, INPUT_PULLUP);
int sensorVal = digitalRead(3);
Serial.println(sensorVal);

There's one sensor connected reading HIGH and one reading LOW. This works as expected (displays 1010101010...).

Now I've got this connected to my Raspberry Pi via Bluetooth (BT shield connected to RX/TX) and using Firmata to communicate with the Nano. Code (C#):

_arduino.pinMode(2, PinMode.PULLUP);
PinState result2 = _arduino.digitalRead(2);

_arduino.pinMode(3, PinMode.PULLUP);
PinState result3 = _arduino.digitalRead(3);

Debug.WriteLine($"Result pin 2: {result2} and pin 3: {result3}");

This always gives me two pinstates of LOW, even though I'm absolutely sure it should be reading HIGH as my test sketch is outputting the correct value. This driving me nuts. The Firmata sketch I've got loaded on the Arduino is this one: https://github.com/jsiegmund/submerged/blob/master/src/Arduino%20Sketches/SubmergedCabinetModule/SubmergedCabinetModule.ino. Also tried the latest available version from the firmata repo, doesn't solve the issue. As I've got the BlueTooth shield connected to RX/TX (and wasn't able to change that) I cannot use the serial monitor to provide more debug info. Should anyone know how to change that, would also be appreciated.

Btw for other things, Firmata is working just fine. So the communication itself shouldn't be the issue I think.


texts: Sparkfun Can-Bus Shield example not working

texts: I recently bought a Sparkfun Can-Bus Shield, and tried the SparkFun_CAN_Demo from here but the program only prints "CAN-Bus Demo" and then does nothing, even when I have it connected into my vehicle's OBD-II port and the key is turned to ON (I can't run the engine because I am in my garage). Any help will be appreciated.


texts: Issues controlling a 10,1 capacitive panel with Arduino

texts:
Some days ago I had the inestimable help of hcheung in this forum to help me find some libraries on github to control a capacitive panel with a HT5xx6 controller. The libraries and code are here.

I have copied and created the libraries into a.h and .cpp files and placed where arduino IDE can find them and run the sketch. The startup works fine, meaning the panel is initialized.

However it doesn't give reliable data. Any time you touch the panel in a specific location it does not give a single set of coordinates, it sometimes give 2 or 3 set of coordinates and most of the time 15. This is as if the panel would detect 15 touches!

Even more issues: the coordinates are never the same in one fixed location. So the data is not reliable and I don't know what I am doing wrong.

Has anybody gone through this experience before?

Thanks for your help in advance!

Take care.

Joan.


texts: HLW8032 UART sends random data ( Registers Overflow often)

texts:
I designed  my own version of smart socket just like the Sonoff with power metering chip HLW8032. And when I read the data in ESP-12F the data doesn't have a fixed format.
To troubleshoot the issue, I bought HLW8032 Breakout Board and analyzed the data sent by HLW8032, and I found the results are the same as the board I designed.

And that made me think that I may be reading the data from the Serial port the wrong way.

HLW8032 sends 24 Bytes on the serial and the format should be like this:

F2 5A 02 DA 78 07 1A E0 00 3D 3B 03 EC F5 4C C4 58 9C 2A 39 61 00 00 79
F2 5A 02 DA 78 07 1A E0 00 3D 3B 03 EC F5 4C C4 58 9D C2 9F 61 00 00 78

The data that I receive is in this format,

F2 5A 2 D3 70 6 BC D4 0 3D 4F 4 98 B4 4D F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 FB EC 17 61 0 1 38 0 3D 4F 4 98 B4 4D E1 80
FD 84 7D 61 0 1 38 F2 5A 2 D3 70 6 AA 59 F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 FE FF 1 61 0 1 38 2 D3 70 6 AA 59 0 3D 4F
4 98 B4 4D E1 80 FE FF 1 61 0 1 38 F2 5A 1 61 0 1 38 F2 5A 2 D3
70 6 AA 59 0 3D 4F 4 98 B4 4D E1 80 FE FF F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 FE FF 1 61 0 1 38 0 3D 4F 4 98 B4 4D E1 80
FE FF 1 61 0 1 38 F2 5A 2 D3 70 6 AA 59 38 F2 5A 2 D3 70 6 AA 59
0 3D 4F 4 98 B4 4D E1 80 FE FF 1 61 0 1 F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 FE FF 1 61 0 1 38 4F 4 98 B4 4D E1 80 10 1B
D4 61 0 1 39 F2 5A 2 D3 70 6 AA 59 0 3D F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 13 4E 9E 61 0 1 39 F2 5A 2 D3 70 6 AA 59 0
3D 4F 4 98 B4 4D E1 80 14 E8 3 61 0 1 39 E1 80 16 82 67 61 0 1 39
F2 5A 2 D3 70 6 AA 59 0 3D 4F 4 98 B4 4D F2 5A 2 D3 70 6 AA 59 0

We can see that the registers overflows again and again.
The code that I use to read the data is:

#include <SoftwareSerial.h>
#define BAUD_RATE 4800

SoftwareSerial swSer(13, 12);

void setup()
{
  Serial.begin(BAUD_RATE);
  swSer.begin(BAUD_RATE);
}

byte data[24];
void loop()
{
  if (swSer.available() > 0) {
    int a = swSer.readBytes(data, 24);
    yield();
  }

  // Display
  for (int i=0;i<24;i++)
  {
    Serial.print(data[i],HEX);
    Serial.print(" ");
  }
  Serial.println();
}

Schematic:

I feel that there is no issue in my hardware design, and the issue seems to be in the sketch.

What can be the possible problem with my setup?

How do I make the output of HLW8032 Stable with no overflow of registers?

Is there any library someone can recommend me to read the data from HLW8032 on SoftwareSerial?

Note: After some troubleshooting I found that delay() cause the problem to be more worse. And won't receive a stream of Bytes whose first byte , second nibble is F like F2, F4, as from the datasheet , first four bits are 1s by default.


texts: R307 Fingerprint Sensor working with more then 1000 fingerprints

texts:
I want to integrate fingerprint sensor in my project. For the instance I have shortlisted R307, which has capacity of 1000 fingerprints.But as project requirement is more then 1000 prints,so I will going to store print inside the host.
The procedure I understand by reading the datasheet for achieving project requirements is :

I will register the fingerprint by "GenImg".
I will download the template by "upchr"
Now whenever a fingerprint come I will follow the step 1 and step 2.
Then start some sort of matching algorithm that will match the recently downloaded template file with
the template file stored in database.

So below are the points for which I want your thoughts

Is the procedure I have written above is correct and optimized ?
Is matching algorithm is straight forward like just comparing or it is some sort of tricky ? How can
I implement that.Please suggest if some sort of library already exist.
The sensor stores the image in 256288 pixels and if I take this file to host
at maximum data rate it takes ~5(256288*8/115200) seconds. which seems very
large.

Thanks
Abhishek
PS: I just mentioned "HOST" from which I going to connect sensor, it can be Arduino/Pi or any other compute device depends on how much computing require for this task, I will select.


texts: Speed data logging using arduino and GPS module

texts:
I am using a Quectel L80-R GPS Module coupled with an Arduino UNO to read and log my car's coordinates and speed. I am currently using TinyGPS++ library which works okay. It does spell out coordinates and speed but with some inaccuracies and delays. After some literature review I realized that NeoGPS library might be a better option. I found a thread over stackexchange where a code block is provided written by slash-dev who most possibly is the writer of NeoGPS library. However, when I am trying to compile the code, I get the following error
'class gps_fix' has no member named 'lat' .I can not get rid of the issue even tough I've tried a whole bunch of workarounds.


texts:
Is it impossible to send a file post request from the ESP32 using the SPIFFS file system? ESP32 freezes while sending.

Code example:

File file = SPIFFS.open("/Images/test.bmp", FILE_READ);

String start_request = ""; String end_request = "";
start_request = start_request +
                "\n--AaB03x\n" +
                "Content-Disposition: form-data; name=\"userfile\"; filename=\"CAM.bmp\"\n" +
                "Content-Transfer-Encoding: binary\n\n";
end_request = end_request + "\n--AaB03x--\n";
uint16_t full_length;
full_length = start_request.length() + file.size() + end_request.length();

WiFiClient client;
if (!client.connect("server_name", 80)) {
  Serial.println("Connected FILED!");
  return;
}

Serial.println("Connected ok!");
client.println("POST /Home/Index HTTP/1.1");
client.println("Host: example.com");
client.println("User-Agent: ESP32");
client.println("Content-Type: multipart/form-data; boundary=AaB03x");
client.print("Content-Length: "); client.println(full_length);
client.print(start_request);

while (file.available()){
  client.write(file.read());
}

Serial.println(">>><<<");
client.println(end_request);


texts: Is there a library to use Amazon IoT services on any Arduino?

texts: I started to work with AWS IoT today, which offers a MQTT based connection to their web service. They officially only have a demo for the Arduino Yún, which is rather expensive. Has someone managed to get it running (e.g. with a NodeMCU with a ESP8266)?


texts: Corrupted characters with an OLED displaying thermocouple output

texts:
I'm super new to Arduinos but I'm learning as I go. I'm in the first stages of a small temperature control project and so far I've been able to display the output of a MAX31855 thermocouple breakout board on 124x64 spi OLED through my Arduino micro.

My problem is that the characters of the temperature are corrupted looking. As I think I understand it, the temperature is changing while it's being written to the display therefore you get overlapping values. I've attached an image of the display.

I've tried making the temp output an integer but that didn't work.

Any input would be greatly appreciated as I'm just banging my head against the wall.

Here's my code:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_MAX31855.h>
#include <U8glib.h>

//Constructor line for OLED

U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9, 8);  // D0=13, D1=11, CS=10, DC=9, Reset=8

// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:

// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXDO   3
#define MAXCS   4
#define MAXCLK  5

// initialize the Thermocouple
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);

// Example creating a thermocouple instance with hardware SPI
// on a given CS pin.
//#define MAXCS   10
//Adafruit_MAX31855 thermocouple(MAXCS);

void draw() {
  double c = thermocouple.readCelsius();
  u8g.setFont(u8g_font_profont29);  // select font
  u8g.setPrintPos(5, 45);  // set position
  u8g.print(c);  // display temperature from MAX31855

}

void setup(void) {

}

void loop() {

  // picture loop
  u8g.firstPage();
  do {

    draw();
  } while (u8g.nextPage());

  // rebuild the picture after some delay
  delay(5000);
}


texts: Timer function without the use of a library

texts:
Trying to do my own timer function. I was wondering if there is any other ways to make my code more efficient without the use of a library. I noticed if I only use one timer function, I wont have multiple instances of the timer. My current code works though.

unsigned long previousMillis1 = 0;
unsigned long currentMillis1 = millis();
unsigned long previousMillis2 = 0;
unsigned long currentMillis2 = millis();
unsigned long previousMillis3 = 0;
unsigned long currentMillis3 = millis();

bool timer1(int preset){
  unsigned long currentMillis1 = millis();

  if(currentMillis1 - previousMillis1 >= preset ){
    previousMillis1 = currentMillis1;
    return true;
  }
  else{
    return false;
  }
}

bool timer2(int preset){
  unsigned long currentMillis2 = millis();

  if(currentMillis2 - previousMillis2 >= preset ){
    previousMillis2 = currentMillis2;
    return true;
  }
  else{
    return false;
  }
}

bool timer3(int preset){
  unsigned long currentMillis3 = millis();

  if(currentMillis3 - previousMillis3 >= preset ){
    previousMillis3 = currentMillis3;
    return true;
  }
  else{
    return false;
  }
}

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

void loop() {
  if(timer1(1000)){Serial.println(1);}
  if(timer2(2000)){Serial.println(2);}
  if(timer3(3000)){Serial.println(3);}
}


texts: I have an Arduino Pro micro and I need to know if it is possible to use an USB device like a camera or things like that Since the processor is a 32U4. the USB Shield is for the Arduino Uno and I don't want to buy more stuff.


texts:
Arduino: 1.8.9 Hourly Build 2019/02/04 10:12 (Mac OS X), Board: "Arduino/Genuino Uno"

Sketch uses 2078 bytes (6%) of program storage space. Maximum is 32256 bytes.
Global variables use 189 bytes (9%) of dynamic memory, leaving 1859 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Problem uploading to board.  See


texts: IR sensor not detecting light or dark sufaces

texts:
I wrote code for the vibrating motors to vibrate when an IR sensor detects a darker surface. I have 4 vibration motors for corresponding 4 IR sensors. My program is not able to read the values from the sensor. In the serial monitor the values that are read from the sensor is a huge non stopping value. None of my IR sensors is detecting the surface. As a result no vibrations are produced. I am using Arduino Pro Mini and my code is:

#include <EEPROM.h>
// pin numbers
const int irLED = 7; // wire connected to transistor/220 ohm resistor (all on same pin)
const int collectors[] = {A0,A1,A2,A3}; // (with pullup resistors)
const int vibrations[] = {3,5,6,9}; // vibration motors

// thresholds for each finger
int detectionThreshold[] = {940,960,970,975};
int whiteThreshold[] = {600,600,600,600};

// timers (in milliseconds)
int lastVibration[] = {0,0,0,0};
const int numFingers = 4;
int readings[] = {1023, 1023, 1023, 1023, 1023, 1023};
boolean vibrating[] = {false, false, false, false};

void blackLoop()
{
  int now = millis();

  // get the current readings
  for(int i = 0; i < numFingers; i++)
  {
    readings[i] = analogRead(collectors[i]);
    Serial.print(readings[i]);
  }

  // vibrate on black, with minimum vibration time
  for(int i = 0; i < numFingers; i++)
  {
    if(readings[i]<=detectionThreshold && readings[i] >= whiteThreshold[i])
    { Serial.print(readings[i]);
      digitalWrite(vibrations[i], HIGH);
      vibrating[i] = true;
      lastVibration[i] = now;
    }
    else // if(now - lastVibration[i] > vibrationDuration)
    {
      digitalWrite(vibrations[i], LOW);
      vibrating[i] = false;
    }
  }
}
void setup()
{
  // put your setup code here, to run once:
  for(int i=0; i<numFingers; i++)
  {
    digitalWrite(collectors[i], HIGH);  // set pullup
    pinMode(vibrations[i], OUTPUT);
  }

   pinMode(irLED, OUTPUT);
   digitalWrite(irLED, HIGH);
   Serial.begin(9600);
   Serial.println("my sketch has started");

}

void loop()
{
  // put your main code here, to run repeatedly:
  blackLoop();

}


texts: NEO 6M data is not working properly with uno

texts:
I am using a arduino uno and neo 6m gps module. The problem I am facing is quite weird. When I connected the setup the data from neo6M was seen in serial monitor, I even printed it on a Oled display. It was a close room at night. I used tiny gps plus plus library to parse the data. I got both latitude longitude. After disconnected the circuit i tried again and that is when nothing came out in serial monitor. The same sketch did not work for a day. But again at afternoon at some point i got the data properly.
Sometimes the red led is blinking but nothing happens.
While I change the rx and tx pins in software serial it got data but then again same problem and changing pins don't work. I have tested it in front of my window so there must be a good signal.
Can someone tell me what is wrong with the system? I have so far waited long enough like 10 mins to get the data but nothing. I have to present the project by tomorrow in office.
This is the code :
https://pastebin.com/TMRYXFNw


texts: pubsubclient won't compile in Arduino and VSCode IDEs

texts:
I've compiled successfully a year ago in Arduino IDE, but lately I'm getting fatal errors:

/Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp: At global scope:
/Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp:473:8: error: redefinition of 'size_t PubSubClient::write(uint8_t)'
size_t PubSubClient::write(uint8_t data) {
^

In file included from /Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp:7:0:
/Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.h:160:19: error: 'virtual size_t PubSubClient::write(uint8_t)' previously defined here
virtual size_t write(uint8_t) {};
^

I've tried using VSCode. I've tried opening an issue on GitHub.

Thanks for any thoughts.


texts: Can anyone suggest me a software timer library that does not use polling but timer ISR instead?

texts:
There are many software timer libraries available in Arduino.
A library called SimpleTimer http://playground.arduino.cc/Code/SimpleTimer is really good with many functions, but it uses polling.
If anyone is familiar with a really good library that uses Timer ISR of Atmega instead of polling, please suggest me as i am using ultrasonic sensors and i can't afford polling.


texts: SPI Arduino Due conflict with pinMode(), bug?

texts:
Consider the following minimal example, where I set pinMode before calling SPI functions:

#include <SPI.h>

void setup() {
  pinMode(10, OUTPUT);
  SPI.begin(10);
  SPI.setDataMode(10,SPI_MODE1);
}

void loop() {
  delay(1000);
  SPI.transfer(10,1);
}

Now when SPI.transfer(10,1) is called in loop(), I always see that the slave selected pin goes down to 1.65V, but not 0 as it should! (see image below)

If we don't call pinMode(), like this:

#include <SPI.h>

void setup() {
  SPI.begin(10);
  SPI.setDataMode(10,SPI_MODE1);
}

void loop() {
  delay(1000);
  SPI.transfer(10,1);
}

We get what we would expect when calling SPI.transfer:

Is that a bug or do you have an explanation for that behaviour?

Thank you very much in advance for your time and interest!


texts: Parsing sd card file to polymorphic objects

texts:
I am trying to read a file from sd card and parse them to polymorphic objects, then have an array of pointers to them so i can access them later.

I was wondering what the best format would be to save these objects in, i was looking at https://github.com/bblanchon/ArduinoJson but i don't know if it's possible to deserialize them to the right object.

Is this even possible?


texts: Can I stack an Arduino to another Arduino?

texts:
I'm using Arduino clones, which have pin headers the same as Arduino's shields have (with extended "legs" below the board to be stackable).

Can I stack my Arduino (Mega) clone to an Arduino (Uno) clone without destroying both? Wouldn't it explode or something?

Just asking before trying it.

Thanks!


texts:
I have been reading a bit about the internal pullup resistor. I know from past projects in school that resistor themselves are fragile (burnt one by accident due to higher current than was made for).

I have two different Arduino models. One by Intel and rest are standard Arduino Uno.

So I was wondering about safely using the internal pullup resistor on the Arduino Uno. Hence my question is about the internal pullup resistor pinmode; How many pin can you connect to it safely and not overload it?


texts:
I am using a led strip WS2812b, an ESP8266 (NodeMCU 1.0) and a gesture sensor APDS9960.
I want that when I move my hand from left to right and from right to left I change the colors of the strip of leds, previously saved in an array of strings:

const char * colors [11] = {"CRGB :: White",
"CRGB :: WhiteSmoke",
"CRGB :: CadetBlue",
"CRGB :: SteelBlue",
"CRGB :: Teal",
"CRGB :: SlateGray" ,
"CRGB :: MediumPurple",
"CRGB :: Purple",
"CRGB :: PapayaWhip",
"CRGB :: LightPink",
"CRGB :: Crimson"};

But when I'm going to turn on the colors using the functions of the FastLed library in this way:

for (int i = 0; i <NUM_LEDS; i = i + 1) {
       leds [i] = colors [2];
       FastLED.show ();
       delay (10);}

All I get is this error:

  invalid conversion from 'const char *' to 'uint32_t {aka unsigned
  int}' [-fpermissive]

I guess the problem is me when declaring the array, could someone help me?


texts: What sensors do I need to detect magnetic "take off"?

texts:
I want to build a sensor using arduino (or any other esp) measuring the release of a leg on a floor panel. I've build a prototype using copper plates and a BBC Micro:bit, which works fairly well. But I want to use magnetic sensors, determining release of the leg.
My education on magnetic is - simple. I know it exists. I know it's one of four basic forces in nature (ha!). But I don't know how to measure it using electronic circuits (I'm new to this topic).
Imagine one person stands on a plate, wearing magnets on his foot (say "magnetic socks"). I want to immediately detect when the person raises his leg. What kind of sensors do I need?


texts: How do I convert code between Arduino platforms?

texts:
What documentation is available regarding the differences between the different Arduino platforms?

For example, I have some code written for an Arduino Teensy that I would like to run on an Arduino Mega.

Is there documentation on the capabilities and equivalencies between each of the platforms?  e.g. memory, number of PWM outputs, etc?


texts: Arduino with interrupts enters in a locking state

texts:
I am quite noobish with using the interrupts on Arduino and I am facing a strange problem. I am using an Arduino Pro Mini, a light sensor and an RTC module(DS3231) which has set 2 alarms, one at sunrise and one at the sunset. Each time the DST triggers the alarm, the interrupt routine (here onAlarm()) blocks the state of Arduino and nothing happens form there. Is there anything wrong with the code I write?
The code bellow is a little bit simplified, I just let the method calls, not the whole declarations of them.
#include <avr/sleep.h>//this AVR library contains the methods that controls the sleep modes
#include <avr/power.h>
#include <DS3232RTC.h>  //RTC Library https://github.com/JChristensen/DS3232RTC

#define ldrInterruptPin  2
#define DS2331interruptPin 3

void setup() {

  Serial.begin(9600);//Start Serial Comunication
  Wire.begin();

  //_____________________setup DS3231 interrupts_________
  pinMode(DS2331interruptPin, INPUT_PULLUP);
  digitalWrite(DS2331interruptPin, HIGH);
  attachInterrupt(digitalPinToInterrupt(DS2331interruptPin), onAlarm, FALLING);

  //_____________________setup LD235R interrupts_________
  pinMode(ldrInterruptPin, INPUT);
  digitalWrite(ldrInterruptPin, HIGH);
  attachInterrupt(digitalPinToInterrupt(ldrInterruptPin), irq1, RISING);

  resetDS3231Alarms();

  time_t t = RTC.get();
  setUpAlarms();
}

void loop() {
 //read the light sensor vlaues
}

Adn this is the onAlarm function:
  void onAlarm() {
  Serial.println("ALARM");
  formatTime(timestamp, RTC.get());
  if (RTC.alarm(ALARM_1))
  {
    Serial << F("SLEEP alarm at ") << timestamp << endl;
    goToSleep();
  }
  else if (RTC.alarm(ALARM_2))
  {
    Serial << F("WakeUP Alarm at ") << timestamp << endl;

    Serial.println("Time to Wake up......!");
    sleep_disable();
    Serial.println("I woke up!!!");
    attachInterrupt(digitalPinToInterrupt(ldrInterruptPin), irq1, RISING);
  }
  //update the sleep and wakeup times based on curreent day
  setUpAlarms();
};

resetAlarms()
void resetDS3231Alarms() {
  // initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
  RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
  RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
  RTC.alarm(ALARM_1);
  RTC.alarm(ALARM_2);
  RTC.alarmInterrupt(ALARM_1, false);
  RTC.alarmInterrupt(ALARM_2, false);
  RTC.squareWave(SQWAVE_NONE);
}

Every time an alarm occurs, the code blocks and outputs exactly what is in the serial monitor capture bellow:
It just prints "AL" form the Serial.println("ALARM"); and nothing happens from there

Does anyone know what causes this issue and how can it be solved?


texts: Distributing power evenly to multiple pins

texts: It's an arduino board, model UNO R3. I have 3 5cmx10cm heating pad power required 5V DC up to 1A and can withstand up to 12V DC. These 3 heating pad are wired up onto arduino board with red wires connected to pin 8 pin 9 and pin 10 on the digital side of the arduino and the black wire connected to GND (ground). Lastly I have a toggle on and off switch connected to the arduino with the red wire attached to digital pin 2 and the black wire to 5V. The arduino uno R3 withstand 20voltage and the 5V heating pads can withstand 12V. I would like my 20V external power to heat up all 3 heating pads evenly, how can I do this? Is it possible? Thank you!


texts: Trying to explain strange behavior when attempting to do a digitalWrite to A7 on a pro mini?

texts:
I found out the hard way today that pins A6 and A7 can't be used as digital outputs, but what actually happens when you try to read/write them?

Some backstory: I soldered some headers onto a pro mini and I wanted to test all the pins to make sure they worked.  I wrote a test program that looped through all the digital pins once a second and toggled their state by doing digitalWrite(pin, !digitalRead(pin);.  I then added a second loop that went through pins A0 through A7 and toggled them using the same method.  After adding this loop the built in LED on pin 13 no longer toggled on and off every second.  Instead, it would just flicker on very briefly.  At first I assumed there was something wrong with my loops (like an off by one) that was causing the strange issue, so I completely rewrote things to use a single loop that iterated over all the pins.  The resulting code should have been effectively equivalent to the original code, but now pin 13's LED was toggling properly again.

After much experimenting, I was able to whittle it down to the following test program to demonstrate the strangeness:

#define WORKS_CORRECTLY 1

int pins[] = {13, A7};
#define SIZE (sizeof(pins) / sizeof(int))

void setup()
{
#if WORKS_CORRECTLY
    for(int i = 0; i < SIZE; i++)
        pinMode(pins[i], OUTPUT);
#else
        pinMode(pins[0], OUTPUT);
        pinMode(pins[1], OUTPUT);
#endif
}

void loop()
{
    for(int i = 0; i < SIZE; i++)
    {
        int pin = pins[i];
        int pinVal = digitalRead(pin);
        digitalWrite(pin, !pinVal);
    }

    delay(1000);
}

With WORKS_CORRECTLY defined as 1 the LED on pin 13 toggles state every second like one would expect.  With it defined as 0, however, it just flickers on very briefly every second.  This is very perplexing.

Ultimately the answer is to not try to do a digitalWrite to A7 (or A6), but I'd like to understand why the behavior changes based on seemingly irrelevant differences.


texts:
I am building a positioner and I store the current position to EEPROM when the move is complete. On start up, I want the positioner to return to the HOME position. I am running an UNO powered from the USB.
My problem is that if the Arduino is turned off, I would like to stop the move and store the current position before the Arduino dies.

Note that this would also be relevant to devices like thermostats which remember the set point through a power outage.

POSSIBLE SOLUTIONS

Store position in EEPROM at each step. No, that will wear out the EEPROM.
Connect a large capacitor from +5V to Gnd. When this falls below a set level, trigger an interrupt (ISR) that stops motion and stores current position in EEPROM.

QUESTIONS

Will #2 work, and how could I program it?
Any other ideas I am missing?


texts:
I'm new here, trying to learn Arduino by hacking, that is plugging stuff in, looking for code and then trying to understand it bit by bit so I can move on to bigger and better projects.

My issue is that I am getting a periodic readout of -999.0 from a 3 pin DHT11 temperature and humidity sensor in between actual readouts. I can't find anything online explaining this but maybe I haven't looked hard enough. Attached is a screenshot containing both the code and serial monitor readout. Mechanical engineering background, so no electronic knowledge but feel free to get techy with your response.

if the image doesn't load this is the code;

#include <dht.h>

dht DHT;

#define DHT11_PIN 7

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

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  constrain (DHT.temperature, -25, 70);
  constrain (DHT.humidity, 0, 90);

  if((DHT.temperature || DHT.humidity) > -25)
  {
  Serial.print("Temperature, Humidity = ");
  Serial.print(DHT.temperature);
  Serial.print(", ");
  Serial.println(DHT.humidity);
  delay(1000);
  }
}

Thanks in advance for help or direction to help.


texts: Conflicting pins between the PCM library and speaker and the NRF24L01

texts:
The PCM library uses pin 11 and the NRF24L01 also uses pin 11. I am using an Arduino nano, and don't know if there is any way to change the pins of either the speaker or the transceiver.
https://github.com/damellis/PCM


texts: What's the most accurate way to time-stamp analogRead data?

texts:
I want to sample an Analog sensor as fast as possible, and time-stamp each sample that I take as accurately as possible.

Currently, I'm doing the following:

val = analogRead(SENSOR_PIN);
clocktime = micros();

writeData(val, clocktime); // writes the values to an SD card

I'm wondering if there is a more-accurate way of time-stamping the data from the analogRead call. Put another way, I would like to record the exact time that the analogRead data was collected. My guess is that this is basically impossible on an Arduino, so what technique will let me get as close as possible?


texts: Optimizing Teensy 3.6 for data sampling?

texts:
So, I have a very basic project where I cycle through 8 IR individual transmitters. After setting the individual transmitter high, I cycle through all 8 IR receivers and print their values, RX_CYCLES many times. I need a huge amount, quality data from these loops to train a neural net, so
I want to optimize my code to where I can analogRead each receiver the fastest, but keep the maximum resolution possible.

I'm having trouble understanding Teensy's documentation and provided libraries and finding any relevant resources that are clear enough for me to weave through the jargon.

My questions are:

What would be or how do I go about calculating the optimization or balance of the fastest baudrate I can match with the Teensy 3.6, with the highest quality resolution possible?
How to optimize analogRead? I've read that the fastest way is to use continuous analogRead instead of single analogRead? I'm having trouble finding clear examples of what this actually does and how to use it effectively. I definitely could be wrong about it this.
Am I outputting data the best way possible? I was wondering if there would be any reason in my case to use print() or println() or if I should be using flush() after every cycle

These are a lot of questions, and I don't expect anyone to optimize my code for me, so if you can help point me in the direction of clear material I can use to direct me in this problem.

I'd also really appreciate any other suggestions or insight anyone would like to offer that I may be missing.

This is my very basic code:

const uint8_t RX_CYCLES = 1;
const uint8_t RX_START = 14, RX_END = 21;
const uint8_t TX_START = 0, TX_END = 7;

void setup() {
    Serial.begin(115200);
    while (!Serial);
    for (uint8_t reciever = RX_START; reciever <= RX_END; reciever++) pinMode(reciever, INPUT);
    for (uint8_t transmitter = TX_START; transmitter <= TX_END; transmitter++) pinMode(transmitter, OUTPUT);
}

void loop() {
    for (uint8_t transmitter = TX_START; transmitter <= TX_END; transmitter++) {
        digitalWriteFast(transmitter, HIGH);
        for (uint8_t i = 0; i < RX_CYCLES; i++) {
            for (uint8_t reciever = RX_START; reciever <= RX_END; reciever++) Serial.println(analogRead(reciever));
        }
        digitalWriteFast(transmitter, LOW);
    }
}


texts: Arduino GSM shield GSM_READY not ready ever

texts:
I am using an Arduino Mega and an Arduino GSM shield. I am using the receive SMS example under GSM in the Arduino IDE. My GSM shield's hardware IP is set correctly.

Here is the sketch:

/*
 SMS receiver

 This sketch, for the Arduino GSM shield, waits for a SMS message
 and displays it through the Serial port.

 Circuit:
 * GSM shield attached to and Arduino
 * SIM card that can receive SMS messages

 created 25 Feb 2012
 by Javier Zorzano / TD

 This example is in the public domain.

 http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS

*/

// include the GSM library
#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

// Array to hold the number a SMS is retreived from
char senderNumber[20];

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("SMS Messages Receiver");

  // connection state
  boolean notConnected = true;

  // Start GSM connection
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
      notConnected = false;
    else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}

void loop() {
  char c;

  // If there are any SMSs available()
  if (sms.available()) {
    Serial.println("Message received from:");
    // Get remote number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);
    // An example of message disposal
    // Any messages starting with # should be discarded
    if (sms.peek() == '#') {
      Serial.println("Discarded SMS");
      sms.flush();
    }

    // Read message bytes and print them
    while (c = sms.read())
      Serial.print(c);
    Serial.println("\nEND OF MESSAGE");

    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }
  delay(1000);
}

The issue is this line:

if (gsmAccess.begin(PINNUMBER) == GSM_READY)

The serial monitor outputs everything until that line.

It just never gets past it, so I assume it cannot connect? The SIM has no pin code: I have tried it with my phone. The SIM has full signal strength when in my phone. I have tried my other SIM card also but the same thing happens.

This seem to be the same question, yet no answer:
http://forum.arduino.cc/index.php?topic=270551.0


texts:
I am trying to plot my counter vs. time on the serial plotter, but the values on the y axis are so big there is no way that it's displaying the counter values.
I have printed both values:

  Serial.print("counter: ");
  Serial.println(counter);
  time = millis();
  Serial.print("Time: ");
  Serial.println(time);

I expected time to show up in the x-axis, but I think it's displaying on the y-axis and I'm not sure how to change this.
The plot should just be an increasing line as the counter and time get bigger...
what am I missing?
Thanks.

Slashing out the Serial.print("Time:") does not correct anything.


texts: How do you count objects (using ultrasonic sensor HCSR04) as 1, after they leave the trigger/echo path?

texts:
I found a simple code online that meets my goal to almost 100%, however when I place my hand in front of it, the number continues to count. I am trying to only count "1" when the solid object has moved from initial view of the sensor, to ending view.
#define trigPin 13
#define echoPin 12
int counter = 0;
int currentState = 0;
int previousState = 0;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 if (distance <= 10){
 currentState = 1;
 }
 else {


texts:
The initialization of the ToF fails with this code. I'm trying to frankenstein it with Radiohead RFM69, so far no luck.

// rf69_reliable_datagram_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RHReliableDatagram class, using the RH_RF69 driver to control a RF69 radio.
// It is designed to work with the other example rf69_reliable_datagram_server
// Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
// Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
// Tested on Teensy 3.1 with RF69 on PJRC breakout board

#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>

#include "Seeed_vl53l0x.h"
Seeed_vl53l0x VL53L0X;

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF69 driver;
//RH_RF69 driver(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
//RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

void setup()
{
  VL53L0X_Error Status = VL53L0X_ERROR_NONE;
  Serial.begin(115200);
  if (!manager.init())
    Serial.println(F("init failed"));

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM

  // If you are using a high power RF69, you *must* set a Tx power in the
  // range 14 to 20 like this:
  // driver.setTxPower(14);

  Status = VL53L0X.VL53L0X_common_init();
  if (VL53L0X_ERROR_NONE != Status) {
    Serial.println(F("start vl53l0x mesurement failed!"));
    VL53L0X.print_pal_error(Status);
    while (1);
  }

  VL53L0X.VL53L0X_long_distance_ranging_init();

  if (VL53L0X_ERROR_NONE != Status) {
    Serial.println(F("start vl53l0x mesurement failed!"));
    VL53L0X.print_pal_error(Status);
    while (1);
  }

}

unsigned int findDistance() {
  VL53L0X_RangingMeasurementData_t RangingMeasurementData;
  VL53L0X_Error Status = VL53L0X_ERROR_NONE;

  memset(&RangingMeasurementData, 0, sizeof(VL53L0X_RangingMeasurementData_t));
  Status = VL53L0X.PerformSingleRangingMeasurement(&RangingMeasurementData);
  if (VL53L0X_ERROR_NONE == Status) {
    if (RangingMeasurementData.RangeMilliMeter >= 2000) {
      Serial.println(F("out of range!!"));
    } else {
      //Serial.print("Measured distance:");
      //Serial.print(RangingMeasurementData.RangeMilliMeter);
      //Serial.println(" mm");
      return RangingMeasurementData.RangeMilliMeter;
    }
  } else {
    Serial.print(F("mesurement failed !! Status code ="));
    Serial.println(Status);
    return 0;
  }
}

uint8_t data[] = "Hello..there";
// Dont put this in the stack:
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];

void loop()
{
  //Serial.println("Sending to rf69_reliable_datagram_server");

  // Send a message to manager_server
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    // Now wait for a reply from the server
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print(F("got reply from : 0x"));
      Serial.print(from, HEX);
      Serial.print(F(": "));
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println(F("No reply, is rf69_reliable_datagram_server running?"));
    }
  }
  else
    Serial.println(F("sendtoWait failed"));
  delay(500);
}


texts: Need to filter low voltage from a piezo buzzer circuit

texts:
I have a 6-28VDC piezo buzzer I'm using at 24VDC. The line has 3-4 VDC when the output is off, which has a soft but annoying buzzer constantly.  What the the easiest way to filter that out so I only get buzzing when the output is activated?
I tried using resisters which works, but then decreases the overall sound level (of course)


texts: ESP01 wont boot when connected to the led strip

texts:
have a wierd bug behavior..
i have an ATX power supply witch powers an long WS2812B 5v strip witch is controlled by the https://www.aliexpress.com/item/4000766948879.html Esp 01 and the board...
NOW the bug happens only when i connect the data pin to the strip. The ESP wont start after i restart the ATX PSU. And if it does it just crashes after some time....
Here is the SPOOKY part: when i start the esp WITHOUT the pin connected and plug it in after it starts it will keeep working for days... but sometimes it just decides it will go bananas... W T F! any ideas why?????
i suspected voltage drops.. but nope. i tried a battery, a second adapter and a usb power... none helped. same behavior as soon you connect the strip and hit restart/update it goes bananas...


texts:
I'm trying to make an LED go from no brightness to max and back down on a loop and I've encountered a problem I can't seem to crack. The LED will go to maximum brightness steadily as it should but then it will drop to zero brightness and start again... Why?

int blue_led=10;

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

void loop() {

  int voltage=0;

  for(int i=0;i<=255;i+1){

    analogWrite(blue_led,voltage);
    voltage=voltage+1;
    delay(8);
  }
   int volts=255;

   for(int i=0;i<=255;i+1){

    analogWrite(blue_led,volts);
    volts=volts-1;
    delay(8);
   }

}