texts: How is the bootloader activated when device is running?

texts:
For the sake of specificity I am referencing my question to Arduino. It applies to all AVRs with hardware USB and a bootloader though.

The bootloader is capable of receiving new program data over the USB interface, and, after programming, releases the interface. It can then for instance be used for the emulation of a serial port, or even register as a HID.

I know what a bootloader is and how it reads program data from the PC and how it writes it to the devices flash memory.

I am asking how the bootloader is triggered again if the user wants to upload a new program. The PC needs to reset the AVR in order to fire up the bootloader. How is this reset instruction implemented in Arduinos with built-in USB hardware (e.g. the Arduino Micro)? Is it solved by performing a software reset after the DTR line goes low just as in e.g. the Arduino Nano, except that the DTR line only exists in software?

EDIT: If that is the case, the solution is unique to Arduinos. I was thinking that there would be some standard way of doing it common to all AVRs.


texts: A4988 stepper motor driver, arduino UNO and Haydon linear actuator

texts:
I bought a Haydon LC1574W linear actuator for a small project I'm working on. I have an A4988 Pololu stepper motor driver, is it possible to control the Haydon linear actuator using this stepper motor driver?

So far I have connected the stepper driver as explained in this article: http://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/
I used the arduino 5v and GND to power the board as well as motor power.

However when I measure the voltage at the 2B,2A,1A,1B pins of the stepper motor driver they seem to be constant at 5.5V without the motor attached. I would expect these outputs to alternate and not all be at 5.5v.  Is this normal?


texts:
Anyone help? It shows incorrect time. Please help.

  /* Conexion pines
     Arduino        GPS
        D3           RX
        D4           TX
  */

  #include <SoftwareSerial.h>  //incluimos SoftwareSerial
  #include <TinyGPS.h>         //incluimos TinyGPS

  TinyGPS gps;  //Declaramos el objeto GPS
  SoftwareSerial serialgps(10,11);      //Declaramos el pin 4 (Tx del GPS) y 3 (Rx del GPS)

  //Declaramos la variables para la obtención de datos
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long chars;
  unsigned short sentences, failed_checksum;

  void setup()
  {
   Serial.begin(9600);  //Iniciamos el puerto serie
   serialgps.begin(9600); //Iniciamos el puerto serie del gps

   //Imprimimos en el monitor serial:
   Serial.println("");

  }

  void loop()
  {
   while(serialgps.available())
   {
    int c = serialgps.read();
    if(gps.encode(c))
    {
     float latitude, longitude;
     gps.f_get_position(&latitude, &longitude);
     Serial.print("Latitud/Longitud: ");
     Serial.print(latitude,5);
     Serial.print(", ");
     Serial.println(longitude,5);
     gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
     Serial.print("Date: "); Serial.print(day, DEC); Serial.print("/");
     Serial.print(month, DEC); Serial.print("/"); Serial.print(year);
     Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":");
     Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC);
     Serial.print("."); Serial.println(hundredths, DEC);
     Serial.print("Altitud (metros): "); Serial.println(gps.f_altitude());
     Serial.print("Rumbo (grados): "); Serial.println(gps.f_course());
     Serial.print("Velocidad(kmph): "); Serial.println(gps.f_speed_kmph());
     Serial.print("Satelites: "); Serial.println(gps.satellites());
     Serial.println();
     gps.stats(&chars, &sentences, &failed_checksum);

     delay(10000);
    }
   }
  }


texts: Directly connect Arduino to Macbook over Ethernet

texts:
I am trying to connect my Arduino to my MacBook over ethernet via a thunderbolt-ethernet dongle. However, I am unable to access my Arduino over Ethernet. The problem is very similar to one mentioned in https://forum.arduino.cc/index.php?topic=475101.0 but for some reason, I am unable to debug it.

I have manually set up the Ethernet on Mac where IP address is 192.168.1.2 and Subnet Mask is 255.255.255.0. I tried accessing Arduino both - by disabling and enabling the WiFi - but it is not working. Please help.

Here is my Arduino code -

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0x40, 0x6C, 0x8F, 0x39, 0x45, 0xDD
};
IPAddress ip(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

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

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, subnet);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");
          }
          client.println("");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}


texts: Need help converting a processing sketch for a robot arm with servo shield

texts:
I'm currently building a robotic arm. I'm using an Adafruit servo shield, 7 servos, Arduino uno, and a 5V 10A power supply.

I found a program that controls the arm with mouse movement using a processing sketch, Fixbot.

However I'm using the Adafruit servo shield, and I've got no clue how to convert the program. I've found the center points for the servos, so I've managed to make the robot stand upright using my own code.

If someone could give me some pointers as to how to convert from the on-board PWM outputs to the servo shield outputs for the linked program, and how to set servo max/min, I would highly appreciate it.


texts:
I have an Arduino Mega 2560 with a cc3000 Wifi shield that is sending messages to dweet.io. Here is the relevant portion of my code:

// Post data to dweetio
    char data[125];
    sprintf(data, "?t1=%i&t2=%i&t3=%i&t4=%i&t5=%i&t6=%i&t7=%i&t8=%i&t9=%i&t10=%i&t11=%i&t12=%i&t13=%i&p=%i",
            (int)(t1*10.),(int)(t2*10.),(int)(t3*10.),(int)(t4*10.),(int)(t5*10.),
            (int)(t6*10.),(int)(t7*10.),(int)(t8*10.),(int)(t9*10.),(int)(t10*10.),
            (int)(t11*10.),(int)(t12*10.),(int)(t13*10.)),(int)(0);
    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);
    if (client.connected()) {
      client.fastrprint(F("GET "));
      client.fastrprint(F("/dweet/for/blahblah"));
      client.fastrprint(data);
      client.fastrprint(F(" HTTP/1.1\r\n"));
      client.fastrprint(F("Host: https://www.dweet.io\r\n"));
      client.fastrprint(F("\r\n\r\n"));
      // client.println();
      // Serial.println(F("Sent dweet\n"));
    } else {
      Serial.println(F("Sending dweet failed"));
      return;
    }

/* Read data until either the connection is closed, or the idle timeout is reached. */
long lastRead = millis();
while (client.connected() && (millis() - lastRead < 1000)) {
  while (client.available()) {
    char c = client.read();
    Serial.print(c);
    lastRead = millis();
  }
}

client.close();
// Serial.println("Connection to dweet.io closed");

In addition to this code, the loop does about two seconds of data collection and setting outputs.

This works most of the time when I connect to a typical wireless router. However, I want to deploy it away from my wifi source so I got a T-Mobile hotspot. When I use the identical code with the hotspot, it only successfully sends the message about one out of ten tries (sporadically though, not on even intervals).

The code doesn't report any errors. Anyone have any suggestions on how to debug this?


texts: Connect the Sparkfun CAN bus shield with an RFduino

texts:
I have a problem which I am working on for some days now. I do have knowledge in electronics, but not extensively. I also posted this question in the RFduino Forum but couldn't get any good answers.

What I am trying to do: I want to connect the Sparkfun CAN bus shield to the RFduino. I am using the code further below. It compiles without problem and does work with my Arduino Leonardo!

I used a logic analyser (ignore the filled shapes, some display error) to further narrow down the problem and found the following on the RFduino:

On the Leonardo, it looks different:

It seems like I don't get a response on the MISO line! I played around with different speeds, but nothing seemed to work.

I do have a suspicion however: The RFduino works with 3.3V, while the Leonardo works with 5V. So the logic signals on the RFduino can only achieve 3.3V P-P. I confirmed this with my old CRO, LOW is at GND and HIGH at 3.3V. The Leonardo has 5V P-P.
On page 70 of the datasheet for the MCP2515 (the chip used on the shield), it says that the supply voltage VDD ranges from 2.7V to 5.5V. So supply voltage should be ok. V_INPUT_HIGH ranges from 2.31 to 4.3V. V_INPUT_LOW ranges from -0.3V to 0.495V. I am in this range! Similarly so for the V_OUTPUT_LOW (up to 0.6V) and V_OUTPUT_HIGH (at least 2.8V). Could this nevertheless be a problem?

What would you try or change?

MCP2515 Datasheet

#include <SPI.h>

// demo: CAN-BUS Shield, send data
#include <mcp_can.h>

MCP_CAN CAN0(SS);                                      // Set CS to pin 10

unsigned char stmp[8] = {0, 1, 0, 3, 0, 5, 0, 7};

void setup()
{
  Serial.begin(115200);
  while (!Serial) {
    ;                  // wait for serial port to connect. Needed for Leonardo only
  }
  // init can bus, baudrate: 500k
  if(CAN0.begin(CAN_500KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
  else Serial.print("Can init fail!!\r\n");
               // send data per 100ms
}

void loop()
{
//    // send data:  id = 0x00, standrad flame, data len = 8, stmp: data buf
//  CAN0.sendMsgBuf(0x00, 0, 8, stmp);
}


texts: Extremely bad analog read on ESP32 while using 433MHz module

texts:
I'm currently trying to transmit data from one ESP32 to another with 433MHz modules. I also need to read some sensor readings from an Hall sensor.
When the ESP32 that sends is not connected the values are stable and good. If, however, it is connected, it is a nightmare.
Averaging about 1000 values makes it decent, but this also makes it slow and annoying to work with.
At first I added a capacitor over the 5V to GND (100nF), then I did the same with 3.3V to GND, and then again with the analog read pin to GND, but nothing smoothed the signal at all.
Here is the serial output with connected communication and disconnected communication:

Please help me fix this problem. I tried so many times, and I couldn't find anything related to serial output and bad analog read on the internet. I'm using pin 34.
Here's the analog read code:
delay(100);
Hallsensoranalog.update();
hallvalue = Hallsensoranalog.getValue();
Serial.println(hallvalue);

I even added a 100ms delay (this needs to be removed as I need a fast analog read) for giving the ADC extra time, but this doesn't help a lot.
I need to use these modules, I don't want to use the internal WiFi ESP-NOW or Bluetooth.
Best Regards,
Felix.


texts: Calculate burden resistor value of current transformer and measure ac current with arduino

texts: I Want to measure AC current with current transformer but i dont know exact value of burden resistor or calculation formula...i want to measure current of borewell pump. company specified pump as 1.5Hp power.


texts: ESP32 saving data to SD card in .csv doesnt format correctly

texts:
i want to save a vector to a .csv file on a SD Card.

I watched this tutorial on how to do it and it describes it perfectly even though its kinda dated.

My Problem is that everything is saved into the first cell of the .csv file so it gets constantly overridden.
It should save only the first vector into the first cell, then the second vector into the second cell and so on.
I just get all three vectors with the commas into the first vector like this:

8, 9, 10

Also the header witch should appear at the top is also gone.

I would really appreciate some help. Thanks!

Here is my setup and loop:

#include <iostream>
#include <string>
#include <vector>
#include "SD.h"
#include "SPI.h"
#include "EKG_data_transmision.h"

#define CS_Pin 5 // Chip Select Pin

EKG_data_transmision EKG_data_transmision;

std::vector<unsigned short> vector_1 = {1,2,3,4,5,6,7,8,9,10};
std::vector<unsigned short> vector_2 = {2,3,4,5,6,7,8,9,10,11};
std::vector<unsigned short> vector_3 = {3,4,5,6,7,8,9,10,11,12};
unsigned int for_x = 0;

void setup() {
  // open serial
  Serial.begin(9600);
  Serial.print("Init SD Card...");
  pinMode(CS_Pin, OUTPUT);

  if(!SD.begin(CS_Pin))
  {
    Serial.println("Card failed or not present");
    return;
  }

  EKG_data_transmision.vectorData = SD.open("/data.csv", FILE_WRITE);  //erstelle data.csv datei

  if(EKG_data_transmision.vectorData)
  {
    EKG_data_transmision.vectorData.println(", , , ,");
    String header = "ID, Value, Time, Whatever";
    EKG_data_transmision.vectorData.println(header);
    EKG_data_transmision.vectorData.close();
    Serial.println(header);
    Serial.println("card init sucess");
  }
  else
  {
    Serial.println("Couldnt open vector data file");
  }

}

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

  while(for_x <= 8){
    for_x++;
    EKG_data_transmision.write_vector_to_SD(vector_1, vector_2, vector_3);
    delay(1000);
  }

  delay(10000);
}

Here is my function that should save everything to the SD Card:

bool  EKG_data_transmision::write_vector_to_SD(std::vector<unsigned short> vector_ADC_1, std::vector<unsigned short> vector_ADC_2, std::vector<unsigned short> vector_ADC_3) // Übertrage
{
  dataString = String(vector_loc) + "," + String(vector_ADC_1[vector_loc]) + "," + String(vector_ADC_2[vector_loc]) + "," + String(vector_ADC_3[vector_loc]); // + "\r\n"

  vectorData = SD.open("/data.csv", FILE_WRITE);

  if(vectorData){
    //sd karte immer noch da und schau ob data.csv exisitiert
    vectorData.println(dataString);
    Serial.println("This is vector:");
    Serial.println(vector_loc);
    Serial.println("Im actually writing this:");
    Serial.println(dataString);
    vectorData.close(); // close the file
    }

  else{
    Serial.println("Error writing to file !");
}
  vector_loc++;

  return 0;
}


texts: Basic communication with nrf24l01 between nodemcu and arduino nano

texts:
I spent the last two days to find a way to set up a basic communication between a nodemcu amica and an arduino nano with a nrf24l01 module; all of this without success..

Here the code uploaded on my nodemcu:

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(D4, D8);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "00001";

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

  radio.begin();

  //set the address
  radio.openWritingPipe(address);

  //Set module as transmitter
  radio.stopListening();

  Serial.println("inizio ad trasmettere");
  Serial.println(radio.isChipConnected());
}
void loop()
{
  Serial.println("qui");
  const char text[] = "Hello World";
  bool ret = radio.write(&text, sizeof(text));
  Serial.print("Write ret: ");
  Serial.println(ret);
  delay(1000);
}

and here the code on the arduino side

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(5, 6);  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "00001";

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

  radio.begin();

  //set the address
  radio.openReadingPipe(0, address);

  //Set module as receiver
  radio.startListening();

  Serial.println("inizio ad ascoltare");
  Serial.println(radio.isChipConnected());
}

void loop()
{
  //Read the data if available in buffer
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

Following my wiring config of
nodemcu
and
arduino nano

Can anyone see something that I don't see?
I'm really frustrated

My nrf24l01 module is this https://www.amazon.it/gp/product/B06WD17WLS, not the module in the fritzing scheme.


texts: Receive sms on android phone without GSM module

texts: I have done a simple project which measures CO gas in air.Now I want that sensor will measure the level of CO gas and sms will be received on android phone when the area is under danger zone.How to receive sms on android phone without GSM module?


texts: How to add the previous value to current value from sensor

texts:
const byte interruptPin = 4;
void ICACHE_RAM_ATTR count();
void setup() {
  Serial.begin(115200);

  // Set up our digital pin as an interrupt
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), count, RISING);
}

void loop() {

}

void count() {
  volatile float rainrate = 3;
  volatile float rate;
  volatile float total;

  rate = rainrate * 0.1;
  Serial.println(rate);

Every time it tips, it returns 0.3.  How do I add the previous value(0.3) to a new tip, to make it 0.6, and save it into a variable.
Thanks!


texts: Best way to add external power supply when main PSU is a solar charge controller?

texts:
I have a 12V 20A Solar Charge Controller (which is part of my existing Solar Panel System Setup connected to a 12V Sealed Lead Acid Battery) that I will use to power up some pumps with the help of relays and some sensors. And because its a solar charge controller, the output varies depending on the sun, from 12.1v to 13.8v (I set the Load Reconnect, Load Disconnect, Float Charge etc which technically 12V to 13.8V)
How do I power my Arduino Mega safely in this case?
I am planning on using a separate buck converter that will give my Arduino a fixed 9V from the Solar Charge Controller.
Should I power the Arduino with the buck converter parallel to the same PSU (the 12V 20A Solar Charge Controller) I'm using for the pumps and is it safe that way?
or
Should I use a 9V battery to separately power the Arduino Mega?  and what is the explanation behind the concept of using an external PSU for the Arduino Mega when the total Amperes all in all is not exceeding the limit 20A at all?


texts: How to add colour change to the strobe coding?

texts:
I have this strobe effect working. However, I would like to change the colour of the LEDs after each 'strobe sequence'. How can it be achieved?
The code I am using is this one:
    // Basic code NeoPixel
    // wwww.arduinoplatform.com

    #include <Adafruit_NeoPixel.h>
    #ifdef __AVR__
     #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
    #endif

    // Which pin on the Arduino is connected to the NeoPixels?
    // On a Trinket or Gemma we suggest changing this to 1:
    #define LED_PIN    6

    // How many NeoPixels ar
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, 6, NEO_GRB + NEO_KHZ800);

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

    // *** REPLACE FROM HERE ***

    void loop() {
      // Slower:
      // Strobe(0xff, 0x77, 0x00, 10, 100, 1000);
      // Fast:
      Strobe(0xFF, 0x00, 0xF8, 10, 50, 1000);
    }

    void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
      for(int j = 0; j < StrobeCount; j++) {
        setAll(red,green,blue);
        showStrip();
        delay(FlashDelay);
        setAll(0,0,0);
        showStrip();
        delay(FlashDelay);
      }

     delay(EndPause);
    }

    // *** REPLACE TO HERE ***

    void showStrip() {
     #ifdef ADAFRUIT_NEOPIXEL_H
       // NeoPixel
       strip.show();
     #endif

    }

    void setPixel(int Pixel, byte red, byte green, byte blue) {
     #ifdef ADAFRUIT_NEOPIXEL_H
       // NeoPixel
       strip.setPixelColor(Pixel, strip.Color(red, green, blue));
     #endif
    }

    void setAll(byte red, byte green, byte blue) {
      for(int i = 0; i < 64; i++ ) {
        setPixel(i, red, green, blue);
      }
      showStrip();
    }


texts:
This topic have been covered in various places, but I still think it hasn't been thoroughly explained anywhere. Doing google search on connecting Arduino to Raspberry Pi via i2c gives for example, this page.

While apparently this should work, there is a factual error there: on arduino side, pins used for i2c do have internal pull ups, and they are activated by Wire library.

Digging further, I've found following information:

  However, it turns out that these are weak (high-resistance) pull-ups;
  the Pi has strong pull-ups which dominate those on the Arduino, making
  direct connection safe.

What does safe mean? And how weaker are those pullups compared to raspberry pi ones?

Let's check:

rpi i2c pullup: 1K8
arduino i2c pullup: 20K-50K from datasheet (if I'm looking correctly, I'm using ATmega8), though the above page states 10K.

What can I make of those values? My (intuition rather than) basic knowledge hints me something along the lines:

If the i2c is floating, it means the 5V is connected with 3.3V and there are only those pullups along the way, so:

calculate voltage drop between 5 and 3.3: 1.7V.
calculate voltage drop across rpi pullup proportionally to voltage drop across arduino pullup:
1800 / 30000 = 0.06, meaning 0.102V across rpi pullup and 1.598 across arduino pullup, so the actual pulled up voltage is gonna be 3.3V + 0.102V = 5V - 1.598V = 3.402V?

Though I'm pretty sure I'm doing some terrible math here and someone is gonna have good laugh:)

So, my question is not whether it's safe (as it's been proved), but rather why is it safe considering the internet resources are inaccurate on this matter.


texts: Why my Arduino can't show tty port entries?

texts:
I installed the latest version of Arduino and also installed the latest version of FTDI driver on my Mac pro. But my serial port are only show cu port. Why?

I also can see the tty port and cu port in my /dev/ directory.


texts: I want to add CO2 measuring feature to my room weather station. Can someone please recommend a CO2 sensor easy to integrate with Arduino?


texts: Arduino crashed my computer when I plug in the USB cable

texts:
I have a 2008 Mac that hardly ever crashes. But from time to time (not always) it crashes (the whole computer shuts down as if the power has been cut off) when I plug in an Arduino via USB.

What could cause this?

I've done some testing and the constant in when this occurs seems to be a cheap PIR sensor from eBay. It works some of the time.

Should I get another sensor? Or is there something about PIR sensors that makes them prone to this? It has a lot of caps... Is there another kind of motion sensor?


texts: What's the difference between ICSP vs ISP?

texts: I'm not sure if these terms are interchangeable or not. What's the difference between ICSP and ISP? Is it simply the reset? I've shown two configurations in this question I just asked. Are they both ICSP?


texts: Help compiling multiple .ino file code with code! (I'm not sure what to name this)

texts: Ok, so i'm trying to make This Project and the code comes all in different .ino files but in the video its all in one program. So how do I compile all of the code onto the arduino? (By the way the code is on step 5 in a .zip file) Thank you!


texts: I2C begginer with I/O expander with mega328p C code

texts:
I've just started with the I2C protocol. I read about it in the datasheet, other documents, blogs and videos.

So, I started to develop my code and I think I did my first success, I succeeded to send start and check TWST for sending start signal.

I get started OK, but I can't proceed to send data. What I'm missing? I'm thinking I didn't send the correct address.

void I2C_init(void);
void I2C_start(void);
void I2C_stop(void);
void I2C_tx(uint8_t data);
void I2C_TWSR_Check(void);

void setup() {
  Serial.begin(9600);
  I2C_init();
  //  I2C_TWSR_Check();
  I2C_start();
  I2C_TWSR_Check();
  I2C_tx(0x40);           // sending the address
  I2C_TWSR_Check();       // waiting for response
}

void loop() {
  uint8_t i;
  // simple loop to blink an LED on the I/O expander pin
  for (i=0;i<5;i++) {
    I2C_tx(0xff);
    I2C_TWSR_Check();
    _delay_ms(500);
    I2C_tx(0x00);
    I2C_TWSR_Check();
    _delay_ms(500);
  }
}

void I2C_init(void) {
  //set SCL to 100kHz
  TWSR = 0x00;
  TWBR = 0x48;
  //enable TWI
  TWCR = (1<<TWEN);
}

void I2C_start(void) {
  TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
  while (!(TWCR & (1<<TWINT)));
}

void I2C_stop(void) {
  TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN);
}

void I2C_tx(uint8_t u8data) {
  TWDR = u8data;
  while (!(TWCR & (1<<TWINT)));
}

void I2C_TWSR_Check(void) {
  uint8_t Status;
  Status = TWSR & 0xF8;
  switch(Status) {
    case 0x08: // start OK
    Serial.println("Start is OK");
     break;
    case 0x10: // Re start
    Serial.println("Re start");
     break;
    case 0x18: // SLA+W OK ACK
    Serial.println("SLA+W OK ACK");
     break;
    case 0x20: // SLA+W no ACK
    Serial.println("SLA+W no ACK");
     break;
    case 0x28: // data OK ACK
    Serial.println("data OK ACK");
     break;
    case 0x30: // data OK no ACK
    Serial.println("data OK no ACK");
     break;
    case 0x38: // arbitration lost in SLA+W or data TX
    Serial.println("arbitration lost in SLA+W or data TX");
     break;
     default:
     Serial.println("Error");
    break;
  }
}


texts: Why do MEGA2560 digital pins go high on serial disconnect?

texts:
I'm trying to set up a system using an that delivers a specific number of digital pulses to a device using one of the digital pins. The number of pulses delivered is specified over a the Mega's USB serial connection using a Python script (or terminal for debugging).
When I close the serial connection to the Arduino, I get a short "blip" that looks like a digital high (see image below). This happens when I disconnect in PySerial using Serial.close() or when I simply close my Arduino IDE terminal window.
It does not occur when I press the reset button on the board
Any ideas on how to get rid of this?  Thanks!


texts: Can I do something like this to simplify the code for arduino?

texts:
Can I simplify the code in arduino where it doesn't promote any error.
Example:

Int led =13;
Blink = digitalWrite(led, HiGH);
             delay(1000);
             digitalWrite(led, LOW);
             delay(1000);

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

void loop(){
Blink
}


texts: FT232RL Chip pinout to flash Arduino Pro Mini

texts:
Looks I have a FTDI USB to TTL adapter that doesn't follow the standard Arduino FTDI pinout order. The chipset is FT232RL and here is the link to Amazon page.

https://www.amazon.com/Adapter-Serial-Converter-Development-Projects/dp/B075N82CDL#customerReviews

Please can someone tell me the right pinout to connect this to Arduino Pro Mini 3.3v Thanks!


texts:
I want to change the clock frequency of the Arduino Due. The default value of the main clock, according to the SAM micro-controller, is 4 Mhz. But I found in some forums that it is 84 Mhz. But I need to work with it at 16 Mhz. Hence, I need to access to the low-level clocks of the Due and change its operating clock frequency.

How can I find the low-level registers of the Due in the Arduino IDE? Any header files for the Due to change its clocking?
Is it possible to write code for the Arduino Due via Atmel Studio 7? When I tried compiling code in AS7, Chip.h was not found. How to avoid this? Is it possible with "micro" IDE in AS7? Can I access registers of the Due via AS7 and change its clocking?
I cannot find the "sam" library in the Arduino IDE. Only avr is present. How can I find this sam library?


texts: How do I change the I2C address on the LCD backpack?

texts:
The 20 x 4 LCD comes with a I2C backpack.  I know it has A0, A1, A2 to set the address, as shown at the bottom here:  https://tronixlabs.com.au/news/tutorial-serial-i2c-backpack-for-hd44780compatible-lcd-modules-with-arduino/

It points to here:  http://www.nxp.com/products/interface-and-connectivity/interface-and-system-management/i2c-bus-portfolio/i2c-general-purpose-i-o/remote-8-bit-i-o-expander-for-icbus-with-interrupt:PCF8574_74A

My unit shows up as 0x3F.

And even with all this information I can't tell how to change it.

I need to have a second display on the same I2C bus.

Question:  How do I change the address of the second one?


texts: Extend battery life with a power-controlling microcontroller?

texts:
This article describes a method to extend the battery life: use a low-power controller to switch on the Arduino only when needed. The author states that this method uses considerably less power than using Arduino's sleep mode.

Are there downsides to this approach? Which variant should I build?(The TPS61240 variant seems to use something from Circuits@Home that's not available anymore.) I'd appreciate schematics or links to detailed instructions.

Background: I'm building a sensor device that's in an environment with no mains power supply. The sensor should wake up eg. hourly, read eg. a temperature sensor, possibly send an SMS and then go back to sleep.


texts: Initializing pointer to vector of objects inside another object

texts:
i want to create a somewhat complex structure of classes in an arduino. The short story is: a Device has Presets, and each Preset has a Patterns. For that i created the following structure (i am only posting the important stuff, if something is missing let me know):

INO file

#include "LedDevice.h"

LedDevice device;

void setup() {
  device = LedDevice(10, 10, 10);
}

void loop() {
  Serial.println(F("Ticking"));
  device.Tick();
  delay(500);
}

LedDevice

#if !defined(_LEDDEVICE_H)
#define _LEDDEVICE_H

#include "Preset.h"
#include<Arduino.h>

class LedDevice {
public:
  Preset* Presets[];

  LedDevice(){}
  LedDevice(int numPixels, int numPresets, int numPatterns)
  {
    *Presets = (Preset*)malloc(sizeof(Preset) * numPresets);

    for (int p = 0; p < numPresets; p++)
    {
      Presets[p] = new Preset("test", numPixels, numPatterns);
    }
  }

  void Tick()
  {
    Serial.print(F("Preset ")); Serial.println(Presets[0]->Name);
    Presets[0]->Tick();
  }
};

#endif  //_LEDDEVICE_H

Preset

#if !defined(_PRESET_H)
#define _PRESET_H

#include "Pattern.h"

class Preset {
public:
  char *Name;
  int NumPatterns;
  Pattern* Patterns[];

  Preset(char* name, int numPixels, int numPatterns) : NumPatterns(numPatterns)
  {
    Name = (char *)malloc(strlen(name) + 1);
    strcpy(Name, name);

    *Patterns = (Pattern*)malloc(sizeof(Pattern) * NumPatterns);

    for (int p = 0; p < NumPatterns; p++)
    {
      Patterns[p] = new Pattern(numPixels);
    }
  }

  void Tick()
  {
    for (int p = 0; p < NumPatterns; p++)
    {
      Patterns[p]->Tick();
    }
  }
};

#endif

Pattern

#if !defined(_PATTERN_H)
#define _PATTERN_H

class Pattern {
public:

  Pattern(int numPixels){}

  void Tick(){}
};

#endif

The code compiles but when i run the full version (this is a simplified version of the code) i get some strange behavior, so i would like to know if i am doing the initialization of the Presets and Patterns correctly.

Also when i try to print the Preset name in the LedDevice Tick function i get strange characters, so either i am not initializing the string correctly or the pointers to the Presets are wrong.

Can you tell if anything is not being done correctly in the constructors?


texts: ESP8266 Wemos D1 Retrieving Wrong AP Mac Address

texts:
Using WiFi.BSSID and WiFi.BSSIDstr gives me some weird mac address.

the code is:

#include "ESP8266WiFi.h"
#include "ESP8266WiFiScan.h"

void setup() {
Serial.begin(115200);
//WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
Serial.println(WiFi.macAddress());
}

void loop() {
   int n=WiFi.scanNetworks();
   Serial.println(n);
   for (int network = 0; network < n; network++){
      Serial.println(WiFi.SSID(network));
      Serial.println(WiFi.RSSI(network));
      uint8_t* mac=WiFi.BSSID(n);
      char APmac[13];
      APmac[0]=0;
      for (int i=0; i<6;i++) {
        char buffer[3];
        sprintf(buffer, "%02x", mac[i]);
        strncpy((char *)(APmac+(i*2)), buffer, 3);
        Serial.print("["); Serial.print(i); Serial.print("]"); Serial.println(buffer);
      }
      Serial.println(APmac);
      Serial.println(WiFi.BSSIDstr(n));

  }
  Serial.println();
  Serial.println();
  delay(10000);
}

The current output is 6D:98:C9:00:00:00 which is completely off. It duplicates this output for other APs too. Is this a hardware problem? I've seen other people using the same codes and it works for them. For reference WiFi.SSID(); and WiFi.RSSI(); both spits out correctly.

edit: I was testing both output to see which ever one was correct and unfortunately they're both wrong


texts: Im having another problem with my code the error is "redefinition of 'AF_DCMotor motor'?

texts:
Heres the code

#include <AFMotor.h>

AF_DCMotor motor(1, MOTOR12_8KHZ);
AF_DCMotor motor(2, MOTOR12_8KHZ);
AF_DCMotor motor(3, MOTOR34_1KHZ);

void setup()  {
  Serial.begin(9600);
  Serial.printIn("Motor Test!");
  motor1.setSpeed(15); //set speed of motor
  motor2.setSpeed(15); //set speed of motor
  motor3.setSpeed(15); //set speed of motor

}
void loop() {
  Serial.print("tick");
  motor1.run(FORWARD);
  delay(2000);

  Serial.print("tock");
  motor1.run(RELEASE);
  delay(5000);

  Serial.print("tack"); //first song starts
  motor1.run(BACKWARD);
  delay(2000);

  Serial.print("tock");
  motor1.run(RELEASE);
  delay(9000);

  Serial.print("tack");
  motor1.run(BACKWARD);
  delay(2000);

  Serial.print("tock"); //first song ends
  motor1.run(RELEASE);
  delay(20000);

  Serial.print("tick");
  motor1.run(FORWARD);
  delay(2000);

  Serial.print("tick");
  motor2.run(FORWARD);
  delay(2000);

  Serial.print("tock");
  motor2.run(RELEASE);
  delay(5000);

  Serial.print("tick");
  motor2.run(FORWARD);
  delay(2000);

  Serial.print("tack");
  motor1.run(BACKWARD);
  delay(2000);

  Serial.print("tock");
  motor2.run(RELEASE);
  delay(1000);

  Serial.print("tick");
  motor2.run(BACKWARD);
  delay(2000);

  Serial.print("tock");
  motor2.run(FORWARD);
  delay(1000);

  Serial.print("tick");
  motor2.run(RELEASE);
  delay(1000);

  Serial.print("tick");
  motor2.run(FORWARD);
  delay(2000);

  Serial.print("tack");
  motor1.run(BACKWARD);
  delay(2000);

  Serial.print("tock");
  motor2.run(RELEASE);
  delay(1000);

  Serial.print("tick");
  motor2.run(BACKWARD);
  delay(2000);

   Serial.print("tock");
  motor2.run(FORWARD);
  delay(1000);

  Serial.print("tick");
  motor2.run(RELEASE);
  delay(1000);

  Serial.print("tick");
  motor2.run(FORWARD);
  delay(2000);

  Serial.print("tack");
  motor1.run(BACKWARD);
  delay(2000);

  Serial.print("tock"); //first song stops
  motor2.run(RELEASE);
  delay(14000);

  Serial.print("tock"); //first song stops
  motor3.run(RELEASE);
  delay(11000);

  Serial.print("tick"); //first song stops
  motor3.run(FORWARD);
  delay(22000);

  Serial.print("tock"); //first song stops
  motor3.run(RELEASE);
  delay(19000);
}

Here is the error:

   ^~~~~~

   motor

snowmanDC_Motor:13:3: error: 'motor3' was not declared in this scope

   motor3.setSpeed(15); //set speed of motor

   ^~~~~~

C:\Users\serluca\Documents\Arduino\snowmanDC_Motor\snowmanDC_Motor.ino:13:3: note: suggested alternative: 'motor'

   motor3.setSpeed(15); //set speed of motor

   ^~~~~~

   motor

C:\Users\serluca\Documents\Arduino\snowmanDC_Motor\snowmanDC_Motor.ino: In function 'void loop()':

snowmanDC_Motor:18:3: error: 'motor1' was not declared in this scope

   motor1.run(FORWARD);

   ^~~~~~

C:\Users\serluca\Documents\Arduino\snowmanDC_Motor\snowmanDC_Motor.ino:18:3: note: suggested alternative: 'motor'

   motor1.run(FORWARD);

   ^~~~~~

   motor

snowmanDC_Motor:47:3: error: 'motor2' was not declared in this scope

   motor2.run(FORWARD);

   ^~~~~~

C:\Users\serluca\Documents\Arduino\snowmanDC_Motor\snowmanDC_Motor.ino:47:3: note: suggested alternative: 'motor'

   motor2.run(FORWARD);

   ^~~~~~

   motor

snowmanDC_Motor:115:3: error: 'motor3' was not declared in this scope

   motor3.run(RELEASE);

   ^~~~~~

C:\Users\serluca\Documents\Arduino\snowmanDC_Motor\snowmanDC_Motor.ino:115:3: note: suggested alternative: 'motor'

   motor3.run(RELEASE);

   ^~~~~~

   motor

exit status 1
redefinition of 'AF_DCMotor motor'


texts:
I'm building a simple RS232 data logger with the Sparkfun OpenLog and a SEEED RS232-TTL adaptor. I'm powering it with a 9 volt battery and a 7805 voltage regulator.

It's dead simple. I built it on a breadboard first and determined that TX-TX and RX-RX connections are called for. I logged several files on the breadboard then soldered it all up. Now it's not working, sigh.

When I power it up  both lights will flash rapidly for about a second and then it settles down to a steady on-off with both lights.

If I delete the config file a new one is created, which shows that it recognizes the card at least.

I've triple checked my wiring and confirmed I have no shorts, and that the voltage is good.

I'm attaching a photo as built. Hopefully it's obvious what's what. The purple trace is ground.


texts: Trying to show g++ (linter-gcc for Atom) where to find Arduino libs

texts:
I'm trying to use Atom as an IDE for arduino and arduino-based boards.
I'm using arduino-cli for compilation and avrdude for upload, and now I'm trying to use linter-gcc for linting.

g++ is running and the linter seems to be working ok, but it's can't find built in libs.  I've added:

"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\*"

to my GCC include paths, I've also tried copying the lib sources to my working directory, but I'm still getting (e.g.):

SPI.h: No such file or directory

Any ideas why gcc isn't seeing SPI.h?


texts: I would like to know if someone could explain to me how to create an arduino electronics laboratory with soldering iron etc. with a low budget <3


texts:
I imagine that the proper way to implement an RS485 multidrop bus is the following:

What happens if, in order to save cables, I connect the same 5 nodes above using this other topology?

Will it works?
If no, why?
If "maybe", under which circumstances will it work?

P.S.: yes! I know that MEGA has three Serials and, as such, I could implement two different BUSses (1: Mega<->Mega<->Mega; 2: Mega<->Nano<->Nano), but this will increase the complexity of the software I'm running, as it needs some hacking in order to play nicely with two distinct RS-485 busses;

P.P.S.: This is the bus discussed in this other question


texts: Uno - error during uploading with library

texts:
I'm writing the code in VS Code on IO Platform. Yesterday i finished my code and uploaded it to the Arduino Uno. It works fine. Next day i launched the VS Code and i changed the code a bit, then i uploaded it and i got the error.

Error:

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
NewPing.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1

I am using the libary NewPing.h. The code should does this: If is distance more than 20cm, the the buzz makes the sound and turns on the red led. If distance is less than 20cm, the blue led turns on

The code:

#include <Arduino.h>  //It has to be there, because the arduino ide in VS Code will not work.

#include <NewPing.h>

#define echo_pin 3
#define trig_pin 4
#define max_range 450

#define red_led_pin 7
#define blue_led_pin 9
#define buzz_pin 10

int distance = 0;

NewPing sonar(trig_pin, echo_pin, max_range);

void setup(){
  Serial.begin(9600);
  pinMode(red_led_pin, OUTPUT);
  pinMode(blue_led_pin, OUTPUT);

  pinMode(buzz_pin, OUTPUT);
}

void loop() {

  distance = sonar.ping_cm();
  delay(50);

  if (distance > 0) {
          distance = 0;

    for (int i=0; i<5; i++) {
      distance += sonar.ping_cm();
      delay(50);
    }
    distance /= 4;

    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.println("cm");

    if (distance > 20) {

      digitalWrite(blue_led_pin, LOW);
      digitalWrite(red_led_pin, HIGH);
      tone(buzz_pin, 1500);
      tone(buzz_pin, 800);
    }

    else {

      digitalWrite(red_led_pin, LOW);
      digitalWrite(blue_led_pin, HIGH);
    }
  }
}

I don't undersand, what has changed. I tried to import again the libary https://www.arduino.cc/en/guide/libraries by importing the *.zip file, also installing in IDE.


texts: How to make PCA9685 work with Arduino Due?

texts:
I have Arduino Due and PCA9685.

I use this library:
https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

The board does not do anything with servo connected. I tried to use SDA/SCL pins and SDA1/SCL1 pins, I tried to use or not use pullup resistors. The board does not react in any case.

The PCA9685 is 100% working, because it operates properly when I connect it to my Arduino Mega using the same library, it works without pullups.

Also I noticed the following indicium, when I tried to use  this scanner
http://playground.arduino.cc/Main/I2cScanner I have no detected devices on SCL1/SDA1 but have detected 2 devices at 0x40 and 0x70 when I connect the board SDA/SCL pins.


texts: How convert eight hex characters to uint32_t using strtol() function?

texts:
I want to control 4 pins using hexa code like this ff00ff00 (255, 0, 255, 0).

strtol() function works fine with three pins like 00ff00, but when i add two extra caracters to &payload[1] variable like this ff00ff00.
((rgba >> 24) & 0xFF) is equal to 127 when it should be 255.
How to make this work?

each analog pin should be set from 0 to 255

    analogWrite(LED_WHITE,  ((rgba >> 24) & 0xFF));
    analogWrite(LED_RED,    ((rgba >> 16) & 0xFF));
    analogWrite(LED_GREEN,  ((rgba >> 8) & 0xFF));
    analogWrite(LED_BLUE,   ((rgba >> 0) & 0xFF));

    uint32_t rgba = (uint32_t) strtol((const char *) &payload[1], NULL, 16);


texts: Arduino Uno + Jaguar Speed Controller + CIM Motor (12V DC)

texts:
I have connected a CIM motor to a Jaguar speed controller, powered by a 12V battery. The Jaguar is connected to an Arduino Uno via the signal and ground. Also, I have two switches connected to the Arduino, for forward and reverse of the motor.

In the code, for speed of the motor, I have set 90 as the mid point and 100 for forward and 80 for reverse. When I push the reverse button, the motor runs smoothly in the reverse direction at the set speed. However, the problem is, when I press the forward button, the motor runs seemingly slower in the forward direction than the set speed.

My logic here was, if I have set speeds in forward and reverse at +/- 10 from the mid-point, the motor should run at the same speed in the forward and reverse direction, but this is not happening.

I am pasting my code below. Any help would be much appreciated. Thank you!

#include <Servo.h>

int forwardPin = 2;
int reversePin = 4;
int motorPin = 10;
int fwdReading = 0;
int revReading = 0;

Servo myservo;

void setup() {
  TCCR1B = TCCR1B & 0b11111000 | 0x04; // PWM Freq. at 122Hz
  pinMode (forwardPin, INPUT);
  pinMode (reversePin, INPUT);
  myservo.attach(motorPin);
  myservo.write(90);  // set servo to mid-point
}

void loop() {
  fwdReading = digitalRead(forwardPin);
  revReading = digitalRead(reversePin);
  if (fwdReading == HIGH) {
    myservo.write(100); // forward
  } else if (revReading == HIGH) {
    myservo.write(80); // reverse
  } else
    myservo.write(90); // neutral
}


texts: Arduino Mega LED doesn't light as expected

texts:
I wrote this for my Arduino Mega 2560:

int LED[14] = { 28,29,30,31,32,33,34,35,36,37,38,39,40,41 } ;
...
... (some other code like setup(), etc. Note:pinmode output for this 14 leds wich pins is defined in
... array named LED[]
...
void intro(){
  for(int j=1; j<100; j++ ){
    for(int r=1; r<15; r++ ){ digitalWrite(LED[r],HIGH); delay(100);  }
    delay(100);
    for(int r=1; r<15; r++ ){digitalWrite(LED[r],LOW); delay(100);}
    delay(100);
  }
  Serial.print("Pattern started");
  delay(1000);
}

So when I run this script, I expect that each LED will light up in the sequence and remain lit until the second loop to turn it off, but I see that when lighting each LED, when lighting the 9th LED, the first 8 LEDs shut off inexplicably and LEDs 9 through 14 light one by one, remaining lit. That I expected but why do the first 8 LEDs shut off before the loop ends and the second loop starts?


texts:
I have the following snippet of code:

const unsigned long fiveMinutes = 5 * 60 * 1000UL;
unsigned long lastCheck = 0 - fiveMinutes;
unsigned long now = 0;

void loop() {
  now = millis();
  if ( now - lastCheck >= fiveMinutes ) {
    doStuff();
    lastCheck = now;
  }
}

The doStuff() routine is getting called on every loop() iteration, because the value of lastCheck isn't getting updated. I thought Icould update global variables inside subroutines, but the behavior I'm seeing says otherwise. What am I doing wrong? (doStuff() is defined and works correctly, I'm not posting it here for brevity.)


texts: Instead of 1 and 0, make display say On or Off

texts:
So for my project, I am making a button that turns on and off an LED, but also display the state of the led on an LCD and by Serial.  But my issue is, I don't want it to just show a 0 or a 1, I want it to say On or Off.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int inPin = 22;         // the number of the input pin
int outPin = 13;       // the number of the output pin

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup(){
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    // Print a message to the LCD.
    lcd.print("System Activated");
    //
    lcd.setCursor(0, 1);
    lcd.print("Ready...");

    pinMode(inPin, INPUT);
    pinMode(outPin, OUTPUT);

    Serial.begin(9600);
    Serial.println("System Activated");
    Serial.println("Made by Mateo Holguin");
    Serial.println("0 = Light is Off | 1 = Light is On");
    Serial.println("=======================================");
}

void loop(){
    reading = digitalRead(inPin);

    if (reading == HIGH && previous == LOW && millis() - time > debounce) {
        Serial.println("Button Switch State Change:");
        if (state == HIGH)
            state = LOW;
        else
            state = HIGH;

        Serial.println(state);
        Serial.println("");
        lcd.clear();
        lcd.print("State: ");
        lcd.print(state);

        time = millis();
    }

    digitalWrite(outPin, state);

    previous = reading;
}


texts: Process Sensor Data from Arduino Yun with Python

texts:
I'm currently working on a small project with my Arduino Yún.
I want to process the sensor data in python and send them in a message queue. I need to use Python3.

I cannot find a way to get the sensor data in my Python code.
I already tried to start the python process in my sketch and use the println method of the process object but this doesn't work.

I also tried to use the BridgeClient class from the Arduino Github but it won't work either.

Summarized:
I can't find a way to send my measurements from my Arduino sketch to the my Python3 program on the Linux side of the Arudino Yún.

I don't think this is an extraordinary problem and I don't understand why there aren't any tutorials for this specific use-case.

The section below contains my Arduino sketch, which does the measurements.

#include <SparkFunHTU21D.h>
#include <Wire.h>

HTU21D myHumidity;

int trigPin = 11;
int echoPin = 12;

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

  myHumidity.begin();

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

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

  //Perform 5 SoilMoisture-measurements and get mean
  float soil = meanSoilMoisture(A0, 5);
  float humd = myHumidity.readHumidity();
  float temp = myHumidity.readTemperature();

  float distance = getDistance();

  String dataString;
  dataString += String(soil) + ", " + String(humd) + ", " + String(temp) + ", " + String(distance);
  Serial.println(dataString);

  delay(4000);
}

long getDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  pinMode(echoPin, INPUT);
  long duration = pulseIn(echoPin, HIGH);

  // Convert the time into a distance
  return (duration/2) / 29.1;     // Divide by 29.1 or multiply by 0.0343
}

float meanSoilMoisture(int analogPin, int nMeasurements) {
  float sum = 0;
  for(int i = 0; i < nMeasurements; i ++) {
    sum = sum + readVH400(analogPin);
    delay(50);
  }

  return sum / nMeasurements;
}

//Perform Measurement
float readVH400(int analogPin) {
  int sensor1DN = analogRead(analogPin);
  float sensorVoltage = sensor1DN*(3.0 / 1023.0);
  float VWC;

  // Calculate VWC
  if(sensorVoltage <= 1.1) {
    VWC = 10*sensorVoltage-1;
  } else if(sensorVoltage > 1.1 && sensorVoltage <= 1.3) {
    VWC = 25*sensorVoltage-17.5;
  } else if(sensorVoltage > 1.3 && sensorVoltage <= 1.82) {
    VWC = 48.08*sensorVoltage-47.5;
  } else if(sensorVoltage > 1.82) {
    VWC = 26.32*sensorVoltage-7.89;
  }
  return(VWC);

}

I'd like to have a way to send dataString to the linux side of the Arduino Yún and process it with Python3.

As explained earlier I've already tried out multiple solutions, e.g. start a new process and use the println method of the process.

{...}
Process proc;
void setup() {
    {...}
    proc.begin("python3 /mnt/sda1/test.py");
    p.runAsynchronously();
    {...}
}
{...}
    proc.println(dataString);
{...}

I've tried to read this dataString in Python3 in different ways, e.g. I've used the input method, because I read in a forum that I can handle such input like a keyboard input.
It didn't work and I didn't get an error, neither in Python nor in my sketch.

I've read different examples using the Bridge library. So I set up the sketch:

{...}
bridge.put("data", dataString);
{...}

I'd like to try out the BridgeClienton the python side but this library was written in Python2. I don't want to migrate the library to Python3 and I need to use Python3, so I didn't find a way to write Python code here.

I would highly appreciate any help from you.


texts: Connect 4 HC-12 transmitters to 1 HC-12 receiver

texts: I am currently receiving data from HC-12 modules via USB-TTL that are working in pair . But I want to receive data simultaneously from 4 Hc-12 modules to a single HC-12 module via USB-TTL.


texts:
Spanish company Libelium makes this pretty impressive sensor board:

http://www.libelium.com/products/waspmote/sensors/

for their Waspmote series of boards.  These are not meant for Arduino compatibility, but they are not only interesting for combining so many sensors, the availability of calibrated sensor sets makes it even more unique.

So here is the challenge: can we reasonably leverage these from an Uno or a Mega?


texts:
I am trying to create my own LED music visualiser for a university project but I can't seem to find anything I am looking for in terms of circuitry that I need for the project. I am using a teensy microcontroller with WS2812B LED strips. I am trying to replicate an example I came across on youtube but can't figure out what I need to do in the circuit with the tools I have available to me. I have found a frequency to voltage converter diagram which seems useful but have no idea how to set it up to send through the LED strip. I have attached below the LED visualiser I am taking inspiration from along with the link to the frequency to voltage converter diagram I want to build. Can anyone help me figure out how to create this with a Teensy microcontroller? Thanks
https://mathscinotes.files.wordpress.com/2014/03/v2f.jpg
https://www.youtube.com/watch?v=lU1GVVU9gLU


texts: I have just ordered MFRC 522 RFID reader from amzon, and I have also orders 5 RFID tags with keychains and a arduino uno board for my project, I have received RFID reader and tags and I have tested the tags with my Sony xperia NFC. The tags that I received with the readers are working fine but the key chain ones are not working. I think because of the frequency difference 13.56 MHz and 125 KHz. So, please tell will this key chain tags work with the Reader


texts: How to get Type name of a variable on Arduino

texts:
I found this post and implemented the code in a separate classed and then passed different variables to it in an attempt to get the type name printed to serial.

The code compiled and worked fine but i get the following strange output:

For type int I get Fn on the serial monitor
For String I get ;y on the serial monitor

If I don't make a type using MAKE_TYPE_INFO(type) then try TYPE_NAME() I don't get unknown printed on the serial monitor. I get fÝ.

All this weirdness is consistent and I could use it to make decisions based on type but why do that if their is a solution.


texts: Shield Compatible third party motor driver

texts:
I recently purchased an Arduino UNO along with some other hardware. At the time of purchase, I didn't know about Arduino's motor shield and so I purchased a two channel stepper motor driver (2A per channel) that was said to be "Shield Compatible". I recently received my hardware and have been following the introductory tutorials since I'm completely new to the Arduino platform. Things are going well but I didn't receive any documentation with the motor driver. There is a datasheet provided on the vendor's website but it is beyond my current level of competency.

My question: since the driver is said to be "Shield Compatible", does this mean that I can assume that I can interface with it the same way as an authentic Arduino shield. In other words, can I follow the motor shield tutorial on Arduino's website without any risk of damaging hardware and expect the driver I purchased to function properly.

The product that I purchased can be seen here: http://www.robotshop.com/ca/en/dual-bipolar-stepper-motor-controller-arduino.html


texts:
I have a two pins for two blinks leds but I need delay the second signal from first. I start the first signal and I need start the second signal 50ms later. The first signal is 500ms HIGH and 500ms LOW, and the second signal is 400ms LOW and 600ms HIGH. If I start the second signal 50ms later, I can center the high period of the first signal with the low period of the second signal.

This is my code:

long DelaySecondSignal = 50;
int A = 1;

while (A == 1)
{
    long millis_actuales = millis();

        //Control Salida_A
        if (millis_actuales - TiempoTranscurrido_SalidaA > (Estado_SalidaA ? 500 : 400)) {
            digitalWrite(SalidaA, Estado_SalidaA = !Estado_SalidaA);
            TiempoTranscurrido_SalidaA = millis_actuales;
        }

        if (millis_actuales > DelaySecondSignal)
        {
            //Control Salida_B
            if (millis_actuales - TiempoTranscurrido_SalidaB > (Estado_SalidaB ? 500 : 600)) {
                digitalWrite(SalidaB, Estado_SalidaB = !Estado_SalidaB);
                TiempoTranscurrido_SalidaB = millis_actuales;
            }
        }
}

TiempoTranscurrido_?? is a int and Estado_Salida? is a boolean.

I need start the second signal with 50ms of delay but "if (millis_actuales > DelaySecondSignal)" no work.

Thanks.


texts:
I am using Atmega328p with 5V power supply,
My Arduino getting hangs [or auto restarts] after some times.

I am using libraries:

Wire.h
CRC32.h
EEPROM.h
Arduino.h
TimerOne.h
RtcDS3231.h
SoftwareSerial.h
Adafruit_NeoPixel.h
avr/wdt.h

I have tried to search, some people are deny to use software serial library.


texts: How close to 5 kHz can I set the PWM frequency on an UNO pin 11?

texts:
I'm rebuilding a laser CNC machine and using LaserWeb4 as the control interface and GRBL 1.1 as the low-level interface to the stepper motors, limit switches and the laser. I have all the motion sorted out and am working on the laser control.

Figure 1. The GRBL 1.1 pinout. Pin 11 is used for spindle (cutter) speed on a milling machine or laser power control on a laser cutter.
The machine is using a Synrad 48 Series laser module which requires a 5 kHz PWM frequency (page 45 - 46).
The GRBL 1.1 sketch can be configured for a variety of PWM frequencies. See cpu_map.h.
  // Prescaled, 8-bit Fast PWM mode.
  #define SPINDLE_TCCRA_INIT_MASK   ((1<<WGM20) | (1<<WGM21))  // Configures fast PWM mode.
  // #define SPINDLE_TCCRB_INIT_MASK   (1<<CS20)               // Disable prescaler -> 62.5kHz
  // #define SPINDLE_TCCRB_INIT_MASK   (1<<CS21)               // 1/8 prescaler -> 7.8kHz (Used in v0.9)
  // #define SPINDLE_TCCRB_INIT_MASK   ((1<<CS21) | (1<<CS20)) // 1/32 prescaler -> 1.96kHz
  #define SPINDLE_TCCRB_INIT_MASK      (1<<CS22)               // 1/64 prescaler -> 0.98kHz (J-tech laser)

  // NOTE: On the 328p, these must be the same as the SPINDLE_ENABLE settings.
  #define SPINDLE_PWM_DDR     DDRB
  #define SPINDLE_PWM_PORT  PORTB
  #define SPINDLE_PWM_BIT     3    // Uno Digital Pin 11

It seems that my options are 62.5 kHz, 7.8 kHz, 1.96 kHz or 0.98 kHz.
Why does it matter? Two excerpts from the Synrad manual:

Tickle frequencies [a 'keep-awake' signal at zero power] lower than 4.5 kHz may compromise laser performance, ..., and stress the RF [radio frequency] electronics thereby reducing long term reliability while tickle frequencies greater than 5 kHz may cause unintended lasing.
Because laser output follows PWM input with a rise and fall time constant of ~100 µs, the laser cannot precisely follow Command signal frequencies over t kHz with duty cycles greater than 50%.

Can anyone see a workaround for this within the constraints of the GRBL configuration?
I can only think of a hardware solution to filter the PWM out and run it through another device to convert the analog signal to a 5 kHz PWM.
Many thanks.


texts: Do I need resistors or capacitors on this relay?

texts:
I'm using my Arduino to control a relay switch, which has an extension cord attached to it (see photo).

The relay is connected to the Arduino via pin 9, which is set to pinMode(9, OUTPUT);

Do I need any resistors or capacitors or diodes attached to this? Almost feels too simple, given I'm running AC power through the relay. But maybe no?

It definitely works, but I want to make sure I'm not going to burn something out (or down).


texts: Problems improving the inquiry speed of Bluetooth HC-05

texts:
I'm buiding a project with the Arduino and Bluetooth HC-05 module that receives the MACs of Bluetooth devices around (does not connect, just inquiry). It works, but I want a better performance in detecting devices, because it doesn't find devices that stay less than 2 seconds in the area. So, I want it to work faster, detecting even if the device stays for 1 second (or maybe less) in the range of the HC-05.

-First, I tried to select the baud-rate (from 9600 to 1382400) of USART, but I tested it, and it did not change anything.

-Then, I tried to config the period and the duration of the inquiry process by "AT+IPSCAN", but, for any value I adjust, also results in anything.

Thought maybe I did not configure parameters, but I tested "AT + IPSCAN?" and "AT + UART?" and the values are those that I set.

This is strange, but I could not find a solution. Does anyone know what it could be?


texts: How do i make my DC motors run simultaneously?

texts:
Im coding an adafruit motor shield for  3 DC motors to go forward & backwards, and so my concern is why only my motor3 is running the whole time and motors 1 & 2 are switching off meaning 1 goes than 2 goes and on and on? My code is below if you see where my mistake is in the code can you just tell me what it is and what to do to make them run simultaneously?
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor(3);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  // turn on motor
  motor1.setSpeed(300);
  motor2.setSpeed(200);
  motor.setSpeed(500);
  motor.run(RELEASE);
}

void loop() {
  uint8_t i;

  //third motor
  Serial.print("tick");
  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    motor2.setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    motor2.setSpeed(i);
    delay(10);
  }

  //second motor
  Serial.print("tick");
  motor2.run(FORWARD);
  for (i=0; i<255; i++) {
    motor2.setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    motor2.setSpeed(i);
    delay(10);
  }
  Serial.print("tack");
  motor2.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor2.setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    motor2.setSpeed(i);
    delay(10);
  }

  Serial.print("tick");
  motor1.run(FORWARD);
  for (i=0; i<255; i++) {
    motor1.setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    motor1.setSpeed(i);
    delay(10);
  }
  Serial.print("tack");
  motor1.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor1.setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    motor1.setSpeed(i);
    delay(10);
  }
}


texts:
I'm using an Arduino Uno Rev3 Board and need to send a trigger signal at a certain frequency (20-50Hz).
This trigger signal should be as accurate as possible (+/- 0.01 ms).
The Arduino site states that the arduino uno has a 16MHz Quartz Crystal, but I'm measuring a frequency accuracy of about 0.35% (which would be typical for a ceramic resonator) instead of what i could expect from a quartz (0.001%).
I'm using the micros() function to measure time.
Am I doing something wrong? How is my frequency so inaccurate?

Thanks for your help! :)

Edit: Indeed when I have a look at the schematics, I see the ceramic resonator (Blue circle). However, there seems to be another 16 MHz part (red circle). could that be a quartz oscillator?


texts: Are there any reasons to pick Nano over Micro?

texts:
Nano is from 2008, and micro from 2012. Micro seems better on every parameter, in particular in having a better (I think) microcontroller, ATMega32u4, over ATMega328P.

However, all the shops I've checked out, both local and online, sell the Nano, and only some sell Micro. And Nano is always more expensive than Micro. E.g. at RS-Online 26GBP for Nano (link) and 16GBP for Micro (link).

Why do many shops only sell the inferior product?

Why is the older and less capable Nano more expensive?

Why would anyone buy the Nano over the Micro?


texts:
I have an problem, which at first thoughts (and being new to Arduino) I though was a perfect application for an Arduino. However, after trying and failing to implement it I am doubting myself!

Simply - I need to control many LEDs independently, many of which will have their own individual patterns - for example "5 seconds on - 5 seconds off". "continuous flashes" - or sequences such as "2 flashes, pause, 1 flash". Obviously without the luxury of threads I am becoming a little unstuck. Be great to hear if a) Arduino is the best choice and b) if it is - how can I go about this!

Thanks in advance :)


texts: Can we write text file to SD card that can also be read in windows?

texts: I tried to use Arduino SD Library, I was able to run Datalogger and Dumpfile sample application to verify that the bits and bytes are written perfectly in the SD card.  When I tried to read from windows, everything is null. Is there an Arduino library that can write text file compatible to windows text format?


texts: Power suply for MicroSD card breakout board

texts:
I'm developing a project and I need to connect to my Arduino Mini with a SD card breakout board. The problem is that I can't plug it directly to the Arduino since it is already powering some sensors and a BITalino, and I was told that it would, for some reason, be better to connect an external battery to the SD board.

My question is if i can supply this  MICROSD CARD BREAKOUT BOARD+ with a 3.7V battery, instead of a 5V.

Thank you!

Description:

Onboard 5V->3V regulator provides 150mA for power-hungry cards
3V level shifting means you can use this with ease on either 3V or 5V systems


texts:
I was wondering is there a way to calculate SpO2 using a pulse sensor?
I calculated BPM and stress before with pulse sensor and now I want to calculate SpO2.

Link to Pulse sensor manual


texts:
So I have SIM900 Shield and Arduino Uno and they have both power jack, is it possible to power one of them using one power jack and connect it's power with another? If it is possible, I sincerely need the explanation.

I've research about the VIN pin of Arduino but I didnt quite get it and can't take the risk that I might fry the board since Im new here.


texts: I recently purchased a LoRa module (https://it.aliexpress.com/item/1005002116232826.html?spm=a2g0s.9042311.0.0.38c74c4dPnh2Gg) but I have not found any working tutorial for this model can you help me


texts: I require additional digital input pins for 5 PIR sensors. Can I use the shift register (74HC165) to read these input? And will I be able obtain real time values from all the 5 sensors?


texts: Is the MKS GEN V1.2 compatible with Arduino IDE as Arduino MEGA Board?

texts:
I need to do a Servo controller using Arduino and I have a spare MKS GEN V1.2 board right now, looking at the documentation from here http://reprap.org/wiki/MKS_GEN it seems this board is actually an Arduino board which can be programmed with the Arduino IDE.

Is this a correct observation that the MKS GEN V1.2 board is, in fact, a Arduino MEGA board internally?


texts: Reading data from ThingSpeak via Arduino Uno+ESP8266

texts:
I am integrating thingspeak and arduino plus Esp8266 mean making a simple project which contain my android app to update the thingspeak channel and then want to read the data of that channel via arduino uno. the android parts works fine but at the arduino side i got stuck and unable to read the channel data via esp8266(attached to my arduino uno).
Here is my code.any help would be appreciated.
it shows in serial monitor connecting to thingspeak.com and show nothing next.

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2,3); // RX, TX
#endif

char ssid[] = "M T G";            // your network SSID (name)
char pass[] = "androidGUII";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiEspClient client;
static const char* host = "api.thingspeak.com";
static const char* apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }
  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  printWifiStatus();
  Serial.println();
}

void loop()
{
      const int httpPort = 80;
    if (!client.connect(host, httpPort)) {
        Serial.println("connection failed");
        return;
    }
  client.println("GET /channels/xxxxxxx/feeds.json?api_key=xxxxxxxxxx&results=2 HTTP/1.1");
  while (client.available() == 0);  // wait till something comes in; you may want to add a timeout here
  Serial.println(client.read());
  client.stop();  // close socket
  delay(10000);
}
void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}


texts: MD_Parola display issue when constructing test

texts:
I'm using ESP8266 and 4 dot Matrix Tiles, to display clock ( updates using NTP and WiFi ).
Everything is working well, but only when I'm constructing text using a const char* type.
But, since I wish to construct text as sprintf(temp, "12:00"); or char temp[20]="12:00\n; creates gibberish text.
MD_Parola dotMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void updateTime()
{
  char clk[10];
  char dat[10];
  char temp[10];
  sprintf(temp, "12:00"); // <---- this ways failes
  const char *t = "12:00"; // <---- this way succeeds
  dotMatrix.displayText(t, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
}

link to library
Appreciate explanation how to construct text not as const char*


texts: Series of µsec pulse generation using Arduino Due

texts:
I'm working on a project in which I need a series of very accurate pulses containing 2 shots in every pulse. The pulse should have 100µsec on time followed by 300ms off time. But when I'm programming the Arduino Due I'm getting random pulses of non-uniform width. But when I'm trying the same code in microsecond range I'm getting perfect wave.
Here is the code that I'm using

#define LED 8 // Pin designated to give out the pulse
int cycles = 2;  // No. of times you want it to give pulse
int high = 100; // High time in microseconds
int low = 300;  // Low time in milliseconds
int i = 0;
int univ_cycle = 10;

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

}
void loop(){
  for (i ; i < univ_cycle; i ++){
  pulse();
  delay(100);
  }
}
void pulse() {

  // put your main code here, to run repeatedly:
  for(int counter = 0;counter < cycles;counter++){
  digitalWrite(LED, HIGH);
  delayMicroseconds(high);
  Serial.println("ontime");
  digitalWrite(13, LOW);
  Serial.println("offtime");
  delay(low);
  Serial.println(counter);
  }

}

Here is the image of the waveform in microsecond setting

Here is the wavefrom that we got in millisecond setting

I would like to know how can I get the similar wave in microsecond also.


texts:
i am working on my final project in the last semester, i want to move nodeMCU data to labview,

nodeMCU has uploaded the wifiscan program to the arduino IDE
(this program is available when we install the nodeMCU library on the arduino IDE)
nodeMCU is connected using USB Type B to the laptop
then how do i move wifiscan data to labview ?,
please give me suggestions, references, sample programs, etc. to achieve my goals.
thank you

[


texts: Ultrasonic Range Sensor won't print distance in Serial Monitor

texts:
I'm using the red Ultrasonic Range Sensor with

Sig -> Digital Pin 4

VCC -> 5V

GND -> GND

The code uploads fine and i can hear the sensor clicking away, but for some reason it won't print the distance into the Serial Monitor.

//Settings
int echoPin= 4;
int trigPin= 4;
unsigned long pulsetime = 0;
unsigned distance = 0;
unsigned OldDistance = 0;

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

void loop(){

  //Work out the distance
  digitalWrite(trigPin, LOW);
  delayMicroseconds(100);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(100);
  digitalWrite(trigPin, LOW);
  pulsetime = pulseIn(echoPin, HIGH);
  distance = pulsetime / 58;
  delay(10);

  //Send value if it's changed
  if (OldDistance != distance) {

  Serial.print(distance);

  OldDistance = distance;
  }

  delay(50);  // Wait .1 Seconds
}


texts: Do I have to use an RTC to build a clock?

texts:
While I was researching ideas for an Arduino clock, I found several clocks that incorporated an RTC (Real Time Clock) module.

I don't know why it is used in some clocks.

So, here are my questions:

How does an RTC module work?
Do I have to use it "like a rule" (is an RTC necessary or unnecessary) in my clock?


texts: Calling a function that is outside of a class from inside

texts:
I have an Arduino sketch with a timer interrupt class and would like to place the TIMER2Services() function in the TimerTwoTest.ino file for easy access. On compile I get a multiple definition of tmb2 error in the .ino TIMER2Services() function. I have tried all the variations I can think of but no luck. Is there a way to do this?

TimerTwoTest.cpp.o: In function `TIMER2Services()':
D:\Arduino157/TimerTwoTest.ino:41: multiple definition of `tmb2'
TimerTwo.cpp.o:C:\Users\...\build8577138580185682113.tmp/TimerTwo.cpp:10: first defined here

collect2.exe:

TimerTwo.h:

class Tmb2
{
  public:
  void initTIMER2(unsigned int Hz, unsigned int ulPeriod);
  void resetTIMER2(unsigned int Hz, unsigned int ulPeriod);
  TIMER2_TYPE getPeriodTIMER2(void);
  void activeTIMER2 (void);
  private:
}tmb2;

TimerTwo.cpp:

extern void TIMER2Services(void);

[this function is line 10 for the error]
void Tmb2::initTIMER2(unsigned int Hz, unsigned int ulPeriod){  //setperiod and enable interrupt
  if (Hz){
    ulPeriod = 1000/Hz;    //if Hz > 0 use frequency microseconds
  }
  Timer2.attachInterrupt(TIMER2Services).setPeriod(ulPeriod).start();
}

TimerTwoTest.ino:

volatile unsigned long burpCount = 0;

//This routine services the interrupt
void TIMER2Services(void){
  burpCount++;
}


texts: Can I connect more than one IR receiver to an Arduino Uno?

texts:
I want to use #include <IRremote.h> to receive information from an infrared remote control. It works perfectly with one IR receiver.

But I want to put three or four IR receivers:

IRrecv irrecv6(pin6);
IRrecv irrecv7(pin7);
IRrecv irrecv8(pin8);
IRrecv irrecv9(pin9);
IRrecv irrecv10(pin10);

And:

void setup() {
  Serial.begin(9600);
  irrecv6.enableIRIn(); // Start the receiver
  irrecv7.enableIRIn(); // Start the receiver
  irrecv8.enableIRIn(); // Start the receiver
  irrecv9.enableIRIn(); // Start the receiver
  irrecv10.enableIRIn(); // Start the receiver
}

Inside the loop function, I am checking each pin to see if there is any data received. But only the last pin (which means pin 10 above) is receiving the data and others are not.


texts: Can i run brushless ESC from any digital pin of arduino

texts:
{assume arming is done}
Can i connect the brushless ESC to any digital pin and give writemicroseconds() to it? Will this work. because i have connected my 4 ESC's to "~" pins. so i thinks that other will not work.


texts:
As I am really newbie in the programming stuff I have maybe stupid question:(
Is it possible to connect my airduno mega (collecting several data from sensors) via ESP8266-07 module to the internet to be able to upload data to ubidots?
Can somebody give me hint regarding connection both modules and programming itself?
Thanks Martin


texts: Totally unresponsive card with RFID-RC522 Module

texts:
I bought an RFID-RC522 module including two attached PICC cards: a blue key chain tag and a white card with the type of MIFARE 1KB. In addition, I bought two other separate cards from the same seller.
I connected the module to an Arduino board and ran some examples of the library MFRC522.

Everything was OK with the two attached PICC cards (blue tag, and white card), BUT NOTHING worked with the other two cards, even they have no UID and NEVER RESPOND to the module. It seems to me that the internal microcontroller is not programmed. The seller doesn’t have any explanation. So, I need to know how to make them work.


texts:
i am completely new to hardware programming and micro controllers and i am unable to figure out what search-engine search-term to use to find the answer i am looking for.
the project
i am working on a project that will use an arduino to control the opening and closing of a window; in a shed. the project i am trying to achieve is further described here.
the question
i want to know what are the limitations of wire length in an arduino project and what do i need to have to be able to extend that wire length capacity?
i currently have those "common" 20cm wires you get off ebay... which i dont think will be long enough.


texts:
I recently tried using Hobbyist.co.nz's guide on the DHT11 sensor. I installed the Adafruit_Sensor and DHT11 Sensor libraries,  but it keeps returning with a fatal error.

Here is the code and the error:

#include <dht.h>

#define dht_dpin A0 //no ; here. Set equal to channel sensor is on

dht DHT;

void setup(){
  Serial.begin(9600);
  delay(300);//Let system settle
  Serial.println("Humidity and temperature\n\n");
  delay(700);//Wait rest of 1000ms recommended delay before
  //accessing sensor
}//end "setup()"

void loop(){
  //This is the "heart" of the program.
  DHT.read11(dht_dpin);

    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature);
    Serial.println("C  ");
  delay(800);//Don't try to access too frequently... in theory
  //should be once per two seconds, fastest,
  //but seems to work after 0.8 second.
}// end loop()

C:\Users\XXXXXX\Documents\Arduino\sketch_dec19c\sketch_dec19c.ino:2:17:

  fatal error: dht.h: No such file or directory

#include <dht.h>


texts: Is it possible to have long wire connections from an NodeMCU to a servo motor or button?

texts: For my proyect, I need to conect my NodeMCU to a servo motor as well as a push button, the thing is, the distance from the NodeMCU and both components has to have a distance of around 6.10 meters (or 20.0131 feet), I dont know if it is possible to do this connection, I worry if the pwm signal or the voltage would drop by the time it reached either component. I havent been able to try this because I dont have long enough cables to do the connections. In the case that it would be possible, what type of cable should I use and should I add something extra to the circuit to make it work better? Thanks.


texts: I'm aware of and currently using an MQTT network to facilitate communication between several Wemos D1 Mini's but that method obviously relies on having a MQTT broker. Is there a way to have the ESP's communicate directly with each other? I'd be willing to use one module as a server to facilitate the communications but i'm not sure what protocol I should be using. I would ideally like the communication to be as fast as possible as I intend to use them to control some wireless RGB LEDs.


texts: Why does my Arduino seem to reboot every time that I open Serial Monitor?

texts: Every time that I open the Serial Monitor, my Arduino Uno, seems to go back to void setup(). Is it a normal thing?


texts: How does one upload a synthesized solution to the Arduino Vidor FPGA?

texts: I've compiled a solution and have received a ttf file from Intel Quartus which is designed for the Vidor 4000 Arduino board. The file represents a synthesized bitstream to be sent to the FPGA. How do I upload the file to the FPGA onboard the VIDOR board? I've got a JTAG programmer if necessary.


texts:
I am using an Arduino UNO board and trying to interface IMU sensor (GY-521) and GPS sensor (Ublox Neo-6M) at the same time. The connections of the IMU and GPS are as follows

IMU to Arduino:
Vcc --> 5V
Gnd --> Gnd
SDA --> A4
SCL --> A5
INT --> D2

GPS to Arduino:
Vcc --> 5V
Gnd --> Gnd
Tx --> Rx
Rx --> Tx

Now when I used the IMU sensor alone and tested it with the Jeff Rowberg library, it was working fine. But as soon as I make the connections with the GPS and upload a program, the IDE gives the following error:

Arduino: 1.7.10 (Windows 7), Board: "Arduino Uno"

Build options changed, rebuilding all

Sketch uses 3,970 bytes (12%) of program storage space. Maximum is 32,256 bytes.

Global variables use 313 bytes (15%) of dynamic memory, leaving 1,735 bytes for local variables. Maximum is 2,048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xa5

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xa5

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

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

I can't seem to spot the problem. Kindly help me out as I am new to the Arduino development. Thanks.


texts:
I have been using two nRF24L01 to communicate with each other using a simple Arduino Uno Board. It worked for 5 days and now all of a sudden it is now working. I tried to change the modules and the Arduino boards too, but even if trying a simple example the communication between them is not happening.

I googled everything and tried every option, it is not working.

I used printDetails() to check the config of the modules. It shows everything is ok but I am not able to understand if the transmitter or the receiver is the problem. Please guide me to solve this problem. Also how to make sure if both are working (any debugging technique)?

I have been trying it for 9 days now, and I badly want it to work.

The code I am using is very simple code. It doesn't have any errors.

Receiver code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CNS, CE
String response;
boolean done = false;

void setup() {
  delay(500);
  Serial.begin(9600);
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.openReadingPipe(0,0xF0F0F0F0AA);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    radio.read(&response, sizeof(response));
    done = true;
  }
  if (done) {
    Serial.println(response);
  }
  done = false;
  delay(1000);
}

Sender code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CNS, CE
String request;

void setup() {
  delay(500);
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(0xF0F0F0F0AA);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  while (Serial.available() > 0) {
    request = Serial.readString();
    Serial.println(request);
    radio.write(&request, sizeof(request));
    delay(1000);
  }
}


texts:
I am new in arduino trying to make race game. My problem is that my button (all buttons) is working sometimes and sometimes not. I am pretty sure that it's because of my code. Could you please help me with it?
Here is my code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pausebetween = 1;
int spaceBetween = 1;
int maxElemnets = 4;
int obstacleArray[4][2];
int obstacles[4] = {3,3,2,3};
bool gameStart = false;
byte player[8] =
{
 B00000,
 B00000,
 B10100,
 B11110,
 B11111,
 B11110,
 B10100,
 B00000
};
byte obstacle[8] =
{
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111
};
byte enemy[8] =
{
 B00000,
 B00000,
 B00101,
 B01111,
 B00101,
 B00000,
 B00000
};
byte empty[8] =
{
 B00000,
 B00000,
 B00000,
 B00000,
 B00000,
 B00000,
 B00000
};
byte fire[8] =
{
 B00000,
 B00000,
 B00000,
 B11111,
 B00000,
 B00000,
 B00000
};
int mat[2][24] = {
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  };
int up = 0;
int down = 0;
int reset=0;
int atack=0;
void setup() {
 pinMode(9, INPUT);
 pinMode(8, INPUT);
 pinMode(7, INPUT);
 pinMode(6, INPUT);
 Serial.begin(9600);
 lcd.createChar(0, player);
 lcd.createChar(1, empty);
 lcd.createChar(2, enemy);
 lcd.createChar(3, obstacle);
 lcd.createChar(4, fire);
 lcd.begin(16, 2);
}
void loop() {
  up  = digitalRead(9);
  down  = digitalRead(8);
  atack  = digitalRead(7);
  reset  = digitalRead(6);
  if(atack){
    for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
            if(mat[j][i]==1){
              mat[j+1][i]=4;
              Serial.println(mat[j+1][i]);
            }
        }
      }
  }
  if(reset){
    clearStage();
    gameStart = true;
  }
  if(gameStart){
    generateObstacles();
    redrawGame();
    moveObstacles();
  }
  delay(1000);

 }

void generateObstacles(){
  int obscount = random(1,4);
  int types[4][2] = {{1,3},{2,1},{1,1},{2,1}} ;
  int type = random(0,4);
  for(int i = 0; i< obscount; i++){
    mat[0][16+i] = types[type][0];
    mat[1][16+i] = types[type][1];
  }
  int spacecount = random(2,5);
  pausebetween = obscount + spacecount;
}
void redrawGame(){
   for(int j = 15; j >= 0; j--){
    for(int i = 0; i < 2; i++){
      lcd.setCursor(j,i);
      lcd.write(mat[i][j]);
    }
  }
}
void clearStage(){
  for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
            if(i!=1 && j!=1){
               mat[i][j] =1;
          }
        }
      }
}
void moveObstacles(){
   for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
           if(mat[i][j]!=0){
            mat[i][j] = mat[i][j+1];
          }else{
            mat[i][j-1]=1;
          }
          if(mat[i][j]==4){
            mat[i][j-1]=0;
            mat[i][j-2]=1;
           }
        }
      }
}

Scheme:


texts:
i've got a bit of a problem with my Arduino UNO.

So coming back to my (pretty basic) build after a bathroom break, I go to un-assemble my circuit (on the breadboard) and grabbing the LED causes a static shock.

Since then I haven't been able to get any power to come out of the Arduino to the breadboard circuitry.

I have tried:

Different Breadboards
All new parts, LED's/cabling/buttons/resistors.
Different power and ground cables (from Arduino to breadboard)
Giving the Board more time to 'cool down' (I heard there was a
temperature based reset device?)
using the 3.5v output (I'm not sure if by doing this i should remove
the resistor? i'm VERY new to electronics
using the alternate ground input

Looking around here for 'shorts' or 'damaged Arduinos' returns mostly results about non communication to the board. the difference here is I can absolutely still upload programs to my Arduino and then run them (I've only tried the pre-existing blink, but i don't think there is any difference). And my computer's USB ports are also fine. So if there is a duplicate question i apologize, but i haven't been able to find anything related.

Any help would be much appreciated!


texts:
Does anyone know what it means by the Atmega 328p has 131 instructions? And could you give an example of how any one of these 131 instructions look like?
Thanks in advance!!


texts: (Firebase and NodeMCU) How to reduce the delay time when control led?

texts:
My project consists of NodeMCU controlling led from Firebase's RealTime Database (Using Esp8266Firebase library)
The problem is that the delayed time is too long ( about 6 seconds from when I change the value on the server until the led is turn ON or OFF)

My code on NodeMCU 1.0

#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>

#define FIREBASE_HOST "-6c5d7.firebaseio.com"
#define FIREBASE_AUTH "hYIBAaJYb8nGPuo8Q9EfZuAIfV"

//define ledPin
int ledPin = 2; //D4

void setup(){
    //setup pinLed
    pinMode(ledPin, OUTPUT);

    //setup general
    Serial.begin(115200);
    delay(1000);
    WifiConnect();
    Serial.begin(115200);
}

void getConfirmDataForLed() {

    int controlValue;
    Firebase.getInt(firebaseData,"/Control/ControlValue",controlValue);

    switch(controlValue) {

        case 1:
            digitalWrite(ledPin, HIGH);
            break;
        default:
            digitalWrite(ledPin, LOW);
            break;
    }

}

void WifiConnect(){
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.println("Connecting to WiFi..");
    }

    Serial.println("Connected to the WiFi network");
    Serial.println(WiFi.localIP());
    Serial.println(WiFi.macAddress());

    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
    Firebase.reconnectWiFi(true);
    //Set database read timeout to 1 minute (max 15 minutes)
    Firebase.setReadTimeout(firebaseData, 1000 * 60);
    //tiny, small, medium, large and unlimited.
    //Size and its write timeout e.g. tiny (1s), small (10s), medium (30s) and large (60s).
    Firebase.setwriteSizeLimit(firebaseData, "tiny");
    delay(1000);
}

void loop(){
    getConfirmDataForLed();
    delay(500);
}

Firebase's Structure

Control
    |
    |--ControlValue : 0


texts: SOLVED: Strange phenomenon with avrdude: stk500v2_ReceiveMessage(): timeout only with ATmega250 on windows 7x64

texts:
I know this problem has been reported multiple times but in my case I think there is a different light on it.
My desktop is a w7x64 box and I also have a notebook with w10.
Both system have the arduino IDE 1.8.5 with the latest updates.
The desktop though has more boards and drivers as it is my main development system.
I have at ATmega2560 clone with CH340 which used to work on my desktop about half a year ago when I tried to get an LCD touch shield to work.
Yesterday I tried to resume on it and I got the ubiquitous timeout error.

So I removed the shield and tried the basic blink sketch but no change.
I tried an arduino nano and there was no problem to upload the blink sketch.
Then I tried different USB cables and ports but the timeout problem with the ATmega persisted.

So I went to the notebook and the ATmega worked like a charm.
Now I know that the board is ok as well as the cable.
The port is also ok as the nano worked on it smoothly.
I also tried the upload from an elevated command prompt with the verbose option but it gave me no further clue.

The output is below:

C:\Users\Pete\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/bin/avrdude -vvvv -CC:\Users\Pete\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf -v -patmega2560 -cstk500v2 -PCOM34 -b57600 -D -Uflash:w:T:\TMP\arduino_build_330193/Blink.ino.hex:i

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Pete\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0 -arduino14/etc/avrdude.conf"

         Using Port                    : COM34
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 57600
STK500V2: stk500v2_open()
STK500V2: stk500v2_getsync()
STK500V2: stk500v2_send(0x1b 0x01 0x00 0x01 0x0e 0x01 0x14 , 7)
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
STK500V2: stk500v2_recv(): avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout

Does anybody have an idea how to further tackle the problem?


texts: Boil water inside a small container with an arduino

texts:
I am currently working with a sciene/electronic project where i need "steam". In order to create steam i need to boil water and i plan to boil it inside a very small container [around 5cmx5cmx5cm]. What i want to do is to control this with an arduino but I am very unsure on what step i currently need to make. Are there any "heating-up" modules out there? Or would I need to order a mini-mini kettle and connect that to my arduino?

I am very grateful for every advice i can get because as u can tell i am a bit confused as of right now!


texts: Button to optocoupler to fire camera 4 times

texts:
Ok, this is my first project where I've not had @forsvunnet close by to help.

I've got a camera connected to an optocoupler, that just fires HIGH then LOW.

I can't get a button working with it, so when I push a button, it fires opto 3 times.

This is my sketch.

 // Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int opto = 12;
int buttonInput = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

// the setup routine runs once when you press reset:
void setup()
{
// initialize the digital pin as an output.m
pinMode(opto, OUTPUT);
pinMode(buttonInput, INPUT);
digitalWrite(buttonInput, LOW);}

// the loop routine runs over and over again forever:
void loop()
{
  buttonState = digitalRead(buttonInput);
  if (buttonState == HIGH) {
      digitalWrite(opto, HIGH);
      delay(1000);               // wait for a second
      digitalWrite(opto, LOW);
      delay(1000);               // wait for a second
      digitalWrite(opto, HIGH);
      delay(1000);               // wait for a second
      digitalWrite(opto, LOW);
  } else {

  }

}

Anyone point me in the right direction? It's driving me mad.


texts: reading from an array and writing into a servomotor

texts:
I have an Arduino Uno.
I am trying to write a code that reads a command and according to that command it saves angles into an array or writes the angles of the array into a servomotor.
I am facing some problems with my code such as executing the instructions of boucle FOR without ending and other strange things.

#include <Servo.h>

Servo s;
int t[6];
int n, r = 2, b = 4 ;
char c;
String ch = "" ;
int i = 0;
int nb, rep = 0;
int cmd = -1;

void setup() {
    Serial.begin(9600);
    pinMode(r, OUTPUT);
    pinMode(b, OUTPUT);
    digitalWrite(r, LOW);
    digitalWrite(b, LOW);
    s.attach(9);
    t[0] = 0;
    t[1] = 90;
    t[2] = 180 ;
}

void loop() {
    while ((cmd == 0) || (cmd == -1)) {
        cmd = lirecmd();
        delay(20);
    }

    if (cmd == 1) {
        digitalWrite(r, HIGH);
        digitalWrite(b, LOW);

        while (i < 3) {
            while (Serial.available() > 0) {
                c = Serial.read();
                ch.concat(c);
            }

            if (ch != "") {
                nb = ch.toInt();
                t[i] = nb;
                i = i + 1;
                ch = "";
            }
        }
    } else if (cmd == 2) {
        int x;
        cmd = -1;
        digitalWrite(b, HIGH);
        digitalWrite(r, LOW);

        for (i = 0; i < 3; i = i + 1) {
            Serial.print(i);
            x = t[i];
            delay(1000);
            s.write(x);
            delay(1000);
            break;
        }
    } else {
        digitalWrite(r, HIGH);
        digitalWrite(b, HIGH);
    }

    i = 0 ;
    cmd = -1;
    rep = 0;
    digitalWrite(r, LOW);
    digitalWrite(b, LOW);
    delay(50);
}

int lirecmd() {
    if (Serial.available() > 0) {
        n = Serial.read() ;
        n = n - 48 ;
    }

    return n ;
}


texts:
I am using Arduino for an IoT class (40 students).  I have set up a test program to check all sensors and actuators used in the class (we need to recycle for next semester). However, I would also like to check the Arduino's themselves (and also NodeMCU´s) in case some of the units have been broken.  I have an idea of testing input/output of each pin to make sure its working - using LEDs and buttons, but if anyone has some ideas to improve testing, it would be great to hear from you. I guess I am not the only one reusing IoT components from one semester to another.  It would be great to hear from other instructors in the IoT field.
Best regards,
Lasse Berntzen,
University of South-Eastern Norway,
lasse.berntzen@usn.no


texts: How to pulse a signal at 100ms to 500ms?

texts:
Based on this PDF I need to pulse between 100ms and 500ms to record a video (the description is apparently wrong according to this guy). How would I generate such a pulse? The small module has 3 wires I can use, which are positive, ground, and a yellow wire. I assume I need to pulse the yellow wire.

I don't want to hook anything up wrong, but my guess would be using pulseIn(). However, I am not sure at all. Any help appreciated.