texts: 5 * tm1637 displaying different school bells timings

texts:
I am working on a project which displays time of School bells for a school, I have got 5*TM1637 Display Tubes which displays 5 Periods/Classes start timings.I can set digits of each TM1637 using the code (attached with this question) which i made to display time.
But the problem is : The time of each period/class changes regularly, some periods will be little longer from yesterday, some shorter and vice versa.

To overcome this problem i adding HC-05 Bluetooth module on Hardware Serial2 , on the other hand i have also developed an app using MIT app inventor which inputs in a form of characters and sends it via bluetooth to HC-05.

The bytes will be in this format : english09:30 ,science11:00 etc, The format includes the period/class name with the time.(is there any other better way around to format and send these values, Please let me know)

I want to take this information and change the displaying time on TM1607 Modules respectively.

edit : I want my code to understand the received byte and set the time to Specified TM1607 associated to it. like when it receive "english09:30" it should change the digits on TM1607 in void english();

Here is my code :

#include "TM1637.h"

#define CLK1 2
#define DIO1 3

#define CLK2 4
#define DIO2 5

#define CLK3 6
#define DIO3 7

#define CLK4 8
#define DIO4 9

#define CLK5 10
#define DIO5 11

TM1637 Display1 (CLK1, DIO1);

TM1637 Display2 (CLK2, DIO2);

TM1637 Display3 (CLK3, DIO3);

TM1637 Display4 (CLK4, DIO4);

TM1637 Display5 (CLK5, DIO5);

void setup ()
{
  Display1.set ();
  Display1.init ();

  Display2.set();
  Display2.init();

  Display3.set();
  Display3.init();

  Display4.set();
  Display4.init();

  Display5.set();
  Display5.init();
  Serial.begin(9600);
  Serial2.begin(9600);
}

void loop ()
{
  while (Serial2.available())
    Serial.write( Serial2.read() );
  english();
  biology();
  social();
  math();
  chemistry();
}

void english ()
{
  int8_t Digits [] = {1, 2 , 3 , 4 };
  Display1.display (Digits);
  Display1.point(POINT_ON);
}

void biology ()
{
  int8_t Digits [] = {1, 2 , 3 , 4 };
  Display2.display (Digits);
  Display2.point(POINT_ON);
}

void math ()
{
  int8_t Digits [] = {1, 2 , 3 , 4 };
  Display2.display (Digits);
  Display2.point(POINT_ON);
}

void social ()
{
  int8_t Digits [] = {1, 2 , 3 , 4 };
  Display2.display (Digits);
  Display2.point(POINT_ON);
}

void chemistry ()
{
  int8_t Digits [] = {1, 2 , 3 , 7 };
  Display2.display (Digits);
  Display2.point(POINT_ON);
}

EDIT:

My question is how to parse the incoming string ("english09:10") the get the class name and the starting hour.


texts: Is there a way to both read and write on the rising edge of the SPI Clock?

texts:
Im trying to use sipo and piso shift registers simultaneously with ESP32 using SPI. However the sipo(SN74AHC) reads data on the rising edge of clock and the piso(SN74HC165) outputs data on the rising edge of the clock. Using the arduino SPI library, there is not a spi mode that can accomidate this. As a result, I am losing a bit from either device no matter what I do.

Is there something I can do to get both read and write at the rising edge or will I be forced to read and then write, changing the spi mode in between?


texts: Graphic fail when rebooting the micro controller and OLED! (NOT when uploading the code??!!)

texts:
Im using Spark fun´s Pro micro: https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro

And Digole OLED 1.8" hooked up with UART: http://www.digole.com/index.php?productID=859

As the head line reads, got code that work just fine when I upload it to the Pro Micro. But when I restart the pro micro (after successful upload it starts to show these weird characters and tokens. I can still se the "working code" but with a lot of additional crap?!

EDIT: This is installed in a car, and I´ve notice its just screwing around when I turn the car ON.. The cars electric is probably somehow interfering with the data-signal to the oled. Maybe I need a resistor of some kind?

What is this, why is it happening, and what can I do to get rid of the problem?!?

Help´s very appreciated!! Thanks!! /Rasmus


texts: How do I segment Arduino program when line count is so large that code maintenance is difficult?

texts:
I'm looking for the Arduino/C++ equivalent of COBOL's 'copy' statement.

I'm working on a program that is approaching 600 lines of code in the TopLevel.cpp source file.  This is hard to manage because I feel like I spend all my time scrolling up and down the source file.  The code in question does not easily lend itself to conversion to a class because it is sections of loop/main.  I've tried using xxx.h (for storage definitions) and yyy.cpp (for code sections).  Those approaches yield error messages, which I think are due to the different timings of the Arduino pre-processor and the compiler code that resolve the #include statements.

Thanks for the help.
--CVTBrakeman

p.s.
I wrote my first program in 1967; the language was GOTRAN on an IBM 1620.  For almost 50 years, I made my living designing/writing COBOL and SAS code on IBM mainframes.  Yes, Y2K was real and I survived it.


texts: Arduino compatible's serial port not showing Mac OSX

texts:
I bought an Arduino-compatible Freaduino board atmega8 (I selected the board type as Arduino ng or older atmega8). I installed the Arduino IDE on Mac OS X and the FTDI drivers. But my serial port looks like this when I connect the board:

And when I try to upload the program, this is the error I get:

Can someone tell me what is the mistake? I am clueless.

UPDATE: the problem was I had not installed the driver properly (I guess). I uninstalled and reinstalled them and it worked perfectly. Also made a YouTube tutorial regarding the same. http://youtu.be/BwatajQO_88


texts: Replacing BT module with 433 MHz transreceiver module

texts: I have made a prototype where I can send data from one arduino to another via Bluetooth(hc-05), they are working fine, but now I want to replace the BT module with RF module, how can I do that???


texts: esp8266 not responding to the AT commands

texts:
I am integrating Arduino Uno with the WiFi module ESP8266.  I have already made the connections between the ESP8266 and the Arduino Uno which are :

txd uno -> rxd esp8266
rxd uno -> txd esp8266
gnd uno -> gnd esp8266

The VCC and chid pind of ESP8266 are connected to an external supply of voltage 3.3V and 160mA current. The code is getting uploaded onto the Arduino and the ESP8266 is also getting powered on.But i am facing a problem while i send the AT commands on the serial monitor. It is not responding even though the red led is on constantly and when i press enter after sending the command , the blue led blinks for a few seconds.
Do i have to update the firmware of the ESP8266?


texts: How to make "IF "Temperature exceeds" logic to work in same arduino code

texts:
I have the below code working from https://www.youtube.com/watch?v=Y30iEOxl1To - to receive temperature & humidity as an sms when i give a missed call to a specific number (sim on the gsm shield)

The above code is like on demand sms. I also want to alter this code so it can automatically send me another sms if the temperature exceeds a threshold.

Please help.

Below is the code...

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "call.h"
#include <DHT.h>
#include "sms.h"

SMSGSM sms;
#define DHTPIN 7
#define DHTTYPE DHT22

CallGSM call;
boolean started=false;
char sms_text[160];

DHT dht(DHTPIN, DHTTYPE);

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

    if (gsm.begin(9600))
    {
        Serial.println("\nstatus=READY");
        started=true;
    }
    else
        Serial.println("\nstatus=IDLE");
}

void loop()
{
    float humidity, temperature;
    String smsText ="";
    if(temperature>29)
    {
        switch (call.CallStatus())
        {
            case CALL_NONE: // Nothing is happening
                break;

            case CALL_INCOM_VOICE : // Yes! Someone is calling us
                Serial.println("RECEIVING CALL");
                call.HangUp();
                delay(1000);
                humidity = dht.readHumidity();
                temperature = dht.readTemperature();
                delay(1000);
                smsText = "Temperature: "+String(temperature,1)+"C Humidity: "+String(humidity,1)+"%";
                smsText.toCharArray(sms_text,160);
                //Serial.println(smsText);
                sms.SendSMS("+91**********",sms_text);
                break;

            case CALL_COMM_LINE_BUSY:  // In this case the call would be established
                Serial.println("TALKING. Line busy.");
                break;
        }
        delay(1000);
    }
}


texts: Is there any way I can light up a candle with an Arduino?

texts: I want to make a candle flame light up triggered by a microcontroller. Is it possible? I only want to light it up. Not turn it down. Moreover, this is for a one-time use so the candle burning down and becoming shorter is not a problem.


texts: Connect USB cable to GPIO pins on an Arduino Uno

texts:
Electronics Newbie!!

I want to connect a USB cable to my Uno's GPIO pins (and then connect it to a USB port on my computer). I have chopped off a USB cable from a keyboard, I read this and I'm hoping that the wires will be in the correct order (the keyboard was made by Dell). I'm a little confused about which wires go where.


texts: Arduino ADC Reference Voltage if it is Battery Powered

texts:
I am looking to possibly monitor battery power to the Arduino using its ADC.  This is fairly straight forward and simple (especially if using the Arduino API); however, if the battery is powering the Arduino and is unregulated externally, won't the ADC reference voltage constantly be dropping with the battery?  In other words, wouldn't the ADC value would constantly read the same value (the max value) even though the battery would actually be decreasing in voltage?

If this is the case, it would be both inefficient and pointless to measure the battery voltage.


texts:
I'm trying to execute a math of analog read but I get some weird result.. I searched about int and floats but didn't understand..
My code is :
#include <SevSeg.h>

SevSeg sevSeg;

int bitsChange = analogRead(A0) ;
float fuel = (923 - bitsChange) * 0.121065375;
sevSeg.setNumber(round(fuel));

Assuming bitsChange = 683, so fuel has to be after rounding 29, what I get is 39!!!!
I want to know why I get this result to learn about it..


texts: On the hardware side of things, what is involved in making the Arduino receive signals from a TV Remote? What kind of infrared receiver is needed? Do TV remotes use some kind of channels, encoding, or encryption requiring special receivers or else additional programming work to decrypt the signals?


texts: Arduino Robot motors disabled when AnalogInput is connected

texts: I have attached a solar panel to the Arduino Robot, connecting the - to the TK3 Input GND, and the + to the TK3 Input Analog Pin. I want to turn the robot around and "scan" the voltage. But the motors only run if a disconnect one of the cables or both of them. Do you have any solutions?


texts: Can't program bareduino. "avrdude: stk500_recv(): programmer is not responding"

texts:
I've built a bareduino. The blink sketch that it came preprogrammed with worked. I was also able to program the ATmega328 by putting it into a arduino uno.

What I can't do is upload a sketch directly. I've tried both of the methods described here: https://www.virtuabotix.com/bareduino328-programming-guide/

I've used FTDI before and I know that my drivers work. I've tried suggestions from many forums and after 3 hours I'm running out of options.

The issue seems to be the reset pin. But the fixes here have not worked. I must admit I'm confused about how to un-ground the reset pin. I tried unplugging the power. When I tried to upload with FTDI I had a capacitor... so shouldn't that fix this error?

Verbose Error Code:

Sketch uses 7,920 bytes (24%) of program storage space. Maximum is 32,256 bytes.
Global variables use 383 bytes (18%) of dynamic memory, leaving 1,665 bytes for local variables. Maximum is 2,048 bytes.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem1d11 -b115200 -D -Uflash:w:/var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build7068227750495702499.tmp/webclient.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/futurebird/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem1d11
         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
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

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


texts: Does SoftwareSerial and the servo library produce interrupt conflicts?

texts: I'm planning a project that will involve multiple serial ports and the Arduino servo library. I have heard that this may cause interrupt conflicts. Are there any simple solutions to this


texts: How can I use Arduino Analog Uno pins as Digital pins?

texts: How can I use Arduino Uno Analog Pins as Digital pins, So that I can Attach more components like sensors to the Arduino? My 13 pins are preoccupied and I want more.


texts: Disable interrupts when doing critical things?

texts:
I've got a few functions like this that log, or do more critical things like get/save configuration variables.

/**
   Write weather data to csv
   commit: datetime,minHumidity,maxHumidity,minTemperature,maxTemperature,rainfall,irrigationRan
*/
void writeWeatherData() {
  noInterrupts();
  DBG_OUTPUT.println(F("[WEATHER DATA] Attempting to save weather data..."));
  bool writeHeader = SPIFFS.exists("/weather_data.csv") ? false : true;
  File file = SPIFFS.open("/weather_data.csv", "a");
  if (!file) {
    addPrintError("[WEATHER DATA] There was an error opening weather_data.csv for writing.");
    interrupts();
    return;
  }
  String data = "";
  if (writeHeader) {
    data += "datetime,minHumidity,maxHumidity,minTemperature,maxTemperature,rainfall,irrigationRan\r\n";
  }
  DateTime now = rtc.now();
  char buf[] = "MM/DD/YY hh:mm:ss";
  String t = now.toString(buf);
  float rainfall = getRainfall();
  data += t + "," + minHumidity + "," + maxHumidity + "," + minTemperature + "," + maxTemperature + "," + rainfall + "," + irrigationRan + "\r\n";
  if (file.print(data)) {
    DBG_OUTPUT.println(F("[WEATHER DATA] File was written."));
  } else {
    addPrintError("[WEATHER DATA] File write failed.");
  }
  file.close();
  DBG_OUTPUT.println(F("[WEATHER DATA] Task completed."));
  interrupts();
}

I surround  code with noInterrupts and interrupts however I am not sure if it is required. Assume that an interrupt is triggered at the exact moment when the above function is saving something, what exactly happens if I didn't have noInterrupts .etc.?


texts: Disable the Amplifier during the flashing ESP8266

texts:
I use ESP-12 and Adafruit Mono Amplifier for playing audio. It works but It has one big issue. My circuit uses RxD to transfer audio (A+ connect to RxD), also ESP uses for flashing the chip. This causes horrible noise when it is programming the ESP8266 from the speaker. The good thing about this module is it has SD pin which can be used to turn it off.

Now the question is how I can connect this SD pin to disable the amplifier during the flashing procedure and also keep it off by default in normal mode and use something like digitalWrite() to turn it on manually in my application when it is needed. Thanks


texts: Reducing lag between the arduino and a processing sketch on my computer

texts:
I'm currently on project #14 of the Arduino project book.

I'm trying to control a processing sketch on my laptop using my Arduino. This is accomplished by using a potentiometer to control the background of an image.

Arduino code:

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

void loop(){
  Serial.write(analogRead(A0)/4);
}

Processing:

//imports serial library
import processing.serial.*;
//setups the serial object
Serial myPort;
//creates an object for the image
PImage logo;
//variable to store background color
int bgcolor = 0;

void setup(){
  colorMode(HSB,255);
  logo = loadImage("http://arduino.cc/logo.png");
  size(logo.width,logo.height);
  println("Available serial ports");
  println(Serial.list());
  myPort = new Serial(this,Serial.list()[0],9600);
}
//equivalent of arduino's loop function
void draw(){
  if(myPort.available() > 0)
  {
    bgcolor = myPort.read();
    println(bgcolor);
  }

  background(bgcolor,255,255);
  image(logo,0,0);
}

Now, while the code works, and the background color changes as i turn the potentiometer, there is a huge lag between turning the potentiometer and seeing the background change color, and the values from the Arduino/potentiometer change on the processing's serial monitor.

What I've tried:

Changing the speed of Serial communication

I've noticed that when I decrease the speed of Serial communication, e.g. around 100, the delay between turning the potentiometer and seeing it change on my laptop decreases to about 1 second. However, when I decrease the speed of Serial communication even further, e.g. a value of 1, the delay increases again.

On the flip side, at the standard speed of 9600, the delay is huge, roughly 5sec ++ before the changes in the potentiometer show up on the laptop/processing.

Why does decreasing the communication speed (up to a certain point) decrease the time lag, and increasing it increase the time lag? Also, is there anyway I can make it near instantaneous?


texts: Connect two D1 R2 (8266) via SPI with Github SPISlave Library

texts:
Problem:
SPI Connection between two D1 (ESP8266) boards does not work properly, only master to slave transfers data correctly.

What I did:
I connected two Wemos D1 R2 via SPI and installed the library from https://github.com/esp8266/Arduino. I connected MISO, MOSI, SCK, SS and ground 1:1. On one D1 I run SPISlaveTest on the other SPIMaster from the examples. The D1 are located directly beside each other, cables are only 15 cm long.

Effect:
While the slave receives strings from the master fine the master seems to get crippeled answers from the slave, they appear as ??? and other characters. If I connect the slaves SS to +3.3V it reacts like expected: The slave receives no more, the master gets no reponses.

What I already tried:

Updated the Libraries to the latest versions
Changed delay to wait for answer
tried SafeMaster.ino
Changed D1 hardware on both sides

Everything unfortunately did not help.

Any tip is very appreciated.

Thanks!


texts:
The second and third "while and "if" are not working but first "While" and "if" does work.. Am I doing something wrong?
#include <DFMiniMp3.h>

int sw1 = 3;
int sw2 = 4;
int sw3 = 5;

class Mp3Notify
{
  public:
    static void OnError(uint16_t errorCode)
    {
      // see DfMp3_Error for code meaning
      Serial.println();
      Serial.print("Com Error ");
      Serial.println(errorCode);
    }

    static void OnPlayFinished(uint16_t globalTrack)
    {
      Serial.println();
      Serial.print("Play finished for #");
      Serial.println(globalTrack);
    }

    static void OnCardOnline(uint16_t code)
    {
      Serial.println();
      Serial.print("Card online ");
      Serial.println(code);
    }

    static void OnCardInserted(uint16_t code)
    {
      Serial.println();
      Serial.print("Card inserted ");
      Serial.println(code);
    }

    static void OnCardRemoved(uint16_t code)
    {
      Serial.println();
      Serial.print("Card removed ");
      Serial.println(code);
    }
};
DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial); //Create the UART connection to the module

void setup()
{

  //3 push buttons with pullups
  pinMode(sw1, INPUT); //Define each button as input with pullup
  pinMode(sw2, INPUT);
  pinMode(sw3, INPUT);

  digitalWrite (sw1, HIGH); //12 Votls supply set to off state
  digitalWrite (sw2, HIGH); //5 Votls supply set to off state
  digitalWrite (sw3, HIGH); //3 Votls supply set to off state

  Serial.begin(9600);
  mp3.begin(); //Start communication with the DFplayer module
  uint16_t volume = mp3.getVolume(); //Get actual volume
  mp3.setVolume(30); //Set new volum (max is 30)
  uint16_t count = mp3.getTotalTrackCount(); //Get the total tracks on the SD card in case we want to sue this later...
}

//just a fucntion that we use to create delays in "ms"
//without using the delay() function
void waitMilliseconds(uint16_t msWait)
{
  uint32_t start = millis();

  while ((millis() - start) < msWait)
  {
    // calling mp3.loop() periodically allows for notifications
    // to be handled without interrupts
    mp3.loop();
    delay(1);
  }
}

void loop()
{

  if (digitalRead(sw1) == LOW)
  {
    mp3.playMp3FolderTrack(1); // Play audio track 0001
    waitMilliseconds(5000); // 1s of delay
    while (digitalRead(sw1) == HIGH); // do nothing until state changes

  }

  if (digitalRead(sw2) == LOW)
  {
    mp3.playMp3FolderTrack(2); // Play audio track 0002
    waitMilliseconds(5000); // 1s of delay

    while (digitalRead(sw2) == HIGH); // do nothing until state changes

  }

  if (digitalRead(sw3) == LOW)
  {
    mp3.playMp3FolderTrack(3); // Play audio track 0002
    waitMilliseconds(5000); // 1s of delay

    while (digitalRead(sw3) == HIGH); // do nothing until state changes
  }

}


texts: Why does it skip the first index - shift register issue

texts:
So, I wrote this code myself and I'm a noob on the issue. I did get my code working, but cannot understand why it has to be the way it is.

int counter;
int ledValue[] = {
  1,0,1,1,1,1,1,1
};

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
}

void loop(){
  digitalWrite(5, HIGH);
  for (counter = 8; counter >= 0; --counter) {
  // turn the pin on:
    digitalWrite(2, ledValue[counter - 1]);
    digitalWrite(3, 1);
    digitalWrite(4, 1);
    digitalWrite(2, 0);
    digitalWrite(3, 0);
    digitalWrite(4, 0);
    delay(100);
  // turn the pin off:
  }
  delay(1000);
  digitalWrite(5, LOW);
}

Now, I am puzzled by both the counter = 8 and the [counter -1]. To me it looks like I am loop-ing this 9 times, though I only got 8 items in the array

A. If I make it counter = 7 and [counter -1] my output is 10111110. This loops 8 times (I think), but gives me 7 leds.

B. If I make it counter = 7 and [counter] my output is 01111110. This loops 8 times (I think), gives me 7 leds but also an extra led burning up front, hence braking the prescribed pattern.

C. If I make it counter = 7; counter >= -1 my output is 10111111.(as it should). But how can it be -1?

My guess is that I am doing something wrong at the beginnen, but I can't find what. Tried several tutorials and explanations, but it still puzzles me why the correct running code is that way.

Just to be sure, I am familiar with an array being 0-indexed.

Please helpt me understand my code  ;-)

Edit:
Small addition:

pin 2 is connected to ShiftRegister pin 14
pin 3 is connected to ShiftRegister pin 12
pin 4 is connected to ShiftRegister pin 11
pin 5 is connected to ShiftRegister pin 10

Thanks for the feedback. My lack of understanding does not concern the loop or array. What I can't get my head around is why the shift registers outputs the loop as it does. Would a picture of the setup help?


texts: Is it possible to send data from internet server to ESP8266 behind proxy or regular requests from ESP8266 are required?

texts:
It would be kind of push notification or something like that probably.
I can first connect to server and send it any data for "registration"...
I found many examples with websockets but all of them was about ESP8266 is like "server". That's not this case...


texts:
I buy a stm32 board as picture below, I connect the Boot0 to 3.3 and use the serial port  download the program.
I use the library https://github.com/rogerclarkmelbourne/Arduino_STM32
The second and third picture is my program. After I download the program, the led on board shine and the serial is normal, but after I press RESET on board, it is not shine. Seemly, the program vanish.
Why it is so ? And how to let the program in board after press reset ?


texts: How to include Vref in thermistor temperature calculation?

texts:
simulate this circuit – Schematic created using CircuitLab
This is the code that I'm using to get the temperature:
#define COEFF_A 0.8662984364E-03
#define COEFF_B 2.780704551E-04
#define COEFF_C -0.9395108479E-07

float VRT, Temp;
float Vref = 2.52;

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

void loop() {
  long Resistance;
  VRT = analogRead(A3);
  Resistance = 10000 / ((1023.0 / VRT) - 1);
  Temp = log(Resistance);
  Temp = 1 / (COEFF_A + (COEFF_B * Temp) + (COEFF_C * pow(Temp, 3)));
  Temp += -273.15;
  Serial.println(Temp);
  delay(500);
}

I know that the calculation should be: V = Vref × VRT ÷ 1023 but i don't know how to implant it in this code, any help appreciated.

Update
After Edgar Bonet answer, the edited code is:
#define COEFF_A 0.8662984364E-03
#define COEFF_B 2.780704551E-04
#define COEFF_C -0.9395108479E-07

float VRT, Temp, VR;

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

void loop() {
  long Resistance;
  VRT = analogRead(A3);
  VR = 2.52 * VRT / 1024;
  Resistance = 10000 * VR / (2.52 - VR);
  Temp = log(Resistance);
  Temp = 1 / (COEFF_A + (COEFF_B * Temp) + (COEFF_C * pow(Temp, 3)));
  Temp += -273.15;
  Serial.println(Temp);
  delay(500);
}

But the temperature reading is 2 centigrade less than what it should be, when i remove the analogReference(EXTERNAL); it shows the normal/correct temperature readings.


texts: What precision can I expect by syncronising DS3231 with PC serial?

texts:
The point here is to syncronise a DS3231 module (on an Arduino) via serial port with NTP time by computer.

The problem here is that I'd like to know how much time is taken by the serial and I2C transmission, because if the PC sends the time at a time t1 and transmit it to the Arduino, the Arduino decodes it and sends it to the DS3231, the time t1 is received at a time t2 greater than t1.

PC (t1) => Serial(t1+x) => Arduino(t1+x+y) => I2C(t1+x+y+z) => DS3231(t2=t1+x+y+z)

t1 -> NTP time recorded by PC
x  -> Time taken by serial transmission
y  -> Time taken by arduino buffering/processing
z  -> Time taken by I2C transmission at 100kHz
t2 -> Time when message is received by DS3231

Is it negligible for a precision at millisecond?

I found a table on Wikipedia that displays time per bit per baudrate. I am planning to use a baudrate of 57600.

I tested offset using a simple echo program available here at 300 baud:

String buff="";

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

void loop() {
  if(Serial.available())
  {
    while(Serial.available())
    {
      buff += char(Serial.read());
    }
    Serial.print(buff);
    buff = "";
  }
}


texts: Maximum frequency of digital signal in Arduino Uno?

texts:
As Arduino Uno has a 16 MHz oscillator but while running program it has less frequency because some of the processing power is used for running the program.
I have used the delay(1) but it is giving me around 500 Hz.

My questions:

Is there any way to achieve more than 500 Hz?
What would be the maximum frequency of digital signal for below program?

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

void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(13, LOW);
}


texts: Changing the order of GUI-elements inside Arduino ESP-Dash-library

texts:
I'm trying to add a new item "index" to GUI-elements that are created by using ArduinoJSON and the Vue.js-framework inside the ESP-Dash-library.
The library creates GUI-elements like buttons, sliders etc. and provides easy to program call-back-procdures to make the microcontroller interact with the user-input from the website.
The code as it is iterates through all defined GUI-elements and creates the HTML-code. First all temperture-showing elements then all humidity elements, then all sliders etc...
This means the sequence and the position of the GUI-elements can't be defined by the programmer.
The new functionality I want to achieve is that the programmer can define the sequence and position of all GUI-elements on the website.
This means a new item like "index" must be added and the HTML-creation-code must be changed to another kind of iteration through the GUI-elements.
Now I'm very lost on where to look into all the Arduino- or the javascript-code  to find that place where the iteration must be changed.
Here is the link to the GiPo https://github.com/ayushsharma82/ESP-DASH
and especially to the app.vue javascript https://github.com/ayushsharma82/ESP-DASH/blob/master/vue-frontend/src/App.vue
If this kind of question is inapropriate please drop a few words what is wrong.
And then add a link to "how to post good questions"
best regards Stefan


texts: Arduino MEGA 2560 board doesn't transmit RF signal

texts:
I tried to test RF communication using nRF24L01 with 2 Arduino boards ( between Arduino Nano and Arduino mega). Codes are working fine (They are very simple codes). When I set Arduino nano as the transmitter and the Arduino mega as the receiver then Arduino mega receives the signal. I print them on serial monitor. So they are working fine.
But when I change the Rx and Tx, When I set Arduino mega as the transmitter and Arduino nano as the receiver, then at the receiver end it doesn't show anything on serial monitor.
I updated Arduino and libraries to the newest version but still not working. And when I set the Arduino Mega board as a Transmitter then only 'L' led and 'ON' LEDs are turned on. Tx and Rx LEDs on Mega board don't turn ON.
I would like to know what is the reason for the problem and any solutions?


texts:
I wrote simple code for my Digispark (Attiny85 with Micronucleus bootloader) in Arduino IDE:

#include <DigiUSB.h>

String inst;

void setup() {
  DigiUSB.begin();
  pinMode(1, OUTPUT);
}

void loop() {
  if (DigiUSB.available()) {

    char inp = DigiUSB.read();

    if (inp == '\n') {
      DigiUSB.println(inst);
      DigiUSB.println(inst.length());
      inst = "";

    }
    else {
      inst += inp;
      }
  }

  DigiUSB.delay(1);
}

DigiUSB works just like Serial communication in classic boards

If i send string and newline char i expect it to output this string back and print its length, but instead i receiving null string and 0 in any case

Is it problem with code or microcontroller itself?

EDIT:
Its seems to be digispark library problem itself:

DigiUSB.println() and DigiUSB.print() accept only char arrays

Also, there is no toCharArray() from classic arduino lib and no c_str() so i cant use atoi()


texts: How time intensive or how long can an ISR be?

texts: I would like to code my ISR to be time intensive or interrupt the main program for atleast 1 or more seconds. My goal is to verify that if I am reading a sensor in the main loop, would it stop reading the sensor when the code is interrupted and for how long. I have trying to call various functions from the ISR like to turn on the motor but everything is instantaneous.


texts: Arduino Pro Micro clone clock cycle issue

texts:
I have several Arduino Pro Micro clones that are giving me an issue where they work immediately after being programmed while the USB cable is still connected, but as soon as I disconnect and reconnect the USB cable the program fails. I was able to break it down to the simplest form and found that the clock cycle is off by what I estimate to be almost a factor of 10.

For testing, the only command in the loop is Serial.println(millis());. Immediately after programming you can watch the milliseconds scroll by in the serial monitor at the expected rate. Unplug and plug the USB, reconnect the serial monitor and now the milliseconds scroll by at about 1 second interval.

The Arduino IDE version is 1.6.8 and have tested it from both a Mac and Ubuntu with the same results. Also tested on 4 different boards with the same results. I also tested the latest Arduino beta with no change. Next I'm going to download some older Arduino IDE versions.

Any suggestions?


texts: How can I make a Parallax Servomotor move a water tap correctly and prevent from vibrations?

texts:
I am using Arduino Mega 2560

I have built an structure with plastic 3D pieces to move this water tap.:

I am using the "Servomotor Parallax Inc 140 mA, 4 6 V" to rotate the tap:

Some more images to show how I mounted it:

Video 1. I tried to use the power of the arduino directly (5V). But the motor is not steady in all the positions I set, in some positions the noise you hear in the video do not stop, and my impression is that the motor will burn soon because it keeps pusshing all the time.

Video 2. Without almost any load, the motor is also making a small sound. I don't know if you can appreciate it in the video. They are like cracks or clicks

Possible solutions:

Is there a way to cut the power supply when the motor already moved the tap? Or just to stop the motor to keep pushing?
Using a external power should solve the problem? I found this tutorial where they use that system. Which will be the benefits of that? It will fix the problem?
Using another stronger servomotor?
A stepper motor?
Is my servomotor faulty?
Would I need some controller?

Any other suggestion?


texts:
#include <Servo.h>

Servo myservo;
int pos = 0;
int servo_pin = 3;
int led_pin = 4;

void setup() {
  myservo.attach(servo_pin);
  Serial.begin(9600);
  pinMode(led_pin,OUTPUT);
}

void loop() {
  if (Serial.available()) {
    char serial = Serial.read();
    if (serial == '2') {
      servo();
    }
    if (serial == '1') {
      digitalWrite(led_pin,HIGH);
    } else if (serial == '0') {
      digitalWrite(led_pin,LOW);
    }
  }
  delay(100);
}

void servo() {
  for (pos = 0; pos <= 180; pos += 1) {
    myservo.write(pos);
    delay(5);
  }
  delay(5000);  // problem is here
  for (pos = 180; pos >= 0; pos -= 1)
    myservo.write(pos);
  delay(5);
}

When I run this code, and send 2 servo functions start but there is an delay function. Now I want to send 2 then send 1. When I do this, the first servo starts but the LED starts after the servo function. I want to start this too at the same time.


texts:
I am new to Arduino. I have an arduino mega board, which I need to interface with MPU6050 accelerometer-gyroscope module.

My connections are

Arduino_SCL->MPU6050_SCL;

Arduino_SDA->MPU6050_SDA;

Arduino_GND->MPU6050_GND;

Arduino_5 V->MPU6050_Vcc;

Arduino_Pin 2->MPU6050_INT;

I have uploaded the following code to the arduino mega.

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"

MPU6050 accelgyro;

int16_t ax, ay, az, gx, gy, gz;
double  time;
int i;

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  accelgyro.initialize();
  time = millis();
  i = 1;
}

void loop()
{
  // collect readings
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  // print result
  Serial.print(i);   Serial.print("\n");
  Serial.print(ax);   Serial.print("\t");
  Serial.print(ay);   Serial.print("\t");
  Serial.print(az);   Serial.print("\t\n");
  Serial.print(gx);   Serial.print("\t");
  Serial.print(gy);   Serial.print("\t");
  Serial.print(gz);   Serial.print("\t\n");

  i = i + 1;
  delay(1000);
}

My problem is when I observe the reading on serial monitor, it shows every reading as zero. Does this mean my sensor is damaged or there's some problem with my connection? Or is my code for fetching the data incorrect?

Thanks


texts: Templated class: How to create instance and work with it?

texts:
I have created a class like this:

#ifndef MyList_h
#define MyList_h

#include "Arduino.h"

template <typename T>
class MyList {
public:
  MyList(void);
  ~MyList(void);

  void addItem(T* item);

  //more stuff

};

#endif

And implementation is like this:

#include "Arduino.h"
#include "MyList.h"

template<typename T> MyList<T>::MyList(void) {
  // constructor implementation here
}

template<typename T> MyList<T>::~MyList(void) {
  // desctructor implementation here
}

template<typename T> void MyList<T>::addItem(T* item) {
  // function implementation here
}

// ...more stuff

In my .ino Sketch I'm doing this (found this solution in a C++ example):

#include "MyList.h"
MyList<word>* list = new MyList<word>(); // global scope
//... more stuff

But when compiling, Arduino IDE complains:

  Test.ino:5: undefined reference to `MyList::MyList()'

I googled a bit and found this alternative way for creating the instance:

ArrayList<word>* list;

Then there's no error, just compiles file. BUT as soon as I want to use this instance (=adding code) like this:

list->addItem(i);

compiler complains again:

  Test.ino:25: undefined reference to `MyList::addItem(unsigned int*)'

What's wrong? Why is this reference undefined?

I tried another way:

ArrayList<word> list; // again global scope

But then the compiler also tells me:

  Test.ino:5: undefined reference to MyList<unsigned
  int>::MyList()' /tmp/ccp8qmCz.ltrans0.ltrans.o: In function
  _GLOBAL__sub_D_list':
  /....../Test.ino:5:
  undefined reference to `MyList::~MyList()'

So, how can I create an instance of my class that uses a template?

Environment: Arduino IDE 1.8.3 (I know, I could update...) + Arduino Nano Board.


texts: What does it take to compile Linux on Arduino, if at all possible?

texts: Is it possible to run Linux on Arduino? If yes, what steps and limitations need to be considered? If not, what are the limitations that prevent this?


texts: Use ATtiny85 to perform initial config on a Cisco router using its USB console port

texts:
We have 200+ brand new Cisco routers that have USB console ports (but not the old RJ45 serial console ports). This is quite frustrating because the routers didn't ship with console cables and Cisco wants to charge $60 for their proprietary USB->RJ45 serial adapters.

When I plug the router in to a computer using a standard USB cable (mini USBb on one end and USB on the other end), it shows up as a virtual com port and allows me to configure the router if I have a VCP driver installed. More specifically it shows up as a "CP2105 Dual USB to UART Bridge Controller". Here's the full lsusb -v output for the router:

Bus 001 Device 005: ID 10c4:ea70 Cygnal Integrated Products, Inc. CP210x UART Bridge
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x10c4 Cygnal Integrated Products, Inc.
  idProduct          0xea70 CP210x UART Bridge
  bcdDevice            1.01
  iManufacturer           1 Silicon Labs
  iProduct                2 CP2105 Dual USB to UART Bridge Controller
  iSerial                 5 12345678
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           55
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              3 Enhanced Com Port
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              4 Standard Com Port
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

Is it possible to have an ATtiny85 board (eg Digispark) interface with the router via its USB console port to send several commands over the link to perform a perform basic initial config?


texts: Is it possible to send 2 or more o/p signal at the same time?

texts:
I wanted run two motors using Cytron MDD10A Dual Channel motor driver. So my concern is based on execution of code that is done line by line, in that case when I'm driving two motors will this delay in output signal at the PWM pins make a difference in nature of performance i.e. for example a car wheel, in case there is such delay it'll cause one wheel to rotate prior to another which is not desired. If yes, how do I rectify the same.
I also wanted to know when I use the delay function does it cause the delay in execution of the previous line or reads the upcoming line upon some 'x' seconds of delay?
Thank you for your help.
edit: code sample:
void FWD() {       // to move forward
    digitalWrite(m1, HIGH);  // motor 1 ON
    digitalWrite(m2, HIGH);  // motor 2 ON
    analogWrite(tm1, 225);   // tm1 assigned to a PWM pin
    analogWrite(tm2, 225);   // tm2 assigned to another PWM pin
}

in the above function I wish to run both analogWrite at the same time as I'm not sure how will it affect the output? I wish for the motors to start at the same time.


texts: Newbie need help to make a motor run for a laser scanner and some questions

texts:
I am trying to make a laser scanner consisting of a webcam and a line laser scanner. I have tried to use a manual scanning (by hand) and has worked, but would now like to consider automating the laser rotation (upwards and downwards) as a higher accuracy entails a slow and smooth rotation.

I came across arduino a few weeks back and realised it could possibly help to make this a reality. From my limited readings so far, I have obtained an Arduino Uno and a motor shield that seems to be the essentials for my purpose.

I have a few queries that hopefully someone can help:

Do I need a stepper motor for slow rotations, instead of a normal brushed motor?
Do I need to connect the Arduino to computer to make it run? Can I run it off battery, if so, does it have an 'ON' button?
How long will a standard 9V battery last?
For the code, I thought of using the simple one here: Arduino Motor Shield Tutorial.
Would it be able to allow me to control the amount of rotation, speed and the ability to reverse its rotation?


texts: Sending SMS once with arduino GPRS SIM900 if an input is HIGH

texts:
I faced a problem to send 1 SMS if an input is HIGH and if it is LOW no SMS will be sent. The code not working, just sends SMS when I turn the GPRS on and after that nothing happens.

Please check this link to see the code : the code

Thank you for helping in advance.


texts: Arduino library not working, can't find header

texts:
I have fair experience with C/C++ so I decided to have a go at writing my first simple Arduino library. I wrote the code which seems to be fine to me except that it keeps complaining about the header file not found during compilation:

/home/me/sketchbook/libraries/SegDisplay/SegDisplay.cpp:1:24: fatal error: SegDispaly.h: No such file or directory
 #include "SegDispaly.h"
                        ^
compilation terminated.

I have the library located in my sketch folder under the name "SegDisplay":

/home/me/sketchbook/libraries/
└── SegDisplay
    ├── examples
    ├── keywords.txt
    ├── README.md
    ├── SegDisplay.cpp
    └── SegDisplay.h

and here's the code:

SegDisplay.h:

#ifndef _SEVEN_SEG_H_
#define _SEVEN_SEG_H_

#include <math.h>

#if defined(ARDUINO) && (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

class SegDisplay
{
public:
    SegDisplay (int clockPin, int latchPin, int dataPin, int digitPins[4]);
    void display (double value);

private:
    const int digitPins[4];
    const int clockPin;
    const int latchPin;
    const int dataPin;
    const byte digit[10] = //seven segment digits in bits
    {
        B00111111, //0
        B00000110, //1
        B01011011, //2
        B01001111, //3
        B01100110, //4
        B01101101, //5
        B01111101, //6
        B00000111, //7
        B01111111, //8
        B01101111  //9
    };
    int digitBuffer[4];

    void setRegisterData (byte data);
    void clearRegister();
    void clearDisplay();
    void updateDisplay();
};

#endif

SegDisplay.cpp:

#include "SegDispaly.h"

SegDisplay::SegDisplay (int a, int b, int c, int d[4]):
    clockPin (a), latchPin (b), dataPin (c), digitPins (d), digitBuffer ({0})
{
    for (int i = 0; i < 4; i++)
    {
        pinMode (digitPins[i], OUTPUT);
        digitalWrite (digitPins[i], HIGH);
    }
    pinMode (latchPin, OUTPUT);
    pinMode (clockPin, OUTPUT);
    pinMode (dataPin, OUTPUT);
}

void SegDispaly::setRegisterData (byte data)
{
    digitalWrite (latchPin, LOW);
    shiftOut (dataPin, clockPin, MSBFIRST, data);
    digitalWrite (latchPin, HIGH);
}

void SegDispaly::clearRegister()
{
    setRegisterData (B00000000);
}

void SegDispaly::clearDisplay()
{
    // deactivate transistors
    for (int n = 0; n < 4; n++) digitalWrite (digitPins[n], HIGH);
}

//writes the temperature on display
void SegDispaly::updateDisplay()
{
    byte outByte;
    // dispaly digits
    for (int i = 0; i < 4; i++)
    {
        clearDisplay();
        clearRegister();

        // enable nth cell cathode (transistor)
        digitalWrite (digitPins[i], LOW);

        // output nth digit on display
        if (i == 1)
        {
            //print the decimal point on the 2nd digit
            outByte = digit[digitBuffer[i]] | B10000000;
        }
        else outByte = digit[digitBuffer[i]];
        setRegisterData (outByte);

        //delayMicroseconds (500);
        delay (5);

        //Serial.print (outByte, BIN);
        //if (i == 3)
        //{
        //  Serial.println (".");
        //}
        //else Serial.print (", ");
    }
}

void SegDispaly::display (double value)
{
    int n = int (value * 100);
    digitBuffer[0] = n / 1000;
    digitBuffer[1] = (n % 1000) / 100;
    digitBuffer[2] = (n % 100) / 10;
    digitBuffer[3] = (n % 100) % 10;
    updateDisplay();
}

My target AVR is Arduino Uno R3, the code used to work fine in a sketch before I decided to create a library out of it. Any help would be greatly appreciated. thanks in advance.


texts: Sending over a number from Arduino to Attiny85

texts:
I recently started my first arduino project, displaying a number on a 4x 7 segment display. I want to keep this code and use the display in other projects to display 4 digit numbers (creating a library and using segmentdisplay.write(number) maybe?).

Just displaying the number went really well, but I wanted to drive it with less I/O pins. Then I discovered shift registers, which reduced the number of necessary I/O pins to 3. But, the code needs to execute constantly to keep the 4 digits on the display via multiplexing. My solution to this was to run the sketch on attiny85, on which I programmed the code below. The only thing left to do is to change the value of 'getal' to a value that I read or calculate on the arduino. But I have no idea on how to achieve this, can I shift out data from the arduino to attiny85, which then updates 'getal's value? Any help is appreciated!

const int dataPin = 0;
const int latchPin = 1;
const int clockPin = 2;

const int Db = B00001111;
const int D1 = B00000111;
const int D2 = B00001011;
const int D3 = B00001101;
const int D4 = B00001110;
const int num0 = B11111100;
const int num1 = B01100000;
const int num2 = B11011010;
const int num3 = B11110010;
const int num4 = B01100110;
const int num5 = B10110110;
const int num6 = B10111110;
const int num7 = B11100000;
const int num8 = B11111110;
const int num9 = B11110110;

int D_4[4] = {D1, D2, D3, D4};
int D_3[4] = {Db, D2, D3, D4};
int D_2[4] = {Db, Db, D3, D4};
int D_1[4] = {Db, Db, Db, D4};
const int num[10] = {num0, num1, num2, num3, num4, num5, num6, num7, num8, num9};

const int tallen[4] = {1000, 100, 10, 1};

int getal = 185;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  int lengte = findn(getal);
  switch (lengte) {
    case 1:
      displaynum(D_1);
      break;
    case 2:
      displaynum(D_2);
      break;
    case 3:
      displaynum(D_3);
      break;
    case 4:
      displaynum(D_4);
      break;
  }
}

int findn(int num) {
  int n = 0;
  while (num) {
    num /= 10;
    n++;
  }
  return n;
}

void displaynum(int *D_x) {
  for (int i = 0; i <= 3; i++) {

    digitalWrite(clockPin, LOW);
    digitalWrite(latchPin, LOW);

    shiftOut(dataPin, clockPin, LSBFIRST, D_x[i]);
    shiftOut(dataPin, clockPin, LSBFIRST, num[(getal / tallen[i]) % 10]);
    digitalWrite(latchPin, HIGH);
    delay(1);
  }
}


texts:
so a brief introduction about the project which I am working on before I go onto my issue.

I am working on a love-o-meter project (Not similar to the arduino example), whereby 2 people place 1 of their hands on a pad and with their other hand holding each other. Making use of a pulse sensor, I measure the BPM for 10s and then indicate the score on a LED strip.
Apart from indicating the compatibility score, I also plan to use the LED strip (cylon/fire effect) to indicate that the arduino is in the progress of calculating (when it is measuring the BPM for 10s) and also to indicate idling (rainbow cycle effect, when there is no one is using the love-o-meter).

However, here comes my issue: Performing the BPM measurement and displaying the cylon/fire effect function at the same time. I know that I cannot use the delay function and instead use millis(). However, the functions in the NeoPixel library already uses the delay effect and it seems like a tough job to edit the function to it using millis(). Is there another way to do so?


texts: Eclipse Arduino Leonardo Pro Micro ATMega32U4 Programming Issue

texts:
Help Needed as I am little bit lost. I've procured a Pro Micro Board from sparkfun. Great little board and it work like clock work when using the standard Arduino Programming IDE.

Well Copied the code thru to the Eclipse Project, Hit compile and all seems well. But Trying to write the code to the device the following happens.

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

     System wide configuration file is "C:/Users/vente/.arduinocdt/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf"

     Using Port                    : COM5
     Using Programmer              : avr109
     Overriding Baud Rate          : 57600
     AVR Part                      : ATmega32U4
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : butterfly
     Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = "F"; type = @
    Software Version = �.u; Hardware Version = �.
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: exit bootloader

avrdude done.  Thank you.

I've setup the Programming interface a as a Leonardo Board. AVR ISP.

For some reason It seems as if and it might be me that the usb does not reset? and go into programming mode.

Please Help


texts: esp8266-01 and arduino UNO communicating over i2c

texts:
i am not able to communicate over i2c with my esp-01 as master and UNO as slave. i get special characters sent back to esp, but my esp is sending correctly...
output on my esp-01

output on my UNO is

connections are esp-01 gpio-0 to uno A4 and gpio-2 to uno A5
is it because i am not using a level shifter or any mistake in my code..?

here is my esp master code

#include <Wire.h>
#define I2CAddressESPWifi 6
int x=32;

void setup()
{
  Serial.begin(115200);
  Wire.begin(0,2);//Change to Wire.begin() for non ESP.
}

void loop()
{
  Wire.beginTransmission(I2CAddressESPWifi);
  Wire.write(x);
  Wire.endTransmission();
  x++;
  delay(1);//Required. Not sure why!

  Wire.requestFrom(I2CAddressESPWifi,10);
  Serial.print("Request Return:[");
  while (Wire.available())
  {
    delay(100);
    char c = Wire.read();
    Serial.print(c);
  }
  Serial.println("]");
  delay(500);
}

and here is my Uno slave code

#include <Wire.h>
#define I2CAddressESPWifi 6

void setup()
{
  Serial.begin(115200);
  Wire.begin(I2CAddressESPWifi);
  Wire.onReceive(espWifiReceiveEvent);
  Wire.onRequest(espWifiRequestEvent);
}

void loop()
{
  delay(1);
}

void espWifiReceiveEvent(int count)
{
  Serial.print("Received[");
  while (Wire.available())
  {
    char c = Wire.read();
    Serial.print(c);
  }
  Serial.println("]");
}

void espWifiRequestEvent()
{
  String ts = getTime();
  Serial.print("Sending:[");
  Serial.print(ts.c_str());
  Serial.println("]");
  Wire.write(ts.c_str());
}

String getTime(){
  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;
  String ts = "U:";
  if (hr<10) ts+="0";
  ts += hr;
  ts +=":";
  if ((min%60)<10) ts+="0";
  ts += min % 60;
  ts +=":";
  if ((sec%60)<10) ts+="0";
  ts += sec % 60;
  return(ts);
}


texts: What makes this library work exclusively with Atmega328P boards?

texts:
I've been looking into libraries that read CPPM signals that I can use on my Arduino Pro Micro, and this one looked promising (github.com/jmparatte/CPPM) until I read that it only works on Atmega328P chips. Sure enough, I tried it, and it doesn't function on the Pro Micro as it does on my Arduino Uno. Why is this the case, i.e. what does it have that the Atmega32u4 doesn't?

  Implementation

  This library works only on ATmega328 implementation of Arduino UNO,
  Duemillanove and similar, also Leonardo. It uses the 16bit Timer1. So
  PWM analogWrite() on pin 9 and 10 are unavailable. The library Servo
  is not compatible because it also uses Timer1.

I tried to do some research on my own, to no avail:

Timer1 isn't specific to 328P, 32u4 has it
For all I can tell, there isn't any difference in the interrupt capabilities of the 32u4...
ICR1 and TCNT are, again, features that the 32u4 has
My signal is connected to the OC1A pin that is used as the CPPM source (pin 9, PB5)

I'm new to this kind of thing and really stumped as to what could be the issue here.


texts: how to send FFT array consist of 512 Samples Data From arduino to raspberry pi using i2c and this is the code for FFT any Suggestion plz?

texts:
#include "arduinoFFT.h"
float y, x = 0;
#define t PE_0
#define SAMPLES 1024             //Must be a power of 2
#define SAMPLING_FREQUENCY 1024 //Hz, must be less than 10000 due to ADC
arduinoFFT FFT = arduinoFFT();

unsigned int sampling_period_us;
unsigned long microseconds;

double  vReal[SAMPLES];
double vImag[SAMPLES];

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

  sampling_period_us = round(1000000 * (1.0 / SAMPLING_FREQUENCY));
}

void loop() {

  /*SAMPLING*/
  for (int i = 0; i < SAMPLES; i++)
  {
    microseconds = micros();    //Overflows after around 70 minutes!
    y=(analogRead(t))*(3.3/4095.0)-1.65;
    x=((1000.0*y)/201.0);
    vReal[i] = x;
    vImag[i] = 0;

    while (micros() < (microseconds + sampling_period_us)) {
    }
  }

  /*FFT*/
  FFT.Windowing(vReal, SAMPLES, FFT_WIN_TYP_HANN , FFT_FORWARD);
  FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);
  FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);
  double peak = FFT.MajorPeak(vReal, SAMPLES, SAMPLING_FREQUENCY);

  /*PRINT RESULTS*/
  //Serial.println(peak);     //Print out what frequency is the most dominant.

  for (int i = 0; i < (SAMPLES / 2); i++)
  {
    /*View all these three lines in serial terminal to see which frequencies has which amplitudes*/

    //Serial.println((i * 1.0 * SAMPLING_FREQUENCY) / SAMPLES, 1);
    //Serial.print(" ");
    Serial.println(vReal[i], 1);    //View only this line in serial plotter to visualize the bins
  }

  delay(1000);  //Repeat the process every second OR:
  //while (1);      //Run code once
Serial.println("//");
}


texts: is there a way to read the current pc volume? This is going to be a part of a project that I have in mind that is essentially reading curent pc volume value and giving it an RGB value (green=>30, yellow=<30>60, red=<60) and lighting up an RGB led accordingly.


texts: How to convert 0-5v inverted serial to 0-3.3v non-inverted serial

texts: This weather stations has a 0-5v serial output.  I'm trying to read the serial output with the Adafruit 32u4 feather board and I get nonsense data out of it.  When I hook the Ultimeter up to my serial->usb cable I get the normal data output.  When I hook up the Ultimeter to a 5v arduino via SoftwareSerial in inverted mode I get proper data.  But I need to connect this weather station to a 3.3v Feather board's hardware uart which doesn't seem to be able to operate in inverted mode.  Is there a 5v -> 3.3 level converter that also will invert the serial signal ?


texts: How do I proceed with a fall detection sensor?

texts:
I am working on a human fall detection system using accelerometer and gyroscope which raises alarm in case of a fall. In all the papers I have read people have used net acceleration magnitude and compared it with a threshold and coupled it with change in orientation to detect fall. My question is would it be better to use acceleration in z-axis(normal to earth's surface) and compare it to threshold as compared to net acceleration as it might reduce false positives as net acceleration can exceed threshold in case of running but that won't happen if i take only acceleration in z-axis. Is my approach right?

How can I implement sensor fusion using a gyroscope and a magnetometer to find the orientation?


texts: How to increase the volume in speaker using talkie library in arduino uno...?


texts: I have Arduino Uno with ultrasonic sensor which I want to hook up on two Raspberrys so they can both receive signal from Arduino at the same time and begin with their part of job. How can i make that kind of wiring?


texts: ESP32 - `Brownout detector was triggered ` upon Wifi begin

texts:
I'm Using an ESP32 - NodeMCU. One of the MCU's is acting weird upon boot, while at start I thought it was something to do with its sleep cycle. But, it seems that even on a minimal code as shown below, I get this message at the Serial output: Brownout detector was triggered
void setup()
{
  Serial.begin(9600);
  Serial.println("\nBegin");
  Serial.println(bootCounter);

  WiFi.begin("Xiaomi", "guy");

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

Edit 1: attaching MCU picture.
Can someone please explain ?
Edit 2: A workaround
stop alerting


texts: Can I connect TFT LCD screen to Arduino Leonardo same way as it's recommanded for Arduino Uno?

texts:
I want to connect the Arduino TFT LCD 1.77" screen to an Arduino Leonardo. Acording to this tutorial I should connect some pins on LCD screen to ICSP pins on Leonardo but I don't have equipment to do it. Can I just connect LCD screen to Leonardo in the way it't recommanded for an Arduino Uno (same tutorial above) using only digital and power pins. And then use sketches for Uno. Will it work?

Also, is it safe for LCD screen?


texts:
I apologise in advance if this question is not right for this Stack or if it has been answered before but here goes. I have been learning C/C++ using the Arduino Uno and have gotten the hang of it now (I have knowledge of other programming languages so it wasn't too difficult to get in the rhythm). I was wondering how I would go about creating a standalone solution if I wanted to display information on four or five displays similar to These. I would pull data from a network to display on them too so I would also need to accommodate an ethernet or WiFi shield.
I appreciate any help or pointers in the right direction that can get me started on my journey to creating some custom embedded systems (if that is indeed what I am describing).


texts: HTTPS GET request working on esp32 but not on esp8266

texts:
I'm trying to port my esp32 program to esp8266, and i've come across a problem where i can't get a response from a HTTPS GET request on esp8266, but on my esp32 the same code works fine.
The function i'm using looks like this:
void GetHTTP()
{
  if (WiFi.status() == WL_CONNECTED)
  {
    HTTPClient http;
    http.begin(requestURL);
    int httpCode = http.GET();
    if (httpCode > 0)
    {
      requestData = http.getString();
      GenerateTable();
      //GetDelimiterCount(requestData, delimiterStart);
    }
    http.end();
  }
}

I've also tried running my request with the esp8266 "BasicHttpsClient" and "BasicHttpClient", and in both cases the program returns the error: "connection failed" from https.errorToString(httpCode).s_str()
or http code "-1" without any API specific error codes.
I'm requesting from Trafiklab's realtime infromation v4 API And
the request looks somewhat like this:

https://api.sl.se/api2/realtimedeparturesV4.json?

I've omitted the API key and parameters i use from this URL. The response is also correct when requested by any browser.
Could this be something to do with SSL? I'm completely out of clues as to what the differences between esp32's and esp8266's http-client libraries might be. I'm also using the latest version of the ESP8266 Boards libraries (2.7.4).


texts:
What is the difference between Serial.write and Serial.print? And when are they used?
Both have been used to print on serial monitor, what are their actual differences?


texts: void loop() stops running after an hour or so

texts:
So I have a program that measures temperature and humidity over time. Here isthe code I use:

#include <SD.h>
#include <SPI.h>
#include <DHT.h>
#include <Wire.h>
#include "RTClib.h"

#define DHTPIN 2
#define DHTTYPE 22
const int chipSelect = 10;

DHT dht(DHTPIN, DHTTYPE);
RTC_DS3231 rtc;

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

  if(! rtc.begin()) {
    Serial.println("Could not find RTC");
    while(1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop() {

  //temperature measurements
  float hum = dht.readHumidity();
  float temp = dht.readTemperature();

  if( isnan(temp) || isnan(hum )) {
    Serial.println("Failed to read from DHT22 sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temp);
  Serial.println(" *C");

  //determining the date
  DateTime now = rtc.now();

  int dayy;
  int monthh;
  int yearr;

  int hours;
  int minutes;
  int seconds;

  String date;
  dayy = now.day();
  monthh = now.month();
  yearr = now.year();
  date = String(dayy) + String(monthh) + String(yearr);

  int seconds_passed; // how many seconds have passed since the start of the day: used for the data plot
  hours = now.hour();
  minutes = now.minute();
  seconds = now.second();
  seconds_passed = ((hours * 60) + minutes)* 60 + seconds;

  //writing to SD card

  if(SD.begin(chipSelect)) {
    Serial.println("Card is initialized! Ready to go!");
  }
  else {
    Serial.println("Error with initializing the card!");
    return;
  }
  Serial.println("Opening file...");
  String FileName;
  FileName = date + ".dat";

  File dataFile = SD.open(FileName, FILE_WRITE);

  if (dataFile) {
    dataFile.print(temp);
    dataFile.print(",");
    dataFile.print(hum);
    dataFile.print(",");
    dataFile.println(seconds_passed);
    dataFile.close();

    Serial.println("Written data to file and closed it");
    Serial.println(" ");
    Serial.print("Seconds passed: ");
    Serial.println(seconds_passed);
    Serial.println(" ");
  }
  else {
    Serial.println("Error with opening the file, trying again");
  }

 delay(1000);
}

It works like a charm, but for the fact that it stops running after an hour, maybe 1,5 hours.

Resetting the board seems to work, but I can't obviously sit there the whole time and reset the board. I use an Arduino Due. Did I program something wrong that something overflows or should I add some more code?


texts: Why I get error on string concatination?

texts:
exit status 1
invalid operands of types 'const char [5]' and 'const char [2]' to binary 'operator+'

  String message = "Page not found\n\n";
  message += "URI: " + HTTP.uri() + "\n";
  message += "Method: " + (HTTP.method() == HTTP_GET)? "GET": "POST" + "\n";
  message += "Arguments: " + HTTP.args() + "\n";


texts:
I'm fairly new to this and I'm having trouble with a code for a dust sensor. Getting a couple of errors. I downloaded this code from GitHub.
Anyone have any idea how to fix any of these errors? Any help is appreciated.
Sorry if this formatted wrong, this is also my first post. Thanks for your time

// SDS011 dust sensor example
// -----------------------------
//
// By R. Zschiegner (rz@madavi.de).
// April 2016

#include "SDS011.h"
#include<SoftwareSerial.h>
SoftwareSerial myserial(0, 1);
SDS011(byte pin_rx, byte pin_tx)
float p10,p25;
int error;

SDS011 my_sds;

void setup() {
  my_sds.begin(0, 1);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
}

void loop() {
  error = my_sds.read(&p25,&p10);
  if (! error) {
    Serial.println("P2.5: "+String(p25));
    Serial.println("P10:  "+String(p10));
  }
delay(100);
}

here are the errors I'm getting

code:10: error: expected ')' before 'pin_rx'

 SDS011(byte pin_rx, byte pin_tx)

             ^

C:\Users\Nick\Desktop\code\code.ino: In function 'void loop()':

code:26: error: 'p25' was not declared in this scope

   error = my_sds.read(&p25,&p10);

                        ^

code:26: error: 'p10' was not declared in this scope

   error = my_sds.read(&p25,&p10);

                             ^

exit status 1
expected ')' before 'pin_rx'


texts:
I'm trying to connect Arduino Leonardo to an Android tablet. I would like to make the Arduino send commands (using pushbuttons or a slider for example) to the tablet to switch between pages, to select a file on the desktop, to scroll up and down the screen, etc.

Thanks. I will really appreciate your help.


texts:
I am using Arduino UNO and trying to interface 2 16-bit ADS8319 ADCs with it via the SPI interface.

I have interfaced the 2 ADCs with the micro-controller using the "4 Wire CS Mode Without Busy Indicator" (data sheet page number 15).

I am using the following code to get the values from the ADCs.

#include <SPI.h>
#define CONVPIN 7
#define SELPIN 8
#define SELPIN2 4
#define MISOPIN 12
#define SCLKPIN 13

int adcvalue;
byte byte1; byte byte2;
const float aRefVoltage = 5;
float volts = 0;

void setup() {

  // put your setup code here, to run once:
  pinMode(SELPIN, OUTPUT); // ADC's selection pin
  pinMode(SELPIN2, OUTPUT); // 2nd ADC's selection pin
  pinMode(CONVPIN, OUTPUT); // ADC's conversion pin
  pinMode(SCLKPIN, OUTPUT); // ADC's clock pin
  pinMode(MISOPIN, INPUT);  // ADC's data out
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(CONVPIN, LOW);
  digitalWrite(SELPIN, HIGH);
  digitalWrite(SELPIN2, HIGH);
  digitalWrite(CONVPIN, HIGH);
  digitalWrite(SELPIN, LOW);

  delay(1000);

  byte1 = SPI.transfer(0x00); //transfer (read) 8 bits from the adc chip D15-8
  byte2 = SPI.transfer(0x00);  //transfer (read) the second 8 bits. D7-0

  adcvalue = (byte1 <<8) | (byte2 & 0xff);  // combine the 2 bytes to make our 16 bit word
  Serial.print("Voltage Value: ");
  Serial.println(adcvalue,BIN);
  volts = (adcvalue*aRefVoltage/65535);
  Serial.print(" Sensor Volts: ");
  Serial.println(volts,5);
  delay(1000);
}

However i am not getting the right values. The ADC that ive selected by "digitalWrite(SELPIN, LOW);" should output 1V, whereas the values keep on changing in between 0 and 2.2 V .I am not sure if my code is correct or not. Can you please verify the code so that i should know whether the problem is in my hardware, or the code.

Below is the screenshot for my schematic :

Your helpful suggestions and comments would be appreciated !
Thankyou.


texts:
The day before I got my used full package arduino uno. I tested it on USB plug. Everything worked fine. I wrote a piece of testing code and uploaded. After I have accomplished with the test I have unpluged arduino from PC and connected to battery and I see that it does not work. I have used a multi-tester to find out the voltage. It showed 4.7V. Now I wonder should I buy a new battery or there is another reason for this. Anybody, please suggest me what to do.
Update
The battery came with arduino set. It is written that it is a 9V battery. I am plugging it to the battery input in my arduino uno. Polarity is ok. The same program working on connection via usb, does not when connected to battery.


texts: Understanding ArduinoJson capacity calculation assistant

texts:
I am trying to figure out how ArduinoJson capacity can be calculated, therefore I came by the Assistant web application developed by the developer of the library https://arduinojson.org/v6/assistant/
Here what I do not understand is, why when I use either of the following two JSON strings, the helper shows me the same capacity? I would expect that the longer JSON values will result in a bigger capacity, but this does not seem to be the case.
{
  "wifi": {
    "ssid": "S",
    "password": "P",
    "hostname": "H"
  },
  "administration": {
    "username": "U",
    "password": "P"
  }
}

{
  "wifi": {
    "ssid": "SSSSSSSSSSSSSSSSSSSSSSSSSSS",
    "password": "PPPPPPPPPPPPPPPPPPPPPPPPPP",
    "hostname": "HHHHHHHHHHHHHHHHHHHHHHHHHHHH"
  },
  "administration": {
    "username": "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUU",
    "password": "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"
  }
}

I am trying to calculate the capacity using the assistant using the following configuration:
ESP8266 / Deserialize / char*
Could you anyone explain this to me? Apparently I understand the "reason" behind the capacity wrong?


texts:
I want to launch a communication between two Arduinos, in which case the first Arduino (S) sends data to the second one (R). The type of the data is mixed, consisting of integers, longs, floats and maybe some text. For example:

{125, 1250, 12500, 125000, 1.25, 12.5, 125.0, "some text"}

I thought about converting each one value to string, adding up all strings to a big one, and send the final string with  Serial.print(Big_string).  In that case I reckon that it would be difficult for the Receiver to extract the string to the exact substrings and convert them to real values.
A second thought was to convert all values to bytes and create a byte (or char) array, but each value would be limited to 0-255 (let alone floats and text)
A third thought was to convert them to word type (let alone the text), but I think that Serial.print( ) sends only bytes, not words.

In any case, which is the best way to send mixed data over serial?

Any thoughts would be appreciated.


texts: 2 Arduino Unos Connected with 1-Wire and Receiver Pin getting Stuck High

texts:
I am trying to accomplish 1-wire communication between 2 Arduinos and so I wanted to start off by having 1 Arduino toggle a digital output pin and have the other read the state of that pin. To accomplish this, I have 2 computers with Arduino IDE installed and each one is connected to one Arduino Uno. Both Arduino Uno's are connected with a single male-male jumper cable on Pin 13 of the header. I am watching the state of the pin by looking at the prints in the Serial Console on both computers.

Here is a diagram of my setup:

Computer1 ---> Arduino1[Sender] --------> Arduino2[Receiver] -----> Computer2

The problem I have is that I am seeing when I first start both Arduinos - the sender is definitely toggling the output pin high->low->high forever - but the receiver Arduino only shows its input pin as toggling for a few seconds and then it gets stuck high. Sometime later, it may go low for 1 iteration, but then sticks at high again. What is going on? I would expect to see the sender and receiver show high->low->high forever. The code seems simple but I must be doing something wrong - thanks for your help.

Sender Code:

int led = 13; // Comm Pin

// Setup pins
void setup() {

  // put your setup code here, to run once:
  Serial.begin(9600);

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);

}

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.println("high");
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  Serial.println("low");
  delay(1000);               // wait for a second
}

Receiver Code:

int led = 13; // Comm Pin

// Setup pins
void setup() {

  // put your setup code here, to run once:
  Serial.begin(9600);

  // Pin is an input - normal state high
  pinMode(led, INPUT);

}
void loop() {

  // Put your main code here, to run repeatedly:
  Serial.println(digitalRead(led));
  delay(1000);

}


texts:
I am new to Arduino.
I have been trying to connect a 7 segment display (3 digits) to my Arduino and I was successful, but I am not doing any connection to ground. I do not find the data sheet so I am not sure if this connection is well done.
My doubt is: Is the connection to ground necessary? Or how do Arduino pins work? I am using 12 pins of the Uno to do the set up.

Thanks

My set up is the following:


texts:
I'm looking to purchase an Arduino for a little robot I'm going to make.  The reason I've chosen Arduino is because it's much easier to use with servos and LEDs than a Raspberry Pi, but a nice little touch would be to have it play some sounds (voice recordings and mechanical SFX).  I was just wondering (now I'm not after opinions here, but looking more at how each of the boards have been designed) what the best Arduino board for playing sound is, or if they are all pretty much the same in this regard.

(Note 'pins' was the best tag I could find for this post for lack of a 'sound' or 'speakers' one.  If you want to edit it to something more appropriate please do)


texts:
So I'm quite new to the whole Arduino coding but constructed a sketch that does work, but I think it doesn't work properly. So I'd love to get some advice on how to improve it.
This script is currently running on a Wemos ESP8266 chip attached to a 1 meter WS2812 144 LED strip.
My questions:

The loop is set to break when fadein is higher then 254.
When I try to break it at fadein == 255 the loop doesn't work anymore as it the fadein value directly jumps to 255. Why?

When I set the delay to zero the led flicker due to too fast updating. however, this flickering continues even after the for loop is broken, which makes me conclude that the for loop is still running even when the break is applied.
Of course this is no longer an issue when the delay is set higher (as it is supposed to be) but it still seems a waste of processing power to keep the for loop active while it's not doing anything new anymore
how can i completely stop the loop from being executed?

How can this be done differently / more effective?

The code
#define FASTLED_ALLOW_INTERRUPTS 0                                    //fix jitter in led strip
#include <FastLED.h>                                                  //add fastled lib
#define NUM_LEDS 144                                                  //set number of leds
#define DATA_PIN D4                                                   //set data pin leds

CRGB ledStrip[NUM_LEDS];                                              //init led strip
int fadeIn = 8;                                                       //init fade in counter
int led = 0;                                                          //init led counter

void setup() {
  Serial.begin(115200);                                               //setup comm channel
  FastLED.addLeds<WS2811,DATA_PIN, RGB>(ledStrip, NUM_LEDS);          //setup ledstrip config
}

void loop()
{
for (int led = 0; led < NUM_LEDS; led++) {                            //move led up the strip till max count is reached
    ledStrip[led] = CHSV( 0+led*1.77, 255, 225);                      //set animated led hue value to make a rainbow
    FastLED.show();                                                   //show led color
    ledStrip[led] = CHSV( 0+led*1.77, 255, fadeIn);                   //set non animated led hue to same hue value while increasing the fade value
    delay(3);
    if (fadeIn > 254) {                                               //if the fadeIn value exceed 254
      break;                                                          //stop led animation
    }
}

    if (led = 144 && fadeIn < 254) {                                   //when the 144th led is reached and the fadein value is less then 255
      fadeIn+=16;                                                      //increase fadeIn value with 16
    }
    if (led = 144 && fadeIn < 255) {                                   //when the 144th led is reached and fadeIn is smaller then 255 show debug messages
      Serial.println(led);                                             //print led counter value
      Serial.println(fadeIn);                                          //print fadein value
    }
    if (fadeIn > 255) {                                                 //if the fadeIn value exceed 255
      fadeIn = 255;                                                     //clamp fadeIn value to 255

    }

}


texts: Components required to control the Speed of Wilo Para AC Synchronous Motor

texts:
I want to control the speed of the AC motor based on the temperature set on the Nextion  HMI. Right now I have my ESP32 Microcontroller and Solid-state relays which supply the maximum output power of 10 amperes. My Wilo Motor requires the power of 0.03 to 0.66Amps. I am in a state of confusion about what component is required in the middle to connect my ESP32 Controller to send the analog PWM control signals of 0 to 10V to my Wilo Para Motor for the speed control. I searched in Google and I got few data like H-Bridge, PWM Speed control manual module. I'm stuck in this work and I'm looking for help.

Below I have attached the link of the datasheet. On page number 34 is my WILO Para Motor and the model name is Wilo Para 25-180/9-87/IPWM1 in the table

https://wilo.cdn.mediamid.com/cdndoc/wilo164576/1544113/wilo164576.pdf

Thanks in Advance.


texts:
When running the board at room temperature (20 C) without any extra cooling mechanisms added, how much can the Arduino Uno be overclocked?

Also, what would I need to change/update to overclock the board?


texts: ATtiny85 MIDI IN using SoftwareSerial - Is it possible?

texts:
I'm trying to read MIDI notes using an ATtiny85 via SoftwareSerial; so far, I've got no success at all.

The ATtiny is using the internal clock, 8Mhz, 5V.
The MIDI keyboard sends clean note on/off messages (tested with a MIDI monitor).
I've tried several test programs, particularly Nick Gammon's, as described here.
I've followed Nick's schematics to build the connector, and I can confirm his program works with an Arduino, but not with the ATtiny.
I calibrated the Tiny with OSCCAL - still no luck.
As far as I can tell, midiSerial.available() is always 0, in every program I've tried.
SoftwareSerial works fine for the purpose of MIDI out.

That's as far as I've got. I'd appreciate any pointers, especially if anyone else could try Nick's code and see if it works.

EDIT

There was an issue with my local version of SoftwareSerial. I had commented out code so that I could use pin change interrupts in my MIDI out program, but those interrupts are essential for MIDI input. Once I uncommented the code, all the programs I tested worked, so it is indeed possible to receive MIDI using an ATtiny.

That said, I've tried four keyboards as inputs and only one has worked so far, a Korg 01/W proX. The same happens when I load the MIDI code directly in the Arduino, so based on the answers below I will try a different optocoupler, and post my results here for the sake of improving on the answer.

Here's the schematics I was talking about:


texts: Writing to serial LCD seems to interfere with servos

texts:
I have an OBD-based Arduino project (OBD adapter link below) which uses two servos and a serial LCD from Sparkfun (link below). My problem: writing to the LCD seems to interfere with the servos. Details:

1) When all LCD-related code is excluded, the servos work smoothly.
2) When LCD-related code is included, but the servos are not hooked up, the LCD displays everything OK.
3) When the LCD-related code is included, even if the LCD itself is NOT hooked up, the problem occurs. There's a brief noise from the servos every time I write to the LCD (the servos don't move much, they just make a brief noise).

Any idea what's causing this? Below are the relevant parts of the code (OBD, servo, LCD):

#include <Arduino.h>
#include <Wire.h>
#include <OBD.h>
#include "MPU6050.h"
#include <SoftwareSerial.h>
#include <Servo.h>

int servoPin1=13;
int servoPin2=12;

Servo servo1;
Servo servo2;

COBDI2C obd;
SoftwareSerial lcd(2,3);

void clearDisplay() {
  lcd.write(0xFE);
  lcd.write(0x01);
}

void setLCDCursor(byte cursor_position) {
  lcd.write(0xFE);
  lcd.write(0x80);
  lcd.write(cursor_position);
}

void Show() {
  setLCDCursor(0);
  lcd.print("Test");
}

void setup() {
  lcd.begin(9600);
  clearDisplay();
  setLCDCursor(0);
  lcd.print("OBD");

  pinMode(servoPin1,OUTPUT);
  pinMode(servoPin2,OUTPUT);
  servo1.attach(servoPin1);
  servo2.attach(servoPin2);
  servo1.write(0);
  delay(200);
  servo2.write(100);
  delay(200);

  obd.begin();
  conn=obd.init(PROTO_AUTO);
  lcd.print("Connected");

  Wire.begin();
}

void loop() {
  conn=obd.readPID(PID_RPM,rpm);
  if (condition) {
     servo2.write(50);
    delay(500);
    servo1.write(100);
    delay(500);
  }
  Show();
  delay(1000);
}

OBD adapter
Serial LCD


texts: how does serial port communication work under the hood?

texts:
im just looking for how to send/ write date to pc over serial port from arduino..vice versa.

I have few Question to ask after taking so much time and couldn't figure it out myself. I hope you guys can guid me please.

First, i found i can use Serial.println() function to send some data then, on the pc side, it just checks and reads the port (/dev/tty..). But, how does this process actually work under the hood? So, if you use serial.println() it knows about where to write?

Second i also found it's something to do with UART communication.. But, inside Hardware.cpp file, i couldn't find any function call to the one for UART.

Third there is the code like extern HardwareSerial Serial; Then where is the definition of this Serial?

Fourth There seem to have ring buffer for serial buffer. So, when data is being sent then, what and who fill the data into this buffer inside Hardware.cpp?

please, forgive my silly question.. i'm just so curious about this..


texts:
I have an RGB LED, connected to my UNO R3 and would like to turn on the written color in the serial by following a table (1 for red, 2 for blue, 3 for green...) and I also want to make that if this LED is already turnt ON, I want it to turn OFF. The problem I have is that when I use Serial.read() it always returns a -1 value. Why is that?
I leave you the code here and in case you see something wrong please tell me. Thank you very much.

#define RED 7
#define GREEN 4
#define BLUE 2
  String ledcolour[] = {"RED", "BLUE", "GREEN", "YELLOW", "PURPLE", "WHITE"}; //array to match the number typed to the LED colour
  char ledstatus[] = {0, 0, 0, 0, 0, 0}; //0 if the LED is OFF and 1 if it's ON
  String ledvaluefix[] = {"HIGH", "LOW"}; //if the ledstatus[] value is 0 it will write HIGH and if it's already ON it will write LOW
  char ledstatusfix[] = {1,0}; //to update in ledstatus[] if the LED is ON or OFF
  int led = Serial.read();
void setup() {
  pinMode(RED,OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE,OUTPUT);
  Serial.begin(9600);
  Serial.println("Type the LED's colour you want to turn on following this table:");
  Serial.println("RED=1");
  Serial.println("BLUE=2");
  Serial.println("GREEN=3");
  Serial.println("YELLOW=4");
  Serial.println("PURPLE=5");
  Serial.println("WHITE=6");
}

void loop() {
  if (Serial.available()){
    Serial.println(led);
    loop();
   if (led <= 6 && led >=1){ //Checks if value is within 0-6
    if (led <=3){ //Classifies in primary or mixed colours (understand primary as just having to turn ON one single LED)
      if (ledstatus[led-1] == 0){//checks if the LED was OFF
        digitalWrite(led-1,HIGH);//turns the typed LED to HIGH
        char ledstatus[led-1] = {1};//updates the array to set the LED is now ON
        confirmer();//sends a serial confirmation message
      }else{//if it was already ON
        digitalWrite(led-1,LOW);//turns the typed LED to LOW
        char ledstatus[led-1] = {0};//updates the array to set the LED is now OFF
      }
    }else{//if it's not a primary colour
      Serial.println("YOU CHOSE " + ledcolour[led-1] + ", WHICH IS A MIXED COLOUR");
    }
    }else{//if the value is not valid (not between 0 and 6)
      Serial.println("SORRY, THE INTRODUCED VALUE IS NOT VALID");
      Serial.println("PLEASE, TRY AGAIN");
    }
  }
}
 int confirmer(){
    Serial.println("YOU CHOSE THE " + ledcolour[led-1] + " LED");//sends the serial message confirming it's been turned ON
   }


texts:
I am trying to write a simple coding to change the color of an RGB LED using a push button trigger.  I just need the the pin output to change when the button is pressed.  I would like to do this using just an ATTiny85 and uploading the code to it using an Arduino Nano.  I don't have much coding experience so I was hoping someone would take a quick look at my attempt and tell me if it will work.

// here are the pin number assignments

int blue = 2;

int green = 1;

int red = 0;

int button = 4; // the pin the button is on.

int choice = 0; // mode selection

void setup() {

  // initialize the pwm pins as outputs.

  pinMode(red, OUTPUT);

  pinMode(green, OUTPUT);

  pinMode(blue, OUTPUT);

  pinMode(button, INPUT);

  analogWrite(red, 255);

  analogWrite(green, 255);

  analogWrite(blue, 255);

}

void loop() {

  // read the pushbutton to see if it's been pushed
  int val;
  val = digitalRead(button);

  // val = HIGH means the button has been pushed
  // and the mode is to be changed.

// SELECT CHOICE //////////////////////////////////////////////////

  if (val == HIGH) {
    choice = choice + 1;

    analogWrite(blue, 255);
    analogWrite(green, 255);
    analogWrite(red, 255);
    delay(500);

    // indicate mode transition with blue flashes
    for (int i = 0; i < 5; i++) {
      analogWrite(blue, 125);
      delay(20);
      analogWrite(blue, 255);
      delay(40);
    }

    delay(500);

    // change this if you want more modes

    if (choice == 5) {
      choice = 0;
    }
  }

  while (val == HIGH) {
    delay(100);
    val = digitalRead(button);
  }

  //////////////////////////////

  // OFF

  if (choice == 0) {
    analogWrite(red, 0);
    analogWrite(green, 0);
    analogWrite(blue, 0);

  }

  // RED

  if (choice == 1) {
    analogWrite(red, 255);
    analogWrite(green, 0);
    analogWrite(blue, 0);

  }

  // GREEN
  if (choice == 2) {
    analogWrite(red, 0);
    analogWrite(green, 255);
    analogWrite(blue, 0);
  }

  // BLUE

  if (choice == 3) {
    analogWrite(red, 0);
    analogWrite(green, 0);
    analogWrite(blue, 255);
  }

  // AMBER
  if (choice == 4) {
    analogWrite(red, 255);
    analogWrite(green, 255);
    analogWrite(blue, 0);
  }

}

Any input?


texts: Send data from arduino to server using GSM, TCP

texts:
My actual connection is like:
Arduino -> GPRS(http)-> my server(php script)-> firebase <-android plotting app

But it only allows to send some data once every 2 - 3 seconds (depending of ping to my server).

I need to send some data (18 bytes) but every 0.5 - 1 seconds

It is possible to send directly over tcp to firebase?
And also i thinked about this schema:

Arduino(client) -> GPRS(tcp) -> my server(tcp socket) -> my database <- android plotter
but I don't know how to go about it, what server software i need to redirect recieved tcp packages to mysql.


texts: How much voltage and current can a Arduino uno digital input sink?

texts: I am having a digital output of 24VDC and 0.5A from ABB IRC5 controller. I need to feed this digital output to the digital input of Arduino uno. How can I do that?


texts:
I am doing this simple introductory exercise to light an RGB Led, but I am confused about the code in the exercise. The following is the code:
/* Adafruit Arduino - Lesson 3. RGB LED
*/

int redPin = 11;
int greenPin = 10;
int bluePin = 9;

 //uncomment this line if using a Common Anode LED //#define
 COMMON_ANODE

void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);   }

void loop() {
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255); // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000);
  setColor(80, 0, 80);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000); }

void setColor(int red, int green, int blue) {
#ifdef COMMON_ANODE
     red = 255 - red;
     green = 255 - green;
     blue = 255 - blue;
#endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);   }

In this code, why were they able to carry out setColor before expanding upon what it means later through void setColor(int red, int green, int blue)? Should that portion of the code come earlier or does it matter? Also I don't quite understand how the definition of the colors red, green, and blue were defined towards the bottom. I know what 255 would indicate maximum brightness, but why do you have to subtract the color from 255? Any help would be much appreciated.


texts:
I want to drive a servo via a HCO6 and HC05 link as a stand alone, using no android or PC.
The question is how to send a 1.5 ms signal (generated with a pulse command on a Nano) from one HC to another HC (to which my servo will be connected) ?
I do not need to care about passwords in my linking. No text to be sent, just the 1ms to 2 ms signal, at a refresh rate of 50 Hz.
I will use the HC with a OOK modulation (on - off on the data pin)?
How to achieve this ?
Thanks !


texts:
I am very new to the Arduino world but have come up against a problem. I wish to use two Nano clones to TX & Rx a 433Mhx setup. I have copied over a simple sketch (1 for Tx, 1 for Rx) to do this which I can load on to the Nano's but it won't function. If I load the same sketch to a pair of Uno clones it works exactly as designed. I am at a bit of a loss as to why it loads Ok but won't run on the Nano clones. The IDE recognises the ports OK, compiles the sketch and sends it successfully to the Nano's, lights flash to confirm successful loading.
Any thoughts please? Thank you......


texts: Problem with interrupts and 4x encoders on Nano 33 BLE

texts:
I have a Pololu 4x encoder and am trying to write some code to make it work on my Nano 33 BLE. (Interestingly enough, the issue preventing some pre-existing libraries from working for me is the same issue that I'm about to describe here...)

When I turn the motor shaft clockwise, these are the signals that I get (first bit in each pair is channel A, second bit channel B):

11 -> 10 -> 11 -> 10 -> 11 -> 10

Note how channel A's value never changes, and B's value toggles back and forth.

Likewise, for the counterclockwise direction:

01 -> 11 -> 01 -> 11 -> 01 -> 11

This is of course wrong, as the channels' values should be something like 00 -> 10 -> 11 -> 01 -> 00 as the shaft turns. As a matter of fact, that is exactly what I get when I run the exact same code on a regular Arduino Nano.

Does anyone know what's going on? Here's my code. AFAIK I'm not using interrupts incorrectly or anything, at least for the regular Nano.

#define PIN_A 2
#define PIN_B 3

volatile int val = 0;
volatile bool newVal = true;

void encoder() {
  int a = digitalRead(PIN_A);
  int b = digitalRead(PIN_B);
  val = ((a << 1) | b);
  newVal = true;
}

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

  pinMode(PIN_A, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PIN_A), encoder, CHANGE);

  pinMode(PIN_B, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PIN_B), encoder, CHANGE);
}

void loop() {
  if (newVal) {
    Serial.print(bool(val & 0b10));
    Serial.print(bool(val & 0b01));
    Serial.println();
    newVal = false;
  }
}

EDIT: After taking a look at the following diagram, it appears that the erroneous encoder patterns match those in which only rising edges are detected. So for some reason, attachInterrupt() is acting as if the CHANGE argument were RISING instead for the Nano BLE.