texts: ESP8266-01E is not responding after successful flash

texts:
I have flashed an ESP8266 with the ESP8266 flash downloader that said my flashing had succeeded.
But when I sent an AT command from the serial monitor it didn't respond and the TX/RX LED from the ESP8266 didn't respond either. I checked all baudrates from 300-200000, but nothing.
I was using CH340 USB to TTL for flashing wired like this:
USB -> ESP8266
3,3v ->CH_PD and VCC
GND -> GND and GPI0 (only when flashing)
TX -> RX
RX -> TX

I was flashing to downgrade the firmware; the default firmware from shop was SDK 1.5.4, AT VERSION 1.1.0.0.

I have been frustrated with this, because this is my second module.


texts: Arduino library creation - Calling library and Merging

texts:
I am new to creating a library in Arduino. I was able to create a library from YouTube. I want to merge two other libraries into the library I created. Can you please help me to do so?

I already created a keywords.txt file for my library but the keywords are not getting highlighted in orange in the IDE. But it identifies as keywords.

Please guide me how to properly create a keywords file and merge the libraries.

Keywords below:

# -----------------------------------------------------------------------------------
# Syntax coloring for IotBlueEmon library
# -----------------------------------------------------------------------------------

# Datatypes (such as objects)
CurrentSense KEYWORD1

#Methods / functions
begin   KEYWORD2
Counter1   KEYWORD2
Counter2   KEYWORD2
counter3   KEYWORD2
getCNT1   KEYWORD2
getCNT2   KEYWORD2
getCNT3   KEYWORD2

# Constants


texts: My Arduino freezes if power removed from the HMI

texts:
I have an Arduino (Pro Mini) connected to an HMI display over serial. When the user pushes a button on the HMI screen, it activates a relay attached to one of the digital pins on the Arduino.

For safety reasons, if the Arduino loses communications with the HMI, I want it to turn off the relay. So, when the button has been pushed, it triggers a polling sequence to verify that the button is still being pushed (I'm not relying on the button release event, again for safety).

The following code works perfectly if I disconnect either of the signal lines (tx or rx) or ground from the HMI. If I disconnect the +5 volts, however, the Arduino freezes completely, and therefore never shuts down the relay.

What could be causing this, and what can I do to overcome the problem?

The code is as follows, however, it works as expected if the data lines or ground are severed.

int getNumber(const char *reqString)
{
  sendString(reqString);

  long startTime = currentMillis;
  long waitTimer = currentMillis - startTime;

  bool responded = false;
  int endcount = 0;
  byte inbyte;
  byte bytebuffer[80];
  int bytecount = 0;

  while (waitTimer < 100 && !responded)
  {

      if (HMI.available())
      {
        inbyte = HMI.read();

        if (inbyte == 0xFF)
        {
          endcount++;
          if (endcount == 3)
          {
            responded = true;
            endcount = 0;
          }
        }
        else
        {
          endcount = 0;
        }

        bytebuffer[bytecount] = inbyte;
        bytecount++;
      }

      // Update the wait Timer.
      waitTimer = millis() - startTime;
  }

  // If we received a response, return the first data byte. If not, return 0
  if (responded)
   {
     Serial.println("Received response");
     return bytebuffer[1];
   }
   else
   {
 Serial.println("No response");
     return 0;
   }
}


texts:
I am trying to detect whether a signal is high or low from an ESU LokSound 5 decoder for HO locomotives. My idea was to use one of the auxiliary pins used to drive an LED (AUX 3 in my case).

The problem is that these decoders are common positive rather than common negative, which means I can't directly connect AUX 3 to a digital pin on the Arduino and expect it to work flawlessly since it outputs a negative voltage rather than positive.
I'm trying my best to not use an op amp, as the locomotive I'm making this accessory for is already cramped. It sort of works if I directly connect it, but it is not smooth at all. I've tried using the built-in pull-up resistor, I've tried using an external pull-down resistor, I've tried using a resistor in line and I can't seem to figure out how to solve this without resorting to using an op-amp.


texts: Programming Arduino Uno R3 to trigger a relay once every 24 hours

texts:
I programmed Arduino UNO R3 to trigger a relay once every 24 hours from the moment it is powered on
I calculated milliseconds and used the function delay()
24 hours * 60 minutes each hour * 60 second every minute * 1000 milliseconds every second
so i used :
delay(86400000)

86 million and 400 thousands milliseconds
and currently i'm still testing it...
Will this work?
If not Is there a better built-in function/library or even external library to do it?
the relay trigger doesn't have to be very accurate at the very exact time each day
I don't need it to be very accurate, It can shift few minutes every few months or so, thats okay with me
But how about after few months or years of use ?
Will it shift the timing much ?
I read somewhere about using millis() function
and others use RTC (Real Time Clock) module
I don't want to use RTC module
Looking for a programmatical solution...
OR if my previous method using the delay() will work for such a very high number of millisecond ?
Thank you


texts: How to connect an L293D and an MPU6050 to run together?

texts:
I'm wondering how to connect the L293D (H-bridge) and an MPU 6050.

I'm using 1 Arduino Uno, 2 DC motors, 1 MPU6050 and an L293D.

When I tried this, I got some sparks/smoke from the breadboard and none of the motors where running. I only used a 9v battery, not 12v.

Here's the L293D:

MPU 6050 wiring: int-digital 2, SDA-A4, SCL-A5, GND-GND, VDD-Vss

L293D wiring: Vss-VDD, Input4-Digital 5, Output4-Motor, Output3-Motor, Input3-Digital 6, Enable2-5V, Enable1-5V, Input1-Digital 9, Output1-motor, Output2-motor, Input2-Digital 10, Vs-12V battery.


texts: Error passing a `time_t` and `struct tm`, ESP32

texts:
I need to create a converter from epoch time stored in a time_t variable, to a struct tm variable, in order to check / create a certain task every hour or a day. This function should get also a past time_t for other uses.

Converting function, inside a library, works OK ( last two lines are for verification purposes, meaning conversion was done as expected ):

void myIOT32::convEpoch(time_t in_time, struct tm *convTime)
{
  convTime = gmtime(&in_time);
  char time_char[40];
  sprintf(time_char, "%04d-%02d-%02d %02d:%02d:%02d", convTime->tm_year + 1900, convTime->tm_mon+1, convTime->tm_mday,
            convTime->tm_hour, convTime->tm_min, convTime->tm_sec);

  Serial.print(" from funct: ");
  Serial.println(time_char);

Now, when calling it from my code and try to use time tm var, it causes the code to crash. In code below, I just try to print it to console:

void sendnewNotif()
{
  struct tm *newtime;
  time_t t=182423032;
  iot.convEpoch(t, newtime); // <--- Using the conversion
  char timeStamp[50];
  // Serial.print(newtime->tm_year);

}

What may be the problem ?

Guy


texts: Problem : Trigger limit switch to stop DC motor

texts:
I want to make a project about automatic gate and garage door via Android app and connected by HC-05 bluetooth module.
Each of the gate and garage door have two limit switches(located at each end of travel) to trigger the DC motor to stop.

I have made some code and do researches, but the DC motor will only stop when I pressed it, if I release it again it will start automatically. I want to make it stop until the bluetooth module send the code again.
I have input the pull-down resistor into the limit switch.

Can anybody please help me?

Here's my current code, thank you

// Motor for Gate (MotorA)
int IN1 = 2;
int IN2 = 3;
int EnableMotorA = 9;

// Motor for Garage Door (MotorB)
int IN3 = 4;
int IN4 = 5;
int EnableMotorB = 10;

const int LimitSwitch1 = A1;
const int LimitSwitch2 = A2;
const int LimitSwitch3 = A3;
const int LimitSwitch4 = A4;

int state;

void setup(){
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(EnableMotorA,OUTPUT);

  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);
  pinMode(EnableMotorB,OUTPUT);

  pinMode(LimitSwitch1, INPUT);
  pinMode(LimitSwitch2, INPUT);
  pinMode(LimitSwitch3, INPUT);
  pinMode(LimitSwitch4, INPUT);

  digitalWrite(LimitSwitch1, LOW);
  digitalWrite(LimitSwitch2, LOW);
  digitalWrite(LimitSwitch3, LOW);
  digitalWrite(LimitSwitch4, LOW);

  Serial.begin(9600);
}

void loop(){
  if(Serial.available() > 0){
    state = Serial.read();
    }
    if(state == 'A') {
      OpenGate();
      if(digitalRead(LimitSwitch2) == HIGH){
      StopMotorA();
      }
    }
    else if(state == 'B') {
      CloseGate();
      if(digitalRead(LimitSwitch1) == HIGH){
      StopMotorA();
      }
    }
    else if(state == 'C') {
      OpenGarageDoor();
      if(digitalRead(LimitSwitch4) == HIGH){
      StopMotorB();
      }
    }
    else if(state == 'D') {
      CloseGarageDoor();
      if(digitalRead(LimitSwitch3) == HIGH){
      StopMotorB();
      }
    }
}

//******************   Motor A control   *******************
void OpenGate(){
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(EnableMotorA, 250);
  }
void CloseGate(){
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(EnableMotorA, 250);
}
void StopMotorA(){
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  analogWrite(EnableMotorA, 0);
 }
//******************   Motor B control   *******************
void OpenGarageDoor(){
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(EnableMotorB, 250);
}
void CloseGarageDoor(){
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  analogWrite(EnableMotorB, 250);
}
void StopMotorB(){
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  analogWrite(EnableMotorB, 0);
}
//**********************************************************


texts:
I used platformio IDE
I did "platformio lib install 1101"
(http://platformio.org/lib/show/1101/ESP8266wifi),
I installed this: http://platformio.org/lib/show/549/WebSockets (follow instructions)
I did similar things to other libraries.
When I click the platformio:build button, it still complains:

fatal error: ESP8266WiFi.h: No such file or directory fatal error:
ESP8266WiFiMulti.h: No such file or directory fatal error:
ESP8266Webserver.h: No such file or directory


texts:
I have a project which uses a DS18B20 temperature sensor and an LCD with an I2C interface on it. I have connected the sensor to my micro-controller (the DS18B20 has a 12-bit digital output) to the ATmega16 PD17, but as I try to print my values on the terminal the sensor output a really high value in decimal. Here is part of the code (and yes everything is working fine, this is a home-made Arduino):

DDRD &= 0x00;
PORTD |=  0x00;
ds18b20_init(&PORTD, 20, 30, DS18B20_12BIT_RES);
int temperature_sensor_output =  (float)ds18b20_temperature(&PORTD);
printf("Temperature: %d  ", temperature_sensor_output);
delay_ms(500);

ds18b20_init is the Dallas function for initializing the module. ds18b20_temperature returns a float value of the temperature

From this code it just prints:

  Temperature: 51603

If I change %d to %f it prints:

  Temperature: without any value

I do not understand where I may have missed some things.


texts: Can this work as a waterproofing method?

texts: Im making my garden automated with temperature, humidity and soil temperature sensors. I want to be able to connect my Arduino Uno to a solar panel and keep it outside at all times. I dont want to have to remove it to water the plants. Could I cover it in clear nail polish to water proof it?


texts: Float magnet switch interrupts atmega328p and RN2483 sends data

texts:
It was so easy to my mind but it is really not. I have a float switch which goes high when water is floating. So I connect the switch to INT0 pin of MCU. So when water is not floating everything is OK. When the water is floating I send data. I declare the interrupt as follows:

attachInterrupt (digitalPinToInterrupt (switch), float, RISING);

Where float is

void float()
{
detachInterrupt(0);
digitalWrite (LED, HIGH);
txReturn = myRN.txCnf("1");
}

And my main loop is

attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, RISING);
digitalWrite (LED, LOW);
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

I can't understand why my led is not going LOW and why I interrupt is useless after the first successful time. I am aware that I must keep interrupts routines short and by txReturn.txCnf("1"); I don't but I can not understand where my logic is wrong.


texts:
I got an Arduino Uno to play around with, and started to actually dive in. During a program that I am writing for a friend, it suddenly stopped outputting to the serial monitor. When I comment out the part I added (the for loop for changing the names), it still doesn't respond.

#include <TrueRandom.h>
#include <EEPROM.h>
#define numPokemon 151
String nameArray[] = {"MISSINGNO","Bulbasaur","Ivysaur","Venusaur","Charmander","Charmeleon","Charizard","Squirtle",
"Wartortle","Blastoise","Caterpie","Metapod","Butterfree","Weedle","Kakuna","Beedrill","Pidgey","Pidgeotto",
"Pidgeot","Rattata","Raticate","Spearow","Fearow","Ekans","Arbok","Pikachu","Raichu","Sandshrew","Sandslash",
"Nidoran♀","Nidorina","Nidoqueen","Nidoran♂","Nidorino","Nidoking","Clefairy","Clefable","Vulpix","Ninetales","Jigglypuff",
"Wigglytuff","Zubat","Golbat","Oddish","Gloom","Vileplume","Paras","Parasect","Venonat","Venomoth","Diglett","Dugtrio","Meowth",
"Persian","Psyduck","Golduck","Mankey","Primeape","Growlithe","Arcanine","Poliwag","Poliwhirl","Poliwrath","Abra","Kadabra","Alakazam",
"Machop","Machoke","Machamp","Bellsprout","Weepinbell","Victreebel","Tentacool","Tentacruel","Geodude","Graveler","Golem","Ponyta","Rapidash",
"Slowpoke","Slowbro","Magnemite","Magneton","Farfetch`d","Doduo","Dodrio","Seel","Dewgong","Grimer","Muk","Shellder","Cloyster","Gastly","Haunter",
"Gengar","Onix","Drowzee","Hypno","Krabby","Kingler","Voltorb","Electrode","Exeggcute","Exeggutor","Cubone","Marowak","Hitmonlee","Hitmonchan","Lickitung",
"Koffing","Weezing","Rhyhorn","Rhydon","Chansey","Tangela","Kangaskhan","Horsea","Seadra","Goldeen","Seaking","Staryu","Starmie","Mr. Mime","Scyther","Jynx",
"Electabuzz","Magmar","Pinsir","Tauros","Magikarp","Gyarados","Lapras","Ditto","Eevee","Vaporeon","Jolteon","Flareon","Porygon","Omanyte","Omastar","Kabuto","Kabutops",
"Aerodactyl","Snorlax","Articuno","Zapdos","Moltres","Dratini","Dragonair","Dragonite","Mewtwo","Mew",
};
int a = 0;
int b = 0;
int value;
String pokemonName;
int currentID = TrueRandom.random(1,numPokemon+1);
// a = CurrentID
void setup(){
  Serial.begin(9600);
  if (EEPROM.read(a)!=0){
    currentID = EEPROM.read(a);
    Serial.print("The Stored ID is ");
    Serial.println(EEPROM.read(a));
    Serial.println("Stored = true");
  }else{
    value = EEPROM.read(a);
    Serial.println(value);
    EEPROM.write(a,currentID);
    value = EEPROM.read(a);
    Serial.println(value);
    Serial.println("Stored = false");
  }
  for (int i = 0 ; i < 152 ; i++){
      if (currentID = i){
        pokemonName = nameArray[i];
        Serial.print(pokemonName);
        break;
      }
   }
  //nameChange(currentID);
  //Serial.println(pokemonName);
}
void loop(){

}
void nameChange(int currentID){
   for (int i = 0 ; i < 152 ; i++){
      if (currentID = i){
        pokemonName = nameArray[i];
        break;
      }
   }
}

What is the problem with this code?


texts: guidance on Mikrobus NFC tag and connecting to arduino

texts:
I've recently purchased an NFC tag reader from MikroE and ive been a little lost on connecting the reader to my arduino board.

I've also been looking online for a library that i could use for this device, and have found little to nothing, though i maybe looking in the wrong place. If you could provide any guidance to the matter please respond.

any help would be much appreciated.

link to the tag: https://www.mikroe.com/nfc-tag-click


texts: Controlling a Stepper Motor - sending to specific positions on a 'buttonPushCounter ==' cue, forwards and backwards

texts:
I am working on a project using an Arduino control a Stepper Motor. The motor drives a lead screw which moves coloured filters to specific positions along a linear track - forwards and backwards.
The movements are triggered by another device that counts its revolutions (using a sensor. The Arduino reads the inputs and activates the motor on specific revs ie. at 10 move 70mm forwards, at 30 move 70mm backwards.
I can control the Stepper to execute precise moves repeatedly one after another, independently of the counter. I can link the Arduino to the counter and switch on/off an LED at specified counts. But when I try to run the motors from the counter, it's triggered but only moves in tiny discontinuous steps, and only goes one way. Here is that Sketch below. Any help very welcome. Thanks.

// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to
const int ledPin = 7;       // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <AccelStepper.h>

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

void forwardstep1() {
  myMotor->onestep(FORWARD, DOUBLE);
}
void backwardstep1() {
  myMotor->onestep(BACKWARD, DOUBLE);
}

AccelStepper Astepper1(forwardstep1, backwardstep1);

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communication:
  Serial.begin(9600);
  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  TWBR = ((F_CPU / 500000l) - 16) / 2; // Change the i2c clock to 400KHz
  Astepper1.setAcceleration(6000.0);
  Astepper1.setMaxSpeed(600);
  Astepper1.setSpeed(600);    // rpm
  //  while (switchIsOff) {
  //turn servo one direction -
  //tell servo this is 0
}

void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
  }
  // save the current state as the last state, for next time through the loop
  lastButtonState = buttonState;

  if (buttonPushCounter == 10) {
    digitalWrite(ledPin, HIGH);
    Astepper1.moveTo(600);
    Astepper1.setSpeed(600);
    Astepper1.run();
  }

  if (buttonPushCounter == 30) {
    digitalWrite(ledPin, LOW);
    Astepper1.moveTo(200);
    Astepper1.setSpeed(600);
    Astepper1.run();
  }

  }
}


texts: powering arduino with a voltage divider to increase lifespan

texts:
I have a chinese arduino nano that I'm planning to use to open a door using a numeric keypad.

My power source is 12V and I want it running 24/7. I have read that the first thing to fail on an arduino is the voltage regulator due to the heat of lowering the voltage to something the arduino can use.

I have think of buying two big resistors of around 1W each to build a voltage divider and only feed 7V to the Vin pin of the arduino, so it will increase its lifespan.

Is this a good idea?


texts: Multiple Buttons to control the same led for different on off times

texts:
I am just learning the Arduino, it is a learning curve that's for sure.

Using the onboard Led I want to use two buttons to make the Led blink for different times.

I am not sure what is missing from the code, as pressing BUTTON2 gives the same time as BUTTON.

Any help would be greatly appreciated.

 const byte BUTTON = 2;
const byte BUTTON2 = 3;
const byte LED = 13;

unsigned long buttonPushedMillis;
unsigned long ledTurnedOnAt;
unsigned long turnOnDelay = 500;
unsigned long turnOffDelay = 500;
unsigned long turnOnDelay2 = 1000;
unsigned long turnOffDelay2 = 1000;
bool ledReady = false;
bool ledState = false;

void setup() {
  pinMode(BUTTON, INPUT_PULLUP);
  pinMode(BUTTON2, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
}

void loop() {
  unsigned long currentMillis = millis();
  if (digitalRead(BUTTON) == LOW) {
    delay(50);
    buttonPushedMillis = currentMillis;
    ledReady = true;
  }
  if (ledReady) {
    if ((unsigned long)(currentMillis - buttonPushedMillis) >= turnOnDelay) {
      digitalWrite(LED, HIGH);
      ledState = true;
      ledTurnedOnAt = currentMillis;
      ledReady = false;
    }
  }
  if (ledState) {
    if ((unsigned long)(currentMillis - ledTurnedOnAt) >= turnOffDelay) {
      ledState = false;
      digitalWrite(LED, LOW);
    }
  }
  {
    unsigned long currentMillis = millis();
    if (digitalRead(BUTTON2) == LOW) {
      delay(50);
      buttonPushedMillis = currentMillis;
      ledReady = true;
    }
    if (ledReady) {
      if ((unsigned long)(currentMillis - buttonPushedMillis) >= turnOnDelay2) {
        digitalWrite(LED, HIGH);
        ledState = true;
        ledTurnedOnAt = currentMillis;
        ledReady = false;
      }
    }
    if (ledState) {
      if ((unsigned long)(currentMillis - ledTurnedOnAt) >= turnOffDelay2) {
        ledState = false;
        digitalWrite(LED, LOW);
      }
    }
  }
}

\\


texts: How can I make push buttons react to being pressed instantly?

texts:
I am making an Arduino alarm clock. I am checking for the state of a button. If it is clicked, I increment the button counter. If the counter is divisible by 2, it is mode 0, if not, it is mode 1. I have small delays in the code for each mode to help the lcd clear itself. Those delays are preventing the buttons to reacting to my touch, because there is likely a delay during that time.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int hours=0;
int minutes=0;
const int modePin=6; //button
int prevModeState=0; //prev state of button
unsigned long timer;
int modeState;//current state
int mode=0;//mode of alarm
int buttonCounter=0;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(6, 0);
lcd.print("Time:");
lcd.setCursor(6, 1);
lcd.print("00:00");
pinMode(modePin, INPUT);
}

void loop() {
modeState=digitalRead(modePin);
if(prevModeState!=modeState){    //this is the part where I check for the state
  if(modeState==HIGH){
    buttonCounter++;
  }
}
prevModeState=modeState;
if(buttonCounter%2==0){
  mode=0;
}
else{
  mode=1;
}

if(mode==0){
  timer=millis();
  if(timer%600==0){
     minutes++;
    if(minutes==60){
        minutes=0;
        hours++;
        }
     if(hours==24){
        hours=0;
     }
    lcd.clear();
    lcd.setCursor(6, 0);
    lcd.print("Time:");
    lcd.setCursor(6, 1);
    writeTime();
    delay(200); //delay
    }
}
else if(mode==1){
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("Set Time:");
  lcd.setCursor(6, 1);
  writeTime();
  delay(500); //delays

}
}

void writeTime(){
if(minutes<10){

      if(hours<10){
        lcd.print(String("0")+hours+":"+"0"+minutes);
      }
      else{
        lcd.print(hours+String(":")+"0"+minutes);
      }
    }
    else{
      if(hours<10){
         lcd.print(String("0")+hours+":"+minutes);
      }
      else{
         lcd.print(hours+String(":")+minutes);//possibly split if problems arise
      }

    }
}

How can I edit my code?


texts: Is it possible to increase the Arduino's input and output pins?

texts:
I am undergoing a BSc (Hons) Degree in Computer Science and working on an Arduino project.

I am using the Arduino Mega and even though this microprocessor has plenty of input and output pins I am running out.

In the event that there are no more I/O pins available for me to make use of, and I am also referring to both analog and digital pins, is it possible to increase them?

I did some research, however the solutions are too vague... One of the suggestions was to use one or more of the following: 74HC595 8-Bit Shift Register DIP-16.

I am good at coding however when it comes to hardware sometimes I'll need some push.

Thanks a lot.


texts: Upload Code on Arduino Mega using FTDI Cable

texts:
I would like to upload my code to the Arduino Mega 2560.

The USB is fried hence I have to use the FTDI
I've a FTDI cable, but it has only 4 wires, Vcc,GND,TX,RX

How do you upload, as the ATmega is not responding to anything?


texts: LEDs Randomly smooth transitioning, accounting for black or how-to switch using HSV

texts:
I am stuck trying to get it not to account for black in RGB.  My first instinct was to use the HSV color spectrum over the RGB rainbow but, the same code will behaves differently in HSV.  If i could get the same effect in HSV I would, and that would account for the black, but I have not found a solution for that or the accounting for black in RGB.  Here is my code:

#include <FastLED.h>

#define LED_COUNT     96
#define LED_OUT       13
#define BUTTON_IN     10
#define ANALOG_INPUT  A9
#define EXTRA_PIN_A    7
#define EXTRA_PIN_B   11

struct CRGB leds[LED_COUNT];

void setup() {
  Serial.begin(57600);
  LEDS.addLeds<WS2812B, LED_OUT, GRB>(leds, LED_COUNT);
  LEDS.show();
}

void colorLoop() {

  static int Col1;
  static int Col2;
  static int Col3;

  static int C1;
  static int C2;
  static int C3;

  if ((((Col1 == 0) || (Col1 == 250)) && (((Col2 == 0) || (Col2 == 250)) && ((Col3 == 0) || (Col3 == 250))))) {

    // select a random number from 1 to 2 for the array
    C1 = random(1, 3);
    C2 = random(1, 3);
    C3 = random(1, 3);
  }

  if (((C1 == 1) && (Col1 != 0))) {
    Col1 = (Col1 - 10);
  }
  if (((C2 == 1) && (Col2 != 0))) {
    Col2 = (Col2 - 10);
  }
  if (((C3 == 1) && (Col3 != 0))) {
    Col3 = (Col3 - 10);
  }

  if (((C1 == 2) && (Col1 != 250))) {
    Col1 = (Col1 + 10);
  }
  if (((C2 == 2) && (Col2 != 250))) {
    Col2 = (Col2 + 10);
  }
  if (((C3 == 2) && (Col3 != 250))) {
    Col3 = (Col3 + 10);
  }

  for (uint8_t i = 0; i < LED_COUNT; i++) {
    leds[i] = CRGB(Col1, Col2, Col3);
  }
  delay(100);
  LEDS.show();
}

void loop() {
  colorLoop();
}


texts: controlling 2 sensor and 3 pump using millis

texts:
i make a 3 pump for output and im using millis for it, i want to stop if rach the intervalm now in my code its still looping not realy stop for it thx
int pump1 = 5;//pin D5
int pump2 = 6;//pin D6
int pump3 = 7;//pin D7
float pompa1;
float pompa2;
float pompa3;
unsigned long prev_pump1    = 0;
unsigned long prev_pump2    = 0;
unsigned long prev_pump3    = 0;
unsigned long initiate_start = 0;
int pump_state1 = false;
int pump_state2 = false;
int pump_state3 = false;

and after this this is my loop program
  //-----------PUMP ALGORITHM--------------------
  long int pompa01 = pompa1*1000;//interval pump1
  long int pompa02 = pompa2*1000;//interval pump2
  long int pompa03 = pompa3*1000;//interval pump2

  unsigned long initiate_start = millis();

  //pompa1
  if(intiate_start-prev_pump1 > pompa01)
  {
    pump_state1 = !pump_state1;

    if(pump_state1)
    {
      digitalWrite(pump1, HIGH);
    }
    else
    {
      digitalWrite(pump1, LOW);
    }
    prev_pump1 = initiate_start;
  }

    //pompa2
  if(intiate_start-prev_pump2 > pompa02)
  {
    pump_state2 = !pump_state2;

    if(pump_state2)
    {
      digitalWrite(pump2, HIGH);
    }
    else
    {
      digitalWrite(pump2, LOW);
    }
    prev_pump2 = initiate_start;
  }

    //pompa3
  if(intiate_start-prev_pump3 > pompa03)
  {
    pump_state3 = !pump_state3;

    if(pump_state3)
    {
      digitalWrite(pump3, HIGH);
    }
    else
    {
      digitalWrite(pump3, LOW);
    }
    prev_pump3 = initiate_start;
  }


texts: Converting Arduino code to Node MCU code

texts:
I'm doing a project on controlling my house appliances with Blynk app and a ir receiver.So basically i can control my lights and fans with The Blynk app and an IR remote as the one used for TV.
So i have a code which i have written thinking that i would use an arduino connected with An ESP8266 and an ir receiver. But i recently found out that this project can be done using a Node MCU also.
I did a lot research and found that the only difference between arduino and node MCU code is the headers like #include statements can any one confirm this or do i have to change anything else in my programm code.
My Code:
#include <IRreomte.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

#define BLYNK_PRINT Serial
#define RELAY_PIN_1      A0   //D6
#define RELAY_PIN_2      A2   //D0

#define VPIN_BUTTON_1    V12
#define VPIN_BUTTON_2    V13

BlynkTimer timer;

int relay1State = LOW;
int relay2State = LOW;
int RECV_pin = 9;
IRrecv irrecv(RECV_PIN);
decode_results results;

char auth[] = "YourAuthToken";

char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3);

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(VPIN_BUTTON_1);
  Blynk.syncVirtual(VPIN_BUTTON_2);
}

BLYNK_WRITE(VPIN_BUTTON_1)
{
  relay1State = param.asInt();
  digitalWrite(RELAY_PIN_1, relay1State);
}

BLYNK_WRITE(VPIN_BUTTON_2)
{
  relay2State = param.asInt();
  digitalWrite(RELAY_PIN_2, relay2State);
}

void checkPhysicalButton()
{
  if (irrecv.decode(&results))
  {
    switch (results.value)
    {
      case 0x1FE40BF:
        relay1State = !relay1State;
        digitalWrite(RELAY_PIN_1, relay1State);
        Blynk.virtualWrite(VPIN_BUTTON_1, relay1State);
        break;
      case 0x1FEC03F:
        relay2State = !relay2State;
        digitalWrite(RELAY_PIN_2, relay2State);
        Blynk.virtualWrite(VPIN_BUTTON_2, relay2State);
    }
    irrecv.resume();
  }
}

void setup()
{
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  pinMode(RELAY_PIN_1, OUTPUT);
  digitalWrite(RELAY_PIN_1, relay1State);
  pinMode(RELAY_PIN_2, OUTPUT);
  digitalWrite(RELAY_PIN_2, relay2State);
  timer.setInterval(500L, checkPhysicalButton);
  irrecv.enableIRIn();
}

void loop()
{
  Blynk.run();
  timer.run();
}

The only change as of what i know is this one
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

To
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

,and removing some statements Right? Can anyone please tell.!!


texts: Arduino protecting analog input with internal voltage reference

texts:
Usually a common way to protect an analog input consists on reducing voltage and current in the following way:

Current limiting components, as Resistors or inductors and voltage limiting components as diodes, zener, tvs.

In this case for components availability I have used two resistors and a zener diode.

The circuits aims to accept a 0-10V input and read it with the internal reference voltage 1,1V.

The question is the following: Assuming I want to use a 2,2V zener diode as overvoltage protection and 1,1V internal voltage reference, can I consider it safe or the 2,2V of zener will be too much for the 1,1V reference?

simulate this circuit – Schematic created using CircuitLab

NOTES: I am using 2,2V zener diode because is the smallest size I can found.
I could use two normal diodes to reach 1,4V but maybe it will be too much for 1,1V reference and the result could be the same.
I could also add an external reference, but I would like to know if I can have problems with this configuration.


texts:
I am having troubles creating a collection of functions to be used in Arduino sketches and libraries. What I want is not a class, but simply a group of functions which do not require an object to be called; general utilities that can be helpful in any Arduino sketch, like an average of analog reads, or a little statistical tool.

Suppose I write a file called Utilities.h    (I am not sure .h is the right extension to use in this case):

Utilities.h

#ifndef Utilities_h
#define Utilities_h
#include <Arduino.h>

void utility1(...){
...
}

float utility2(...){
...
}

//and so on

#endif

I then save this file in ../Arduino/libraries/Utilities. Whenever I want to use my utilities from this file directly in a sketch I type #includethe full path to the file (#include <Utilities.h>  won't work).

The real problem is if I want to use this collection of functions in a library, like in the following example.

myClass.h

#ifndef myClass_h
#define myClass_h
#include "full path to Utilities.h"

class myClass{
 private:
  int a;
 public:
  myClass();
};

#endif

myClass.cpp

#include "myClass.h"

myClass::myClass(){
 a = utility2(...);
}

Whenever I try to #include <myClass.h>  in my sketches and compile, I get 'multiple definition' error messages for the functions on my  Utilities.h.

So to summarize, my question is: how can I create a collection of functions that can be used both in a sketch and in a library for Arduino?


texts: I have used the SIM800L module in the past, but with Ting shutting down their 2G network, I have been looking for alternatives. I have a SIM7000A, but I can't seem to find a microphone or speaker pin. Can this make calls, or will I have to find something else? I am using an Arduino Mega.


texts:
I have my ESP8266 connected via serial to USB like the image shows:

It worked just fine, however, when I tried flashing Blynk code

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "YourAuthToken";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "ssid", "pass");
}

void loop()
{
  Blynk.run();
}

It started outputting loads of garbage in the serial monitor, while Blynk app said ESP is not connected to network. I've tried since then flashing empty sketches or some other stuff, whatever I do, serial monitor shows loads of junk. I've tried changing modes, I've tried changing baud rates (57600 was default, and AT worked just fine).

Junk example:

  …ÕZªP‚,JHVYº—¡VÕ]J*ÉW¥¡Õ¥Õ-”ªUŠQd®”¡âJ%H
!HiZÊIIRPÖuUPÒ‚BñZT¥ *EUeZB\)*EVjU!\©Š_¥¢”ÅVªqYiUµP”¬ÕPQT°*uH)HZKB*ÕXªuH!HBHBH…µEIâHBH!H©ªqY+hZVB\BH!HÊ*Òµe�qHBHBHŠ*i±…Z¦-hUµPÔ¬ÔPQT°*uH)H-KB*ÕXªuH!HBHBH…µEB\!H!HBVªqY+iZVB\BH!HeVÒZ¢qHBHBHŠ*iQ…Z¦-hUµPÔ¬ÔPQTaYRB\    jHiBHªaYRB\BH!HBVªaYRB\BH!HBVªqY+iZVB\BH!HÊVÒZ¢qHBHBHŠ*i±Õ\V
iUµPÔ¬ÕPQT°*uH)H-JBVªaYRB\BH!H!VªaYR!\BHBH!Vªq©+hZW!\BHBHJ*iµE�âHBH!HŠ*i±…Z¦-hUµPÕ¬ÔPQTaYR!\    %Hi!HÕXªuH!HBHBH…µEIqHBHBH


texts: How to interface USB to custom Arduino Uno Schematic and programming atmega?

texts:
I'm fairly new to designing schematics and working with the atmega on its own and I'm designing an arduino schematic on eagle. Ive gotten to the stage where I need to incorporate a TTL USB interface in order to program the chip. I've just became aware that the arduino uses another avr chip to do so but it appears similar to the microcontroller and just need some clarification.

Since I want it all on one board like the arduino uno, my question is how is the USB-B connected to the microcontroller and how would I Incorporate it into my schematic?

Another question (out of curiosity) if I was to mass produce said PCB with one program on the atmega chip and leave out a USB module so people wouldnt be able to reprogram it (without taking the board apart obviously) How would that be done?

Heres a photo of my current schematic:


texts: How to show one thing in the serial monitor?

texts:
I am trying to make a device which has two push buttons and one analog input. At first the serial monitor will show INITIALIZING, then it will show ready to begin if the measured pin is pressed. Then only it will start to measure if again pressed, then it will show ****************************** and if the reset pin is pressed, it will show reset. If again pressed then ------------------------
but the problem is, it is showing

*************

(analog value) at the same time.

This is my code.

int sensor = A0;
int A = 0;
int resetPin = 3;
int measurePin = 2;
int resetstatus = 0;
int measurestatus = 0;
boolean flag1 = true;
boolean flag2 = true;
long current = 0;

void setup() {
    Serial.begin (9600);
    pinMode (sensor, INPUT);
    pinMode (resetPin, INPUT_PULLUP);
    pinMode (measurePin, INPUT_PULLUP);
    current = millis ();
}

void loop() {
    while (current < 3000) {
        Serial.println ("INITIALIZING");
        current = millis ();
        delay (200);
    }
    Serial.println ("Ready to begin");
    delay (200);
    resetstatus = digitalRead (resetPin);
    measurestatus = digitalRead (measurePin);
    if (resetstatus == LOW) {
        flag1 = !flag1;
        delay (50);
    }
    if (flag1 == HIGH)  {
        delay (50);
        reset ();
    }
    if (flag1 == LOW) {
        Serial.println ("------------------------------------");
    }
    delay (100);
    if (measurestatus == LOW) {
        flag2 = !flag2;
        delay (50);
    }
    if (flag2 == HIGH) {
        delay (50);
        measure ();
    }
    if (flag2 == LOW) {
        Serial.println ("***********************************");
        digitalWrite (13, LOW);
    }
    delay (100);
}

void measure() {
    A = analogRead (sensor);
    Serial.println (A);
    digitalWrite (13, HIGH);
}

void reset() {
    Serial.println ("reset");
}


texts: Read signal from USB mouse on an Arduino ?

texts:
I've got a project where I'd need to read my mouse's signal. My mouse is a G700S (so USB) and the thing was I don't really know how to do and even if it's feasible.
I'm using an Arduino Micro and my initial idea was to get a PS/2 to USB Adapter (I already have one) and then to plug it to something like this wired to my Arduino.
So my question basically is "will it work ? and if not, why ?"

The main idea is not to use USB (like an USB Host Shield) because Arduino doesn't have any USB mouse driver.

Thank you in advance


texts:
I have a piece of equipment that has a USB output, that a flash drive gets inserted into, to collect data as the equipment completes its cycles. I need to make a device that can replace the Flash Drive and take the data from the USB port and either save onto an SD Card, to re transmit when completed, or to transmit live as the cycles complete.
I was thinking about using a UNO, & a USB HOST Shield. to receive the data. Then transmit with a wireless or Bluetooth shield.
I have a "SANDISK WIRELSS FLASH DRIVE" which works as a flashdrive, and then you can connect it to other devices through wireless transmission, problem with it is, the wireless feature disables when plugged into the usb port. If the wireless stayed connected, then this would be exactly what I needed.
Any help or ideas, sample schematics would be welcomed.


texts:
Hi I'm new to coding arduino and I'm trying to check if a get request has the a paramater that is the string '1', but it gives me the error

D:\hforr10\My Documents\Arduino\wifi_control_test\sketch_jul29a\sketch_jul29a.ino: In lambda function:

sketch_jul29a:38:24: error: invalid conversion from 'char' to 'const char*' [-fpermissive]

         if(Valuetwo == LedNumon){

                        ^

In file included from C:\Users\hforr10\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146:0,

                 from sketch\sketch_jul29a.ino.cpp:1:

C:\Users\hforr10\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:190:23: note:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'

         unsigned char operator ==(const char *cstr) const {

                       ^

Multiple libraries were found for "WiFi.h"
 Used: C:\Users\hforr10\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
invalid conversion from 'char' to 'const char*' [-fpermissive]

My code has followed this tutorial https://techtutorialsx.com/2017/12/17/esp32-arduino-http-server-getting-query-parameters/ to recive the paramaters.
the code that is throwing the error is this:
    #include "WiFi.h"
    #include "ESPAsyncWebServer.h"

    const char* ssid = "MyNetwrokName";
    const char* password =  "MyNetworkPassword";

   AsyncWebServer server(80);
    const int ledPin = 13;

   void setup(){
   Serial.begin(115200);
   pinMode(ledPin, OUTPUT);

   WiFi.begin(ssid, password);

   while (WiFi.status() != WL_CONNECTED) {
     delay(1000);
     Serial.println("Connecting to WiFi..");
    }

    Serial.println(WiFi.localIP());

    server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){

    int paramsNr = request->params();
    Serial.println(paramsNr);

    for(int i=0;i<paramsNr;i++){

        AsyncWebParameter* p = request->getParam(i);
        Serial.print("Param name: ");
        Serial.println(p->name());

        Serial.print("Param value: ");
        string Valuetwo = p->value();
        Serial.print(Valuetwo);
        char LedNumon = '1';
        if(Valuetwo == LedNumon){ //this line throws the error
          digitalWrite(ledPin, HIGH);
          delay(1000);
          digitalWrite(ledPin, LOW);
          delay(1000);
        }
        Serial.println("------");
    }

     request->send(200, "text/plain", "message received");
  });

    server.begin();
  }

  void loop(){}


texts: Why I cannot change array values even if a statement is successfully called? TFT Touch Screen

texts:
#include <Adafruit_GFX.h>    // Core graphics library
#include "LGDP4535.h" // Hardware-specific library
#include <zTouchScreen.h>
#define BOXSIZE   40
// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

LGDP4535 tft; // Using the shield, all control and data lines are fixed

#define YP A3  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin

// You need to calibrate to fit your LCD
#define TS_MINX 930
#define TS_MINY 903
#define TS_MAXX 142
#define TS_MAXY 117

#define PENRADIUS 3
#define MINPRESSURE 10
#define MAXPRESSURE 1000

int matrix[2][3]; // Initial Declaration
int array[3]

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// array = start with 1 but the variable read start with 0
String ButtonAction[9]={"a", "b", "c", "d", "e", "f", "g", "h", "i"};
boolean ActiveMenu=true;

void setup(void) {
   Serial.begin(9600);
   tft.reset();
   tft.begin();
   ts.InitVariable(3, 240, 320, TS_MINX, TS_MAXX, TS_MINY, TS_MAXY, MINPRESSURE, MAXPRESSURE);
   tft.fillScreen(BLACK);
   DrawIt(CYAN, "draw");
   DrawIt(BLACK, "text");
}

void loop() {//SOME OTHER STUFF}

unsigned long DrawIt(uint16_t color, String CurrentAction) {

  int timedcycle=0;

  if (CurrentAction == "text") {
     int matrix[2][3]={{25,150,265},{45,100,155}};
     int array[3]={3,3,3};

     tft.setRotation(3);
     tft.setTextColor(BLACK);
     tft.setTextSize(1);

     Serial.println("Text Columns");
  }

  else if (CurrentAction == "draw") {
    int matrix[2][3]={{260,140,20},{40,150,95}};
    int array[3]={3,3,3};
  }

  Serial.println(CurrentAction);

  for(int j=0; j<3; j++) {
     for(int i=0; i<array[j]; i++) {

       if (CurrentAction == "draw") {

         if (timedcycle == 7) {
           tft.fillCircle(100, 160, 15, WHITE);
         }
         else {
           tft.fillRect(matrix[1][j], matrix[0][i], 20,40, color);
         }

       }
       else if (CurrentAction == "text") {
         if (timedcycle == 4) {
           true;
           //tft.fillCircle(100, 160, 15, WHITE);
         }
         else {
           tft.setCursor(matrix[0][j], matrix[1][i]);
           tft.println(ButtonAction[timedcycle]);
         }

       }
     timedcycle++;
     }
  }
}

So as you can see I'm trying to draw some things in a TFT Touch Screen. Everything seems to be working but no matter what I do I can't change the array value.

If I initialize the array variable with a predetermined value it won't change even if the statement is called correctly. I can see that it runs over serial but the array still doesn't change.

I suppose there's something wrong but I can't pinpoint what it is! Thanks in advance!


texts: How to keep a 24 hour maximum and minimum temperature

texts:
I am keeping a simple weather station to monitor humidity and temperature in my greenhouse. I have a ds18b20 and dht probes.  everything works great and I even used a little trick to hold my maximum and minimum values, but I would like them to reset every 24 hours. Is there anyway i can code the arduino to reset itself. i tried several examples of connecting digital pins to the reset pin and i couldn't get any of those to work.  i tried to reset the values of my max and min to 0 and 99 respectively after my millis() reached the equivalent of a day, but they just stuck at 0 and 999. I understand fully why it does this i just don't know how to fix it. all i want to do is reset my minimum and maximum temperatures after 24 hours.

//       Green HAUS Version 1 by Kent Scipione 9/3/2017
//       Monitors temperature and humidity
long timenow;
long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second =  1000; // 1000 milliseconds in a second

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#define ONE_WIRE_BUS 10
double temp;  // sensor is precise to .1 degree.
//Double gives smoother serial graph, byte doesn't overflow oled screen
Adafruit_SSD1306 display(OLED_RESET);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

#include <Adafruit_Sensor.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

int maxtemp=0;
int mintemp=999;

void setup() {

  Serial.begin(9600);
  Serial.println("green HAUS Version 1 by Kent Scipione 9/3/2017");
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  display.setTextColor(WHITE);
  sensors.begin();
  dht.begin();

}

void loop() {
  timenow = millis();
  sensors.requestTemperatures();
  temp = sensors.getTempFByIndex(0);
  int humid = dht.readHumidity();
  float dtemp = dht.readTemperature(true);
  if (temp > maxtemp) {
    maxtemp=temp; }
  if (temp < mintemp) {
    mintemp=temp; }

  if (timenow >= day){
      digitalWrite(4, HIGH);
      pinMode(4, OUTPUT);       //*************************this is the part where I'm trying to reset the mintemp and maxtemp**********

    }

  Serial.print("Probe Temperature: ");
  Serial.println(temp); Serial.println("*F");
  display.setCursor(0,0);  //refreshes display
  display.clearDisplay();
  display.setTextSize(1); display.print("Probe "); display.println(temp);  //line 1 of text
  display.print("DHT  "); display.print(dtemp); display.print("  "); display.print(humid); display.println(" %");  //line 2 of text
  display.print("HIGH "); display.println(maxtemp);           //line 3 of text
  display.print("LOW  "); display.println(mintemp);   //line 4 of text
  display.display();

}

Thank you so much for your help this is driving me mad haha


texts: SD-Card-Module doesnt work with external power supply

texts:
Problem description

I am trying to build a datalogger with an Arduino UNO. I have connected a SD card module to the Arduino. I have planned to catch the measurement data from the analog input pins. Everything works fine if connected to the usb port. But if I run the Arduino over an external power supply, the SD.open-method fails (It simply returns false).
The problem occurs even, if I connect the external power supply additional to the USB connection. So the problem can't be a missing serial connection.

Note that the problem only occurs, if SD.open is in WRITE-mode.
(File dataFile = SD.open("datalog.txt", FILE_WRITE);)

What I've already tried:

running the SD-card example code, which is included in the SD card library.
trying different types of file-system formattings (FAT, FAT32, with different cluster-sizes)
powering the sd-card reader with 3.3V instead of 5V

Arduino wiring

Look at the pictures to check if there are some mistakes with the wiring:

Specifications of the power supply

And here are the specifications of the power supply:

Manufacturer: MyVolts
Model: DD282MU
Input: 100-240V (AC) - 50-60 Hz
Output: 9V, 1A (DC)

I hope you can help me with my problem. And of course, I hope there is a solution for the problem at all. Thank you.


texts: WiFiManager - Combine NonBlocking portal AND addParameter

texts:
I wish to config WiFiManager and addParameter of MQTT topic and local server on its ConfigPortal.
Additionally in a case of a power outage or any, in case of losing WiFi, to continue in a NonBlocking way.
The problem is when combining both features in one sketch, I get some errors.
Entire code is ( please notice comments marked Marker[i] ):
#include <WiFiManager.h>
#define MQTT_SERVER "192.168.3.200"
WiFiManager wm;

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

  WiFiManagerParameter custom_mqtt_server("mqtt_server", "mqtt server", MQTT_SERVER, 40);
  WiFiManagerParameter custom_mqtt_user("mqtt_user", "mqtt user", "", 10);
  WiFiManagerParameter custom_mqtt_pwd("mqtt_pwd", "mqtt password", "", 10);
  WiFiManagerParameter custom_mqtt_topic("mqtt_topic", "mqtt topic", "", 10);
  WiFiManagerParameter custom_mqtt_group("mqtt_group", "mqtt group", "", 10);
  WiFiManagerParameter custom_mqtt_root("mqtt_root", "mqtt rootTopic", "", 10);
  wm.addParameter(&custom_mqtt_server);
  wm.addParameter(&custom_mqtt_user);
  wm.addParameter(&custom_mqtt_pwd);
  wm.addParameter(&custom_mqtt_topic);
  wm.addParameter(&custom_mqtt_group);
  wm.addParameter(&custom_mqtt_root);

  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  //  wm.resetSettings();

  //  wm.setConfigPortalTimeout(180);
  // wm.setConfigPortalBlocking(false);  // <--- Marker [#1]

  //  if (!wm.autoConnect("AutoConnectAP")) {
  //    Serial.println("failed to connect and hit timeout");
  //    delay(3000);
  //    //reset and try again, or maybe put it to deep sleep
  //    ESP.restart();
  //    delay(5000);
  //  }

  bool res;
  res = wm.autoConnect("test123", "password"); // password protected ap
}

void loop() {
  // put your main code here, to run repeatedly:
  //  wm.process(); //<--- Marker [2]
  Serial.println("hi");
  delay(100);

}

When Marker[1] & Marker[2] are commented out ConfigPortal works as expected, and in Blocked state - meaning there is no hi's on Serial monitor.

When only Marker[2] is commented out, ConfigPortal is reached, lacking all addParameter fields.

When Marker[1] & Marker[2] are not commented out, ConfigPortal is now reachable, but not having Non-Blocking feature...

What is the purpose of wm.process() ?

Guy


texts: Can I control solid state relay directly from arduino digital pin?

texts:
I want to switch on/off some AC device using solid state Omron G3MB relay
I know that for magnetic relay there should be transistor and flyback diode, but what about SSR?
Can I connect it directly to arduino digital pin without any transistors and anything else?
In a closer look on special arduino module, we can see some extras. Are they necessary? I want to put solid state relay (not separated module) into my custom PCB, and I'm confused about that extras.


texts: Using a scrolling text in OLED Adafruit_SSD1305

texts: I have been in internet for the past week looking for a way of programming a scrolling text (either left or right) using Adafruit_SSD1305 but I only find scrolling commands for Adafruit_SSD1306. Has anyone tried this before? I really need help on this


texts:
backgrounds

I bought arduino leonardo and connect it to Ubuntu 15.04.
With arduino IDE 1.0.5(from Ubuntu official repo) running in sudo, the arduino was recognized as /dev/ttyACM0.
So I tried to upload sample sketch Blink to the port ttyACM0 with settings of Leonardo, but every time I tried to upload IDE said that serial port is wrong. and then actually leonardo was recognized as ttyACM1. If I set ttyACM1 and retry, leonardo moved to ttyACM2; and so on.

So I searched some websites and installed oracle-java7-installer package and Arduino IDE 1.6.5 from official site.
After doing so and several tries, my leonardo finally stopped to be recognized. no ttyACMx appears from that time.
I guessed it's the problem on software environment, so I connected the arduino to Windows7 pc, but device manager also didn't recognize the arduino.

How my leonardo is now

Connecting to PC, "ON" LED have turned on and "L" LED blinks each 1 seconds. I guess it's thanks to default bootloader.
So looks not completely broken or bricked, but still can't access from any PC in normal way.

What I want to be taught

Is my leonardo broken?
Is there a way to make it work?

reply(20151018)
@Chris Stratton
Thank you for suggesting! It's good news for me that it doesn't seem to broken.
I ran lsof | grep ttyACM and found nothing.
And about brltty, Ubuntu has installation of it by default, and sudo service brltty status says its enabled.
So I try sudo service brltty stop and connect my Leonardo, but it still not be recognized. X(


texts: lcd.clear doesn't work with Serial.begin(9600) on Arduino Mega 2560

texts:
So I have a standard 16x2 LCD display with 16 pins. The LCD display works fine with every other aspect, however, the "lcd.clear" function doesn't work with "Serial.begin(ANY BAUD)". I have tried changing bauds and downgrading the board software but it still doesn't work.

Basically, instead of clearing the display like it should do, it displays a weird character with 4 horizontal lines (in one character space) and then continues to write stuff after it.

Here is my code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

void setup() {
 pinMode(8, INPUT);
 lcd.begin(16,2);
 Serial.begin(9600);
}

void loop() {
 lcd.print("incorrect");
 delay(3000);
 lcd.clear();
 delay(100);
}

Whenever I delete the Serial.begin everything works fine, but when I add it the clear function doesn't work anymore.

So in this case, what happens is that the Arduino prints "incorrect", then instead of clearing the display, it prints out four horizontal lines, and then continues to print out "incorrect" infinitely.


texts:
I've got an Arduino Uno, SIM900 GPRS, and the Adafruit Breakout GPS.

Can this code be optimized?

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <Ubidots_Arduino_GPRS.h>
//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART
#define APN "myapn"
#define USER ""  // If your apn doesnt have username just put ""
#define PASS ""  // If your apn doesnt have password just put ""
#define TOKEN "ubidotsToken"  // Replace it with your Ubidots token
#define ID "Your_id_here" // Replace it with your Ubidots' variable ID
// You can send 1 to 10 variable at the same time
#define ID1 "idHere" // Replace it with your variable ID
//#define ID2 "" // Replace it with your variable ID
//#define ID3 "Your_id_here" // Replace it with your variable ID

TinyGPSPlus gps; // The TinyGPS++ object for interfacing with the GPS
//Declare indexes, and strings
char latitude[12];
char longitude[12];
float value_1 = 1;
char var[18] = "Lat: ";
char var2[18] = "Long: ";
Ubidots client(TOKEN);
SoftwareSerial ss(2,3);
void setup() {

// the Serial port of Arduino baud rate.
  Serial.begin(9600);

  client.powerUpOrDown();
  client.setApn(APN,USER,PASS);
//.endC is for _client.end() in Ubidots_GPRS.cpp
  client.endC();
  ss.begin(9600);
}

void loop() {

  //handling GPS data parsing
  while (ss.available() > 0) {
    gps.encode(ss.read());}
  //Once a valid location comes up it updates Lat/Long variables
   if (gps.location.isUpdated())
{
    strcpy(var, "Lat: ");
    strcpy(var2,"Long: ");

    dtostrf(gps.location.lat(),10,6,latitude);
    strcat(var, latitude);

    dtostrf(gps.location.lng(),10,6,longitude);
    strcat(var2, longitude);
  //Added ss.flush();
    ss.flush();
    ss.end();
    Serial.flush()
  //Added client.beginC() for _client.begin(9600) is Ubidots_GPRS.cpp
    client.beginC();
    client.add(ID1, value_1, var, var2);
    client.sendAll();
    client.endC();
    ss.begin(9600);
  }
 Serial.println(var);
 Serial.println(var2);
}

From this link, I moved the println from inside .isUpdated() to outside the if statement. I was able to get GPS data sent from the unit to my Ubidots account while driving around town. Afterwards I was able to input the data into Google Maps and the route produced was accurate. Do I need flush()?


texts:
I'm trying to create my own library for HX711. In that, I created a .h file and a .cpp file. There are some issues in my program. Please tell me what the error in the code is.

hx711adc.h file->

#ifndef hx711adc_h
#define hx711adc_h

#include <Arduino.h>

#define ON true

class hx711adc {
  public:
    hx711adc(int pin1);
    hx711adc1(int pin2);
    int read_data(bool value);
    unsigned long readCount(void);

  private:
    uint8_t pinNumber1;
    uint8_t pinNumber2;
};

#endif

hx711adc.cpp ->

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

#define ON true

hx711adc::hx711adc(int pin1) {
  pinMode(pin1, OUTPUT);
  pinNumber1 = pin1;
}

hx711adc::hx711adc1(int pin2) {
  pinMode(pin2, OUTPUT);
  pinNumber2 = pin2;
}

int hx711adc::read_data(bool value) {
  float y = 1;
  if (value == true) {
    for (int h = 0; h < 2; h++) {
      long count = 0;
      for (int i = 0; i < 50; i++) {
        count = readCount();
        Serial.println(count);
        float w = 0;
        w = count / 10;
        y = w + y;
        delay(1);
      }
      y = y / 50;
    }
  }
  return y;
}

unsigned long hx711adc::readCount(void) {
  unsigned long Count;
  unsigned char i;
  pinMode(pinNumber2, OUTPUT);
  digitalWrite(pinNumber2, HIGH);
  digitalWrite(pinNumber1, LOW);
  Count = 0;
  pinMode(pinNumber2, INPUT);
  while (digitalRead(pinNumber2))
    ;
  for (i = 0; i < 24; i++) {
    digitalWrite(pinNumber1, HIGH);
    Count = Count << 1;
    digitalWrite(pinNumber1, LOW);
    if (digitalRead(pinNumber2))
      Count++;
  }
  digitalWrite(pinNumber1, HIGH);
  Count = Count ^ 0x800000;
  digitalWrite(pinNumber1, LOW);
  return (Count);
}

hx711_trail.ino ->

#include "hx711adc.h"
void setup() {
  // put your setup code here, to run once:
  hx711adc pin1 (6);
  hx711adc pin2 (7);
}

void loop() {
  // put your main code here, to run repeatedly:
  int a = hx711.read_data(ON);
}


texts: RF24 library commands, channel, and address

texts:
I'm trying to use the RF24 library for wireless communication.
However, it appeared that this library does not have "help" option.
There was a keywords file but it did not explain what it does.
I found couple of examples online, and in the library, but id did not explain things quite in detail.

Could you explain to me how those command works, and weather there's any help file for the library?

Especially, I have a question about the channel and address used in the library.

A. Does address take character or number as input?
The official example in the library used

byte addresses[][6] = {"1Node","2Node"};

But I also say some example use

byte addresses[][6] = {"00001","00002"};

The byte command was suppose to be a 8-bit unsigned number, from 0 to 255, but why they used string " " as input?

I found a sentence in RF24.h file: Addresses are assigned via a byte array, default is 5 byte address lengths. But why they wrote byte addresses[][6] instead of byte addresses[][5]?

B. From some other video I learned that RF24 have channel and address for communication, where channel can take value from 0 to 125; pin/port take value from 0,1-5; and the address.

setChannel  KEYWORD2

The pin was explained in RF24.h. However,

Can one open multiple channel at once?
If one use the same addresses in multiple channel at once, can the address being distinguished, or were they treated as the same address?
Is channel-pin/port(while writing)-address a tree structure?

C.
Can one open up more pin/port in transmitting and writing?

  openWritingPipe   KEYWORD2
  openReadingPipe   KEYWORD2


texts: I am not able to use ESP8266 12E with Arduino

texts:
I am doing my engineering degree. I want to make a project connecting multiple ESP8266 with a router and control multiple relay boards. I am unable to use ESP8266 12E with Arduino. I used this connection shown in the link below, but it didn't work. So please help me with the solution. I also referred to all possible posts, but it didn't help. Please help me as soon as possible.

Connection:

post: How to connect ESP8266 12e directly to Arduino Uno (without shields)


texts:
I am using an Arduino SMD UNO r3 board ,and connecting thermal sensor MLX 90614 , wifi modem ESP 8266 , a buzzer and an arduino based sound sensor .
How much power distribution will it require ?
What should be the capacity of the battery ?


texts: Printing Serial Readings for 2+ Parallax Ping Sensors

texts:
trying print values for two sensors, one works the other is 0, any tips on how i can use more than one?

const int pingPin = 10;
const int pingPinz = 11;
unsigned int duration1, duration2, inches1, inches2;

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

void loop() {
  pinMode(pingPin, OUTPUT);          // Set pin to OUTPUT
  pinMode(pingPinz, OUTPUT);          // Set pin to OUTPUT
  digitalWrite(pingPin, LOW);        // Ensure pin is low
  digitalWrite(pingPinz, LOW);        // Ensure pin is low
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);       // Start ranging
  digitalWrite(pingPinz, HIGH);       // Start ranging
  delayMicroseconds(5);              //   with 5 microsecond burst
  digitalWrite(pingPin, LOW);        // End ranging
  digitalWrite(pingPinz, LOW);        // End ranging
  pinMode(pingPin, INPUT);           // Set pin to INPUT
  pinMode(pingPinz, INPUT);           // Set pin to INPUT
  duration1 = pulseIn(pingPin, HIGH); // Read echo pulse
  duration2 = pulseIn(pingPinz, HIGH); // Read echo pulse
  inches1 = duration1 / 74 ;        // Convert to inches
  inches2 = duration2 / 74 ;        // Convert to inches
  Serial.println(inches1);            // Display result
  Serial.println(inches2);            // Display result
  delay(200);                 // Short delay
}


texts:
I have the following code:

int count = 0;
char serial_char;
char serial_message[96];

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

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

    serial_char = Serial.read();
    if (serial_char == '\n' || serial_char == '\r'){

      serial_message[count] = 0; // <<-- What does this line do?
      count = 0;
      Serial.println(serial_message);

    }
    else{
      serial_message[count++] = serial_char;
    }

  }

}

With this code, I can type a message into the serial monitor, and it will print the message back at me. So if I type 'Goodbye', it returns:

Goodbye

If I send it another message 'Word', it returns:

Word

However, my questions is when I comment out the line:

serial_message[count] = 0;

And then I repeat the same sequence of actions before, 'Goodbye' returns 'Goodbye', but when next I enter 'Word', it returns:

Wordbye

Could anyone explain this to me? I am really curious to know why this occurs. What does adding that 0 in the char array accomplish? Thank you.


texts: Use object of LiquidCrystal class within another class

texts:
I am quite new to C++ and hope that I don't bore you too much with my question.

I want to use an object of LiquidCrystal Class in another class called "Display_ManagerClass". I followed the instructions of the 2nd alternative in the following link:

Use object of other class within class

Unfortunately, I receive a linker error.

.ino-file:

#include "Licht_Manager.h"
#include "Display_Manager.h"
#include "Zeit_Manager.h"

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

void setup()
{

    Licht_Manager.init();
    Display_Manager.init(&lcd);
}

void loop()
{
    Display_Manager.showText("Hello", "World");
    while (1)
    {
        Licht_Manager.blink(1);
    }
}

Display_Manager.h:

#ifndef _DISPLAY_MANAGER_h
#define _DISPLAY_MANAGER_h

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

#include <LiquidCrystal/src/LiquidCrystal.h>

class Display_ManagerClass
{
    protected:

    public:
        //void init();
        void init(LiquidCrystal* _p_lcd);
        void showText(String DisplayText1, String DisplayText2);
    private:
        LiquidCrystal* p_lcd;

};

extern Display_ManagerClass Display_Manager;

#endif

Display_Manager.cpp:

#include "Display_Manager.h"

void Display_ManagerClass::init(LiquidCrystal* _p_lcd)
{
    p_lcd = _p_lcd;
    p_lcd->clear();
}

void Display_ManagerClass::showText(String DisplayText1, String DisplayText2)
{
    p_lcd->clear();
    p_lcd->setCursor(0,0);
    p_lcd->print(DisplayText1);
    p_lcd->setCursor(0,1);
    p_lcd->print(DisplayText2);
}

Display_ManagerClass Display_Manager;

I receive the following errors:

Display_Manager.cpp.o:In function `Display_ManagerClass::init(LiquidCrystal*)
Display_Manager.cpp:clear()
Display_Manager.cpp.o:In function `Display_ManagerClass::showText(String, String)
Display_Manager.cpp:clear()
Display_Manager.cpp:setCursor(unsigned char, unsigned char)
Display_Manager.cpp:setCursor(unsigned char, unsigned char)
collect2.exe*:error: ld returned 1 exit status
Error creating .elf

I made sure that the correct directory of the library is set up in the project properties. The library also works in the normal way, but in combination with the class it doesn't.

I work with Atmel Studio 7 in combination with VisualMicro, Arduino IDE 1.6 and Arduino Uno.

Thank you in advance.


texts: 433M modules w. soldered 34.6cm antenna, first test

texts: I'm doing a first tx/rx on a pair of modules, and some hams have alluded that they 'autoadjust' - since I've soldered halfwave antennas onto the modules, what's the optimal range for first tests? And will I benefit from 1/2 or 1/4 wave radials? I was thinking about 4-6 spokes from a bicycle wheel. Also, what library would be best for RC control of a medium power pump - I'm pretty sure it's going to induce noise. How far away from the pump should I position the rx module? Thanks in advance.


texts: How do pins on an arduino mega 2560 work?

texts:
I got a copy of Arduino from a local retailer here (it's a local copy and I'm pretty confused with how the pins actually work).

I know basic electronics so far, there should be two pins for every node one acting as the negative terminal and other as the positive terminal. If I were to connect an LED with my Arduino board which pins would I be utilizing?

Here let me tell you how pins are arranged on mine:

IOREF                                                                         GND

                                         13
RESET                                                                         12
3.3V     //this left group marked power                                        .
5V                                  //right group marked PWM                   2
GND            //right groupmarked communication                          TX0 -1
GND                                                                       RX0- 0

V1N                                                                       TX3-14
                                                                         RX2 -15
A0                                                                         ..
A1                                                                      SCL -21
..   //THIS left GROUP MARKED ANALOG IN
A7

A8
A9 //I believe it is part of the above group
..
A14
A15

     //the pins below marked DIGITAL
     52-50-`48-46...........................................................22`


texts: Use of a logic level converter with Arduino Due PWM

texts:
Maybe I am way over my head here, but here it is:

I am trying to regulate a spindle RPM. The tachymeter part is now working flawlessly.

Now I am on the PID part, to control and regulate that speed. I am using the PID library on my Arduino Due. It "looks" like it works, but it does not.....

What I mean is that, if I measure with a multimeter the output directly from the Due, I can see the voltage increase steadily from a few millivolts up to 2.75/2.8 Volts, as it should.

BUT, if I measure after going through the logic level converter (as the spindle speed controler is for 5 volts), the voltage min is +- 1.3 volts (instead of a few millivolts), and max is 1.565 volts.

It's clearly not working as I thought it would. What am I missing here?


texts: Weird behavior of variables when replacing for loops with if statement

texts:
See the picture of serial monitor showing I get a large number, 4 billion, when I multiply two called functions together. It always happens after 53 if I change the amount the if statement counts to. I serial monitored the if statement and it counts to 600 then down then up and repeats good and the sensorValue stays the same.  I get rid of the division in y and I put it all in the for loop and still get a large number. My purpose is to fade pin and adjusts analogWrite at same time. It adjusts but does not fade. Does replacing for loop with if statement or calling to many functions create a bug.

int analogInPin = A0;
int analogOutPin3 = 3;

int sensorValue;

int i = 0;
int a;
int y;

void sens(int &sensorValue){
  sensorValue = (((long)analogRead(analogInPin)*255)/1023);
}

void inOut(int &i){
  if (i > -1){
    i = i + a;
  if (i == 0){
     a = 1;
  }
  if (i == 600){
    a = -1;
  }
  return i;
 }
}

void updateFade(){
  sens(sensorValue);
  inOut(i);
  unsigned long y = ((sensorValue*i)/600);
  Serial.println(sensorValue);
}

void setup() {
  Serial.begin(9600);
  pinMode(analogInPin,INPUT);
  pinMode(3,OUTPUT);
}

void loop() {
  updateFade();
  delay(100);
  analogWrite(3, y);
}


texts: Stack arduino, motor shield and lcd shield

texts: I made arduino-stack which consists of arduino r3, robotdf motor shild and robotdf lcd shield. But motor shield and lcd use same pins 4 and 5, so we have a conflict of pins. Can i use other pins?


texts: MQTT on nano with Ethernet shield not working

texts:
I'm using an arduino nano with an ethernet shield (ENC28J60), and  ethernet eem to be working (I can create a webserver with Ethercard library).However, i'm stuck when i try to connect to a MQTT server.
I tried NanodeMQTT (stuck at waitforlink), Adafruit MQTT Library + Ethernet.h ( MQTT_connect() : Connection failed, endlessly retrying), PubSubClient + Ethernet.h (client.connect return 0) and some others.
At this point i am wondering if i am doing the right configuration each time:

when asked an ip, i set the static one i want for my arduino : 192.168.1.50
when asked an gwip, i set one of wy internet router : 192.168.1.254
when asked for a server, i set it to my mqtt server ipv4 : 192.168.1.185 (and port is 1883)
when asked for a mac adress, i keep the one in the example, or just write a random one

Do you know what can cause the ethernet.h or mqtt library to fail, but still ethercard is working fine ?


texts:
I would like to know where I can see the output when I use the command printf. I am programming using the Arduino interface.

Update

I'll add a few lines of code for better understanding:

#include <stdio.h>

int main(void)
{
    printf("Hello World");

    return 0;
}


texts: how to make arduino as mind thought reader?

texts: I'm trying to create arduino base mind reader... And for that I thought that EEG electrode connected to arduino and then the data send to arduino in 01 form .. But I facing problem in how to convert this or which wave (alpha, beta,delta)give very high or acutrate result.


texts: When GPS can't see satellites, how can I continue to tick off a smooth-ish time?

texts:
I'm getting 10 updates/sec from my GPS unit (The MTK3339 used in the Adafruit breakout board), and using it to update a clock display. This works well enough, though there's one minor problem that I'd like to solve and one major one that I have to solve.

The minor issue first; I don't get an update every 100ms. I get one roughly every 100ms... plus or minus about 20-30ms. If a late and an early update arrive back-to-back right when the display goes from n to n+1 seconds, it's noticeable that it's not ticking at a regular cadence. It's not fatal, but the arythmic stutter of it is deeply painful to watch.

The major issue is - what do I do when the GPS can't find a signal? Maybe the device is driving through a tunnel for a minute or there's some other sky obstruction. I still want the clock to update in a best-guess sort of way.

You can't just update the seconds display and then, 1000 (arduino-measured) milliseconds later, update the clock if a new message hasn't arrived. 1000 real-world milliseconds can be anywhere from 700 - 1400ms measured by an arduino, depending on the board and the quality of the crystal. Worse yet, the discrepancy is far from consistent within a single crystal. Seeing the processor speed up and slow down by several percent over the course of a few minutes isn't uncommon.

So what I'd like is a mechanism that will constantly smooth the received (GPS) time to give a best-estimate of current actual time. I'm okay with it being a second or two off (at most) from real time, as long as the cadence feels like actual seconds, and a loss of GPS for a few minutes can be quickly corrected when the signal is re-acquired.

I'm somewhat aware of (strikethrough)DIP(/strikethrough) PID methods, but I'm not sure how to apply them here. It seems that someone must have solved the problem for the sake of syncing internet time, so I shouldn't be reinventing a solution.


texts: Nested for loop used to evaluate a two dimensional array of integers

texts:
I am trying to use a nested for loop to evaluate and change numbers within the two dimensional array. Basically these numbers are minutes, or hours. This function is meant to reset the button controlled numbers when they go above 23 (hours) or above 59 (minutes) and also from going below 0. The two dimensional array that I made also has three arrays that need to be skipped (P1[0], P1[2] and P1[10] because they do not contain any time variables. When I click the buttons and increment the numbers nothing unusual happens they just don't bounce back like they are supposed to.

Here is the two dimensional array:

int P1[][12] = { //0-10
  {0}, //MODE
  {0, 0, 0, 0,}, //TOD variables
  // OnHR, OnMin, OffHr, OffMin
  {0}, //DOW
  {0, 0, 0, 0,},  //Sunday
  {0, 0, 0, 0,},    // OnHR, OnMin, OffHr, OffMin
  {0, 0, 0, 0,},
  {0, 0, 0, 0,},
  {0, 0, 0, 0,},
  {0, 0, 0, 0,},
  {0, 0, 0, 0,},  //Saturday
  {0, 0, 0, 0, 0,} // Temperature variables
  //Sensor, GreaterThan/LessThan, Temp, Buffer, State
};

Here is the for loop that doesn't seem to work:

void HrMinBounce() {
  int i = 0;
  int q = 0;

  for (int i; i < 10; i++) { //iterating down Plug arrays
    for (int q; q < 4; q++) {
      if (i != 0 || i != 2) { //non time arrays
        if (q == 0 || q == 2) { //hours
          if (P1[i][q] > 23) {
            P1[i][q] = 0;
          }
          if (P1[i][q] < 0) {
            P1[i][q] = 23;
          }
        }//End of hours
        if (q == 1 || q == 3) { //minutes
          if (P1[i][q] > 59) {
            P1[i][q] = 0;
          }
          if (P1[i][q] < 0) {
            P1[i][q] = 59;
          }
        }//End of minutes
      }
    }
  }
}

I have 5 of these arrays, so I was hoping to make one loop that could take care of all 5 at once. Here is my previous loop that works but I would have to copy and paste a whole lot to get the result without the extra for loop.

void MinHrLimit() {
  int i = 0;

  for (int i; i < 3; i++) {
    if (i == 0 || i == 2) {
      if (P1[1][i] > 23) {
        P1[1][i] = 0;
      }
      if (P1[1][i] < 0) {
        P1[1][i] = 23;
      }
    }
  }
}


texts:
I am using a Leonardo board and am testing the APIs in the Serial type. The board is talking to a screen using serial.

The pseudo code is as follows (I show code relevant to Serial):

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

void loop(void) {

    if(Serial.available())
    {

        if (Serial.find(0x30))
        {
             func1();
        }

        if (Serial.find(0x31))
        {
             func2();
        }

    }

 }

 void func1()
 {
      // Serial.print() used multiple times

      asm volatile ("  jmp 0");
 }

 void func2()
 {
      // Serial.print() used multiple times

      asm volatile ("  jmp 0");
 }

I test using the Arduino IDE (1.8.0) and its Serial Monitor. When I send 0x30 over serial, the first if case gets triggered to invoke func1, but when I send 0x31, I cannot get the second if case (func2) to get triggered. This even happens when I test 0x31 first; the second if case never gets triggered. Can someone tell what I am doing wrong here and what is the right way to use serial ?

Edit For testing, one can use the pseudo code itself; I tested using different number of LED blinks in func1 & func2, and the problem still holds.

Edit 2 Based on Dave's answer, I tried a test with serial using sample code from

I did another test where I used the sample loop code for read (https://www.arduino.cc/en/Serial/Read) and tried typing 0 or 1 through serial monitor. I observed the following:

// Typed 0
I received: 48
I received: 13
I received: 10
// Typed 1
I received: 49
I received: 13
I received: 10


texts: Correct position for buttonState in my FSM

texts:
I wrote a FSM with the help of some tutorials through out the world wide web and so far it does what I want to do with it.

But one thing that is not the way I want to be, is to exit the state noLightPause during the non blocking delay with the button to enter the yellowLight state again.
I cannot figure out where to put the buttonState inside my code, if it should be that simple to exit that state, because it was hard enought for me to get my machine going to that point :D.

Do not get confused, I soldered the button from ground to the pin, so LOW gets the input :).

Hope you guys can help me with that problem to get me further with my machine.

Thanks in advance for all your help, here is my code:

#include <FastLED.h>

#define NUM_LEDS 16

CRGB ledStrip [NUM_LEDS];

const int buttonPin = 4;
const int ledStripPin = 8;
const int ledOnBoard = 13;
const int interval = 100;

int buttonState = 0;
int lastButtonState = 0;

int ledOnBoardState = LOW;

unsigned long previousMillis = 0;
static unsigned long noDelayPause;

enum statusType {whiteLight, yellowLight, noLightPause, noLight};

statusType currentStatus = whiteLight;

void setup() {

  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledStrip, OUTPUT);
  pinMode(ledOnBoard, OUTPUT);

  FastLED.addLeds<NEOPIXEL, 8>(ledStrip, NUM_LEDS).setCorrection(DirectSunlight);
  FastLED.show();
}

void loop() {

  //----------------------------------------
  // just to see if the machine is blocking something

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    if (ledOnBoardState == LOW) {
      ledOnBoardState = HIGH;
    } else {
      ledOnBoardState = LOW;
    }
    digitalWrite(ledOnBoard, ledOnBoardState);
  }

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

  switch (currentStatus) {

    case whiteLight:
      currentStatus = whiteLightFunction();
      break;

    case yellowLight:
      currentStatus = yellowLightFunction();
      break;

    case noLightPause:
      noDelayPause = millis();
      currentStatus = noLightPauseFunction();
      break;

    case noLight:
      if (millis() - noDelayPause > 1000) {
        currentStatus = noLightFunction();
        break;
      }
  }
}

statusType whiteLightFunction() {

  if (digitalRead(buttonPin) == LOW) {

    return (yellowLight);

  } else {

    fill_solid(ledStrip, NUM_LEDS, CRGB::White);
    FastLED.setBrightness(100);
    FastLED.show();

    return (whiteLight);
  }
}

statusType yellowLightFunction() {

  if (digitalRead(buttonPin) == LOW) {

    fill_solid(ledStrip, NUM_LEDS, CRGB::Yellow);
    FastLED.setBrightness(100);
    FastLED.show();

    return (yellowLight);

  } else {

    return (noLightPause);
  }
}

statusType noLightPauseFunction() {

  fill_solid(ledStrip, NUM_LEDS, CRGB::Black);
  FastLED.show();

  if (digitalRead(buttonPin) == LOW) {

    return (yellowLight);

  } else {

    if (digitalRead(buttonPin) == HIGH) {

      return (noLight);
    }
  }
}

statusType noLightFunction() {

  if (digitalRead(buttonPin) == LOW) {

    return (yellowLight);

  } else {

    return (whiteLight);
  }
}


texts: Problem with running 2 DC motors with ultrasonic sensor

texts:
I'm not expert in electrical circuits, maybe I am making a very simple mistake or missing some basic points with my circuit.

What I'm trying to achieve is simple, to run 2 DC motors with an ultrasonic sensor to detect obstacles and change direction. When I unplug the ultrasonic sensor everything is working fine as expected without obstacle detection but when I connect the ultrasonic sensor, sensor always responds with 0 cm distance. Then I removed 9 V battery from the circuit and plug Arduino to computer via USB, sensor works fine but motors are not working properly, it looks like the power from USB is not enough to drive motors at the same time. I've added my circuit scheme below:


texts:
I have Arduino Mega and Weather Shield. I want to calculate wind speed.

float get_wind_speed()
{

float deltaTime = millis() - lastWindCheck; //750ms

deltaTime /= 1000.0;

  float windSpeed = (float)windClicks / deltaTime; //3 / 0.750s = 4

  windClicks = 0; //Sıfırla ve yeni oluşan rüzgarı izle
  lastWindCheck = millis();

  windSpeed *= 1.492; //4 * 1.492 = 5.968MPH

 Serial.println();
 Serial.print("Windspeed :");
 Serial.println(windSpeed);

 return(windSpeed);
}

But when I run my code I see two windspeed value. First one is windspeed=0.0 or any value. Second one is windspeed=nan.

How can I make it better?


texts:
void Sensor_value()
{   server.handleClient();
    humidity = dht.readHumidity();
    temperature = dht.readTemperature();
 }

I want to make condition if temperature = null and Humidity= null that means the sensor fails to take reading so I want to return and take value again


texts: using more than 8 temperature probe of DS18B20 on Arduino

texts: I am trying to use more than 8 temperature DS18b20 on one bus. Is there any problem to make it work?


texts: Having trouble bootloading my Two-Up printer

texts:
I am following these instructions to set up my Two-Up 3D printer, and I have no problems all the way up until step 18.  The board uses the arduino IDE to burn the bootloader, which is why I am posting this here.

I have my board set to "[BootloaderCDC]Teensylu/Printrboard" in the tools menu, and I have selected the appropriate COM port.  I use arduino for tons of other things so I know my way around the IDE reasonably well, but I have never encountered this error before so I'm not quite sure what to make of it or how to fix it.

Here is the error.

I have the red board (version 2) and I am using Arduino version 1.0.6.  As far as I can tell, I have perfectly followed all of the steps up until this part with no noticible problems.  I remembered to bridge the boot pins and everything.

In the video the guy says there may be an error when you go to program the board but my error is way different than his error in the video, and hbe says you should hear the dissconnect and reconnect sounds as the board gets reset after a bootload (I didn't hear them).

Anyone have any idea how to fix this issue?


texts:
Is there any way to know the resolution of micros() for the Arduino Portenta H7. I have checked for other boards e.g. Nano which is mentioned as 4 uS. However, I couldn't find one for Portenta H7.
Is there any way to measure or look for that


texts: Arduino uno + cnc shield v3 + Stepper Motor Driver A4988 + AccelStepper?

texts:
I successfully run the AccelStepper examples on an Arduino Mega with a RAMPS 1.4 shield, two A4988 stepper motor drivers and two 17HS16-0284S stepper motors.

I used 3 jumpers on the RAMPS to set the microstep resolution to 1/16.

I used this code inspired by the Polargraph Server for Polargraph:

#include <AccelStepper.h>

/*
// for the Arduino Uno + CNC shield V3

#define MOTOR_A_ENABLE_PIN 8
#define MOTOR_A_STEP_PIN 2
#define MOTOR_A_DIR_PIN 5

#define MOTOR_B_ENABLE_PIN 8
#define MOTOR_B_STEP_PIN 3
#define MOTOR_B_DIR_PIN 6
*/

// for the Arduino Mega + RAMPS 1.4
#define MOTOR_A_ENABLE_PIN 30
#define MOTOR_A_STEP_PIN 36
#define MOTOR_A_DIR_PIN 34

#define MOTOR_B_ENABLE_PIN 56
#define MOTOR_B_STEP_PIN 60
#define MOTOR_B_DIR_PIN 61

AccelStepper motorA(1, MOTOR_A_STEP_PIN, MOTOR_A_DIR_PIN);
AccelStepper motorB(1, MOTOR_B_STEP_PIN, MOTOR_B_DIR_PIN);

void setup()
{
  motorA.setEnablePin(MOTOR_A_ENABLE_PIN);
  motorA.setPinsInverted(false, false, true);
  motorB.setEnablePin(MOTOR_B_ENABLE_PIN);
  motorB.setPinsInverted(false, false, true);

  motorA.setAcceleration(100);
  motorA.move(1000);
  //motorA.setMaxSpeed(100);
  //motorA.setSpeed(100);

  motorB.setAcceleration(100);
  motorB.move(1000);
  //motorB.setMaxSpeed(100);
  //motorB.setSpeed(100);

  motorA.enableOutputs();
  motorB.enableOutputs();
}

void loop()
{

  motorA.run();
  motorB.run();

}

I tried to use the same code with the same stepper motor drivers and motors on a Arduino Uno and a CNC shield v3 without success (I also used the 3 jumpers to set the microstep resolution to 1/16). The motors do not work and jitter.

What is wrong with my code?

Bonus questions:
I have taken this setup and code from the Polargraph server but I didn't get how I'm suppose to know how to use setEnablePin() and setPinsInverted() methods. In fact, I have troubles finding documentation about the CNC shield V3 and the A4988 drivers (I only found this page) to work with AccelStepper.


texts: Can the nRF24L01+ CE and CSN pins be attached to Arduino pins A0 and A1?

texts: This documentation states that the CE and CSN pins can be specified.  Can I specify A0 and A1 as these pins?


texts: delay() runs super fast unless I remove a while loop that never runs

texts:
I'm working on a small game on arduino but I'm facing some really odd behavior. When I run this code all of my leds flash on and off in less than a second even though delay(10000); should stop them for 10 seconds. However if I remove the while(game_running) block they go back to flashing every 10 seconds even though that block of code never actually runs.

int yellow = 12;
int green = 10;
int red = 9;
int blue = 11;

int debug = 13;

int sequence[1000];
int level = 0;

int game_running = false;

void setup() {
  pinMode(yellow, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);

  pinMode(debug, OUTPUT);
}

void loop() {

  // Pre Game light flash
  digitalWrite(yellow, HIGH);
  digitalWrite(green, HIGH);
  digitalWrite(red, HIGH);
  digitalWrite(blue, HIGH);
  digitalWrite(debug,HIGH);
  delay(10000);
  digitalWrite(debug,LOW);
  digitalWrite(yellow, LOW);
  digitalWrite(green, LOW);
  digitalWrite(red, LOW);
  digitalWrite(blue, LOW);
  delay(10000);

  game_running = false;
  level = 0;

  while(game_running) {

    sequence[level] = random(4); // Select next color

    // Blink LEDs
    for (int i=0; i < level; i++) {

       if(sequence[i] == 0) {
         digitalWrite(yellow, HIGH);
         delay(1000);
         digitalWrite(yellow, LOW);
         delay(1000);
       } else if(sequence[i] == 1) {
         digitalWrite(green, HIGH);
         delay(1000);
         digitalWrite(green, LOW);
         delay(1000);
       } else if(sequence[i] == 2) {
         digitalWrite(red, HIGH);
         delay(1000);
         digitalWrite(red, LOW);
         delay(1000);
       } else {
         digitalWrite(blue, HIGH);
         delay(1000);
         digitalWrite(blue, LOW);
         delay(1000);
       }
    }
    level += 1;
  }
}


texts: How to serially transfer/read an image to Arduino

texts: I am using Arduino Uno and the image size is 12.7 kb. I want to read a jpeg image from computer and convert into bitmap in arduino. Later on it will be implemented using SD card.Is it possible to read a .jpeg image from computer to Arduino using serial communication? If yes, then how?


texts:
I have two classes in my sketch that are independent of each other (a serial output and an LCD display) A simplified structure of my code is as follows:
class A
{
  public:
   int x;
   void afoo()
   {
     x=1;
   }
   void afoo2
   {
     x=ClassB.bfoo+1;
   }
};

A ClassA;

class B
{
  public:
    int y;
    void bfoo()
    {
      y=ClassA.afoo+2;
    }
};
B ClassB;

However, if I don't comment out  class afoo2 I get the following error:

exit status 1
'ClassB' was not declared in this scope

I'm guessing that this is because I haven't yet created B ClassB while class is being defined. Is there a way I can do what I'm intending here?


texts:
Is it possible to "send" a serial command to the device itself to see the response?
I have written a little routine based on a couple of serial sends and receives and want to see if that works out like I want.

EDIT:

I have a device (an AVR with arduino boot loader) and as part of my program, the device exchanges phrases with peripheral devices over a serial connection. Since I have right now just the arduino itself and can't really test, if at least the logic behind the serial part of works out, I would like to get serial commands from somewhere and trigger 'continuous talking', so I want to monitor the response behavior of my module, if it gets a certain command (stability reasons). Instead of waiting for a second device, is it possible to "link the TX/RX line to itself" internally or externally to test my program with itself?


texts: My Arduino isn't showing up on my computer. What should I do?

texts:
You have your spangly new Arduino board, you've installed the software, and you plug it in. Nothing happens. Diagnosing problems may be a little tricky for the beginner, so what hoops should you go through to try and work out where the problem is and why you can't get your board working?

Note: this is an FAQ. Do not use it to ask about your specific problem. Comments will be deleted. Either ask a new question detailing all the steps you have taken, or, better, discuss your problem in chat.


texts: Multiple definition of "..." Compiler Error

texts:
I am creating a simple library to test how multiple files in an Arduino program works. I have three files. MotorController.ino:

#include <motor.h>

void setup() {
   motorInitialize();
}

void loop() {

}

motor.cpp:

#include "motor.h"

void motorInitialize() {

  for (int i = 0; i < 4; i++) {
     motorArray[i].writeMicroseconds(2000);
     delay(1500);
     motorArray[i].writeMicroseconds(2000);
     delay(1500);
  }
  delay(1000);

}

and motor.h:

#ifndef _motor_h_
#define _motor_h_

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

Servo motor1, motor2, motor3, motor4;
Servo motorArray[4] = {motor1, motor2, motor3, motor4};

void motorInitialize();
#endif

When I try to compile the program, I get the error:

libraries/motorLibrary/motor.cpp.o (symbol from plugin): In function `motor1':
(.text+0x0): multiple definition of `motor1'
sketch/test.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/motorLibrary/motor.cpp.o (symbol from plugin): In function `motor1':
(.text+0x0): multiple definition of `motor2'
sketch/test.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/motorLibrary/motor.cpp.o (symbol from plugin): In function `motor1':
(.text+0x0): multiple definition of `motor3'
sketch/test.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/motorLibrary/motor.cpp.o (symbol from plugin): In function `motor1':
(.text+0x0): multiple definition of `motor4'
sketch/test.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/motorLibrary/motor.cpp.o (symbol from plugin): In function `motor1':
(.text+0x0): multiple definition of `motorArray'
sketch/test.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

I have read similar posts on this issue, but none of the solutions seem to work for me. I've followed the instructions on the Arduino website on how to create a library, and that doesn't seem to resolve this issue.


texts: It gives some glitching on 7 segment display

texts:
It gives the right value on the monitor but it doesnt display the value on my display.

int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8};
int num_array[11][7] = {
  { 1, 1, 1, 1, 1, 0, 1 }, // 0
  { 0, 1, 1, 0, 0, 0, 0 }, // 1
  { 1, 1, 0, 1, 1, 1, 0 }, // 2
  { 1, 1, 1, 1, 0, 1, 0 }, // 3
  { 0, 1, 1, 0, 0, 1, 1 }, // 4
  { 1, 0, 1, 1, 0, 1, 1 }, // 5
  { 1, 0, 1, 1, 1, 1, 1 }, // 6
  { 1, 1, 1, 0, 0, 0, 0 }, // 7
  { 1, 1, 1, 1, 1, 1, 1 }, // 8
  { 1, 1, 1, 0, 0, 1, 1 }, // 9
  { 0, 0, 0, 0, 0, 0, 0 }  //nothing
};

int pin = 2;
int button = 12;
int buttonVal;
int randVal;
bool pressVal;
void setup() {
  Serial.begin(9600);

  for (int i = 0; i < 7 ; i++)
  {
    pinMode(pinNumb[i], OUTPUT);
  }
  pressVal = false;
  pinMode(button, INPUT);
}

void loop() {
  buttonVal = digitalRead(button);
  if (buttonVal == 0)
  {
    //zero();
    turnOff();
    pressVal = false;
  }
  else
  {
    //zero();
    if (pressVal == false)
    {
      randVal = rand() % 10;
      pressVal = true;
      delay(100);
    }
    Serial.println(randVal);
    if (randVal == 0)
    {
      zero();

    }
    else if (randVal == 1)
    {
      one();

    }
    else if (randVal == 2)
    {
      two();

    }
    else if (randVal == 3)
    {
      three();

    }
    else if (randVal == 4)
    {
      four();

    }
    else if (randVal == 5)
    {
      five();

    }
    else if (randVal == 6)
    {
      six();

    }
    else if (randVal == 7)
    {
      seven();

    }
    else if (randVal == 8)
    {
      eight();

    }
    else
    {
      nine();

    }
  }
}

void zero()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[0][j]);
    pin++;
  }
}

void one()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[1][j]);
    pin++;
  }
}

void two()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[2][j]);
    pin++;
  }
}
void three()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[3][j]);
    pin++;
  }
}
void four()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[4][j]);
    pin++;
  }
}
void five()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[5][j]);
    pin++;
  }
}
void six()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[6][j]);
    pin++;
  }
}
void seven()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[7][j]);
    pin++;
  }
}
void eight()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[8][j]);
    pin++;
  }
}
void nine()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[9][j]);
    pin++;
  }
}
void turnOff()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }

}


texts:
I have a project in which several Arduinos will be running independent programs. I would like to use an Arduino Mega as the main controller. It will receive input from a variety of switches, as well as data input from 2 Arduino Unos and 3 Arduino Nanos.

Each Nano will run a basic collection of switches and LED displays.

Each Arduino Uno will be connected to a 2 axis joystick and will have several button inputs from the joystick, as well as several 7 segment Led displays and several LED indicator displays.

The Mega would need to gather information of at least 16 bytes from each slave at highest possible speed, and be able to transfer at least 16 bytes to each slave at the same rate. I would also need the clock signal for all devices to default to the Mega.

What would be the best way to begin setting up the program logic to get these boards to interact in a smooth manner without a lot of lag in communication between boards?

Also, what would be the limitations on speed with this sort of com setup between the boards?

If more setup or function information is needed I can add description, just didn't want this post to be overly lengthy.


texts: Can't make Wee serial WiFi work with Arduino Uno

texts:
I'm trying to plug a Wee serial WiFi module on my Arduino Uno, through an XBee shield .

I'm simply trying to make work the example from the library.

All I get is

setup begin
FW Version:
to station err
Join AP failure
setup end

The code i'm using :

#include <SoftwareSerial.h>
#include <doxygen.h>
#include <ESP8266.h>

SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
ESP8266 wifi(mySerial);

#define SSID "yuflowoffice"
#define PASSWORD "cashless"

void setup(void) {
  Serial.begin(9600);
  mySerial.begin(115200);
  Serial.print("setup begin\r\n");

  Serial.print("FW Version: ");
  Serial.println(wifi.getVersion().c_str());

  if (wifi.setOprToStation()) {
    Serial.print("to station ok\r\n");
  } else {
    Serial.print("to station err\r\n");
  }
  delay(1500);

  if (wifi.joinAP(SSID, PASSWORD)) {
    Serial.print("Join AP success\r\n");
    Serial.print("IP: ");
    Serial.println(wifi.getLocalIP().c_str());
  } else {
    Serial.print("Join AP failure\r\n");
  }

  Serial.print("setup end\r\n");
}

void loop(void) {
}

What can I do?


texts: Maximum sampling rate of Arduino Mega2560

texts:
I'd like to know what is the maximum sampling rate achievable while using ADC on Arduino Mega2560.

Thanks


texts: A question about resistance measurement with arduino

texts:
Lately I was asking myself about the possibility of measuring a potentiometer resistance with Arduino.

My questions are:

Is it possible?
If it's possible, what kind of restriction does the Arduino have with the resistance value measured?