texts:
Is there a difference between Pro Micro 8MHz 3.3V and LilyPad USB bootloaders?

Both are based on 32U4 running at 8 MHz.


texts: Grbl on Arduino Uno (Elegoo) with DM542 + nema24 stepper motor not working

texts:
i've already searched and tried for a quite depressing amount of hours, but am not able to solve this problem:

The parts are the following:
 - Elegoo Arduino Uno, on wich i flashed GRBL
 - 24v Power Supply (wich powers the stepper motor(s)
 - Nema24 3nm stepper motor
 - A DM542 Driver
 - bCNC (exe-build on win7 and win10)

Now, i connected one stepper-driver and stepper-motor as x-axis to the arduino.
The wiring is as following:
 - 5v from arduino to the three + Pins (ENA, DIR and PUL)
 - Pin 2 to PUL, Pin 5 to DIR, Pin 8 to ENA
 - 24V go to + and ground port of the driver, the 4 motor-wires are wired accordingly to the driver

I downloaded GRBL from Github and flashed it to the Arduino (i can run grbl-commands from the serial monitor inside the arduino ide, grbl is unlocked), connected everything and opened up bCNC, searched for the arduino on com-port, wich is shown correctly, and connected wich works fine (in the main screen "connected" shows up).
However when i try to move the x-axis under the control-panel in bcnc, nothing moves, on the screen the numbers change correctly and i get an ok in the logs, but the motor does not move a bit.
I double checked the wiring and tried to write a little program in arduino ide to move the stepper motor without grbl (deleted grbl, wrote a little program wich manually set the intervals ecc), without changing the wiring, that worked...
How can i debug this? Any suggestions?

Thanks in advance!


texts:
I am 6 months into my Arduino Uno work and I would like a step by step way to find and download a "library". I work using WINDOWS and WORD and although I was eventually successful in getting a 7 segment display library to download and work, I must say I could not do it again since the path I followed was far from clear due to my lack of understanding about basic computer stores etc. I have enjoyed my work with the Uno but I have been very disappointed at lots of "help" offered on other sites since they assume I know far too much. It is a skill to be able to communicate with we lesser people so I am really hoping a step by step guide is possible.
Thanks


texts: Arduino Nano- Programer not responding after upload WDT

texts:
I followed an example link for WDT. Code was copied as is, and uploaded to Nano successfully.

Now- when I wish to upload another code, I get an error message saying avrdude: stk500_recv(): programmer is not responding.

Is it possible to undo it ?

code:

#include <avr/wdt.h>

#define led 13 // pin 13 is connected to a led on Arduino Uno

void setup()
{
  pinMode(led, OUTPUT);      // set pin mode
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                // wait for a tenth of a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                // wait for a tenth of a second
}

void loop(){
  wdt_enable(WDTO_15MS);     // enable the watchdog
                             // will fire after 15 ms without reset

  while(1)
  {
//     wdt_reset();          // uncomment to avoid reboot
  }
}


texts: Is the arduino nano 33 IOT schematic wrong?

texts:
As am i was copying the schematics of the arduino nano 33 IOT from the Official arduino schematic i noticed something was wrong in the schematic, specifically in the PRTV5V component

Here is a snip on the schematic

It would seems that the pin numbering on the PRTR5V is wrong. Here are snippits from the PRTR5V Datasheet

The sample schematic does look like the same of the arduino but if you look at it using the pin number it is different.For example on the arduino schematic pin 2 is at the middle of the two diodes, while on the datasheed pin 2 is before the diodes.

Now which one should i follow? Did arduino intentionally pin it that way ?


texts:
THIS QUESTION ISN'T IN USE ANYMORE

  Solved by using an other remote that is supported by the libary

====NEW CODE====

    #include <IRremote.h>

    int RECV_PIN = 11;
    int relay1 = 2;
    int relay2 = 3;
    int relay3 = 4;

    int on = 1;
    int on1 = 1;
    int on2 = 1;

    IRrecv irrecv(RECV_PIN);
    decode_results results;

    void setup()
    {
      digitalWrite(relay3, HIGH);
      pinMode(relay3, OUTPUT);
      digitalWrite(relay2, HIGH);
      pinMode(relay2, OUTPUT);
      digitalWrite(relay1, HIGH);
      pinMode(relay1, OUTPUT);
      pinMode(13, OUTPUT);
      irrecv.blink13(true);
      irrecv.enableIRIn();
    }

    unsigned long last = millis();

    void loop() {
      if (irrecv.decode(&results)){
        if (results.value == 0x36167A85) {
          if (millis() - last > 250) {
            on = !on;
            digitalWrite(relay1, on ? HIGH : LOW);
          }
          last = millis();
        } else if (results.value == 0x36161AE5) {
          if (millis() - last > 250) {
            on1 = !on1;
            digitalWrite(relay2, on1 ? HIGH : LOW);
          }
             last = millis();
        } else if (results.value == 0x3616FA05) {
         if (millis() - last > 250) {
            on2 = !on2;
            digitalWrite(relay3, on2 ? HIGH : LOW);
          }
            last = millis();
        }
        irrecv.resume();
      }
    }

================

I'm working on this bit of arduino code for a while now but i can't get it to work. My circuit is wired up correctly, but it isn't returning any data in the serial prompt. Here is my code:

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

int main = 0;
int left = 0;
int right = 0;

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

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    switch (results.value) {
      case 0x2E3A06C0:
        main = 1;
        Serial.println("MAIN: on");
        break;
      case 0x8C2921D6:
        left = 1;
        Serial.println("LEFT: on");
        break;
      case 0x226270DA:
        right = 1;
        Serial.println("RIGHT: on");
        break;
      case 0x4AC6E6A:
        main = 0;
        Serial.println("MAIN: off");
        break;
      case 0xDD5E26EF:
        left = 0;
        Serial.println("LEFT: off");
        break;
      case 0x3E5BEF99:
        right = 0;
        Serial.println("RIGHT: off");
        break;
    }
    irrecv.resume();
  }

  delay(100);
}

I'm using the libary Arduino-IRremote. When I try the demo "IRrecvDemo", it works fine. I have the hex codes from this demo. So can someone help me get this code working? It would be nice!


texts:
I am trying to understand the maximum BT SPP transmission speed that can be achieved using ESP32.

What my project requires is to send 2bytes of data every 200us (5kHz) AND additional 15bytes of data every 50ms(20Hz) via BT.

I am trying to achieve that using BT SPP, however, I could not understand the speed of BluetoothSerial::write AND BluetoothSerial::print.

Based on my testing for 5kHz, the BluetoothSerial::write freezes after 2-3 seconds of connection.

BluetoothSerial::println function doesn't seem to freeze, however, the time taken for the function to complete doesn't seem to be constant. Please refer to the code below on how I measure the time taken for the function to complete.

The picture below shows the time in microseconds each time the function (dataFormat()) takes place. If you look through, there are 2 instances where the time duration is more than an average 0f 80us.

I would like to know, ESP32 BT SPP can achieve such a speed or there is another way I could achieve this.

Thank you for your time and assistance in this matter.
I have asked the same question in ESP32 Forum as well here.

void dataFormat(record r){
  serialBtPrint_dur = micros();
  char msg[20];
  sprintf(msg,"%04d%05d%05d%05",r.e, r.r, r.p, r.y);
  SerialBT.println(msg);
  serialBtPrint_dur = micros() - serialBtPrint_dur;
  }
}

void loop() {
  char msg[20];
  uint8_t testMsg[20] = "abcdefghijklmnop\n";
  if(!structs.isEmpty()){
    dataset[local_rd_ptr].yawData);
    data::dataFormat(structs.shift());
    Serial.println(serialBtPrint_dur);
  }
}


texts:
I'm running a modifed code on Arduino Uno + WiFi shield (updated), and I have seen strange behaviors with String ; here is my code, the goal is to parse a HTML request to know which page was requested :

String line = client.readStringUntil("\n");
Serial.print("Line : [");
Serial.print(line);
Serial.println("]");

String cmd = line.substring(0, 3);
Serial.print("Command : [");
Serial.print(cmd);
Serial.print("]");

My problem comes from what appears in the console :

Line : [GET / HTTP/1.1
Host: 192.168.43.200
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Ac]
Command : []

I was expecting the cmd variable to contain GET, and I do not understand why it contains nothing.

I suspect this behavior comes from the lack of RAM (compiler says there are only 670 bytes available for local variables), but if it's the case, I do not know how to solve it, as I'm pretty inexperienced in C++ and I need to store a String containing the values that are sent as a reply to the HTTP request.

PS. I'm also wondering why the client.readStringUntil("\n") method sends the full request instead of only the first line.


texts: Can arduino interrupts occur in a middle of if statement?

texts:
I got an issues from few days, got some code which reset millis time on successful i2c communication, if not it restart an relay after specified period of time. Here is part of the code:

 if ((unsigned long)(i2c1Millis1 - i2cpreviousMillis1) >= i2cset1 )  // check if not restarted soon
        {

i2c1Millis1 are updated every run of the loop and on successful i2c communication.

i2cpreviousMillis1 is updated on successful i2c request (coming from interrupt)

I manage to debug when false restart occur and looks like i2c1Millis1 is lower than i2cpreviousMillis1

So question is: can an interrupt occur while those two millis are compared when value of i2c1Millis1 is taken for compare and then come interrupt where i2cpreviousMillis1 is updated to current millis and it become greater and trigger the condition?

(I already modified my code i2cpreviousMillis1 is updated with i2c1Millis1  value on successful communication to prevent that, but it is not working, from time to time it made false restarts).


texts:
I am controlling a motor with an Arduino Nano, that motor is controlled by Cytron MD-10c motor controller.

i want to wire a momentary switch in parallel with the analog output PIN from the Arduino and PWM input on the MD-10c, the switch will connect the 5v output from Arduino to the PWN input on the MD-10c. Basically an override to go full power.

Is there any risk of damage with this sort of wiring with the switch?


texts: Can a 0.2V voltage drop (i.e. from 5.0V to 4.8V) cause Arduino to stop working?

texts:
I want to log wind speed, using adafruit anemometers (https://www.adafruit.com/product/1733) at three different levels. For this, I have connected an Arduino UNO with an SD logger shield (Shield Arduino Uno Data Logger Rtc Ds1307 Slot Sd). All three anemometers are connected to pins A0, A1 and A2 from the logger shield (since its on top of the Arduino). The Arduino UNO, logger shield and sensors are powered by a 12V 7Ah lead battery using a Step-Down DC-DC voltage controller (set to 4.8V to 5.2V, according to my cheap voltmeter). The battery is connected to a charge regulator 12V-24V 10A, which is also connected to a 10W solar panel.
Everything works fine (e.g. logs data each 1 second). However, after some time (e.g., 2 hours) starts giving the same measurements for 3 hours and then it stops working.
Any thoughts on why this might be occurring?
The code I am using is the following:
#include <SPI.h>
#include <SD.h>
#include "RTClib.h"

RTC_DS1307 rtc; // create local instances of library class objects

DateTime time;

File dataFile;

const int chipSelect = 10;

//sensor characteristics go here just removed for ease of reading...

void setup() {
 Serial.begin(9600);
 while (!Serial) {;} // wait for serial port to connect.
 Serial.print("Initializing SD card...");
 if (!SD.begin(chipSelect)) {
 Serial.println("Card failed, or not present");
 while (1); // loop forever
 }
 Serial.println("Have SD card");
 rtc.begin();
}

void loop() {

// sensor readings formulas go here just removed for ease of reading...

 time = rtc.now(); // Read RTC
 String dataString = ""; // Assemble data

log:
 dataString = time.timestamp(DateTime::TIMESTAMP_DATE);
 dataString += ", ";
 dataString += time.timestamp(DateTime::TIMESTAMP_TIME);
 dataString += ", ";
 dataString += String(sensorVoltage0);
 dataString += ", ";
 dataString += String(WindSpeed0);
 dataString += ", ";
 dataString += String(sensorVoltage1);
 dataString += ", ";
 dataString += String(WindSpeed1);
 dataString += ", ";
 dataString += String(sensorVoltage2);
 dataString += ", ";
 dataString  += String(WindSpeed2);
 dataFile = SD.open("WSlog.txt", FILE_WRITE);
 if (dataFile) { // Write to logfile

 //dataFile.println("Date, Time, WindSpeed0, WindSpeed1, WindSpeed2"); //Write header on the file

 dataFile.println(dataString);
 dataFile.close();
 Serial.println(dataString);
 delay(1000); // pause for one second between sensor logs
 }
 else {
 Serial.println("error opening datalog.txt");
 }
}


texts: I would like to control the Radino40 breakout board with arduino. But i don't know if is it possible. I know that the single Radino40 DW1000 antenna could controlled by Arduino through SPI, but my board haven't this connection.


texts:
I am trying to connect to esp8266 using Arduino UNO. There are various things on the internet having mixed information and hence I am seeking some clarity.

I followed these instructions, but could not get to connect to ESP8266 using AT command. http://cordobo.com/2300-flash-esp8266-01-with-arduino-uno/

I have following questions:

Can I connect ESP8266 directly to Tx/Rx without voltage divider or level shifter? I also suspect that the voltage divider connections are wrong. As per my understanding, the Tx from Arduino should be divided, and the divider output should be connected to ESP8266.
When I connected the shield as described, the shield gets hot. Is there any way to conclude if the shield is damaged or not?
When I connect the device using voltage divider the blue LED on the shield also lights up. Without divider, it does not light up. What is the significance of the blue LED?

Hardware

ESP8266-01 pinout

Circuit using voltage divider

Circuit without voltage divider


texts: How do I output tone() and audioFX board output through a single speaker?

texts:
I'm building a BMX start gate controller. It requires a voice sample to be played ("Riders ready, watch the gate!") before playing a series of tones at very specific frequencies and intervals. After the tones are complete, a relay is triggered which drops the start gate.

I'm intending to use one of the header pins with the tone() function to output the tones, and an Adafruit AudioFX board to play the voice sample.

How do I connect both of these to an Adafruit mono amplifier (https://www.adafruit.com/product/2130) ?

Note that only one or the other will be playing at one time.

Can I use a "passive mixer" (which I think is putting a 10kΩ resistor on each input source for the amplifier?)


texts: Why is my esp8266 still visible under "available connections" when connecting to WiFi?

texts: I wrote a "Hello world" type of sketch using the Arduino IDE and uploaded it to an esp8266. I used no libraries, or any kind of WiFi commands. However, when I powered up the esp8266, it was visible under "available connections" when I connected to WiFi using a Windows laptop. I was told that the firmware on an esp8266 (which has the AT commands) is being flashed when the Arduino IDE uploads a sketch. Why do I still see the esp8266 when my laptop connects to WiFi?


texts: Serial Communication between ESP8266 and Arduino ( Sofware and Hardware )

texts:
I wish to connect an Arduino ( any of 328P family ) which its 5v, with ESP8266 (ESP-01, or even NodeMCU or Wemos D1 mini ) which is 3v3 logic. My goal is that ESP8266 will be in-charge of MQTT messages and other remote abilities, while Arduino board will be in charge of UP/Off/Down rocker switch and 2 relays ( For reliability I rather have this setup ). Both MCU's code is written by me using Arduino
I Know of 2 main ways: voltage divider and level shifter ( and 3rd will be to use a 3v3 logic as pro-mini - but let's leave for now ).
My questions are:
A) Does Rx Tx need a voltage to be the same ( some on-line tutorial ignore this at all )? if so, is it needed both ways ?
B) Some Tutorial mention that using a voltage divider create some communication interference. It is true and/ relevant for use as explained ?
C) Does SofwareSerial library is recommended (again - reliability ).


texts:
I have a weird problem, and it's probably because I'm doing something wrong. I'm quite new to Arduino.
My Uno R3 (Elegoo) has been working fine for a month. It has been sitting on a bench for the past week, unused though. Last night I tried to push a sketch from the IDE: v1.8.14 on Windows 10 Pro (fully updated), board: Arduino Uno, Com port 5. I got this error:
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe6

So, I googled it and tried to fix it. No luck. And, the code changes frequently (right now it's 0x3a). So, I tried

Using the blink sketch
Rebooting my laptop
Using a different USB port
Using a different USB cable
Using different settings in the IDE (Mega 2560 with the ATMega2560 processor)
Using a different operating system (Ubuntu) on a different laptop with a different version of the IDE (1.8.13)
Using a different Arduino (A Freenove Uno r3 from a robot kit)

Using a different board on windows does work! So, my original board is bricked maybe?
I got the same result, more or less. The only difference was that the response code changed. On Ubuntu, the response code is always 0x00 so I suspect the changing code is down to some problem in windows (I trust Linux a lot more than windows). I used the default blink sketch for all these attempts.
Note: I do have a green 'on' led and the L is orange and does the 3xflash on powerup and reset. This is the only USB port in use, so there's only one to choose in the IDE (happens to be com5) and it's clearly shown as Arduino. When I push the sketch, the orange L led stays solid orange and there is no flashing of the rx or tx leds.
Update:
I have read, with interest:
Have I bricked my Arduino Uno? Problems with uploading to board
Because of this I have now checked the power rail with a multimeter and found 5v and 3.3v respectively on USB, and with a 9v battery I have 3.3v and 7.8v respectively. The L led flashes 3 times as expected on power up and reset.
Also, I have nothing attached to the board at all.
When I tried the loopback test the board would not power-on with reset connected to ground, so I don't know how to proceed with that.
I have just tried the Atmega16U2 chip test, and it failed. I'm pretty sure the wiring is correct (though it's hard to tell -- I can't find a dot indicating pin 1 on the good board so I'm guessing it's close to the 'n' in 'on' as mentioned in the post).
How could I have damaged this? What could I have possibly done to break that? I was only driving leds.


texts: ethernet router in arduino using two enc28j60

texts:
I have read in the uIP manual that only one interface can be managed by the uip stack:
"The uIP implementation is designed to have only the absolute minimal set of features needed for a full TCP/IP stack. It can only handle a single network interface and contains the IP, ICMP, UDP and TCP protocols. uIP is written in the C programming language".
since i want to build an ethernet (simple static) router in arduino, I am confused by this reading whether it is possible at all!


texts: Connecting button as PC usb input via arduino

texts:
I have button with 2 leads (one red and one black). I would like to connect it to PC which allows a press of the button to register as a key press on the computer. I understand an interface board is necessary and I currently have an arduino UNO board with me with a USB cable out to the computer.

Can someone guide me in the right direction regarding soldering of the 2 wires to the board and the relevant sketches for the board itself?

Thank you very much

Regards
Ben


texts: ZS-040 (HC-05) blueetooth module Arduino Mega

texts:
I followed this tutorial http://www.martyncurrey.com/using-an-arduino-mega-with-a-hc-05-zs-040-at-mode/ and it seems that the AT mode is on. (the LED is blinking like it's supposed)

I connected my pins like this:

  BT VCC to Arduino 5V out. Disconnect before running the sketch

  BT GND to Arduino GND

  BT RX (through a voltage divider) to Arduino TX1 (pin 18)

  BT TX  to Arduino RX1 (no need voltage divider)   (pin 19)

This is the code I run: (from the tutorial)

// Basic Bluetooth test sketch 5a for the Arduino Mega.
// AT mode using button switch
// HC-05 with EN pin and button switch
//
// Uses serial with the host computer and serial1 for communication with the Bluetooth module
//
//  Pins
//  BT VCC to Arduino 5V out. Disconnect before running the sketch
//  BT GND to Arduino GND
//  BT RX (through a voltage divider) to Arduino TX1 (pin 18)
//  BT TX  to Arduino RX1 (no need voltage divider)   (pin 19)
//
// When a command is entered in to the serial monitor on the computer
// the Arduino will relay it to the Bluetooth module and display the result.
//

char serialByte = '0';
const byte  LEDPIN = 13;

void setup()
{
    pinMode(LEDPIN, OUTPUT);

    // communication with the host computer
    Serial.begin(9600);

    Serial.println("Do not power the BT module");
    Serial.println(" ");
    Serial.println("On the BT module, press the button switch (keep pressed, and at the same time power the BT module");
    Serial.println("The LED on the BT module should now flash on/off every 2 seconds");
    Serial.println("Can now release the button switch on the BT module");
    Serial.println(" ");
    Serial.println("After entering AT mode, type 1 and hit send");
    Serial.println(" ");

    // wait for the user to type "1" in the serial monitor
    while (serialByte !='1')
    {
        if ( Serial1.available() )   {  serialByte = Serial1.read();  }
    }

    // communication with the BT module on serial1
    Serial1.begin(38400);

    // LED to show we have started the serial channels
    digitalWrite(LEDPIN, HIGH);

    Serial.println(" ");
    Serial.println("AT mode.");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("The HC-05 accepts commands in both upper case and lower case");
    Serial.println(" ");
}

void loop()
{
    // listen for communication from the BT module and then write it to the serial monitor
    if ( Serial1.available() )   {  Serial.write( Serial1.read() );  }

    // listen for user input and send it to the HC-05
   if ( Serial.available() )   {  Serial1.write( Serial.read() );  }
}

I want to mention that the baud rate is set to 9600 and Both NL & CR is also set.

The problem is when I insert 1 in the Serial Monitor and nothing happens. How can I solve this problem?


texts:
Im currently moving a servo from one side to another by using the typical for loop like this:
int lightON = 180;
int lightOFF = 90;

if (buttonState == HIGH) {

  digitalWrite(LED, HIGH);
  for (pos1 = lightOFF; pos1 <= lightON; pos1 += 1) {
    servo1.write(pos1);
    delay(15);
  }
  digitalWrite(LED, LOW);

}

That would be moving the servo one way and if I push the button again the servo would move another way.
if (buttonState == LOW) {

  digitalWrite(LED, HIGH);
  for (pos1 = lightON; pos1 >= lightOFF; pos1 -= 1) {
    servo1.write(pos1);
    delay(15);
  }
  digitalWrite(LED, LOW);

}

The thing is, I have this very same code in 3 other servos and I don't want to be repeating the same code with 2 different variables (pos and servo) over and over again, so I tried
void runServoLight(int pos, int light1, int light2, Servo servo, int state) {

  if (state == 1) {

  digitalWrite(LED, HIGH);

  for (pos = light1; pos <= light2; pos += 1) {
     servo.write(pos);
     delay(15);
  }

  digitalWrite(LED, LOW);

  } else if (state == 0) {

  digitalWrite(LED, HIGH);

  for (pos = light2; pos >= light1; pos -= 1) {
    servo.write(pos);
    delay(15);
  }

  digitalWrite(LED, LOW);

  }

}

Now instead of running the whole for loop code I only run:
runServoLight(pos1, lightON, lightOFF, servo1, 1);

The problem is that it doesn't seem to work and I can understand why, I may be writing the function wrong but im nor really sure. I would really appreciate some help. Thank you!


texts:
I have written a code for my Arduino which spans multiple files, In the file containing the main task, i have a Global Array like this

addr_t childAddr[NUM_CHILDS] = { CHILD1_I2C_ADDR, CHILD2_I2C_ADDR };

where

#define NUM_CHILDS  0x02
#define CHILD1_I2C_ADDR         0x10
#define CHILD2_I2C_ADDR         0x02

Now to debug my issue, in my Task i do this

Serial.print(childAddr[0]);
Serial.print(childAddr[1]);

All i receive is

00

I looked at the issue online, someone pointed it towards overshooting the RAM, I am working on a Pro Mini with ATmega328P with 2K RAM.


texts: Can I get the current connection speed with ESP8266?

texts: Using an ESP8266 I can get the RSSI of the Wifi network using Wifi.getNetworkInfo() or Wifi.RSSI(). But is there a way to know the actual connection speed in Mbps, after joining successfully a WiFi network?


texts:
I got a beginner level problem.
I got two esp2866 nodeMCU, they both work with the usb cable and I can get the blink program to run though it.
Running them with external power doesn't seem to work though. I expect the blink program to run when I plug them in but I get no led light signal at all. My power source looks identical to this. I got jumpers set on 5V. I don't have a voltage meter but I've tested against my Arduino Uno and it runs as expected when connected to the same wires.

Shouldn't I get the blink signal or any other led signal if the nodeMCU got power?
Any clue to how I could fail to provide power?

thank you!
edit: picture and jack barrel power input: 5V 3A


texts: Why use an int variable for a pin when const int, enum or #define makes much more sense

texts:
Why do people use a variable to specify a pin number when the pin is unlikely to change throughout the execution of the code?

Many times I see an int being used for a pin definition,

int led = 13;

when the use of a const int

const int led = 13;

or enum, or #define

#define LED 13

makes much more sense.

It is even in tutorials on the Arduino site, for example, the first tutorial that most people run, Blink.

I read somewhere that const int is preferred over #define. Why isn't this encouraged right from the beginning, rather than allowing people to develop bad habits, from the outset? I noticed it a while back, but recently it has started to irritate me, hence the question.

Memory/processing/computing wise is a const int, enum, or for that matter #define, better than a plain int, i.e. occupies less memory, stored in different memory (Flash, EEPROM, SRAM), faster execution, quicker to compile?

This may appear to be a duplicate of Is it better to use #define or const int for constants?, but I am addressing the question of why people use variables, and how does the performance improve when they don't, rather than which type of constant is better.


texts: Need help with an Arduino project using a RTC and LEDs

texts:
I need some help with a project I am doing involving the DS1307 RTC. I am trying to make what is essentially a way to mins quickly check the time which involves nine LEDs slowly lighting up every 10 so that I can quickly check time but looking at it. : So far I've tried TimeAlarms but I can't figure out how to do this. I have a Arduino Uno by the way.

Can someone possibly help?


texts: Inexpensive way of connecting a lot of modules on a distance

texts:
I need to connect a lot (~100) of modules with a computer (Raspberry pi). The modules are based on Arduino micro and are very simple. They will be spread around, but for the two adjacent the distance would not be larger than 2 meters.
From time to time they receive information from the computer and also can send some data back. So bandwidth requirement is small.

My first idea was connecting them in one i2c network. It would be fine, except I have figured out that i2c is not good for a distances. Signal degrades and communication is unreliable if works in the first place.

Second idea is the nrf24 network (mash). But I am not sure how reliable communication is with them? Wired seams more reliable.

What would you recommend? It needs to be as cheap as possible, because of number of modules. Reliability of communication is important. The bandwidth requirement is very small (1Kbps is enough). Also modules are not battery powered so no need to be low power option.

What is the best way of doing this?

EDIT:
Network topology (it can be changed):

simulate this circuit – Schematic created using CircuitLab


texts: Can Arduino Sketch be used for production

texts:
There are lot of device support with the help of Boards Manager today and is on going in Arduino IDE.
So I am curious to know about can one use those for production purpose. Or it is recommended for quick prototyping purposes only...


texts:
I'm using the SIM800L module but i've problems. I'm triying to connect it to the Elegoo UNO i've, but it restarts at all times. Also the led of signal strengh blink every second, so i dont get signal.

I also upload a video to Youtube to explain the problem, this is the link.

Thanks in advance!


texts: How to interface ESP8266-01 Wifi Module with Arduino Uno

texts:
I have an Arduino Uno and ESP8266-01 Wifi module with me currently. So I'm going to use ESP8266 to connect to the MQTT broker to allow me publish data to other devices. However, I have a problem with uploading my sketch due to the following error:

error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

I uploaded the example sketch WIFIScan provided by Arduino IDE to test ESP8266 whether working or not, so the code is not a problem. This is how I connect ESP8266 to the laptop.

The Arduino Uno is connected to my laptop through USB port.


texts: How come people connect their arduinos to buzzers without any coil protection?

texts:
If you connect your arduino to a motor you use this schematic:

However, when it comes to buzzers, which also have a coil, no one protects the circuit:

What the hell is going on? Are these just buzzers "coiless"? How can I find the type of buzzer I have?


texts: What is the necessity of "Prototyping Shield" for an arduino UNO R3?

texts: I just want to learn Arduino and make some  small projects. But in  the beginner starter kit there's  a part named Prototyping Shield. Is it necessary or will it help me?


texts:
After experiencing failures of my Arduino projects due to low memory, I decided to do some research into it so I could understand better where the problems were. I eventually came to this code:

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

  int len = 5000;
  byte *data = (byte *)malloc(len * sizeof(*data));
}

void loop() {
  int timing = 1000;
  delay(timing);
  digitalWrite(13, HIGH);
  delay(timing);
  digitalWrite(13, LOW);
}

I expected that since my Arduino Uno does not have enough RAM to hold an array of 5000 bytes (Atmel's information on the Atmega328P shows us it only has 2KB of SRAM), the code in void loop() would not be able to run due to lack of memory. As far as my understanding goes, once malloc has allocated 5000 bytes (or as many as it could of the 5000 bytes), there would physically not be enough space left in memory for the variable timing and the LED I attached on pin 13 would not flash on and off at intervals of 1 second.

However, my LED toggles at perfect intervals of 1 second. Why would this occur? Isn't memory allocated by malloc unavailable for use by anything else until free is called on it?


texts:
Do ultrasonic sensors sense through transparent materials?

In my case, I have to read if there's something inside a transparent acrylic bottle.


texts: How to not wait for USB to become active?

texts:
EDIT: My original question was a bit "off" since the Arduino Nano I was using appeared to be faulty. This edited question is based on my other Arduino Nano which is working.

When I plug my Arduino into the PC, it keeps blinking it's LED until I open the Serial Monitor.

After opening the serial monitor the Arduino will start to execute my code.

How can I get my Arduino to "not wait on a connection", or simply put, start whenever it receives power.

I believe it's the bootloader which somehow doesn't time-out (I'm not sure if that's how the bootloader works).

The code below (though I don't see why this would make it hang until a connection):

void setup() {
  // put your setup code here, to run once:
  Serial.begin(256000);
  Serial.write("Restart");
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {
    incomingByte = Serial.read();

    // say what you got:
    startSend();
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
    stopSend();
  }else{
    startSend();
    Serial.println("I'm still standing");
    stopSend();
    delay(400);
  }
}

(Code is only for testing purposes)


texts:
Im having some problems with parsing gps coordinates with the arduino ide.

To be honest I want to process the data without a library.

From my sensor I get this String: 4815.98450

The result of String.toDouble(): 4815.9843750

I also parsed it on my own, but i got the same result: (yes this code is not nice ;))

char buf[10];
  msg.toCharArray(buf, 19);
  double num = 0.0;

  int c;

  c = buf[0] - '0';
  double num0 = (c * 1000);
  c = buf[1] - '0';
  double num1 = (c * 100);
  c = buf[2] - '0';
  double num2 = (c * 10);
  c = buf[3] - '0';
  double num3 = (c * 1);
  c = buf[5] - '0';
  double num5 = (c * 0.1);
  c = buf[6] - '0';
  double num6 = (c * 0.01);
  c = buf[7] - '0';
  double num7 = (c * 0.001);
  c = buf[8] - '0';
  double num8 = (c * 0.0001);
  c = buf[9] - '0';
  double num9 = (c * 0.00001);
  num = num + num0;
  num = num + num1;
  num = num + num2;
  num = num + num3;
  num = num + num5;
  num = num + num6;
  num = num + num7;
  num = num + num8;
  num = num + num9;

Does somebody have a solution for my problems?

Thank you very much :=)


texts: C3 not declared in this scope when running MIDI example code

texts:
I'm trying to run the MIDI example from Arduino.CC in Arduino Studio.

I am using an Arduino Leonardo, which has USB HID capabilities. I have installed the library as mentioned:

When I press the compile or upload button, it says:

'D3' was not declared in this scope

What's wrong? How do I fix this?


texts: Has anyone here setup an MQTT Broker on an Arduino?  I am looking to use pubsubclient to send sensor data from 12 individual wireless sensors to an Arduino every 250ms.  I know this can be done using a Raspberry Pi, but I am new to all this and am just now comfortable with programming an Arduino.  I also looked at using XBee, but have heard it may not be able to handle the data frequency.  I am only sending 1 byte of data from each sensor each time.  Any help or suggestion is appreciated.


texts:
I've been learning how to program this fine piece of equipment but i seem stuck. I came upon the "Knight rider" example where you are supposed to blink LED's from one side to another and i can't understand where some of the code comes from. For example:

byte ledPin[] = {4,5,6,7,8,9,10,11,12,13};
int ledDelay;
int direction = 1;
int currentLED  = 0;
unsigned long changeTime;
int pot = 2;
int i;

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

    for (i = 0; i < 10; i++)
    {
        pinMode(ledPin[i], OUTPUT);
    }

    changeTime = millis();
}

void loop()
{
    ledDelay = analogRead(pot);

    if ((millis()- changeTime) > ledDelay)
    {
        changeLED();
        changeTime = millis();
    }
}

void changeLED()
{
    for (i = 0; i < 10; i++)
    {
        digitalWrite(ledPin[i], LOW);
        Serial.print("i = ");
        Serial.println(i);
    }

    digitalWrite(ledPin[currentLED], HIGH);

    currentLED += direction;

    if (currentLED == 9)
    {
        direction = -1;
    }

    if (currentLED == 0)
    {
        direction = 1;
    }
}

In this code I don't  know where the "direction" variable is coming from I searched on the arduino reference page but can't find it. Are there other references where I could look or am I misunderstanding something?


texts:
My LCD info is called from an IF statement but since it's clock and temperature info i don't want to just show the information but update the information constantly in real time.
i don't want to use (while) loop or any other "code-blocking".

Here's the whole code:

#include <OneWire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2
int Heater= 3;
int Switch1= 4;

Time t;
LiquidCrystal_I2C lcd(0x27, 16, 2);
DS3231  rtc(SDA, SCL);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Push button

boolean oldSwitchState = LOW;
boolean newSwitchState = LOW;
boolean lcdScroll = LOW;
boolean lcdBacklight = LOW;
boolean lcdWelcome = LOW;

unsigned long previousMillis = 0;
const long BacklightTime = 10000;

void setup() {
  Serial.begin(115200);
  pinMode(Heater, OUTPUT);
  pinMode(Switch1, INPUT);
  lcd.begin();
  rtc.begin();
}
void loop() {
  float testTemp = sensors.getTempCByIndex(0);
  sensors.requestTemperatures();
  t = rtc.getTime();
  if(lcdWelcome == LOW){
      lcd.setCursor(0,0);
      lcd.print("Welcome, Admin!");
      lcd.setCursor(0,1);
      lcd.print("press Start");
  }

  // LCD
  newSwitchState = digitalRead(Switch1);
    if (millis() - previousMillis >= BacklightTime) {
      lcd.noBacklight();
      lcdBacklight = LOW;
    }
    else if ( lcdBacklight == LOW ){
      lcd.backlight();
      lcdBacklight = HIGH;
    }
    if ( newSwitchState != oldSwitchState ) {
       if ( newSwitchState == HIGH ){
       previousMillis = millis();
       lcdWelcome = HIGH;
       lcd.clear();
      if ( lcdScroll == LOW ){
        lcd.setCursor(0,0);
        lcd.print(testTemp);
        lcd.print("   ");
        lcd.print(rtc.getTimeStr());
        lcdScroll = HIGH;
      }
      else{
        lcd.setCursor(0,0);
        lcd.print(rtc.getDOWStr());
        lcd.print("   ");
        lcd.print(rtc.getDateStr());
        lcdScroll = LOW;
      }
       }
       oldSwitchState = newSwitchState;
    }
}

How can i update the functions inside the if(lcdScroll == LOW){} and else{} statements constantly to show on display?


texts:
I have 2 Arduino Unos, 2 XBees and 2 Wireless Proto Shields. The first setup has a humidity/temperature sensor (SHT21P) and it writes data to serial and it works (I've tested it).

Now, the other Arduino with shield and XBee is plugged in my PC to get data from the sensor. So here's the problem: as far as I understand, I can't use XBee and Arduino at the same time, because USB and Arduino both use TX/RX pins to communicate to PC/XBee. I've tested both of the XBees when they are powered with DC jack and they both work. So can anyone confirm that it's true that they're not made for being used by PC and Arduino at the same time? If so, how can I get the data to my computer?


texts: Transient buttons control non-transient behaviour of LEDs

texts:
Imagine a system where you have two transient non-exclusive buttons and two LEDs.

When you press button 1, the LED 1 is HIGH and LED 2 is LOW (and stays that way).

When you press button 2, the LED 1 is LOW and LED 2 is HIGH (also stays that way).

Which C++ code allow me, to keep the LED 1 turned on indefinitely (until button 2 is pressed)?

Basically, my problem is, that the buttons are transient and the behaviour of LEDs shouldn't be.

Here is code, that would work for pernament exclusive buttons, but doenst work for transient non-exclusive buttons.

if (digitalRead(button1) == HIGH)
{
    led1 = HIGH;
}
else
{
    led2 = LOW;
}
if (digitalRead(button2) == HIGH)
{
    led2 = HIGH;
}
else
{
    led2 = LOW;
}


texts: Regarding turning exact 180 degrees using an MPU6050

texts:
I want to turn robot exact 180 degrees by using an MPU6050. This is the code I tried. Can anyone help me?

#include <MPU6050_tockn.h>
#include <Wire.h>

#define enA 9
#define in1 4
#define in2 5
#define enB 10
#define in3 6
#define in4 7

MPU6050 mpu6050(Wire);

void setup() {
  Serial.begin(9600);
  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
  setupmotor();

}

void setupmotor(){
    pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

}

void loop() {
updatempu();

while(mpu6050.getAngleZ()== 180 || mpu6050.getAngleZ()== -180 ){
       turn();
  }

}

void updatempu(){
    mpu6050.update();
  Serial.print("\tangleZ : ");
  Serial.println(mpu6050.getAngleZ());

}

void turn(){
  Serial.println("turn");
        digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);
      digitalWrite(in4, LOW);
    digitalWrite(in3, HIGH);
      analogWrite(enA, 100); // Send PWM signal to motor A
  analogWrite(enB, 100);
}

void stp(){
    Serial.println("stop");
        digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);
      digitalWrite(in4, LOW);
    digitalWrite(in3, LOW);

}


texts:
I bought a few MCP4651 dual 8 bit I2C pots for a project. After browsing the arduino libraries and finding nothing,"No big deal" I thought to myself ... I've already written I2C libraries for other parts that were much more complicated! (e.g: ADS1219 24 bit ADC)! so just load up the datasheet and watch the memory maps and commands! ok, there are some stuff on page 49 which seem useful! oh boy was I ever wrong! this data sheet looks like nightmare! the worst documentation for any I2C device I've seen so far. The commands I wrote based on that did absolutely nothing!

I found a code for controlling an I2C pot in one of the arduino examples which is something like this:

#include <Wire.h>

void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
}

byte val = 0;

void loop() {
  Wire.beginTransmission(44); // transmit to device #44 (0x2c)
  // device address is specified in datasheet
  Wire.write(byte(0x00));            // sends instruction byte
  Wire.write(val);             // sends potentiometer value byte
  Wire.endTransmission();     // stop transmitting

  val++;        // increment value
  if (val == 64) { // if reached 64th position (max)
    val = 0;    // start over from lowest value
  }
  delay(500);
}

I decided to just try it and see what happens (changed the address to the correct value) and crazy enough it actually worked! so I hacked this piece of code to get the first pot to work!

void setPot0(int n){
  if (n>256) n=256;
  if (n<0) n=0;
  Wire.beginTransmission(address);
  if (n<256){
    Wire.write(0x00);
    Wire.write(n);
  } else{
    Wire.write(0x01);
    Wire.write(0);
  }
  Wire.endTransmission();
}

and somehow this works! I still can't find this pattern in any of the pages on datasheet, but hey! it works so I'm not gonna complain about that?
I still haven't managed to make the pot1 to work, only pot0 ... if you can make sense of how the commands and data bytes should be like, please help me. It's so much more clear in T.I datasheets; you just use the command to write to the register you want and they detail what each register does:

Edit: here is a link to the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/22096b.pdf


texts:
I am a beginner to electronics and trying to make a portable air conditioner using a Peltier cooling pad (12V). I am planning on using a solar panel to power the Peltier and looking forward to your expert opinion  for below;
- Is this possible?
-What the specifications I have to consider prior to purchasing the solar panel?
- What is the weight of the solar panel?
- Can I operate the Peltier through an Arduino using Solar panel as the power source( without using batteries to power Arduino and Peltier). My idea is to control the Peltier cooler via Arduino using a phone App.
Really sorry if these questions are basic, yet your guidance will be very much helpful for me as well as for the other beginners like me.


texts: OSX upload error: avrdude: ser_open(): can't open device "/dev/cu.mydev" : Resource Busy

texts:
I'm trying to upload the blink script to my unnamed Arduino-like board. However, the USB port appears to be busy.

This is all the output I get:

Archiving built core (caching) in: /var/folders/43/7_h5zwcs1csdr2dc635m1yq40000gp/T/arduino_cache_942504/core/core_arduino_avr_uno_51f02b7210b938436b779d1c032618e1.a
De schets gebruikt 928 bytes (2%)  programma-opslagruimte. Maximum is 32256 bytes.
Globale variabelen gebruiken 9 bytes (0%) van het dynamisch geheugen. Resteren 2039 bytes voor lokale variabelen. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "/dev/cu.mydev": Resource busy

I've tried all solutions I could find on internet, but they haven't solved my issue. The main difference with my error and online solutions/errors is that I only have this error. Other people experienced extra errors which enabled the debugging of the problem.

Can anyone help me please?


texts: TinyGPS++ Question about gps.encode(ss.read())

texts: I am trying to make an oled gps display, however when looking at multiple examples and other people's code, I am seeing that people are using different methods. I see some code that has gps.encode(ss.read()); and other people use if gps.encode(ss.read()). I am confused on why this is. Also, people either use .isUpdated, or .isValid, when checking for location/speed, etc. On the TinyGPS++ page it talks about these, but does not say what should be used for certain applications.


texts:
I have a circuit with a blue led, 470ohm resistor and one IR led. I want the led to be switched off when the IR led has a digitalRead value of LOW(i move my hand over it). So I wrote the code:-

void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT); // this is the blue led
pinMode(10, INPUT);  // this is the IR sensor's O/P

}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // first I give HIGH voltage to the blue LED

if(digitalRead(10) == LOW){  // when the voltage of the IR sensor decreases
digitalWrite(13, LOW); // the blue LED should switch off or have 0 Voltage
}

}

But the blue LED just dims and doesn't switch off. Thanks in advance


texts:
I want to read strings from Serial.read() to send them later.

To get the data from the Serial monitor I'm doing this:

String stringOne  = "";
int  incomingByte;

if (Serial.available() > 0) {

  while(Serial.available() > 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

  Serial.println(stringOne);
  stringOne = "";

The issue is that when I type:

'a'

I got:

'97'

for
    'abc'

I got

'979899'

so on and so forth.

What should I do in order to get the same string I type?


texts: Arduino mega board 5v pin does not gives 5v when 7.5v is applied through external source

texts:
I gave 7.5v to the arduino mega board through battery. 5v pin in the board gives me the same voltage as input. Earlier it was working fine now it is giving problem.Please let me know the solution as soon as possible.

Thanks and regards,
Thippeswamy


texts:
I have an Arduino Uno Rev. 3 and I'm trying to make it so that the Arduino can send a key press / mouse action to the computer. However, these libraries are restricted to a few other versions of the board. Is there another alternative method to doing this without actually pressing any buttons/interacting with the arduino other than USB? Thanks!
Link


texts:
In my project I need to convert a string to a char array. From various examples I concluded that toCharArray() will convert a string to a char array. But I failed to do so. The error is:

  'a' does not name a type

The code I am using is:

String a = "45317";
char b[6];
a.toCharArray(b,6);

Resources are https://www.arduino.cc/en/Reference/StringToCharArray and http://forum.arduino.cc/index.php?topic=199362.0


texts: How can I stop someone from hacking in to my Arduino via Bluetooth?

texts: I am using an HC-05 bluetooth Module. How can I stop someone from pairing with my device by brute forcing the key? Failing that, and if someone does pair with my device, is there a way to authenticate the user? I was thinking of salted hash with a shared secret key. Is there anything better?


texts: Parsing and comparing strings on Arduino: different behaviour from gcc?

texts:
I am trying to parse a simple string, print the result of the parsing via serial.println, and trigger a function on the basis of the received command. I wrote the code below, which perfectly works in c (see the c file attached). However, the behaviour of the same code on the arduino IDE is completely different and I really can't figure out why.

#include <string.h>

void rcv_msg(char *rcv_msg) {

  char *all_tokens[2];
  int i = 0;

  all_tokens[i] = strtok(rcv_msg, "{,}");
  while (all_tokens[i] != NULL) {
    all_tokens[++i] = strtok(NULL, "{,}");
  }

  char *command = all_tokens[0];
  char *value = all_tokens[1];

  /*
  //These printls do not work, they are ignored, why?
  Serial.println("all_tokens[0]: ");
  Serial.println(all_tokens[0]);
  Serial.println("all_tokens[1]: ");
  Serial.println(all_tokens[1]);
  */

  if (strcmp(command,"message_1") == 0 && strcmp(value,"1") == 0) {

    Serial.println("message 1: ");
    Serial.println(command);
    Serial.println(value);
    Serial.println(" ");

  }

  if (strcmp(command,"message_2") == 0 && strcmp(value,"0") == 0) {

    Serial.println("message 2: ");
    Serial.println(command);
    Serial.println(value);
    Serial.println(" ");

  }
}

void setup() {

    Serial.begin(115200);
}

void loop() {

    char msg1[] = "{message_1,1}";
    char msg2[] = "{message_2,0}";

    Serial.println("Send msg1: ");
    rcv_msg(msg1);
    delay(5000);

    Serial.println("Send msg2: ");
    rcv_msg(msg2);
    delay(5000);
}

This code gives the following output on the serial monitor, which is wrong:

Send msg2:
message 2:
message_2
{message_2,0}

Send msg1:
message 2:
message_1
{message_2,0}

Send msg2:
message 2:
message_2
{message_2,0}

Send msg1:
message 2:
message_1
{message_2,0}

Firstly, I don't understand why at the beginning, message 2 is printed before message 1, although message 1 was sent first. Second it is not clear to me the comparison done with strcmp is always returning the message 2.

More importantly, why running the same code in c has instead the correct output? I wonder if there is any error in my arduino code. BTW, I am testing the code on Teensy 3.2 but I plan to use it also on Arduino Uno.

The c code (which is perfectly working is this:

#include <string.h>
#include <stdio.h>

void rcv_msg(char *rcv_msg) {

    char *all_tokens[2]; //NOTE: the message is composed by 2 tokens: command and value
    int i = 0;

    all_tokens[i] = strtok(rcv_msg, "{, }");
    while (all_tokens[i] != NULL) {
        all_tokens[++i] = strtok(NULL, "{, }");
    }

    printf("all_tokens[0] : %s \n", all_tokens[0]);
    printf("all_tokens[1] : %s \n", all_tokens[1]);

    char *command = all_tokens[0];
    char *value = all_tokens[1];

    printf("command : %s \n", command);
    printf("value : %s \n", value);

    if (strcmp(command,"message_1") == 0 && strcmp(value,"1") == 0) {
        printf("activating command : %s %s \n\n\n", command, value);
    }

    if (strcmp(command,"message_2") == 0 && strcmp(value,"0") == 0) {
        printf("activating command : %s %s \n\n\n", command, value);
    }
}

int main() {

    char msg1[] = "{message_1, 1}";
    char msg2[] = "{message_2, 0}";

    rcv_msg(msg1);
    rcv_msg(msg2);

}


texts: Modbus Communication protocol for Arduino as Slave

texts:
I have an Arduino Uno board, with these components:

rs-485 Modbus module shield
Multiprotocol radio shield board for Arduino

In addition I have a level sensor which reads either 1 when it is above water, and 0 when it is below.

I need to be able to give the value of this sensor to a modbus master over rs485.

Cooking Hacks Tutorial

This page has a description of how to use the ModbusMaster485 library, but I can not find any information about the slave library.

I can not find any documentation for this library, and would really appreciate any pointers.


texts: How to get read user input from DAQ for a given time interval?

texts:
I'm using a built-in DAQ simulator. When it opens, it shows 3 different LEDs with 3 pushbuttons,  one corresponding to each LED.

I'm trying to read the user input from 3 pushbuttons for a time interval of 5 seconds. However when I use digitalRead() (from <DAQ.lib>) it only reads input at that instant in time, not continuously for the entire time interval.

As well, I can't figure out how to get the program to wait for entire button press - right now it only reacts when the button is pushed down, but it should react after the button is pushed down then released.


texts:
I'm trying to use the MS5803 pressure sensor with a Teensy 3.2. Compiling the Sparkfun, or other, libraries, however, results in no output.

Can you provide guidance on how to modify the libraries to work with the Teensy (t3_i2c)?


texts: Arduino Uno CTC mode interrupt is not tiggering

texts:
I am trying to generate LED blink after 4 second using Interrupt  but Interrupt is not triggering not even once .
Request: if you have arduino uno r3 please check at your end and let me know result.
I have read Timer counter section multiple times and applied everything i can for example :-

Enabled Global Interrupt
Select CTC Mode
Enable Interrupt for OCIE0A
Prescaling to clk/1024
Initializing OCR0A
When OCR0A equal TCNT0 ,interrupt will generate

int var;
void setup() {
  // put your setup code here, to run once:
    SREG = SREG | (1<<7);          // Gloval interrupt enable
    TCCR0A = TCCR0A | (1<<WGM01); // Clear counter on compare match mode
    OCR0A = 255; // when TCNT equal OCR0 interrupt will generate
    TIMSK0 = TIMSK0 | (1<<OCIE0A); //  Output Compare Match A Interrupt Enable
    TCCR0B = TCCR0B | (1<<CS01) | (1<<CS02);  // Prescaling by 1024
    DDRB = DDRB | (1<<5);
    Serial.begin(9600);      // Testing
    Serial.println("Start");   // Testing
}

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

}

ISR(TIMER0_COMPA_vect){
    var++;
    Serial.print(var); // Testing
    volatile long unsigned i;
    if(var == 246){
        PORTB = PORTB | (1<<5);
        for(i=0; i<30000; i++);
        PORTB = PORTB & ~(1<<5);
        for(i=0; i<30000; i++);
        var=0;
    }
}

clock is 16 00 00 00 Hz
Prescaling by 1024 = 15625
1 Tick = 1/15625 = 0.00 00 64 sec
OCR0 is initialized by 255
TCNT0 Ticks to 255
Total time taken to generate one interrupt = 255 * 0.00 00 64 =
0.01632 sec that means after every  0.01632 sec Interrupt supposed to generate
How many interrupt is required to generate LED after 4 sec =>
4/0.01632 = 246

Update working code

int var;
void setup() {
  // put your setup code here, to run once:
  SREG = SREG | (1<<7);          // Gloval interrupt enable
  TCCR0A =(1<<WGM01); // Clear counter on compare match mode
  OCR0A = 255; // when TCNT equal OCR0 interrupt will generate
  TIMSK0 = (1<<OCIE0A); //  Output Compare Match A Interrupt Enable
  TCCR0B = (1<<CS00) | (1<<CS02);  // Prescaling by 1024

  DDRB = DDRB | (1<<5);

    Serial.begin(9600);      // Initialize the USART
    Serial.println("Start");   // Write the welcome message

}

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

}

ISR(TIMER0_COMPA_vect){
  var++;
 // Serial.print(var);
  volatile long unsigned i;
  if(var == 246){
        PORTB = PORTB | (1<<5);
        for(i=0; i<300000; i++);
        PORTB = PORTB & ~(1<<5);
        var=0;
  }
}


texts: Blinking LEDs as fast as possible at different rates.

texts:
I'm trying to use the Arduino Uno to make a strip of LEDs blink as fast as they can while still blinking at different rates. I am able to get them blinking at different rates but the blinking is very slow:

#include <Adafruit_DotStar.h>
#include <SPI.h>         // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET

#define NUMPIXELS 144 // Number of LEDs in strip

// Here's how to control the LEDs from any two pins:
#define DATAPIN    11
#define CLOCKPIN   13
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);

void setup() {
strip.begin(); // Initialize pins for output
strip.show();  // Turn all LEDs off ASAP
}

  int brightness = 1; //Setting brightness of all LEDs

   void loop() {

  for(int i=1; i<6; i++)
//This loop is here so the number i can be used below to get different blink     //rates for the 3 LEDs blink at the same time
  {
    if(i%2==0){

    strip.setPixelColor(0, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(0, 0);
    }
    //Sets blink rate of first LED, will be the fastest

    if(i%3==0){

    strip.setPixelColor(1, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(1, 0);
    }
     //Sets blink rate of second LED

    if(i%4==0){

    strip.setPixelColor(2, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(2, 0);
    }
     //Sets blink rate of third LED

   strip.show();
  }
  }

I thought I would be able to make them blink as fast as possible by using the micro() function as my counter instead of the i in the for loop, but this led to strange behavior:

#include <Adafruit_DotStar.h>
#include <SPI.h>

#define NUMPIXELS 144 // Number of LEDs in strip

// Here's how to control the LEDs from any two pins:
#define DATAPIN    11
#define CLOCKPIN   13
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);

void setup() {

  strip.begin(); // Initialize pins for output
  strip.show();  // Turn all LEDs off ASAP

  Serial.begin(9600);
}

int brightness = 1;

void loop() {

    int time = micros();

    if(time%2==0){

    strip.setPixelColor(0, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(0, 0);
    }

  if(time%3==0){
    strip.setPixelColor(1, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(1, 0);
    }

   if(time%4==0){
    strip.setPixelColor(1, brightness, brightness, brightness);
    }
    else
    {strip.setPixelColor(2, 0);
    }

   strip.show();
}

This led to the first LED appearing on (good, presumably I wouldn't be able to see it blinking) and the second blinking at a rate I could see (I shouldn't be able to see this) and the third LED is not on at all.

Can anyone see the mistake I'm making? Am I using the micro() function right?
Thank you!


texts:
I want to send some data to an IP Modem from Arduino Uno. That IP Modem has TTL levels TX and RX inputs.

I used this connection between Arduino to the IP Modem:

I am powering Arduino with 12 V plugged in the barrel.

This is the photo of the connections:

I connected the PC to the USB connector of Arduino and I uploaded the following sketch to send "AABB" to the Modem:

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

void loop(void) {
 Serial.print("AABB");

 delay(5000); // Envía la temperatura cada 5 segundos
}

When monitoring what is received by the modem, it is

0x5F 0x5F 0xAF 0x2F

If I send just "A", the character received each 5 seconds is 0x5F.

Of course, both ends are configured as 115,200bps, 8N1.

In order to discard Modem problem, I connected RX, TX and GND in Arduino to a DB9 female connector and then to a RS232 - USB converter and started monitoring with my PC.

My surprise was that the data received is exactly the same as the received by the modem when it was connected. As seen in the following picture:

As you see in the picture, "_" twice was shown (ASCII 0x5F), {\xaf} and finally "/" (ASCII 0x2F).

Above test confirms Arduino is sending wrong data.

Something to note. When I monitor using USB cable connected to Arduino and using Monitor Serie in the Arduino IDE, I  see correctly "AABB". The problem is when using TX and RX pins (the same happened if I used other pin along with SoftwareSerial library)

What may be going on?


texts: Is it possible to see a graphical view of digital and analog pin values?

texts:
Using Visual Studio for my Arduino project I am struggling to know the states of various pins during operation.

I do use the Visual Micro debugger but I don't want to have to set a watch for every pin.

How can this be done easily?


texts:
Problem:

In short, the Arduino IDE won't compile a sketch for the Teensy 3.6. It gives the error:

exec: "A:\\arduino-1.8.5\\hardware\\teensy/../tools/teensy_post_compile": file does not exist
Error compiling for board Teensy 3.6.

What I have tried

-Re-installing teensyduino (And yes, I have it installed, along with a compatible Arduino IDE (version 1.8.5))

-completely wiping the IDE and re-installing

-using a different USB cable

Other information

The OS I'm using is Windows 10

A broken Teensy is not out of the question, as I have been doing some soldering on it and I may have slipped or something, although I don't think that's the problem

Thanks in advance.


texts: How to read data from a rotary encoder with ATmega328

texts:
I'm using a home made "bare bones" Arduino, made with the ATmega328, and I need to read angle data from a geared DC drill motor, turning at speeds between 0 and 450 RPM. This is so I can use it as feedback for an angle control system implemented on the Arduino.

I've not yet bought the encoder. I'm waiting until I find a suitable one which works easily with Arduino.

I have already written the control algorithm. I'm using state variable feedback, and the algorithm depends on a getAngle() function that I have not written yet. This function is inside an if statement that executes every 0.2 seconds. It needs to return the angle of the DC motor in degrees.

My questions:

How can I implement this getAngle() function using a rotary encoder?
What is an example of a rotary encoder that is suitable for this application?
Will it be better to use the interrupt pins of the Atmega328, or use some other method?

I have seen a few library's on Arduino Playground that claim to make reading angle data easier, but how do I use them? I need something that is fast (it, and the control algorithm operations, both needs to finish before the 0.2 seconds sample time), and more importantly it needs to be easy to implement. I'm coming up to the project deadline so I don't want to have to spend a whole day figuring out how to implement this getAngle() function.

Thank you!


texts:
It seems that I can't get the DC Motor function to work while also having servos driven off the other ports :(

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

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor
int spead =220;//define the spead of motor

Servo SteeringServo;  // create servo object to control a servo

void setup()
{
  // Steering servo pin setup
  SteeringServo.attach(5);  // attaches the servo on pin 9 to the servo object

  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);

  Serial.begin(9600);

}

void forward()
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
     digitalWrite(pinI1,HIGH);
}
void backward()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(pinI1,LOW);
}
void left()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(pinI1,LOW);
}
void right()//
{
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
     digitalWrite(pinI1,HIGH);
}
void stop()//
{
     digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
     digitalWrite(speedpinB,LOW);
     delay(1000);

}

void loop()
{
  left();
  delay(15000);
  stop();
  right();
  delay(1000);
 stop();
 // delay(2000); Already commented out
  //forward();
 // delay(2000);
 // stop();
// backward();
  delay(12000);
  stop();
}


texts: Arduino MKR GSM 1400: Can I tell from code if the power has tripped

texts:
Is there a way to tell if an Arduino MKR GSM 1400 has lost power and has to rely on the connected battery?
Ideally, I'd like to do this without adding additional circuitry. Alternatively, can I connect VIn to an analogue input pin?
On the schematic, there are two lines that seem promising. One named VBATT\2.4B that go into PB09 of U1 via a voltage divider and another named VBAT\1.4B. Also the BQ24195L is an I2C device which would probably be connected the the main micro controller.
What I need to do is to send an SMS as soon as the incoming power is lost to notify a user that the power supply has tripped. Does anyone have any code samples?


texts: Coding or Wiring? Dual Piezo sensor not triggering LED lights

texts:
I am running two piezos off an Arduino UNO and trying to get 10 LED lights to trigger when the piezo voltage exceeds a certain threshold. Problem is, the LEDs wont fire when the Piezo voltage exceeds that threshold and I'm not sure if it is a coding or wiring problem.

Below are pictures of the wiring (Top and bottom) and code. Any help is much appreciated!!

/*
  Dual Piezo Bond Auger Sensor; Blinking LED Light Stack Sketch

  -----------------------------------------------------*/

//Piezo 1 Pin (PiezoPin1)
//Piezo 1 connected to A0
int PP1 = 0;

//Piezo 1 Pin (PiezoPin1)
//Piezo 2 connected to A1
int PP2 = 1;

//Sets the threshold for the detected sound to trigger the LED
const int threshold = 0.01;

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

  for (int i = 4; i < 12; i++) {
    pinMode(i, OUTPUT);
    //sets the led pins 2-11 to output
  }
}

void loop() {
  //Ensure to turn off ALL LEDs before continuing
  for (int i = 4; i < 12; i++) {
    digitalWrite(i, LOW);
  }

  /* Read the Piezos
    Reads both piezos and outputs the values. Triggers LED lights
    to fire when a peak voltage is exceeded
    Adjust the value based on the peak signal voltage you
    want to trigger the LED lights*/
  int Piezo1ADC = analogRead(PP1); // Read Piezo 1 ADC value
  float Piezo1V = Piezo1ADC / 1023.0 * 5.0; // Convert to voltage
  int Piezo2ADC = analogRead(PP2); // Read Piezo 2 ADC value
  float Piezo2V = Piezo2ADC / 1023.0 * 5.0; // Convert to voltage
  Serial.println(Piezo1V); //Print the voltage from Piezo 1
  Serial.println(Piezo2V); //Print the voltage from Piezo 2
}

// The blink function - used to turn the LEDs on and off
void blink(int LEDPin11, int LEDPin2, int LEDPin3, int LEDPin4, int LEDPin5, int LEDPin6, int LEDPin7, int LEDPin8, int LEDPin9, int LEDPin10, int Piezo1V, int Piezo2V, int threshold) {
  if (Piezo1V >= threshold || Piezo2V >= threshold) {  //toggle status of LED pins linked to PP1
    // Blink the LEDs on for both Piezos
    { digitalWrite(LEDPin2, HIGH);
      // Delay so that you can see the LEDs go On.
      delay(10);
      // Turn the LEDs Off
      digitalWrite(LEDPin2, LOW);
      // Increase this Delay if you want to see an actual blinking effect.
      delay(10);
    }
    { digitalWrite(LEDPin3, HIGH);
      delay(10);
      digitalWrite(LEDPin3, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin4, HIGH);
      delay(10);
      digitalWrite(LEDPin4, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin5, HIGH);
      delay(10);
      digitalWrite(LEDPin5, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin6, HIGH);
      delay(10);
      digitalWrite(LEDPin6, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin7, HIGH);
      delay(10);
      digitalWrite(LEDPin7, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin8, HIGH);
      delay(10);
      digitalWrite(LEDPin8, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin9, HIGH);
      delay(10);
      digitalWrite(LEDPin9, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin10, HIGH);
      delay(10);
      digitalWrite(LEDPin10, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin11, HIGH);
      delay(10);
      digitalWrite(LEDPin11, LOW);
      delay(10);
    }
    { digitalWrite(LEDPin10, HIGH);
      delay(10);
      digitalWrite(LEDPin10, LOW);
      delay(10);
    }
  }
}


texts:
I'm making a Data Acquisition System for force impact usign an AD7606 from Analog Devices, an Arduino DUE and a load cell. I already tested it following this guide an making the proper changes for Arduino DUE and some potentiometers for simulating the input signals. I can read variable 1-5 V signals pretty good but when I tried to read mV signals from my load cell I can't see any changes in the Visuino Scope. I've read some forums and using an amplifier is recommended. However, when I read the AD7606 datasheet it says that since it has a High Analog Input Impedance and Internal amplifiers, a previous  amplification phase isn't needed. Also, I want to avoid the noise from the external amplifiers.

I also tested my load cell using the HX711 ADC and it works fine, but I can't use it for my application because of its limited sampling frequency (80 Hz). AD7606 can give up to 200 kilo samples per second.

Does any one knows if I'm missing something for my input signal? if an amplifier is really nedded can you recommend me one?

Thanks


texts: I've connected a strand of WS2811 to a 5V power supply and an Arduino Uno and no matter what I do the lights are always red. I'm using the fast led library and for some reason, the WS2811 lights are only red.


texts: How to communicate the Arduino board with SIM900?

texts:
I have a problem. I bought a SIM900 board, but I can not connect there with the Arduino. To send AT commands on the serial the SIM900 doesn't respond, but the LED indicating that the network is on. I've tried to change the baud rate of 9600 to 19200 in the firmware of the Arduino, but it still fails. I think I'm having a problem with the connections of the SIM900, since this board strikes me as obscure (could not find the schematic on the Internet)

The board I have is identical to this:

I'm 90% sure that I am connecting to the wrong pins. But I tried to reverse the jumpers and even some soldered pins on UART.


texts: What is more power efficient: GPRS or SMS for a GSM sim Arduino application?

texts:
I have a GSM shield for my arduino and am wondering the most efficient way to receive and send data to the cloud.

The specific project I am looking to accomplish is starting my car from a web browser (or custom built ionic mobile app) that will send data to my GSM shielded arduino and the arduino then "press the button" of an already installed remote car starter (which is all probably in the car's trunk).

What is more power efficient, sending and receiving a SMS (text message) or sending and receiving data via GPRS?

What is best when considering strategies like sleep, or deep sleep cycles?


texts: How to use H3LIS331DL 3-Axis Linear Accelerometer with arduino to detect Harsh braking of vehicle

texts:
I am a newbie here, Recently I was working with H3LIS331DL 3-Axis Linear Accelerometer I²C Mini Module

Here is code for the X, Y, Z-axis.

 #include <movingAvg.h>
 #include <Wire.h>

// H3LIS331DL I2C address is 0x18(24)
 #define Addr 0x18

       movingAvg xAxisAverage(5);

       int readingIndex=0;
       int readingArray[10];
       int firstFiveReadingAverage;
       int lastFiveReadingAverage;

    void setup()
   {

      // Initialise I2C communication as MASTER
         Wire.begin();
     // Initialise Serial Communication, set baud rate = 9600
        Serial.begin(9600);

    // Start I2C Transmission
       Wire.beginTransmission(Addr);
   // Select control register 1
      Wire.write(0x20);
  // Enable X, Y, Z axis, power on mode, data output rate 50Hz
     Wire.write(0x27);
  // Stop I2C Transmission
     Wire.endTransmission();

// Start I2C Transmission
   Wire.beginTransmission(Addr);
// Select control register 4
   Wire.write(0x23);
 // Set full scale, +/- 100g, continuous update
  Wire.write(0x00);
 // Stop I2C Transmission
  Wire.endTransmission();
  delay(300);

   }
 void loop()
 {

   unsigned int data[6];
   for(int i = 0; i < 6; i++)
  {
    // Start I2C Transmission
    Wire.beginTransmission(Addr);
    // Select data register
    Wire.write((40+i));
    // Stop I2C Transmission
    Wire.endTransmission();

    // Request 1 byte of data
     Wire.requestFrom(Addr, 1);
    // Read 6 bytes of data
    // xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
     if(Wire.available() == 1)
       {
       data[i] = Wire.read();
      }
    }
   delay(300);

     // Convert the data
       int xAccl = ((data[1] * 256) + data[0]);
       int yAccl = ((data[3] * 256) + data[2]);
       int zAccl = ((data[5] * 256) + data[4]);

    if(readingIndex<10)
  {
     readingArray[readingIndex]=xAccl;
     readingIndex++;
     if(readingIndex == 10)
  {
    firstFiveReadingAverage=(readingArray[0]+readingArray[1]+readingArray[2]+readingArray[3]+readingArray[4])/5;
    lastFiveReadingAverage= (readingArray[5]+readingArray[6]+readingArray[7]+readingArray[8]+readingArray[9])/5  ;
   if(lastFiveReadingAverage>firstFiveReadingAverage)
    {
     Serial.print("Hardbrake Pressed");
     Serial.println();
    }
     readingIndex=0;
    }
    }

  //int avg = avgAccl.reading(xAccl);
  // calculate the moving average

     // Output data to serial monitor
        Serial.print("Acceleration in X-Axis : ");
        Serial.println(xAccl);
        Serial.print("Acceleration in Y-Axis : ");
        Serial.println(yAccl);
        Serial.print("Acceleration in Z-Axis : ");
        Serial.println(zAccl);
        delay(300);
        Serial.println();

     int average=xAxisAverage.reading(xAccl);

    if (average < -1000)
    {
     Serial.print("Hardbraking: ");
    //Serial.print(average/100.0);
      Serial.print(average);
      Serial.println();
        }
       }

I have changed the code, but values are keeps on repeating when I trigger the hard braking and it keep on repeating even I released the brake.

Here is the output


texts: Create a device to detect object and voice alert what kind of object it is

texts:
Here is what I want to do (since I'm not a embedded guy)

create a prototype with an Arduino to detect objects using camera(object classification?)
that prototype will detect objects and alert that object's name

My questions are....

Is it possible? :)
What things should I use to create a prototype?
What camera should I use?
Is it related to image processing?
Connection between object detection and voice alert?


texts:
I am using 4 LDR To track the sun for solar panels. Not using servos, but linear actuators(a little irrelevant but just to give scope)

my code gets stuck in this while loop as soon as it enters it, even tho the conditions are changed to break the loop. I want to leave the motors running in one direction until the "dvert"=Vertical difference is less then "tol"=tolerance. there are 4 of these loops. there is an if condition before each. so no adjustment is made if its already in tolerance.

Segment of code

  if (avgtop > avgbot)
  {  Serial.println("enter avgtop > avgbot");
    Serial.println( "");

   while (abs(dvert) > tol)
     {
      Serial.println("Enter While loop vert up....");
      Serial.println("Moving Vertical Axis begin...Moving UP  ");

                   digitalWrite(vrelay1, HIGH);              // Setting frame down
                   digitalWrite(vrelay2, LOW);              // Setting frame down
      delay(200);
      int topl = analogRead(ldrtopl);
      int topr = analogRead(ldrtopr);
      int botl = analogRead(ldrbotl);
      int botr = analogRead(ldrbotr);
      int avgtop = (topl + topr) / 2; //average of top LDRs
      int avgbot = (botl + botr) / 2; //average of bottom LDRs
      int dvert = avgtop - avgbot; // check the diffirence of up and down

      Serial.print("NEW DVERT:"  );
      Serial.println(dvert);

  }  ```


texts:
I'm working on a project where I need 7 analog pins.
I read the datasheet of Ardnuino Uno : 6 analog pins available.
So I decided to use an arduino mega with 16 analog pin available.
Then I saw the arduino nano had 8 analog pins.
But when I read the datasheet, both arduino uno and nano use Atmega328
In my final project, I will not use the board but only the pdip chip (analog pins are from pin number 23 to 28).
Is it possible to "convert" another pin of the pdip to be an analog pin ?

Thank you


texts:
I'm fairly new to this and I need some help before I buy anything...

If I understand correctly I can buy an arduino, couple of shields and just stack them one onto another if they are compatible...

I'll be doing some work with an arduino and I would need both WiFi and GSM shields but I'm not sure if they're compatible... On the arduino.cc I saw that they both use pin 7 (GSM as modem reset and WiFi as "handshake")

Is there any way I can use both of the shields even though they use the same pin?

Thanks


texts: I get an error saying, "exit status 1 expected initializer before 'void'."

texts:
I will be wiring a switch to the Arduino that controls the voltage. When the I turn the switch it can adjust the voltage from 0 to 5. The overall task is to print the output voltage. The print is to be a multiplication table of the voltage.
I created this code:
void setup()

void loop(){

  int (n,i,j,result);

  printf("enter N Value");

  scanf ("%d", &n);

  for (i=1; i<=n; i++);

  {
    for (j=1; j<=n;j++);

    {
      result= (i*j);

      printf("%d", result);

    }
    printf("\n");

  }
  return 0;

}

But i get the error exit status 1
expected initializer before 'void' when I try to verify it. what does it mean. How do you fix it?


texts: Nano Every clone with ATMega4808 not recognized

texts:
I've bought an Arduino Nano Every clone/compatible (not a standard Nano V3) that uses an ATMega4808 instead of the ATMega4809 the official Nano Every uses. This rather insignificant change of chip is detected by the Arduino IDE (v. 1.8.13) which tells me that the chip is wrong when I select "Nano Every" from the boards list and try to upload a sketch. The seller (link to the product) does not answer to my help requests. Does anybody own one of these and knows how to make it run?
Below a photo of the board. Note the small difference in pinout (4 extra pin, D22, D23, D24 and UPDI)


texts: Can I share the VCC (5V) on my Arduino Pro mini with multiple modules?

texts:
Right now I am onto a new project where I am building an obstacle avoiding landrobot.

I use an arduino pro mini as my board and I have a few hc-sr04 sensors here at home. The problem I have right now is that many pins is occupied with other modules, motors and bluetooth.

So right now on my Pro Mini the VCC is occupied by my BLE device and I was wondering if there is a possibility to solder a few wires together so that my BLE device share the same VCC with 4 other hc-sr04 modules? I do this regularly with the GND where I solder multiple wires together and share the GND across different modules which works fine.

I have soldered a wire looking like this:

The idea is to power the arduino itself through the "RAW" pin. I have a power distribution board that connects to my battery/motor and the VIN pin of the PDB goes to the "RAW".

I try to avoid a breadboard to decrease the size as much as possible so if it were to be possible then that would be the optimal solution for this project.

Something I am also wondering is if it is possible to use these hc-sr04 on both the analog pins and also the digital pins. I do not have enough space to fit all the sensor cables on the digital pins but if I use the analog pins also then they all would fit. Is this possible? Each HC-sr04 has two cables that needs to be inserted (Trig and echo) and right now I have 3, 4 free and all the analog pins 0, 1, 2, 3, 4, 5 which is enough to fit them all.


texts:
I am trying to save a string/char to EEPROM with EEPROM.put() and then get the value, but it doesn't work and I get a blank value when I do a EEPROM.get().
I remember this is how it worked on arduino nano, but now I am trying with an ESP32 board, do they work different ?
#include <EEPROM.h>

char my_string[8];

void setup() {

  Serial.begin(115200);

// I am writing by this code, then comment it out to try to read from EEPROM
/*
    my_string[0] = 'S';
    my_string[1] = 'N';
    my_string[2] = '-';
    my_string[3] = 'A';
    my_string[4] = 'B';
    my_string[5] = 'C';
    my_string[6] = 'D';

  EEPROM.put(0, my_string);
*/

  EEPROM.get(0, my_string);

  Serial.println("data is: ");
  Serial.println((char*)my_string);
}

void loop() { }


texts: How to measure whether air is flowing through a pipe?

texts: I'm looking for a way to check the air-flow from an aquarium air pump. I need something that can test whether air is flowing or not and I'm not bothered about measuring flow speed. The air will be flowing through a pipe but if required I can have the sensor on the end of an additional pipe just used for measuring.


texts:
I have 2 rows of 12 MAX7219 connected in series with DOUT to DIN (rows are isolated). Now the thing is I am using LedControl Library to work with it. The problem is the last 4 Matrices on both the rows don't work. The sequence in my code is like this where (row, column, matrix) is used to define the row and column of the matrix and I am talking about a single ROW from two ROWs of 12.

Sequence in Code      What Happens
----------------      -----------------
(0, 1, 0)             (0, 1, 0)
(0, 1, 1)             (0, 1, 9)
(0, 1, 2)             (0, 1, 1)
(0, 1, 3)             (0, 1, 10)
(0, 1, 4)             (0, 1, 2)
(0, 1, 5)             (0, 1, 11)
(0, 1, 6)             (0, 1, 3)
.                     .
.                     .
.                     .
(0, 1, 11)            (0, 1, 8)

Now I can understand why does this happens. This code works like this even if the Device Count is 8.

Code:

#include "LedControl.h"
LedControl row1=LedControl(2,4,3,12);
LedControl row2=LedControl(5,7,6,12);

unsigned long delaytime=500;

void setup() {
  int d_row1 =row1.getDeviceCount();
  for(int address=0;address<d_row1;address++) {
    row1.shutdown(address,false);
    row1.setIntensity(address,15);
    row1.clearDisplay(address);
  }

  int d_row2 =row2.getDeviceCount();
  for(int address=0;address<d_row2;address++) {
    row2.shutdown(address,false);
    row2.setIntensity(address,15);
    row2.clearDisplay(address);
  }
}

void loop() {
  int devices=row1.getDeviceCount();
  for (int i = 0; i < devices; i++){
    delay(delaytime);
    row1.setLed(i,0,0,true);
    row2.setLed(i,0,0,true);
    delay(delaytime);
    row1.setLed(i,0,0,false);
    row2.setLed(i,0,0,false);
  }
}

EDIT
I just noticed something, there is no data going to the last 4 matrices. The timings of the blinking of the LEDs on last 4 matrices does not ties correctly (500ms) but it is in fact 250ms (i.e. half time). It means the blinks on last 4 matrices are between pulses of the first 4 matrices.


texts: I bought USB > FT232RL, can I use it to program a bootloader onto an Arduino?

texts:
I bought this thing off of eBay:

eBay Link

Will it allow me to program an ATmega[xxx] (Arduino clone) with a bootloader?
 --> If so, how would I go about it? What should I do, and what should I certainly not do?
 --> If not, what do I need (or where can I learn) to be able to use an Arduino clone with the Arduino IDE?

I'm a bit new to Arduino, and since I learned that a fair amount of the clones being sold on eBay don't have a bootloader, I wondered how to fix this. (and the "barebones" seem to be quite a bit cheaper)

Answer - summarized from different answers below (as I can only mark one answer below as accepted):

Can you use an FT232R to burn a bootloader onto an AVR (such as an ATmega328)?

=> Yes you can, though it's a bit annoying to do, as it's slow and a bit more complicated than just plug and play. See the first part of Chris Stratton's answer below.

I already have a working Arduino style board, can I use that?

=> Yes, you can use for example a UNO-style board to program another. This process is explained here: http://arduino.cc/en/Tutorial/ArduinoISP, which was referenced in the second part of Chris Strattons' answer below.

The two options above are too much of a hassle for me, or I don't have an Arduino yet/available, is there another option?

=> Yes, you can buy a USB to ISP (In-System Programmer) board/programmer. They're pretty cheap and are called USBISP or USBASP for example. Here's an example: http://www.ebay.com/itm/180980285082, referenced at the end of MatsK's answer. (or an even cheaper one: http://www.ebay.com/itm/390806886235).


texts: Arduino Nano, DS3231 RTC clock module and 4 cascaded FC-16 led matrix modules

texts:
Like I said in the title, I am using a DS3231 real time clock module and 4 cascaded FC-16 modules(they are basically MAX7219 led matrices based modules). My goal is to display a timetable, a schedule for a classroom on the matrices. The purpose of the DS3231 module is to keep track of time(mainly hours) from 8:00AM to 20:00PM, to display the hour on the matrix and to change the subject when it hits even hours.
Eg: when it's 8:00AM we have subject A, when it's 10:00AM we have subject B etc

And after that I have to use a ESP8266 wifi module to change the schedule from distance.

EDIT1:
I managed to display the hour on the matrix, but now I really can't figure out how to display the text in 4 rows. I have 4 FC-16 modules and I want to put each of them on top of the other so I can have 4 rows of text. I managed to do this by inserting space between words but this is not optimal. I want this to be automated so the person changing the text in the program doesn't have to do the spacing thing by themselves.

#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

const uint16_t WAIT_TIME = 1000;

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 16

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

RTC_DS3231 rtc;

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

void setup () {
  P.begin();

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

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

  }
}

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

    char buffer[] = "hh:mm";  // hours and minutes
    P.print(now.toString(buffer));  // display

   // Serial.println();
    delay(1000);
}```


texts: How can I create a battery level circuit

texts:
Im trying to create a circuit so that I can monitor the voltage drop on my battery and send an message when the voltage drop reaches the drop out. But I'm having some problems with my voltage divisions.

I created this circuit to enable a flow so that it does not flow (drain the battery) while not necessary. But as I understand it analog input must not be above 1 volts.

The +3.3V represent the MCU (ESP-12, arduino with wifi) turning the circuit on, letting battery flow to the analog input (red circled ground). However, at analog input, the volt is 2,24V, which is more than the 1V it should be. Do I just divide it again? If I divide it again ill be at 1,12 so I need to divide it yet again. I don't think Im doing it right.

The maximum voltage of the analog pin on the ESP-12 is 1V. How can I get there?


texts: DMX dimmer appears to receive data from Arduino but connected lights do not respond

texts:
I'm trying to control a DMX dimmer (eurolite ES-12 IEC DMX Switchback) through an Arduino Mega. In an earlier test, we were able to make one RGB DMX light run through the color spectrum. Now, a technician has installed this ES-12 dimmer pack with 12 1-channel DMX lights attached to it. The dimmer has some kind of built-in testing program and all the lights work.

The documentation on the dimmer is very sparse regarding the programming side of things. The dimmer is set to mode d--- and when the Arduino is running its program, a little green light flickers next to the d---, apparently responding to the signals it's receiving, like so: d---. Unfortunately, that the only light that responds.

I've tried using the DMXSimple library (the DMX is connected to pin 3), but even the example code (after correcting the brightness-- to ++) does not get any response -- none at all, not even the little green light. The only thing the little green light responds to is an analogWrite() on pin 3.

I'm guessing it's an addressing issue, but I don't know enough to fix it. As I understand it, the dimmer is seen as the controller and is sent a LOW on channel 0 as the Start Code (SC): http://www.dmx512-online.com/packt.html. The first light on the dimmer will then be channel 1, the second light channel 2, etc. (since, the technician tells me, they are 1-channel lights). Is this correct? Or is the dimmer its own universe that should be addressed in some other way?


texts: How to Store 2 analogRead values and read using EEPROM for Arduino Uno?

texts:
Trying to write 2 values coming from analogread(A0) and analogread(A1) by EEPROM.write  and retrieve the values by EEPROM.read. I tried the following sketch for each write and read. However, could not get the values. Any help please.

For writing to EEPROM:

#include <EEPROMex.h>
int addr = 0;
int array[] = {0, 0};
char a;
void setup() {
}
void loop() {
    array[0] = analogRead(0) / 4;
    array[1] = analogRead(1) / 4;
    EEPROM.write(addr, a);
    addr = addr + 1;

    if (addr == 512) {
        addr = 0;
    }

    delay(100);
}

For reading from EEPROM is:

#include <EEPROM.h>
int address = 0;
int value[2];
void setup() {
    Serial.begin(9600);

    while (!Serial) {
        ;
    }
}
void loop() {
    value = EEPROM.read(address);
    Serial.print(address);
    Serial.print("\t");
    Serial.print(value[0]);
    Serial.print("\t");
    Serial.print(value[1]);
    Serial.println();
    address = address + 1;

    if (address == 512) {
        address == 0;
    }

    delay(500);
}


texts: Moving a character around an LCD screen - is there a better way?

texts:
I have some basic programming experience but I am a novice at both C and Arduino.

I messed around with the example LCD code to try to move a character around with the onboard keypad. I also wanted the actual move to occur only once the button is released, like you would expect from a keypad.

The code works, but I have a feeling all the empty WHILE loops inside the main loop() function I used are not the best practice.. :)

How did I do? Is there a more convenient/elegant solution I missed and can learn from?

Thanks, and sorry for the messy code!

void loop()
{
  lcd.clear();
  lcd.setCursor(posCol,posRow);      //initialized beforehand
  lcd.print("O");                    //random char to move
  lcdOld = btnNONE;

  while (read_LCD_buttons() == btnNONE)     //do nothing while nothing is pressed
  {
  }

  lcdOld = read_LCD_buttons();

  while (read_LCD_buttons() == lcdOld)     //do nothing while button is down
  {
  }

  switch (lcdOld)               // depending on which button was pushed, we perform an action
   {
   case btnRIGHT:
     {
     posCol++;
     break;
     }
   case btnLEFT:
     {
     posCol--;
     break;
     }
   case btnUP:
     {
     if (posRow == 1)
     {
        posRow = 0;
        break;
     }
     else
     {
     break;
     }
     }
   case btnDOWN:
     {
     if (posRow == 0)
     {
        posRow = 1;
        break;
     }
     else
     {
     break;
     }
     }
   case btnSELECT:
     {
     break;
     }
     case btnNONE:
     {
     break;
     }
 }
}


texts: I want to know how exactly do I program (upload arduino sketches) an ATMEGA2560 which is boot loaded with an Arduino Bootloader using a FTDI programmer and an Arduino IDE, is there any capacitors/resistors required?


texts: What programmer do I select in Arduino IDE for the ATMEL-ICE ISP?

texts:
I have been using an AVRISPmkII for many years but recently gave mine away to another hobbiest. I wnated to buy a replacement and have had to buy an ATMEL-ICE ISP as the AVRISPmkII is now unavailable.
Occasionally, I like to program the Arduino Uno from the Arduino IDE using the ISP.
However when I go to select the programmer (from the tools menu), I don't see the ATMEL-ICE in the list.
How do I get Arduino IDE to recognize the ATMEL-ICE ISP?
Note: I am using Arduino IDE v1.6.8.


texts: Powering ESP8266EX with batteries and a voltage divider

texts:
So I recently bought a ESP8266 chip, it requires 3V3 and a large current( around 210mA max which is more than that can be supplied by an arduino uno at least). I managed to connect it to my arduino uno and got it to operate in standby mode, but Wifi mode wouldn't work because it requires more power.

After reading multiple online articles, I've decided to construct my own power supply. I'm planning on hooking 3 AAA batteries in series(4V5) and then use resistors(of small values to decrease power loss) to construct a voltage divide which powers the chip.

My concern is that I have not seen a single person doing this online and this seems like a straight forward thing to do, which makes me worried. Did I miss something? Is my plan feasible?


texts:
Non-technical person here, so please be gentle. I moved into a place that has ceiling speakers in each room (I tried, but they don't come apart, aren't marked other than manufacturer, and that is a company that went out of business 15+ years ago). So, let's assume they are 8 ohm speakers.

I have a media amplifier, and have successfully played music over all the speakers so I know that they work.

My wife would like the ability to select which speakers are on or off, so I'm thinking a quick Arduino project and relay board with 8-12 relays... but I'm not sure how to estimate the load, so I don't know how to appropriately size the relays.

Any suggestions on the best way to do this, or should I just get mains-rated relays and over-engineer the heck out of this?


texts:
I am interested in writing a simple Arduino program that will turn a servo back and forth (180 degrees each time) continuously.

I am looking at these servos and am planning on following this example.

Being so new to Arduino, I first wanted to confirm that the SoftwareServo library in that example will drive those particular servos. If it will not, then can someone begin by explaining to me why these servos are incompatible with the lib?

Assuming they are compatible, I am looking at the main example on that page (comments stripped out for brevity):

#include <SoftwareServo.h>

SoftwareServo myservo;

int potpin = 0;
int val;

void setup() {
    myservo.attach(2);
}

void loop() {
    val = analogRead(potpin);
    val = map(val, 0, 1023, 0, 179);
    myservo.write(val);
    delay(15);

    SoftwareServo::refresh();
}

My concerns:

There seem to be 3 pins involved here: a potentiometer pin (0), an analog pin (val) and a servo pin (2). What is the purpose of each of these pins, and is this 3-pin wiring common across all/most servos?
Is there anything "wrong" with defining myservo.attach(2); up above the setup function, and leave the setup function an empty no-op function?
Where does the map(...) function come from? If it was defined inside SoftwareServo I would have expected its usage to be something like SoftwareServo::map(...), etc.
Why do we need the delay after calling myservo.write(val);? What would happen if this delay wasn't in there?
According to that link, calling SoftwareServo::refresh() once every 50ms is necessary in order to: "keep your servos updating." But what does this mean, really? Updating to what?!?


texts:
I tried asking a question in my earlier post - SerialEvent with RS485 communication it helped me understand Hardware serial and Software serial but i had few more questions for which i started this new thread. Now i didn't write any code yet, but i will be using same code as my earlier post if i get expert inputs.

My Project - I have 6 Arduino nano which will do some simple task, mostly its one way communication at a time, like once master send message to slave i don't want immediate response slave will push button or something and then it will send response to master. So its rare that i will have two way communication at same time.

RS485 - I am going to use RS485 as distance is around 40ft.

Now my questions -

1 - Can i use Hardware serial pins with RS485 for 40ft distance, i tested code and it does work but i couldn't test that for 40ft. So not sure if it works or not.

2 - Is it good idea to use hardware serial pins for my project i explained, as i see plus and minus over internet and making me confuse. I see majority people recommend Hardware pins though.

3 - Is there limitation connecting multiple arduino nano with this approach, i only did this with 2 so far.

I would appreciate your inputs, which will make me decide to go on right path. Sorry i didn't post any code because my post is more to understand correct path to be followed...