texts: Code for activating a led after 2 minutes and will blink after 30 seconds interval

texts:
Can anyone help me to build a code which will activate a LED after 2 minutes when the power supply is cut off and blink that LED after a time interval of 30 seconds.
I want to import the code on Arduino-Uno.

I will power the Arduino with cell and assign two pins as sensor if they are connected to each other than every this is fine if they are cut the Arduino will blink the LED after 2 minutes and will keep blinking at 30 seconds interval


texts: I'm currently learning about using BLE with Arduino and iOS. From what I understand (correct me if I'm mistaken), each type of BT device has a UUID. I'm using a HC-06 module connected to my Arduino. How do I find out what the UUID of a HC-06 is? I've been looking through data sheets to no avail.


texts: Remotely uploading code to an Arduino board over the internet

texts:
I recently used Particle Photon that allows me to upload firmware (.bin file) remotely over the internet.

I would like to use something like this for my Arduino but I cannot find anything like that. Does anyone know any possible way to upload firmware to my Arduino board remotely connected to internet via Ethernet shield of any WiFi module?


texts:
My basic question is: What is a good alternative to EEPROM chips for external memory on the Arduino Unor R3?

I know that there are EEPROM chips when one would like an external memory chip. It, in fact, seems like this is the standard choice. I am wondering if there are any other good ways to work with external memory. Are there, for example, memory chips that work a bis simpler? Like, a chip that doesn't require any specific libraries in the Arduino?

(I do not have extensive experience working with the Arduino.)


texts:
I need to connect NodeMCU and NRF24L01. where I'm receiving data from another NRF24L01 Transmission. I managed to connect to a WiFi network but the data receiving is not taking place as expected. Here is my code

#include <SPI.h>
#include "RF24.h"
#include <ESP8266WiFi.h>

RF24 myRadio(7, 8);
const char* ssid = "******";
const char* password = "********";
struct package
{
    int id = 0;
    float longitude = 0.0;
    float latitude = 0.0;
    char text[100] = "empty";
};

byte addresses[][6] = {"0"};

typedef struct package Package;
Package data;

void setup()
{
    Serial.begin(115200);
    delay(1000);
    WiFi.begin(ssid, password);

    Serial.println();
    Serial.print("Connecting");
    while (WiFi.status() != WL_CONNECTED)
    {
     delay(500);
     Serial.print(".");
    }
    Serial.println("success!");
    Serial.print("IP Address is: ");
    Serial.println(WiFi.localIP());
    myRadio.begin();
    myRadio.setChannel(115);
    myRadio.setPALevel(RF24_PA_MAX);
    myRadio.setDataRate(RF24_250KBPS);
    myRadio.openReadingPipe(1, addresses[0]);
    myRadio.startListening();
}

void loop()
{

    if (myRadio.available())
    {
        while (myRadio.available())
        {
            myRadio.read(&data, sizeof(data));
        }
        Serial.print("\nPackage:");
        Serial.print(data.id);
        Serial.print("\n");
        Serial.println(data.longitude);
        Serial.println(data.latitude);
        Serial.println(data.text);
    }
}

Any idea on why this is not receiving data as expected?. This somehow managed to connect to my WIFI successfully. Here are my pin connection


texts: How to transmit data from Arduino to Raspberry Pi?

texts:
I am planning to build a network with five Arduino Mega devices, each of which will collect data using multiple sensors. Each Arduino will periodically transmit the sensor data to a gateway Raspberry Pi using XBees. As it is the first time I am working with Arduino and Raspberry Pi, I need help with the following:

Which protocol to use to transmit data from Arduinos to the Raspberry Pi? Do I have to write code for both Arduino and Raspberry Pi or are there existing solutions that I can use for this purpose?
Does MQTT, Node-RED or Node.js have any role in the above?

Thank you for your advice!

A.


texts:
How can we make the Arduino board interact with old, analog telephone, and to make phone calls?

I guess it involves connecting the board to the telephone with some specific cable (how it's called?)

In addition, I assume it will require us to use the telephone low-level dialing protocol (in order to actually interact with the phone and to send commands). Where can I read about it?

Is there a reason to concern about conversation between the digital/serial board and an analogous device?

By the way, I've read that analog telephones have relatively high voltages that can easily damage the board. I'd love to get any information about things like this, related to connecting Arduino to analog telephones, in order to know about such issues and about what to be concerned and to explore.

Thanks a lot!


texts: Arduino Mega keep states after reprogramming

texts:
Based on:

https://forum.arduino.cc/index.php?topic=440978.0

And some previous experience with Arduinos. What I would like to accomplish here is that I have a 8 channel relay board with the relays in different states. The Arduino is connected to a RaspberryPI via USB.

The first problem is well known the automatic reset of the Arduino which can be taken care of with a resistor or desoldering a pin on the Mega board so you can reconnect your Arduino as many time as you wish (while running on an external +5V power source) to the Raspberry and it will never reset.

However I also remember that doing this to the boards will also make them impossible to program because they cannot reset at the end when the sketch is uploaded.

I have think of a workaround:

1, Create a programming command on the arduino which is when it's received from the RPI it will connect that cut off pin with a relay which will make resetting possible again

2, Save all relay states to the EEPROM

3, After reset the Arduino always checks this programming flag in it's EEPROM and if it's present it either does not touch the relays or set them to the same position ON/OFF depending on the value it read back from the EEPROM

The last guy claims that: When the Arduino is in reset, all pins act like they aren't connected to anything. If you have an output which must be in a specific state during that period, you must add an external resistor to pull it up or down as required.

Is there any other solution for this problem? Like using a newer Arduino board which can keep pin states over reprogramming?


texts:
I have been using the ATmega328P TQFP32 chip for quite a while and I would like to try something new. I came across the ATSAMD21G18 used by Arduino Zero and M0. However, there aren't any information online regarding how to develop a standalone, very basic setup of it.

Previously, I have used...

ATmega328P TQFP32
For the crystal: 16Mhz and 22pF caps
For bootloading: 10 11 12 13 for Arduino ISP
For uploading programs: TX and RX of an Arduino Uno with its chip removed.

For the ATSAMD21G18, I am also looking for a similar setup. I checked out the Sparkfun Mini breakout schematics, but I am not good at reading them and there seems to be a lot of components just for protection and to make it more stable, which I don't need as you can probably know from the setup I used for the 328.

https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/sparkfun-samd21-mini-breakout-v10.pdf

What are the basic required components for it to work properly?

For bootloading, am I required to use the Atmel Ice? If so, what are the pins and components needed for burning the Arduino Zero bootloader?

For uploading a program, am I required to use the USB functionality built in? How can I use it (components pins and connections)? Can I use Arduino ISP using an Arduino Zero?

Finally, what should I bear in mind when switching from an ATmega328P to an ATSAMD21G18?

Thanks in advance!


texts: Which arduino will be suitable with bill acceptor

texts:
I want to connect a bill acceptor (protocol ID003) and 3 switches and an Ethernet shield to Arduino. I am building a system that accepts bill and pass on the information to our software. Which Arduino will be the best choice, we need something which will have lot of code and also communication should be fast.

ARDUINO MEGA 2560 REV3
ARDUINO DUE
Arduino Uno REV3

--Edit--

This is I want to create:

A bill acceptor connected with arduino. Arduino has 3 buttons. (1. Play button, 2. redeem cash button. 3rd is not necessary).

When user login on machine, I get the details of user account through an API.

When user inserts money in bill acceptor, it enables the play button and add money in users account (If user already has money in account, button will be enabled). User can play until his account is not empty (i.e. if user has 200 in account, he can play 10 times). User can earn or lose money.

I have to send this transaction detail through an API.
If user press redeem button, it will print a slip of account details (Total money in account)

I am using Python.

I need to know which arduino is suitable for this, Ethernet shield compatible with that arduino (I think I am going to use ARDUINO MEGA 2560 REV3, but I don’t know Ethernet shield compatible with this model).

Also I need some Idea how can I make this. This is first time I am using arduino and bill acceptor.


texts: Detect and stream if a chair is occupied

texts: I am planning to build a device able to detect and tell a server via Wi-Fi if a chair is occupied. How would you do it? And how cheap do you think the device could be?


texts: Splitting a string in arduino from computer

texts:
I am having an issue splitting an incoming string from a computer program to arduino.
The incoming format is as follows:
123.456,987.654 \r\n

The comma separates the two values.
code is this(edit to add code most likely too many variables):

char c;
String com;
String targetstr;
String actualstr;
bool newdata = true;
float target =1;
float actual = 5;
float diff;
int pwm = 0;
float firstup = 2.75;
float firstdown = 2.25;
float intensifier = 5;
unsigned long lasttime = 0;
unsigned long currenttime = 0;
int watchdog = 1000;

void setup() {
  // put your setup code here, to run once:
Serial.begin(19200);
dac.begin(0x60);
}

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

while(Serial.available()>0&&newdata == true){
  c = Serial.read();
// switched to '\r' from '\n' for testing.
  if(c == 0x0D){}

  if(c ==0x0A){
  targetstr = getValue(com,0x2C,0);
  //targetstr = com.substring(0,com.indexOf(0x2C));
  target = targetstr.toFloat();
  actualstr = getValue(com,0x2C,1);
  //actualstr = com.substring(com.indexOf(0x2C)+1);
  actual = actualstr.toFloat();
  com = "";//reset string
  diff = actual - target;
  newdata = false; //reset flag
  lasttime = currenttime;
  //Serial.print("Diff = ");
  //Serial.println(diff);
  Serial.print("Tgt ");
  Serial.print(targetstr);
  Serial.print(" Act ");
  Serial.println(actualstr);
  }
  else{
    com += c;
  }

The getValue is an example that I found on stack exchange

String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

So I have attempted two different ways to make this work. If I use the arduino serial monitor the code executes perfectly, but if I use the computer program it will not split the values.

In a serial monitor this is the sent code to the arduino via serial monitor(hex and ascii)

31 32 33 2E 34 35 36 2C 34 35 36 2E 31 32 33 0A   123.456,456.123.

and this is the arduino response
54 67 74 20 31 32 33 2E 34 35 36 20 41 63 74 20 34 35 36 2E 31 32 33 0D 0A                         Tgt 123.456 Act 456.123..

And this is code sent from the computer program to arduino:

31 36 31 2E 39 35 32 2C 31 35 30 2E 38 30 30 0D 0A    161.952,150.800..

arduino response:

54 67 74 20 2E 39 35 32 2C 31 35 30 2E 38 30 30 0D 20 41 63 74 20 0D 0A                   Tgt 161.952,150.800. Act ..

I am not sure of the reason of not splitting, I have tried ascii and hex in the code for the comma, as well as two methods of actually splitting.

What are some other things I can try?


texts:
I face a problem and I really need help.
For my Arduino project, I'm using RFID reader with tags.
The story is, I have a desired arrangement for the cards and I defined it as an array called desired[]= {.... , .... ,....}
Then, I want my RFID reader to read the real sequence of the cards and Arduino will tell me if the sequence is right or wrong.
My real problem is, how to put the input which will come from the reader in my empty array real[2];
My code is:

#include <SPI.h> //// Library
#include <MFRC522.h> // Library
constexpr uint8_t RST_PIN = 9;     // Configurable, see typical pin layout above
 constexpr uint8_t SS_PIN = 10;     // Configurable, see typical pin layout above
 MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
String Desired[]={ "f01ca379" ,"60d7a1a5" , "64d7a3a6"};
String Real[2];

void setup() {
Serial.begin(9600);                                           // Initialize
serial communications with the PC
SPI.begin();                                                  // Init SPI bus
mfrc522.PCD_Init();                                              // Init MFRC522 card
 }

   String readUID() {
  String readUID = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
     readUID = readUID + (mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
    readUID = readUID + String(mfrc522.uid.uidByte[i], HEX);
          }
            mfrc522.PICC_HaltA();
       return readUID;
      }

void loop() {
 if ( ! mfrc522.PICC_IsNewCardPresent()) {
return; }
 if ( ! mfrc522.PICC_ReadCardSerial()) {
return; }
String UID = readUID();
if (UID == "f778f19"){
******************************************
******************************************
     }
 }

I used f01ca379 card as a master card only to start the loop.
in the {*************} I need to complete the code in order to save the input in my Real Array, then to compare it with the desired array and decide if the real arrangement matched with the desired one.with tags


texts: Arduino Esp8266 Signal(TIMER0_COMPA_vect) can’t compile

texts: Trying to compile a program containing the statement SIGNAL(TIMER0_COMPA_vect) written for arduino. But I want to use it on an esp8266 board. The code will compile  for Arduino uno. But I get an error “expected constructor, destructor, or type conversion before ‘(‘ token when I try to compile for a Wemos D1 board. Can anyone help me convert the statement to pass the compile test. Thank you


texts: Protecting your computer from stupid (arduino) mistakes

texts: I recently ran way to much voltage through my Arduino and back into my computer via the USB connection. I'm looking for a USB hub with a fuse or some sort of protection to protect my laptop from these types of mistakes.  Any suggestions as to products that would serve this function or other precautions I might take?


texts: Difference between SoftwareSerial and Serial

texts:
From the sample code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

What is the difference between, why use 2 types of calls to make AT command calls.

  SoftwareSerial mySerial (10,11)
  mySerial.begin(10,11)

and

  Serial.begin(9600)

Edit, this answers my question in my own words based on @jfpoilpret response.

It is important to initialize both Serial and SoftwareSerial, since SoftwareSerial is used to send the actual commands to the GSM, and Serial is used to view all the commands and their responses on the debug port of the GSM
The pins on the GSM and Arduino are used to connect the the 2, and pass on actual commands. While the RS232 is only used for debugging. We can however connect a RS232 to USB connector so as to connect the GSM to the desktop(or laptop)
The code in the loop is essential to help convert all actual commands to the debugging RS232 port, and the other way around, so as to enable us to use a tool like cutecom (on ubuntu) to pass commands to the GSM serial input pins.

  Important Note : When using cutecom ensure that you select CR line end to send commands.


texts: Can't detect I2C displays with Arduino Nano

texts:
All cables tested and work:

SCL - A5
SDA - A4
VCC - 5V
GND - GND

I'm using an Arduino Nano board and an I2C display - I've tried everything to get it to work and I'm now convinced it's a hardware fault. Using the Arduino I2C address scanner, it is unable to find a device, even though it is wired correctly (I've checked multiple times).

This is the code I used, i2c_scanner, and this output:

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

... is all I get.

Any suggestions, or is my board output fried?


texts: Trying to save .wav files with new name every loop

texts:
I have built a set up with an Arduino UNO hooked up to a switch, so that whenever the switch goes from HIGH to LOW it saves audio to an SD card. I am using the TMRpcm Library. The problem is the current code will only be able to record 1 audio file; I want to the Arduino to run for a long period of time collecting multiple audio files as the switch is turned on and off. I need a way that will allow it so everytime the switch is pushed back down the next file saved will have a different name than the one previously saved (preferably by an increased numeric value eg "1.wav" & "2.wav"). I have tried audio.startRecording(audiofile+".wav", 16000, A0); and it makes it so no files save to the SD card accept an empty file simple titled 'WAV'. I have tried using a switch case but it will not allow me to reach a case over 10, without running out of RAM. Currently, my code can save 1 audio file but I want it to reach a point where it can save as many as the SD card can hold, without having to restart the software.

My current code is here. Any help would be greatly appreciated

//////////////////////////////////////// SD CARD
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>
#define SD_ChipSelectPin 10
TMRpcm audio;
//////////////////////////////////////// SWITCH CASE
int audiofile = 0;     // # of recording
unsigned long i = 0;
bool recmode = 0;      // recording state
//////////////////////////////////////// SWITCH
int inPin = 2;         // input Switch Pin
int state = HIGH;      // the current state switch
int reading;           // the current reading from the switch

void setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT);  // Microphone
  pinMode(inPin, INPUT_PULLUP); // Switch
  //////////////////////////////////////// SD CARD
  SD.begin(SD_ChipSelectPin);
  audio.CSPin = SD_ChipSelectPin;
}

void loop() {

  reading = digitalRead(inPin);
  ////////////////////////////////////////
  while (i < 300000) {
    i++;
  }
  i = 0;
  ////////////////////////////////////////
  if (reading == LOW) {
    if (recmode == 0) {
      recmode = 1;

      Serial.println("Recording");

      audiofile++; // To move case
      audio.startRecording("1.wav", 16000, A0);
    }
  }
  ////////////////////////////////////////
  else if (reading == HIGH) {
    recmode = 0;

    Serial.println("Hung-Up");
    audio.stopRecording("1.wav");
  }
}


texts:
is there a way to make the Arduino act as a voltage source, by generating sinusoidal, triangular and other kinds of signals? If so, can it be done using LabVIEW? (I've already managed reading analog signals using VISA)

Thank you!


texts: avrdude Programmer is not responding Mac

texts:
I'm VERY new to Arduino programs.

I'm trying to upload the AnalogInOutSerial example to my Arduino, however, I keep getting an error saying that there is a problem uploading to the board.

Thank you so much for your help, here is my error message:

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/karthikbalasubramanian/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem1421
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding


texts: How can I have different routines fire off at different intervals

texts:
So i'm making an interface that will have a digital clock....once a secondd..
i'd like to do other things at different intervals but if I delay(1000) then I have to wait that second which is now the minimum other things have to run at..


texts:
Similar to Will the Uno bootloader work in the Duemilanove? but the other way around.

I have an Arduino Uno. I require a slower upload speed than the 115200 baud rate used in the Uno's Optiboot bootloader.

The Arduino Duemilanove uses the ATmegaBOOT_168_atmega328 bootloader which has an upload baud rate of 57600. The Arduino Duemilanove also uses the ATMega328P like used on the Arduino Uno.

Will the Duemilanove bootloader work in the Uno?


texts:
Easy secret knock detector to trigger anything with only an Arduino and a few cheap components

First of all I need to state that I'm new to Arduino and electronics in general. My question is about a project where the Nano is being powered up with a 12v rechargeable li-ion 2800 mAh battery on pins VIN and GND.

I'm using the 5v Nano pin to power a SRD-05VDC-SL-C relay along with the ground pin from the Nano. The IN pin on the relay is from the D11 pin on the Nano. So far so good. I'm also using the same 12v battery to power up a solenoid latch, which energizes for just a few seconds.

When I tested this setup (less the relay AND solenoid) for battery life, my volt meter read 9.8v and 1 hour later 2.8v. causing the Nano to go off.

How can I increase battery life?

This is the link to the code I used:

I'm not having an issue with the code or the operation of the setup but the battery life is unacceptable.


texts: Which is faster, Serial or DigitalWrite?

texts: I am working on an Arduino Uno battle bot that uses a Sabertooth moter controller. Right now it is connected to the Arduino through Serial communication. Which is would be faster (So I can increase response time on my robot) Serial, or pwm using DigitalWrite?


texts: Arduino HC05 - AT commands won't respond

texts:
A little while ago i tried using AT commands on my HC05 bluetooth module using my arduino mega 2560 and it worked fine , skipping a few weeks ahead i tried doing the same , only now i suddenly doesn't work , i tried replacing the arduino and HC05 module , even used the same script for the commands. So i unplugged the module's VCC , pressed the button on the module , reconnected the VCC and the module was blinking every 2 seconds (it's in AT mode !) , now i go ahead to the serial monitor and using that script i typed the command i wanted to execute and it just didn't do nothing , i saw the serial LED on the arduino blink , but nothing was written in the serial monitor and nothing was changed in the arduino.

Does anyone know how to solve this ? it worked perfect before , but now it wont D:


texts:
I am using the Timer library here with the Adafruit feather m0:
https://github.com/JChristensen/Timer
https://playground.arduino.cc/code/timer
I cannot figure out why I am getting the error:

no matching function for call to 'Timer::every(int, void (&)())'

Here is that part of the code:

void setup(){
      everyAlt = t.every(100, readAltimeter);
      everyLaunch = t.every(500, detectLaunch);
      t.oscillate(blueled, 500, HIGH);
    }

    void readAltimeter(){
      alts[altPlace] = bmp.readAltitude()-zeroAlt;
      altPlace++;
    }

    void detectLaunch(){
      tempSpeed = 0;
      int x = 0;
      while (x < 5){
        tempSpeed += abs((alts[x]-alts[x+1])*10);
      }
      if (tempSpeed/5 > 5){
        t.stop(everyLaunch);
      }
    }

I am pretty new to arduino so any help would be much appriciated!


texts: What is the maximum frequency input signal that I can accurately track on a GPIO pin?

texts:
This all started with me wanting to use an Arduino to make a tachometer. This is all now working fine, but it got me wondering what the highest frequency digital signal that I could read?
So I built a simple test sketch and have run this on both a Nano and an ESP32. The result was about 6300Hz on both. Anything above this gives chaotic results. This is somewhat lower than I expected.
Has anybody done better than this?


texts: Risks of ftdi_eeprom? - TX always high after flashing

texts:
I flashed an Arduino Nano compatible with ftdi_eeprom and the following config:

vendor_id=0x0403    # Vendor ID
product_id=0x6001   # Product ID

max_power=0     # Max. power consumption: value * 2 mA. Use 0 if self_powered = true.

###########
# Strings #
###########
manufacturer="FTDI"     # Manufacturer
product="Arduino Nano"  # Product
serial="arduino_1"      # Serial

###########
# Options #
###########
self_powered=false  # Turn this off for bus powered
remote_wakeup=false # Turn this on for remote wakeup feature
use_serial=true     # Use the serial number string

# Normally out don't have to change one of these flags
BM_type_chip=true       # Newer chips are all BM type
in_is_isochronous=false     # In Endpoint is Isochronous
out_is_isochronous=false    # Out Endpoint is Isochronous
suspend_pull_downs=false    # Enable suspend pull downs for lower power
change_usb_version=false    # Change USB Version
usb_version=0x0200      # Only used when change_usb_version is enabled

########
# Misc #
########

filename="eeprom.new"   # Filename, leave empty to skip file writing

My corresponfing udev rules work and I get /dev/arduino_1 after connecting.

However. After the flash, everything seems to work, But: The TX-LED is constantly on. Even, when the device is not sending. Why?

Update & solution

First, I removed this line, because it threw warning messages (outdated)

# BM_type_chip=true         # Newer chips are all BM type

Then I studied the schematics of the Nano and figured out, that RX and TX  LEDs are indeed connected to CBUS0 and CBUS1. So, I added two lines to my config

  cbus0=RXLED
  cbus1=TXLED

Which had the effect, that now both RX and TX where constantly on. So, I finally read the manual which says on page 11, that the commands in question need a trailing #. I updated my config again:

cbus0=RXLED#
cbus1=TXLED#

Extra:

Indeed, I had to install ftdi_eeprom to get the job done

 apt-get remove ftdi-eeprom
 apt-get install swig libusb-1.0-0-dev libconfuse-dev doxygen
 git clone https://github.com/legege/libftdi.git
 cd libftdi.git
 cmake .
 make
 make install
 ftdi_eeprom/ftdi_eeprom --flash-eeprom myconfig.conf


texts: Way to use other baud rates in console or different input/output rates

texts:
I want to send some test codes to a MIDI synthesizer, so I wrote a program that lets me just type in hex codes on the serial monitor and send it over serial as the byte value. For example typing "90 45 63" should turn on note 0x45 with a velocity of 0x63.  This part works ok and I have the arduino hooked up to a midi connector and from there to a midi synth. I've verified that this works ok with some test code.

Where I'm having trouble is that MIDI requires a rather unorthodox baud rate of 31250.  The problem is then that on an Arduino Uno, I don't see how I can enter serial data when the Arduino's serial monitor doesn't allow that baud rate. Also trying to set that baud rate under Linux using stty generates an "stty: invalid argument ‘31250’" error.  So is there a way to use a different baud rate for input than for output or some other solution here?  I do have a Teensy 3.1 with multiple Serial ports, but its kinda tied up at the moment and I just thought I could use an Uno for this.

UPDATE: It works now. Something to keep in mind when working with complex external components like a professional synthesizer. The Roland JV-880 that I'm interfacing with wasn't receiving program changes even though I was sending the 0xC0 0x03 codes or whatever. This is why I made this debugging program to begin with. After searching around and being stumped, I looked around the system settings on the synthesizer and discovered a setting called "System MIDI Rx switch Program change=OFF". After I changed that to ON the program change codes worked. Sometimes the problem is nothing in your code or circuit.


texts: Building a line follower and keep getting errors just need help getting in the right direction to finish the code error located at the bottom

texts:
const int leftMotorPin = 9;
const int leftSensorPin = A0;
const int rightMotorPin = 8;
const int rightSensorPin = A1;
int rightlightThreshold = 100;
int lightThreshold = 300;
int buttonPin = 7;
int buttonState = 0;
int resistorValue1 = 0;
int resistorValue2 = 0;
int thresHoldAverage;

void setup()
{
//Set Baud Rate, Required to use Serial Monitor
Serial.begin(9600);
pinMode(leftMotorPin , OUTPUT);
pinMode(leftSensorPin, INPUT);
pinMode(rightMotorPin , OUTPUT);
pinMode(rightSensorPin, INPUT);
pinMode(buttonPin, OUTPUT);

  }

void loop()

{
  int main(void)
  {

//Read Sensor Valuesif (buttonState == HIGH)
String int buttonState = digitalRead(buttonPin);

   while(buttonState == LOW)
  {

   int reading1 = analogRead(A0);
   int reading2 = analogRead(A1);
   int resistorValue1 = (reading1 + reading2) / 2;
    return;
   delay(10000);
   }
   buttonState = digitalRead(buttonPin);
    while (buttonState == LOW)
    {

   int reading1 = analogRead(A0);
   int reading2 = analogRead(A1);
   int resistorValue2 = (reading1 + reading2) / 2;
   delay(10000);
   return;
   int thresHoldAverage = (resistorValue1 + resistorValue2 / 2);
    }
}

//int rightLightLevel = analogRead(rightSensorPin);
// If right light sensor is greater than threshold
// then turn right Motor on, else turn right Motor off

String int buttonState = digitalRead(buttonPin);
while (buttonState == HIGH)
 {
    int thresHoldAverage;
    digitalRead (A1);
    digitalRead(A0);
    }
if ( rightlightThreshold > thresHoldAverage)
{
  //( rightlightThreshold > thresHoldAverage);

digitalWrite( rightMotorPin , HIGH);
}
else
{

digitalWrite( rightMotorPin , LOW);
}
//int leftLightThreshold = analogRead(leftSensorPin);

// If left motor sensor is greater than threshold
// then turn left Motor on, else turn left Motor off

if (lightThreshold > thresHoldAverage)
{
  //(leftLightLevel > thresHoldAverage)

digitalWrite( leftMotorPin , HIGH);
}
else
{
digitalWrite( leftMotorPin , LOW);

}

}
}

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

/Users/xavier/Documents/Arduino/finalprojectnew/finalprojectnew.ino: In function 'void loop()':
finalprojectnew:38:3: error: a function-definition is not allowed here before '{' token
   {
   ^
finalprojectnew:71:12: error: two or more data types in declaration of 'buttonState'
 String int buttonState = digitalRead(buttonPin);
            ^~~~~~~~~~~
/Users/xavier/Documents/Arduino/finalprojectnew/finalprojectnew.ino: At global scope:
finalprojectnew:107:1: error: expected declaration before '}' token
 }
 ^
exit status 1
a function-definition is not allowed here before '{' token

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

/Users/xavier/Documents/Arduino/finalprojectnew/finalprojectnew.ino: In function 'void loop()':
finalprojectnew:38:3: error: a function-definition is not allowed here before '{' token
   {
   ^
finalprojectnew:71:12: error: two or more data types in declaration of 'buttonState'
 String int buttonState = digitalRead(buttonPin);
            ^~~~~~~~~~~
/Users/xavier/Documents/Arduino/finalprojectnew/finalprojectnew.ino: At global scope:
finalprojectnew:107:1: error: expected declaration before '}' token
 }
 ^ERROR
exit status 1
a function-definition is not allowed here before '{' token


texts:
Here is the image of Ethernet shield near RJ45 socket:

These small boxes are probably SMD capacitors which may mean, that internal board is glavanically disconnected from the UTP line.

Is this true?

If this is true, then what will happen, if I pass 5V DC current just into my UTP? Won't I be able to wire appropriate conductors just into Arduino power input? Won't I be able to power Arduino this way?

The question is about not using premade PoE splitter. I have an injector, which injects 5V into line.

UPDATE

I found my injector put power to lines 4,5 and GND to 7,8. Can I take this power on Arduino side?


texts: I have a fan control circuit with Arduino (PWM). I did all things and it worked. My question is why we did not directly connect the fan to Arduino. Why should we have a driver circuit?


texts: Function pointers that call one function

texts:
I'm reading a library file timer.h for STM core library that I just installed in Arduino hardware folder.

Of course, there has to be a lot of questions for me as a beginner about many approaches/stratgegies that programmers rule in writing the code.

One thing is that calling a function with a function pointer that only call one function, but the difference is that the function pointer is declared/defined as an inline function.

Edit: I deleted the code and posted a link for it in github.

stm32/timer header file

OK, the part that I started to think about starts from line 595.

It's functions declarations.

In line 598, it's a declaration for a function that receiver a pointer to a function.

In later lines, starting from line 634, these functions have only one line to execute. So my question is why to develop a function to only execute one line ?

Why they didn't just put that line directly instead of putting it inside function ?


texts: Convert serial value into hex using in Genuino zero

texts:
hello there my code is here.

/* Simple Serial ECHO script : Written by ScottC 03/07/2012 */

/* Use a variable called byteRead to temporarily store
   the data coming from the computer */
byte byteRead;

void setup() {
// Turn the Serial Protocol ON
  Serial.begin(9600);
}

void loop() {
   char a[8];
    int b;
   /*  check if data has been sent from the computer: */
  if (Serial.available())
  {
    /* read the most recent byte */
    byteRead = Serial.read();
    Serial.print(byteRead,HEX);
  }

now when i send '12' from terminal, it prints 3132. means it is ASCII value. but i want to print 12. can you help me?? how to do it??


texts: Assign and control Digital pin from String

texts:
Here is modified version of Blink example

#define D8  13

String p = "D8";

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(D8, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  byte pin[2];
  p.getBytes(pin, sizeof(pin));

  digitalWrite(D8, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(D8, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

D8 defined above is a byte of length 2. So LED turns on/off if I mention D8 on digitalWrite(D8, HIGH). Similarly I am getting the same byte D8 from String p = "D8", and converting it into byte of length 2, but assigning pin to digitalWrite(pin, HIGH/LOW) doesn't works. Has anyone tried something similar before ? any help would be appreciated :)


texts: Programming problem I need both if else cases to work but only else loop is running

texts:
#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo1, myservo2, myservo3;

int bluetoothTx = 14;
int bluetoothRx = 15;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
myservo1.attach(9);

//Setup usb serial connection to computer
Serial.begin(9600);

//Setup Bluetooth serial connection to android
bluetooth.begin(9600);
 }

void loop()
  {
    if(bluetooth.available()>0)
     {
      if(bluetooth.available()>=4)
       {
        char buffer[4];
          for(int i=0;i<4;i++)
         {
          buffer[i]=bluetooth.read();
         }
       int incomingValue = atoi(buffer);

      if(incomingValue>=1000 && incomingValue<=1360)
        {
           unsigned int servopos = bluetooth.read();
           unsigned int servopos1 = bluetooth.read();
           unsigned int realservo = (servopos1 * 256) + servopos;

         if (realservo >= 1000 && realservo < 1360)
          {
              int servo1 = realservo;
              servo1 = map(servo1, 1000, 1360, 0, 360);
              myservo1.write(servo1);
              Serial.println("servo 1 ON");
           delay(10);
            }
           }
          }
         if(bluetooth.available()==2)
          {
            char inbit=bluetooth.read();
            if(inbit=='A'||inbit=='D');
           {
            char myval= bluetooth.read();
            if(myval== 'A')
            {
              myservo1.attach(9);
            }

             if(myval== 'D')
              {
               myservo1.detach();
              }
             }
            }
           }
          }


texts:
I would like to get the serial numbers of SD cards, with follow code:

#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

cid_t cid;  // *****at the top with the other globals (for get cid)

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;

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

  Serial.print("\nInitializing SD card...");

  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();

  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

  Serial.println();

  // *****list all files in the card with date and size
  //Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  //root.openRoot(volume);
  //root.ls(LS_R | LS_DATE | LS_SIZE);

  card.readCID(&cid);
  Serial.print("Serial number: "); Serial.println(cid.src); // psn is the serial number field of the struct

}

void loop(void) {

}

I tried to get serial from SD card but I only get this "Serial number: 2065301974". I really need it in hex format, for example "0x0033515c".

Also, I would like to get the complete CID like this:

CID: 0x1B, 0x53, 0x4D, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x45, 0x5D, 0x04, 0xE5, 0x00, 0xF9, 0x69


texts: What are the differences between the 1.0.x and 1.6.x IDEs?

texts: What is a summary the main differences between the Arduino 1.0.x and 1.6.x IDEs?  Why do some Arduino products, such as the LightBlue Bean, still require use of the 1.0.6 IDE?


texts:
How to format an integer as 3 digit string? If I give 3 formated string should be 003

printf("%03d\n", 3); // output: 003

This doesn't work in Arduino.


texts: DS1307RTC Outputting cryptic 165/165/2165 date. What are some possible fixes?

texts:
My board.

I think I have it wired correctly (the lights aren't, but the board is).

I've read through the first few Google results to no avail.

My sample code to test the chip:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
    }

void loop () {
DateTime now = rtc.now();

Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");

// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));

Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();

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

Serial output:

`RTC is NOT running!
2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31

2165/165/165 (Tuesday) 165:165:85
 since midnight 1/1/1970 = 1551138385s = 17952d
 now + 7d + 30s: 2019/3/5 12:16:31


texts: Is there a delay function available that does not use millis() which itself makes use of a timer? Does not need to be hyper-exact.


texts: Flash firmware with hex file over serial with Python (no avrdude, Arduino IDE)

texts:
I'm trying to make a Python function in the TCLab package to flash firmware to an Arduino Leonardo (32u4). I can compile the TCLab ino (firmware) and deploy with the Arduino IDE or with the Python avryp package. The Python avr_helpers package looks like a possible solution but is only supported with the older Python 2.7. Forum posts such as this one, how can I upload a hex file to an arduino uno?, and others suggest avrdude to upload a hex file. However, I need a Python solution that can be used on any platform (MacOS, Windows, Linux, etc) without a requirement to install packages (avrdude, Arduino IDE, etc).

I have the hex file from a successful Arduino build. Here is an unsuccessful attempt to load the hex file with serial communication:

import serial
import time
import os

# open and close COM8 to activate bootloader
ser = serial.Serial('COM8',baudrate=1200)
print(ser.isOpen()); ser.close()
time.sleep(2)

# load hex file on COM9
filesize = os.path.getsize('tclab_v2.ino.hex')
fid = open('tclab_v2.ino.hex','rb')
offset = 0; MTU = 20
ser2 = serial.Serial('COM9',115200)
while (offset < filesize):
    fid.seek(offset, 0)
    ser2.write(fid.read(MTU))
    offset = offset + MTU
ser2.close()

The script is able to activate the bootloader on another port and connect. If I transfer all at once with ser2.write(fid.read()), it semi-bricks the Arduino and I recover it by hitting the reset button just before the Arduino IDE installs the firmware. I use a Maximum Transfer Unit (MTU) of 20 but I couldn't verify if there is one for the Leonardo. I can write a Python function to identify the ports and have used COM8 and COM9 here just to simply the test. Although the TCLab firmware is preloaded for Python, sometimes users change the firmware to use MATLAB, Octave, or Java and then want to switch back to Python. I'd like to make that as easy as possible without adding more steps or more instructions to the troubleshooting FAQ. Can I update the firmware like the MATLAB Arduino Support Package that detects a new device and transfers the firmware automatically with user confirmation?


texts: Device manager sees my nano as FT232 USB UART not as COM port

texts: Until yesterday I had 2 arduino nanos (atmega328, 16Mhz, 5V), and they worked fine,when  I changed the cable and was able to upload code to them. Then I tried to make a breadboard arduino, but my PC (win8.1) was unable to see my FDTI 232RL USB2Serial converter as a COMPORT, so I tried to download drivers but nothing worked out.Anyway I decided to reinstall windows and now one of my Nano works just fine, but the Other appears as a FT232 USB UART at the device manager,so I stepped back... Can anyone help me with that?


texts:
I'm writing an Arduino program, and I need to write a function to input some numbers trough a computer connected to it trough the serial interface.

This function should perform many different and well-defined tasks, e.g.: obtain data (characters) from the computer, check if the characters are valid, transform the characters in actual numbers, and many others. Written as a single function it would be at least 500 lines long. So I'll write a group of shorter functions and one "main" function that calls the others in the only meaningful order. Those functions will never be called in the rest of the code (except of course the main function). One last thing - the functions need to pass each other quite a lot of variables.

What is the best way to organize those functions? My first tough was to create a class with only the "main" function in the public section and the other functions and the variables shared by different functions as private members, but I was wondering if this is good practice: I think it doesn't respect the C++ concept of "class"... for example to use this "group of functions" I would need to do something like that:

class GetNumbers {
    public:
        //using the constructor as what I called "main" function
        GetNumbers(int arg1, char arg2) {
            performFirstAction();
            performSecondAction();
            ...
        }
    private:
        performFirstAction() {...};
        performSecondAction() {...};
        ...

        bool aSharedVariable;
        int anotherVariable;
        ...
};

And where I actually need to input those numbers from the computer:

GetNumbers uselessName (x,y);

Making the "main" function a normal class method (and not the constructor) seems to be even worse:

GetNumbers myClass;
myClass.getNumbers(x,y);
...
//somewhere else in the same scope
myClass.getNumbers(r,s);


texts: Reset I2C connection with arduino as slave

texts: I am currently using I2C serial communications with arduino as slave and raspberry pi as the master. I am sending sensor data from arduino to raspberry pi. I need to reset the I2C connection once the sensor readings cross a threshold. I tried setting the TWCR =0 but it throws a Error 121 Remote I/O error on the raspberry pi when I do that. I also read that one way is to set TWCR =0, but for this I need to execute the Wire.begin(), Wire.onRequest(), and Wire.onReceive() again. Can you please tell me how to run these again since they are put in setup function. Does it mean I need to restart the Arduino program again? Or can I put these in void loop()? Thanks for the help.


texts:
I have built this little setup, which is supposed to record and replay input from a classic 9 pin Joystick. I connected the 9 pin connectors with the Arduino, read the input on the left side from the Joystick and then pass it to the right side by setting the corresponding pins to high.

It does work and I can play games on the Commodore 64.
However, I noticed that with this setup, current is passed to the Commodore 64, which is very likely harming the machine a lot (I stopped immediately after noticing).

So my question is: how do I need to modify this setup so that no current is going from the Arduino to the Commodore 64 anymore?

Picture of the setup

Any advice is greatly appreciated, thanks in advance.


texts: When I interface LM35 temperature sensor and MQ-2 gas sensor with Arduino - my LM35 sensor gave incorrect values. From research I've found out that MQ-2 gas sensor dragging the AREF voltage down and causing the error due to its 31ohm heater that drawn 161mA current . What'll I do to solve this problem?


texts:
I have to send from MATLAB to Arduino a char line 'S' to start the Arduino program and send back values from a sensor.
This is my MATLAB code

clear;
delete(instrfind);
s = serial('/dev/cu.usbmodem1411','BaudRate',9600, 'Terminator','CR/LF');
fopen(s);
fprintf(s,'%s\n','S');

t = 0;
valor=zeros(1,100);
tiempo=zeros(1,100);
fid=fopen('resultats.txt','w');
for i=1:100
    a = fscanf(s,'%d');
    wd = 0.0189*a - 14.499;
    valor(i)=wd;
    tiempo(i)=t;
    fprintf(fid,'%3d %6d\n', wd,t);
    t = t+200;
end
plot(tiempo,valor);
fclose(fid);
fclose(s);

and my Arduino code is this

int outValue = 0;
unsigned long time;
void setup() {
  Serial.begin(9600);
  while (Serial.available() <= 0 || Serial.read() != 'S') {
    Serial.println("Send 'S' to start");
    delay(200); }
  Serial.println("Starting measurement");
}
void loop() {
  outValue = analogRead(A0);
  Serial.println(outValue);
  delay(200);
}

the problem is that when I use the MATLAB code it send an 'S' and it makes Arduino start sending values back, but Arduino does not do that and just sending the while loop again and again.

Is the problem in the MATLAB code when it send the char 'S'?


texts:
We are Using I-CUBE-LRWA Lora Module AT Cmd with Arduino ProMini
Set of commands set with DockLight working Perfectly but with Arduino, we are getting some coded response and well every time RXTimeout response.

Docklight Response

Arduino Response :

Arduino Code:

mySerial.flush();
lora.flush();
Serial.flush();
digitalWrite(lorapin, HIGH);
delay(500);
lora.listen();
lora.print(“AT\r\n”);
String dr = lora.readStringUntil("\r\n");
delay(10);
Serial.print(“AT:” + dr);
Serial.println();

                lora.print("ATZ\r\n");
                String ATZ = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("ATZ:"+ATZ);
                Serial.println();

                lora.print("AT+NJM=0\r\n");
                String NJM = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("AT+NJM:" + NJM);
                Serial.println();

                lora.print("AT+DADDR=as:23:00:00\r\n");
                String DADDR = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("AT+DADDR:" + DADDR);
                Serial.println();

                lora.print("AT+APPSKEY=90:22:53:85:44:7A:22:32:75:35:26:35:63:30:A9:56\r\n");
                String APPSKEY = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("AT+APPSKEY:"+APPSKEY);
                Serial.println();

                lora.print("AT+DEUI=5bb1605000032as\r\n");
               String DEUI = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("AT+DEUI:" + DEUI);
                Serial.println();
                lora.print("AT+NWKSKEY=23:43:67:9A:22:44:22:69:50:67:3A:A3:34:27:26:72\r\n");
                String NWKSKEY = lora.readStringUntil("\r\n");
                delay(10);
                Serial.print("AT+NWKSKEY:" + NWKSKEY);
                Serial.println();

                lora.println("AT+CFM=1\r\n");
                String CFM = lora.readStringUntil("ok\r\n");
                delay(10);
                Serial.print("AT+CFM:" + CFM);
                Serial.println();

                lora.println("AT+ADR=1\r\n");
                String ADR = lora.readStringUntil("\r\n");
                delay(10);
                Serial.println();
                Serial.print("AT+ADR:" + ADR);
                Serial.println();

                lora.print("AT+CLASS=C\r\n");
                String CLASS = lora.readStringUntil("ok\r\n");
                delay(10);
                Serial.print("CLASS:" + CLASS);
                Serial.println();

                lora.print("AT+JOIN\r\n");
                String JOIN = lora.readStringUntil("ok\r\n");
                delay(10);
                Serial.print("JOIN:" + JOIN);
                Serial.println();
                delay(500);

                lora.print("AT+NJS=?\r\n");
                String NJS = lora.readStringUntil("ok\r\n");
                delay(10);
                Serial.print("NJS:" + NJS);
                Serial.println();
                delay(500);

                String sendatavar="AT+SEND=2:30";
                Serial.print(sendatavar);
                Serial.println();
                lora.print(sendatavar);
                delay(10000);
                String sedndr = lora.readStringUntil("rxDone\r\n");
                delay(1000);
                Serial.print("AT+send:" + sedndr);


texts: How to make XBee module interrupt/wake arduino

texts:
What I am trying to do is, to have arduino in low power mode and waking up only when a packet is received and is available to be read from the buffer.

A scenario : Zigbee XBee module is not receiving anything, arduino is asleep. Once this particular module receives any data from any other module, it makes the arduino wake up and process this packet.

I've looked almost everywhere possible about this, and people say they do not have a 100% working solution.

Does the XBee module produce a particular output on a specific pin when it receives data? If so, can I connect that pin to the interrupt enabled pin on arduino and with that interrupt arduino or wake it up?
do I need arduino mega for that or is the uno a good enough option?


texts: How to reprogram Arduino if USB port is already in use?

texts:
I'm developing a keyboard emulator using Digispark Pro (based on Arduino) which uses USB port as the keyboard interface. I haven't programmed it yet because I doubt how should I recognize the chip to Arduino IDE again using USB port after programming the board.

So my question is, how to reprogram Arduino if USB port is already recognized as keyboard HID?


texts:
I have a function in which I change the pinMode on many of my Arduino's pins based on a passed in mode. I first construct an array of bytes specifying each pin to be an input or an output and then I iterate through the array to set all the pins.

void pinout(byte mode) {
  switch(mode) {
    case 0: char pins[13] = {'O','O','I','I','O','I','I','I','I','O','I','I','O'}; break;
    case 1: char pins[13] = {'O','I','I','O','O','I','O','O','I','O','I','O','I'}; break;
  //etc..
  }
  for(byte i = 0; i <= 13; i++) {
    if(pins[i] == 'I') pinMode(i, INPUT);
    else pinMode(i, OUTPUT);
  }
}

However, since the array is defined inside the switch statement, I loose scope of the pins array when I move onto the for loop. I tried defining the pins[] outside of the switch statement, but then I am confused on how to populate it efficiently. These all threw errors when I tried to populate the variable inside the switch statement:

pins[0,1,2,3,...,12,13] = {...};
pins[13] = {...};
pins[] = {...};
pins = {...};

I know I could go through each entry individually, but this could be rather inefficient use of memory and computational power as I add more cases. Any ideas?


texts:
I am trying to access my Arduino Yun from the internet, and it's not quite working. I have correctly port forwarded the port 5555 from the router to the Yun (verified I am able to access my many other NAT'd resources).

I can access the Yun from my internal network.

In the Arduino sketch I have this (among many other things). Mainly taken from example sketches.

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

YunServer server;

void setup {
   // Listen for incoming connections on port 5555
   server.noListenOnLocalhost();
   server.begin();
}

Is server.noListenOnLocalhost(); the right one to use to access from the outside world?


texts: Help a noob, no idea on Programming, only started 2 days ago Help please

texts:
As said no programming skills only started 2 days ago when Nano arrived.
Heads in bits. This is how far i got. Any help much appreciated..
int EMagnetPin = 8;
int solenoidPin = 9;
int ReedPin = 13;

void setup()
{
  pinMode(EMagnetPin, OUTPUT);     // assign pin type
  pinMode(solenoidPin, OUTPUT);   // assign pin type
  pinMode(ReedPin, INPUT);        // assign pin type
  Serial.begin(9600);             //serial port open

void loop()
{
Serial.print(digitalRead(ReedPin));
if (digital REad(ReeddPin)==0 ) {
digitalWrite(solenoidPin,HIGH);

                  // Once magnet applied to Reed Switch Will activate the below

  digitalWrite(EMagnetPin, low);
  delay(11000);
  digitalWrite(EMagnetPin, HIGH);
  delay(500);
  digitalWrite(EMagnetPin, low);
  delay(500);
  digitalWrite(EMagnetPin, HIGH);
  delay(500);
  digitalWrite(EMagnetPin, low);
  delay(22500);
  digitalWrite(EMagnetPin, HIGH);
  delay(500);
  digitalWrite(EMagnetPin, low);
  delay(500);                          // Stops EMagnet
  digitalWrite(solenoidPin, HIGH);     //Start Solenoid
  delay(500);
  digitalWrite(solenoidPin, low);
  delay(500);
                    // Program Ends


texts: How to design and debug a custom I2C master-slave system?

texts:
How to proceed, when in need of a custom I2C master-slave system?

What are the design criteria to apply?

What are the debugging tools one can use to troubleshoot problems?


texts:
I have to admit that I can't really use this function.

I'm trying to format some json but it crashing all the time my arduino:

char response[300];
tmp = "123";
snprintf(response, 300, "[{Name:'Furnace',Value=%s,Alarm={MinValue=%s,MaxValue=%s}},{Name:'Room',Value=%s,Alarm={MinValue=%s,MaxValue=%s}}]", tmp);

How should I use this function properly?


texts: How to communicate with GPS SIM900a without Serial Monitor

texts:
I am fairly new to Arduino. I was working on a project where I use a GSM SIM900a modem interfaced with an Arduino. The AT commands are sent via the Arduino to the GSM Modem. The problem, however, is that the commands are only sent when I open the Serial Monitor. I have an IR proximity sensor and I would like the AT commands to be sent when the sensor detects an object. I am putting the code for the GSM modem below (I have not yet put in the code for the IR sensor).I want to know how to send the AT commands when the Arduino is hooked up to a battery and not to a PC

#include <SoftwareSerial.h>
SoftwareSerial myGsm(7,8);
float temp;
int tempPin = 0;
void setup()
{
 myGsm.begin(9600);
 Serial.begin(9600);
 delay(500);

myGsm.println("AT+CIPSHUT");
 delay(1000);
 printSerialData();

 myGsm.println("AT+CIPMUX=0");
 delay(2000);
 printSerialData();

 myGsm.println("AT+CGATT=1");
 delay(1000);
 printSerialData();

 myGsm.println("AT+CSTT=\"bsnlnet\",\"\",\"\"");//setting the APN,2nd parameter empty works for all networks
 delay(5000);
 printSerialData();

 myGsm.println();
 myGsm.println("AT+CIICR");
 delay(6000);
 printSerialData();

 myGsm.println("AT+CIFSR"); //init the HTTP request
 delay(2000);
 printSerialData();

 myGsm.println("AT+CIPSTART=\"TCP\",\"122.178.80.228\",\"350\"");
 delay(5000);
 printSerialData();
 delay(5000);

 myGsm.println("AT+CIPSEND");
 delay(2000);
 printSerialData();

sendtemp();
delay(3000);
myGsm.println("AT+CIPCLOSE");
printSerialData();

myGsm.println("AT+CIPSHUT");
delay(1000);
printSerialData();
}

void loop()
{
}

void printSerialData()
{
 while(myGsm.available()!=0)
 Serial.write(myGsm.read());
}

void sendtemp()
{
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;
  Serial.print("TEMPERATURE = ");
  Serial.print(temp);
  Serial.print("*C");
  Serial.println();
  delay(5000);
 myGsm.println(temp);
 delay(3000);
 printSerialData();
 myGsm.write(0x1A);
 delay(3000);
   printSerialData();

}


texts:
I have node mcu and i am trying to use the example code on github and pubnub blog to send a msg as an experiment but can't figure how to do it.

I used 2 example as the reference - https://github.com/pubnub/arduino , https://www.pubnub.com/docs/arduino/data-streams-publish-and-subscribe

Here is the code which i have. I modified it to include some libraries and my API keys. Let me know what changes i have to make:-

#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient
#define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP

#include <PubNub.h>

String pubkey = "pub-c-4a9cdbca-5688-4939-a852-f63cf6743980";
String subkey = "sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094";
String pubchannel = "sec-c-NmFiYjliODYtMTc3Mi00YTMzLTg0OWMtMDgzYjE2ZGUwNzg5";

void setup() {
    /* For debugging, set to speed of your choice */
    Serial.begin(9600);

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);
}

void loop() {
    /* Maintain DHCP lease. For other HW, you may need to do
       something else here, or maybe nothing at all. */

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"message\"");
    if (!pclient) return;
    PublishCracker cheez;
    cheez.read_and_parse(pclient);
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`.
    */
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
    pclient->stop();

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        ritz.get(msg);
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);
        }
    }
    sclient->stop();

    delay(1000);
}

Error:-
node_mcu_test_code:44:46: error: 'subchannel' was not declared in this scope

     PubSubClient *sclient = PubNub.subscribe(subchannel);

                                              ^

node_mcu_test_code:54:14: error: 'class PubSubClient' has no member named 'stop'

     sclient->stop();

              ^

exit status 1
no matching function for call to 'PubNub::begin(String&, String&)'


texts: Why isn't ESP8266 connecting to wifi when calling yield()?

texts:
I'm experimenting with ESP8266 and I want it to cycle through various states: LED on/off, WiFi on/off and measure the connection time, deep sleep.

I wrote the following script, using millis() to define the time intervals. I cut away the previous parts of the code to have a minimum test case.

I read that ESP8266 has the watchdog automatically on, so I used yield() when spending time waiting, instead of using an empty while loop. I didn't use delay() because it block further execution of the code, and I tend to avoid it. I know it would reset the watchdog too.

#include <ESP8266WiFi.h>

const char* ssid = "wifi";
const char* password = "pass";

const int led = 2;

void setup(void){
  unsigned long refTime;

  pinMode(led, OUTPUT);
  Serial.begin(115200);
  digitalWrite(led, 1);

  refTime = millis();
// isssue from here
  while ((millis() - refTime) < 3000) { yield(); }
// to here

  Serial.println("Connecting...");
  refTime = millis();
  WiFi.begin(ssid, password);
  Serial.println("");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // never gets here when "issue" code enabled
  Serial.println(millis() - refTime);
  digitalWrite(led, 0);
}

void loop(void){

}

If I use the yield(), then I never get a WiFi connection (well, it happened only once, actually).

Why is yield causing issues?


texts: Is Gsm antenna effect on microcontroller working?

texts: in my embedded system I used patch antenna and Atmega 328 microcontroller,but somehow it causes the abrupt function of a microcontroller or reset. how can it be solved?


texts: Is there any way to check with Arduino UNO if a sensor is connected and ready to be read?

texts:
I would like to check the status of the sensors with Arduino UNO. For example, when I turn on the robot, I would like to check if all the sensors are connected and ready to be read or not. Maybe one sensor is unplugged and I want to detect this situation.

I read something about pull up resistors, but I didn't find any clear example of my problem. Also, I don't have any idea how to connect the resistor, how to calculate the resistor needed, as well as how to use the pull up resistor for digital and analog sensors.

Any schema, explanations and example would be very helpful!


texts: Purpose of extra pin slots on Pololu DRV8835

texts: I have a Pololu DRV8835 motor controller. I managed to properly solder and connect it and it actually works, however I've been wondering about the purpose of the extra pin slots - especially the ones without pins headers soldered to them on the right side of the picture below, but also the ones marked A and B (I assume these ones are an alternative way to connect to motors, though). I wasn't able to find anything about them, so I assumed that it may be obvious to someone who is not a complete beginner (like me). What, if anything, could I use them for if I soldered pin headers there?


texts: Set Arduino PWM frequency to 20KHZ instead of fixed values given on each pin

texts: Here i found the datasheet of each timer and each pin frequency, but I can't understand how to generate a desired frequency. Someone please help me.


texts: Use Arduino pro micro to program pro mini?

texts: So I got a pro micro and 2 pro minis and I was wondering if I could use the pro micro to program my minis? Anyone has any links or guides on how to do this, if at all possible?


texts: Actual baud rate of UNO R3 Firmata protocol

texts:
Probably a silly question. But the Internet is confusing me.
The Firmata website says the default baud rate is 57600. But AFAIK, the baud rate set for UNO R3 is 9600(In Windows device manager, it say so). I'm making the Firmata client program and have to set the baud rate. I'm confused whether it's similar to the serial protocol or not.
[Using the StandardFirmata sketch]


texts: Porting the FastNoise c++ library to Due

texts:
I'm trying to use the FastNoise library with a Due, however, I get something like the following errors, when I try to complie.

error: 'abs' was not declared in this scope
error: 'mt19937' is not a member of 'std'
error: 'uniform_int_distribution' is not a member of 'std'

so I added the following:

#include <cstdlib>
#include <cmath>
#include <random>

which solved most of the problems, however it still says printf hasn't been declared. So I tried to edit cstdio to comment out the #undef printf, but it just brought back the full list of error messages, so that's not the solution. I googled some solutions but none of these seem to work. Do you have any suggestions I should try?

I'm not trying to use printf, just want to use the library.

Thanks for any help.


texts: Wiring 5V ultrasonic sensor to Arduino Due

texts:
Is it possible to use the 2760342 ultrasonic range sensor with an Arduino Due? The docs say it takes a 5V input, but doesn't specify the output, but I'm assuming it also outputs a 5V signal. Does this make it incompatible with the Due?

I've tested it with an Uno, it it works flawlessly. I've been researching using a Due and some other ARM based single-board computers, but they all seem to use 3.3V, while almost all Arduino shields and sensors use 5V. I'm hesitant to "upgrade" to these boards if I have to purchase an entire new set of shields and sensors. And I have no interest in hacking in some clunky custom voltage level shifter. Why isn't everything standardized on 5V?


texts: RFID does not respond after Ethernet.begin(mac, ip) initialization

texts:
Good day, I have this problem with my simple project. I have a database with all RFID number of employee. What I want to do is to use an rfID to check if it is registered in the database. If it is, it would return a value of 1 else would be a value of 0.

I tried with arduino HanRun Ethernet shield. I was able to get a response from the php web server to the serial monitor. Tried the seeedrfid it successfully get the rfcard number. However, when i tried to combine the two, it would hang on Ethernet.begin(mac, ip) initialization. My code is below.

#include <Ethernet.h>
#include <SoftwareSerial.h>
#include <SeeedRFID.h>

#define RFID_RX_PIN 10
#define RFID_TX_PIN 11

SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN);

char state = '0';
char c;
byte mac[] = {0x60, 0xF8, 0x1D, 0xBA, 0x1D, 0x52};
IPAddress ip(192, 168, 20, 228);

EthernetClient client;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Serial set up");

  Ethernet.begin(mac, ip);
  Serial.print("My IP Address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {

  long rfID;
  // put your main code here, to run repeatedly:

  if (RFID.isAvailable()) {
    rfID = RFID.cardNumber();
    Serial.println(rfID);
  }
}

Serial.println(rfID) is not executed unless I remove the Ethernet.begin(mac, ip). Can anybody point me to the right direction?


texts: Troubleshooting WS2812b LED strip with toggle on/off button

texts:
I have a very rudimentary setup with an arduino nano, an LED strip, a pushbutton and a resistor.
I was trying to use the pushbutton as a toggle, using this code
#include <stdio.h>
#include <stdlib.h>
#include<FastLED.h> // header file

#define NUM_LEDS 14 // number of led present in your strip
#define DATA_PIN 12 // digital pin of your arduino

CRGB leds[NUM_LEDS];

const int button = 2;            // GPIO 8 for the button
int status = false;

void setup() {
  //Serial.begin(9600);
  pinMode(button, INPUT);         // define button as an input
  pinMode(DATA_PIN, OUTPUT);           // define LED as an output
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  if (digitalRead(button)==true) { // if button is pressed
    // flip status
    //Serial.println("Changing status");
    status = !status;
    //Serial.println(status);
    toggle(status);
  }

  while (digitalRead(button) == true) {
    //Serial.println("while loop");
    delay(50);
    //Serial.println(status);
  }//

  delay(50);
} // begin again

void toggle(bool status) {
  if (status == true) {
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;  //set the all leds to white
    }
    FastLED.show();
  } else {
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::Black;  //set the all leds off
    }
    FastLED.show();
  }
}

This is my circuit

I am powering this from a battery (PNY model 12200, 2200 mAh, Output 5 V=1A) via USB into the arduino board. I am having some issues. Mainly, the lights would go on by themselvs after a while, maybe not full power but still would be on. Not sure where the problem is, any hints appreciated.
I also sometimes get the lights turned off, maybe I'm feeding current into the wrong place and a safety mechanism either on the arduino or the battery stick turns everything off to protect itself?


texts: Arduino: The program exited the loop early and execute setup() repeatedly

texts:
I'm working with Arduino Uno, Adafruit PN532 NFC/RFID Shield and along with other modules. I'm posting this test program because I found there's conflict with the serial output while writing code to integrate all the modules together. I tried troubleshooting by running this code. The result wasn't what I'd expected.

In Arduino, as far as I know, setup() only runs once after starting the program and then loop() will be executed repeatedly. I ran the example sketch called readMiFare provided by Adafruit alone and it was fine. This code can be found at https://github.com/adafruit/Adafruit_NFCShield_I2C/blob/master/examples/readMifare/readMifare.pde. However, when I did the following in main,

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

void loop(void)
{
  nfctestloop();
}

the following conflict showed up. When happened was that whenever I scanned a card to the reader it executed the loop() partially and exited the loop. Even worse, it executed the setup() again and again whenever I scanned a card.

In nfctestsetup(), I just commented out    Serial.begin(115200); from readMiFare.

My hardware setup was a no brainer since I'm using I2C.

Appreciate the help.

After spending a good amount of hours on troubleshooting, I found something interesting. When I commented out all other files except NFC and main, it worked like a charm. So I suspect there could be redefinitions on the pins that the NFC shield uses on other files. I suspect the following code in the other file gave me the problem because I commented out the rest of the code in this file and ran this block of code together with NFC and main. In fact, it's the last line of code in this block that gave me the problem.

Also, I probed on the RESET pin (see the readMiFare link above). It generated a high-low-high pulse whenever I scanned a card. Is this related to the problem?

#include <SPI.h>
#include "Adafruit_BLE_UART.h"

// Connect CLK/MISO/MOSI to hardware SPI
// e.g. On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11
#define ADAFRUITBLE_REQ 10
#define ADAFRUITBLE_RDY 3     // This should be an interrupt pin, on Uno thats #2 or #3
#define ADAFRUITBLE_RST 9

Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);

Any thought is appreciated.


texts: NodeMCU ESP8266 burnt. What have I done fundamentally wrong here?

texts:
So my setup is:
A 12v DR7-12 battery is providing the power for the board through a DC buck converter set to 3.3V connected to the 3.3V pin of the esp8266.
I then am using pins D5 and D6 to control an L298N motor driver, which has it's 12V connected to the battery (not through the board), it's ground to the battery and the IN1 and IN2 pins connected to the D5 and D6 pins.
I've ended up with three dead ESP8266 boards, they heat up and become unresponsive but as far as I know, I'm not putting any power through the board am I? What am I doing wrong?!


texts: I know that you can't expand your ram because it is intern. But I want a extern memory chip (1024KBytes) that is very fast. I know that I need a library to access information on this chip. And functions to read and write data. A shield or breakout board it doesn't matter, and I want that it is compatible with Arduino mega. If the arduino lost power it doesn't matter if I lost the data. It must hold the data when the arduino is powerd.


texts: Integrating an analog signal using Arduino Uno SMD

texts:
I need to integrate an analog signal using my Arduino Uno. I am sampling the input signal at 1 KHz using a delay command in my void loop() and adding up the values at the analog read at that specific time. Then I multiply my added output with 0.001 s to get my integration.

Since, I am new to Arduino Uno, I want some review on the code to check whether I am correct or not. Kindly help, I'll be indebted.

const int a=13; //my output pin
const int c=A0; //my input pin
int d=0; //my summation variable
int e=0; //my integration variable(integration as a summation)
void setup()
{
  pinMode(a, OUTPUT);
}
void loop()
{
  int b=analogRead(c);
  d=d+b; //my summation
  e=d*10^-3; //my integration as a summation, by sampling my signal at 1ms
  analogWrite(a,e); //writing my integration into my output pin

  //print the results to the serial monitor
  Serial.print("input=");
  Serial.print(b);
  Serial.print("\t output=");
  Serial.println(e);

  delay(1); //wait for 1ms as I want it sampled at that rate
}


texts: How can I connect an 8-relay board without using 8 digital pins?

texts:
I'm looking to connect an 8-relay board to an Arduino Uno. A board like this one. However, I don't really want to use up 8 digital outputs if I don't have to. Is there some intermediate circuitry I can either buy or build that would do this?

For example, can I connect something to the serial so that sending '3' would result in binary 00000011 and thus turn on relay's 1 and 2?

Alternately, and probably more lazy, is there an extension board that would just give me a pile more digital pins?


texts:
I am trying to prototype a wearable device which will have about 120 RGB LEDs. I was considering the WS2812B but they seem to draw about 50mA and so may not be a good option since I will be powering them from a battery.

I would be glad to know of other options or ways to implement the LEDs in order to consume less power.


texts: Particle Electron to RS232 Serial gibberish

texts:
I've spent all day trying to monitor serial console output of a router. I'm using an "ebay" MAX3232 RS232 to TTL converter connecting only GND, TX and RX to the Electron. Trying to simply monitor the console output during bootup - all I get is gibberish.

Even connected to computer's COM1 port and was unable to echo back and forth. All I get is 0 or weird symbols. (this was tried with more code than below)

Here's my most basic code. I'm about ready to give up. Any ideas?

#include "Particle.h"

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600); // tried with 2400/even 1200 really should be 9600
  Serial.println("Starting up Serial");
  Serial1.println("Starting up Serial1");
}

void loop() {
 while(Serial1.available()>0)
 {
   Serial.write(Serial1.read());
 }
 delay(50);
}


texts: How to write analog signals to control throttle of the ship?

texts:
I am using teensy 2.0 as DAC. I am trying to write signals on rudder and throttle of the ship via relay. How can I write these analog signals? Should I specify voltage for every pin?
Here is my code:
int Rudder_p= 21; //Digital Write
int Rudder_s= 20; //Digital Write
int Throttle_p= 19; //Analog write
int Throttle_s= 18; //Analog write
int Throttle_T= 17; //Digital Write

void setup() {
  Serial.begin(9600);
  pinMode(Realy1,OUTPUT);
  pinMode(Rudder_p,INPUT);
  pinMode(Rudder_s,INPUT);
  pinMode(Throttle_p,OUTPUT);
  pinMode(Throttle_s,OUTPUT);
  pinMode(Throttle_T,INPUT);

  if (Serial.available() > 0) {
    incomingByte = Serial.read();
  }
}

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

  //Relay
  digitalWrite(Relay1,HIGH);
  delay(500);
  digitalWrite(Relay1,LOW);
  delay(500);

   //I am missing logic here:

  // read the input on analog pin 21
  int Value = analogWrite(F0);
  delay(1);        // delay in between reads for stability
}


texts: What is the best delay to use between characters sent to the serial port

texts:
I have an Arduino Uno. It's role is to echo back what it receives.
But if I send it a stream of ascii characters it starts to error after the first one. Occasionally it gets the second character correct but often not.
If I delay each character then it works ok. I couldn't see this limitation mentioned in the SoftwareSerial library: https://www.arduino.cc/en/Reference/SoftwareSerial
The Arduino is running the following code:

#define BT_RX_PIN 16 // A2
#define BT_TX_PIN 17 // A3
#include <SoftwareSerial.h>
SoftwareSerial OtherSerial(BT_RX_PIN, BT_TX_PIN);

void setup()
{
  Serial.begin(9600);  // not used
  OtherSerial.begin(9600);
}

void loop()
{
  if (OtherSerial.available()) {
    char value = OtherSerial.read();
    String stri = "Received: ";
    stri += value;
    OtherSerial.println(stri);
  }
}

The limitations do say "If using multiple software serial ports, only one can receive data at a time.".  I don't have multiple software serial ports though I do have an instance of the "normal" serial port but I'm not sending any data to it... but perhaps even just initialising it is enough to disrupt seamless communication with the SoftwareSerial port?
Using the following test code for serial communication from a Raspberry Pi (using logic level conversion to go from 5V -> 3.3V and visa versa):
import time

def write(msg, delay):
  for char in msg:
    with open("/dev/ttyAMA0", "w") as f:
      f.write(char)
      time.sleep(delay)

write("hello", 0.01)

I got the following results (repeated 10 times at each delay time and averaged):
Delay (ms)   |   Success rate
10           |   100 %
9            |   100 %
8            |     0 %
5            |     0 %
1            |     0 %

A delay of 9 ms between each character means the communication rate falls from ~ 960 characters per second (9600 baud / 10 bits per 7 bit character) to ~ 100 characters per second (1 / (1 / 960 characters per second + 9ms)).  Is this right?  Perhaps I'm doing something else wrong / set it up wrong in software / hardware?


texts: How best to power down an Arduino for ~5 minutes at a time?

texts: Reading over the datasheet it appears the longest it can shutdown for is 8s so should I just keep a counter in the loop method that checks if it's run 38 times and then execute the code I want? Would this wakeup every 8s hurt battery life much if it's doing nothing but incrementing a counter?


texts: How to send a pitch bend MIDI message using arcore?

texts:
I'm new to MIDI and started playing with an Arduino Leonardo and arcore.
Based on the example code, I can easily send noteOn/noteOff/controlChange messages, but I can't seem to send a pitch bend message.

Having a look at this table:

0xE0    Chan 1 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE1    Chan 2 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE2    Chan 3 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE3    Chan 4 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE4    Chan 5 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE5    Chan 6 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE6    Chan 7 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE7    Chan 8 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE8    Chan 9 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xE9    Chan 10 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xEA    Chan 11 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xEB    Chan 12 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xEC    Chan 13 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xED    Chan 14 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xEE    Chan 15 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
    0xEF    Chan 16 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)

I've tried to send a message like so:

MIDIEvent pitchwheel = {0xe0, 127,127};
MIDIUSB.write(pitchwheel);

but this didn't work and I'm not sure what I'm missing/doing wrong.

Any hints/tips will be helpful.


texts: Problem in integrating speed sensor LM393 with L298N

texts:
I am currently working on a project that has an automatic support wheel for bicycle.

The mechanism of this project is when the speed sensor is detecting the RPM of the rear bicycle wheel it will triggered the support wheel. The support wheel is oriented by the motor power. Basically, when the bicycle reaches a certain speed limit, it will activate the support wheel whether to move upwards or downwards. I have done some coding for this.

int sensor = 11;
unsigned long start_time = 0;
unsigned long end_time = 0;
int steps=0;
float steps_old=0;
float temp=0;
float rpm=0;
int motorPin = 9;

void setup()
{
{
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(motorPin, OUTPUT);
   Serial.begin(9600);

  pinMode(sensor,INPUT_PULLUP);
}
}

void loop()
{
 start_time=millis();
 end_time=start_time+1000;
 while(millis()<end_time)
 {
   if(digitalRead(sensor))
   {
    steps=steps+1;
    while(digitalRead(sensor));
   }

 }
    temp=steps-steps_old;
    steps_old=steps;
    rpm=(temp/5)/60;
    Serial.print("RPM = ");
      Serial.println(rpm,DEC);
      delay (1000);
      //Restart the interrupt processing

    if (rpm==0)
    {
      digitalWrite(8, HIGH);
      digitalWrite(7,LOW);
      analogWrite(motorPin, 255);
      delay(1000);

    }

   if (rpm>0.02)
   {
      digitalWrite(8, HIGH);
      digitalWrite(7,LOW);
      analogWrite(motorPin, 255);
      delay(1000);
      digitalWrite(8, LOW);
      digitalWrite(7,LOW);
      analogWrite(motorPin, 255);

   }

   }

The problem with this code is that I do not know how to stop the motor when the rpm>0 until the sensor read rpm=0. I want to make the motor rotate backwards for a few seconds and stop completely as long as the rpm is above zero (my coding will make the motor rotate forward when rpm>0 again and again, the same goes for when rpm=0) and it will only rotate forward for few seconds when the rpm=0 and stop completely until the sensor read rpm>0. The process continues looping.

Please help me, I'm new to Arduino and sorry for my English as I'm not really fluent in English.


texts: Porting code from Arduino IDE to other IDEs - expected code size reduction

texts: Could I realistically be expecting some 25% - 50% code size reduction if I abandoned Arduino IDE's framework and moved to something more rudimentary such as AVR Studio ? I am using the EEPROM, Timer1 and Wire libraries whereas my own code is about 700 lines of code.


texts: Grounding analogue signals through ads1115

texts:
Quick question - I have some pretty expensive gas flow sensors outputting a 0-5V signal, which need at least 2.5 KOhms minimum load. Can I connect them to the Adafruit ADS1115 breakout (ADS1115 chip, Adafruit breakout board circuit, adafruit ferrite bead input impedance (or I think it is, pls correct me if I'm wrong))? If I put a 2KOhm resistor (for example) from the ADS1115 GND to the arduino ground, will that solve this issue, if it exists?

Many thanks for your help

EDIT: The flowmeter manual is here. It states the impedance of the 0-5V receiver should be greater than 2.5KOhms.


texts: How to get keyboard input to arduino from the computer its plugged in to?

texts:
I have an arduino uno connected to my laptop.
and i need to get keypress info from the laptop's keyboard
with only the arduino sketch and without any program running on the laptop.
Is there a specific library or some way of doing so?


texts: NodeMCU not responding AT after blink app

texts:
I've just bought NodeMCU LoLin ESP8266, I tried to send AT commands (after spending days on ESP8266-01) and everything was okay. Than I've uploaded the Blink example to the board, after that moment it's not responding to any command.

I tried to update firmware, it's updating successfully but nothing has changed. By the way blink app is not working also...


texts: How to scan Lora E32-TTL-100 devices by using only one ESP 8266 + Lora E32-TTL-100s?

texts:
I'm investigating for some function of Lora E32-TTL-100.
Currently, I can communicate between two E32 like the following image:

But 3 days ago, I saw a person used only one MCU to scan the other E32 is power-on or power-off:

It's so interesting, and tried many way, but wasn't successful.
I found many documents but they always mention communicate 2 MCUs + 2 Loras.
Again, the purpose is how to do for the 1st E32 know that the 2nd E32 is power-on.
Can anyone please help me with it or have any ideas about it?
This's the link I followed https://www.mischianti.org/2019/11/10/lora-e32-device-for-arduino-esp32-or-esp8266-fixed-transmission-part-4/
This is the schema to simulate it:

Thank.


texts:
Has anyone connected BLE devices with Python + GUI on OSX? I've looked into a few libraries (most are old), but one that has the most success if Adafruit's BlueFruit library. However, this library works poorly with GUI's since it requires use of the main event loop (which GUI's usually use). After doing a bunch of Google searches, I couldn't find any good examples of using a GUI with Python + BLE. There seems to be no good BLE libraries for Python either.

Specifically looking for help integrating BLE with Kivy, but other GUI toolkit examples should be fine.

Also trying to gauge interest in this to see if I can do development to solve this (if it really is a problem).


texts: Device is not online yet while trying to connect Arduino uno (with USB) to Blynk App

texts:
I am trying to run my Arduino Uno using Blynk app.
I have Arduino IDE , Blynk library on the same folder within the Arduino library folder, changed the AuthCode using the one provided , checked all the pins and tried to run the code(sketch) given below in the link . It says device is not online yet .
https://examples.blynk.cc/?board=Arduino%20Uno&shield=Serial%20or%20USB&example=Widgets%2FTerminal

I have checked the port too before uploading the code.
My laptop and Android phone both are connected to same WiFi.
I have edited the blynk-ser batch file to my specific port number(COM 6).
I have tried uninstalling and reinstalling the Blynk app.
I had turned off firewall temporarily, but same result.
Need help to get going.
How can this problem be solved?

Edit: The error message shown is DSR is off , Received EOF, EVENT_CLOSE


texts:
So I bought the Arduino starter kit a few weeks ago and I've done a few of the projects in the book supplied with the set. Unfortunately the book is quite poor, with inaccurate explanations and sometimes no explanation behind what they want you to do in the projects.

So I'd like to know what people would reccomend? I found 2 well reviewed books; Arduino for Dummies and Arduino Workshop, but I'm torn which to take. So I'm asking in here in hope that I can save time and money on buying and reading a good book from the start.

I'm a programmer by profession and also know a bit of physics, but have little experience with electronics.


texts: Serial communication mac to Digispark ATtiny85

texts:
I want to use the Arduino IDE serial monitor with my Digispark ATtiny85 over USB.

I can without problems upload this code(Digispark CDC example):

#include <DigiCDC.h>
void setup() {
  SerialUSB.begin();
}
void loop() {
  SerialUSB.println(F("TEST!"));
 //SerialUSB.delay(10);
}

In a terminal, I can confirm, that it indeed creates a new devise:

ll /dev/*usb*
crw-rw-rw-  1 root  wheel   21,  89 27 Sep 10:36 /dev/cu.usbmodem1411
crw-rw-rw-  1 root  wheel   21,  88 27 Sep 10:36 /dev/tty.usbmodem1411

When trying to start the Arduino serial monitor, I get the error:

 Error opening serial port '/dev/cu.usbmodem1411'. (Port busy)

I have confirmed that there are no open files or processes using the USB port. I have the same problem trying to use cu or screen in the terminal.

I have googled the problem, and found that several people has the same problem on new mac computers, but I have not been able to find a solution. -any ideas?

Digispark Rev3 (Chinese clone - with bootloader firmware 1.6 (1.06))
Arduino IDE 1.8.7
Mac OSX High Sierra 10.13.6


texts: How to Specify Array Length during Object Construction within Arduino IDE?

texts:
I'm working on a group project to involving the creation of an in-house library using the Arduino IDE. As the Arduino IDE uses C++, the library must be a class. One of the classfields is an array of numbers. We would like it if we could specify the array length during object construction, as there are pros and cons to low and high array lengths. Is it possible to specify or change the array length during object construction?

Unfortunately, the Arduino IDE doesn't allow the usage of C++ vectors, so that's out of the question.


texts: I am creating an arduino alarm clock/light sculpture, but I can't for the life of me find any information about the lifespans of LCDs that are running 24/7 for a very long time. If anyone has any information on them, please tell me. Specifically, I am using this one.


texts: Controlling 4 motors using the Arduino Uno

texts:
I've decided to make a quadcopter but since I'm a rookie, i decided against doing it from scratch. I'm planning to order this kit, first understand the dynamics and then try and make a quadcopter on my own using the components in it.
My first question are

Can I control the 4 motors using 2 H-bridges (L293D)?
Are ESC's necessary if I use the PWM pins?

Thanks in advance!


texts: Arduino / BitVoicer Sending IR code on loop

texts:
I was designing a voice automated kitchen lighting system. I have led strips under the cabinets which are remote controlled by an IR remote, so I captured the IR codes and got an IR led to turn them on. Now I introduced BitVoicer so that I could use voice commands to control the LED. I have ran into the issue that the IR led keeps turning the lights on and off, but my IR codes worked prior to using BitVoicer.

Here is my arduino code:

#include <BitVoicer11.h>

int IRledPin = 13;

BitVoicerSerial bvSerial = BitVoicerSerial();

void setup()
{
 Serial.begin(9600);
 pinMode(IRledPin, OUTPUT);
}

void loop()
{
  bvSerial.getData();

  if(bvSerial.strData == "")
  {
    return;
  }

  if(bvSerial.strData == "wake")
  {
   LightOnCode();
  }
}

  void pulseIR(long microsecs)
   {
     cli();

     while (microsecs > 0)
      {
        digitalWrite(IRledPin, HIGH);
        delayMicroseconds(10);
        digitalWrite(IRledPin, LOW);
        delayMicroseconds(10);

        microsecs -= 26;
      }
     sei();
    }
   void LightOnCode()
{
  pulseIR(8940);
  delayMicroseconds(4380);
  pulseIR(520);
  delayMicroseconds(600);
  pulseIR(520);
  delayMicroseconds(560);
  pulseIR(560);
  delayMicroseconds(560);
  pulseIR(520);
  delayMicroseconds(580);
  pulseIR(520);
  delayMicroseconds(560);
  pulseIR(540);
  delayMicroseconds(580);
  pulseIR(520);
  delayMicroseconds(580);
  pulseIR(520);
  delayMicroseconds(580);
  pulseIR(540);
        delayMicroseconds(1660);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(520);
  delayMicroseconds(1660);
  pulseIR(540);
  delayMicroseconds(1680);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(500);
  delayMicroseconds(1680);
  pulseIR(540);
  delayMicroseconds(1680);
  pulseIR(520);
  delayMicroseconds(1660);
  pulseIR(540);
  delayMicroseconds(580);
  pulseIR(520);
  delayMicroseconds(560);
  pulseIR(560);
  delayMicroseconds(560);
  pulseIR(520);
  delayMicroseconds(600);
  pulseIR(500);
  delayMicroseconds(580);
  pulseIR(540);
  delayMicroseconds(560);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(540);
  delayMicroseconds(560);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(540);
  delayMicroseconds(1660);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(520);
  delayMicroseconds(1640);
  pulseIR(580);
  delayMicroseconds(1660);
  pulseIR(520);
  delayMicroseconds(1660);
  pulseIR(560);
  delayMicroseconds(560);
  pulseIR(520);
  delayMicroseconds(1680);
  pulseIR(520);

}

If anyone could answer my question as to why the led keeps sending extra signals I would appreciate it! If you have any questions don't hesitate to ask!