text:
Arduino Pro Mini and Electronic Speed Controller (ESC)
I want to send servo signal to ESC and Servo with my 3.3V Arduino Pro Mini.
Can the ESC/Servo read 3.3V signal from Arduino Pro Mini? Or do I need to make some level shifter to make 5V signal?

The ESC should have no problem with 3v3 signal.

i have 1 more stupid question.. if i use pro mini 5V, is it ok if i power it with regulated 5V to the RAW pin?

If you put 5V on the RAW pin you will loose voltage over the voltageregulator thats on the Nano, might be as low as 1V or more, depending on the regulator and current draw. If you have 5v regulated use the 5v pin.

Signal can be send easily from Arduino Pro mini to ESC, Simply either use .write() or .Microseconds() function.


text:
MQ135 Air Quality Sensor Signal Amplifier needed? Higher Quality Sensor?
I am trying to strengthen the signal from my MQ135 air quality sensor so it can detect aerosols from 3 feet away, as, currently as it stands the resolution is pathetic, it only blips from 0.21 to 0.58 when you practically insert the sensor into the nozzle of a bottle full of vinegar/rubbing alcohol.
It would be ideal if you could guide me as to what sort of signal amplifier to buy to strengthen the signal coming from this board?
Alternatively: Could I increase the sensitivity of this sensor?
I'd like to plot this to a graph at some point, so I will be working on an ASP.NET app that tells me if there are any aerosols in my room or not.

Here's the code:
/*
  Graph

 A simple example of communication from the Arduino board to the computer:
 the value of analog input 0 is sent out the serial port.  We call this "serial"
 communication because the connection appears to both the Arduino and the
 computer as a serial port, even though it may actually use
 a USB cable. Bytes are sent one after another (serially) from the Arduino
 to the computer.

 You can use the Arduino serial monitor to view the sent data, or it can
 be read by Processing, PD, Max/MSP, or any other program capable of reading
 data from a serial port.  The Processing code below graphs the data received
 so you can see the value of the analog input changing over time.

 The circuit:
 Any analog input sensor is attached to analog in pin 0.

 created 2006
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe and Scott Fitzgerald

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/Graph
 */

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
}

void loop() {
  // send the value of analog input 0:
  Serial.println(analogRead(A0));
  // wait a bit for the analog-to-digital converter
  // to stabilize after the last reading:
  delay(20);
}

/* Processing code for this example

 // Graphing sketch

// This program takes ASCII-encoded strings
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 1023, followed by a newline, or newline and carriage return

// Created 20 Apr 2005
// Updated 24 Nov 2015
// by Tom Igoe
// This example code is in the public domain.

import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph
float inByte = 0;

void setup () {
  // set the window size:
  size(400, 300);

  // List all the available serial ports
  // if using Processing 2.1 or later, use Serial.printArray()
  println(Serial.list());

  // I know that the first port in the serial list on my mac
  // is always my  Arduino, so I open Serial.list()[0].
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // don't generate a serialEvent() unless you get a newline character:
  myPort.bufferUntil('\n');

  // set inital background:
  background(0);
}
void draw () {
  // draw the line:
  stroke(127, 34, 255);
  line(xPos, height, xPos, height - inByte);

  // at the edge of the screen, go back to the beginning:
  if (xPos >= width) {
    xPos = 0;
    background(0);
  } else {
    // increment the horizontal position:
    xPos++;
  }
}

void serialEvent (Serial myPort) {
  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    // trim off any whitespace:
    inString = trim(inString);
    // convert to an int and map to the screen height:
    inByte = float(inString);
    println(inByte);
    inByte = map(inByte, 0, 1023, 0, height);
  }
}

*/

/* Max/MSP v5 patch for this example
 ----------begin_max5_patcher----------
1591.3oc0YszbaaCD9r7uBL5RalQUAO3CvdyS5zVenWZxs5NcfHgjPCIfJIT
RTxj+6AOHkoTDooroUs0AQPR73a+1cwtK3WtZxzEpOwqlB9YveAlL4KWMYh6
Q1GLo99ISKXeJMmU451zTUQAWpmNy+NM+SZ2y+sR1l02JuU9t0hJvFlNcMPy
dOuBv.U5Rgb0LPpRpYBooM3529latArTUVvzZdFPtsXAuDrrTU.f.sBffXxL
vGE50lIHkUVJXq3fRtdaoDvjYfbgjujaFJSCzq4.tLaN.bi1tJefWpqbO0uz
1IjIABoluxrJ1guxh2JfPO2B5zRNyBCLDFcqbwNvuv9fHCb8bvevyyEU2JKT
YhkBSWPAfq2TZ6YhqmuMUo0feUn+rYpY4YtY+cFw3lUJdCMYAapZqzwUHX8S
crjAd+SIOU6UBAwIygy.Q1+HAA1KH6EveWOFQlitUK92ehfal9kFhUxJ3tWc
sgpxadigWExbt1o7Ps5dk3yttivyg20W0VcSmg1G90qtx92rAZbH4ez.ruy1
nhmaDPidE07J+5n2sg6E6oKXxUSmc20o6E3SPRDbrkXnPGUYE.i5nCNB9TxQ
jG.G0kCTZtH88f07Rt0ZMMWUw8VvbKVAaTk6GyoraPdZff7rQTejBN54lgyv
HE0Ft7AvIvvgvIwO23jBdUkYOuSvIFSiNcjFhiSsUBwsUCh1AgfNSBAeNDBZ
DIDqY.f8.YjfjV1HAn9XDTxyNFYatVTkKx3kcK9GraZpI5jv7GOx+Z37Xh82
LSKHIDmDXaESoXRngIZQDKVkpxUkMCyXCQhcCK1z.G457gi3TzMz4RFD515F
G3bIQQwcP3SOF0zlkGhiCBQ1kOHHFFlXaEBQIQnCwv9QF1LxPZ.A4jR5cyQs
vbvHMJsLll01We+rE2LazX6zYmCraRrsPFwKg1ANBZFY.IAihr8Ox.aH0oAL
hB8nQVw0FSJiZeunOykbT6t3r.NP8.iL+bnwNiXuVMNJH9H9YCm89CFXPBER
bz422p8.O4dg6kRxdyjDqRwMIHTbT3QFLskxJ8tbmQK4tm0XGeZWF7wKKtYY
aTAF.XPNFaaQBinQMJ4QLF0aNHF0JtYuHSxoUZfZY6.UU2ejJTb8lQw8Fo5k
Rv6e2PI+fOM71o2ecY1VgTYdCSxxUqLokuYq9jYJi6lxPgD2NIPePLB0mwbG
YA9Rgxdiu1k5xiLlSU6JVnx6wzg3sYHwTesB8Z5D7RiGZpXyvDNJY.DQX3.H
hvmcUN4bP1yCkhpTle2P37jtBsKrLWcMScEmltOPv22ZfAqQAdKr9HzATQwZ
q18PrUGt6Tst2XMCRUfGuhXs6ccn23YloomMqcTiC5iMGPsHsHRWhWFlaenV
XcqwgCQiGGJzptyS2ZMODBz6fGza0bzmXBj7+DA94bvpR01MffAlueO7HwcI
pWCwmzJdvi9ILgflLAFmyXB6O7ML0YbD26lenmcGxjVsZUN+A6pUK7AtTrPg
M+eRYG0qD9j4I7eEbco8Xh6WcO.or9XDC6UCiewbXHkh6xm5LiPEkzpJDRTu
mEB44Fgz4NCtJvX.SM1vo2SlTCZGAe7GZu6ahdRyzFOhYZ+mbVVSYptBw.K1
tboIkatIA7c1cTKD1u.honLYV04VkluHsXe0szv9pQCE9Ro3jaVB1o15pz2X
zYoBvO5KXCAe0LCYJybE8ZODf4fV8t9qW0zYxq.YJfTosj1bv0xc.SaC0+AV
9V9L.KKyV3SyTcRtmzi6rO.O16USvts4B5xe9EymDvebK0eMfW6+NIsNlE2m
eqRyJ0utRq13+RjmqYKN1e.4d61jjdsauXe3.2p6jgi9hsNIv97CoyJ01xzl
c3ZhUCtSHx3UZgjoEJYqNY+hYs5zZQVFW19L3JDYaTlMLqAAt1G2yXlnFg9a
53L1FJVcv.cOX0dh7mCVGCLce7GFcQwDdH5Ta3nyAS0pQbHxegr+tGIZORgM
RnMj5vGl1Fs16drnk7Tf1XOLgv1n0d2iEsCxR.eQsNOZ4FGF7whofgfI3kES
1kCeOX5L2rifbdu0A9ae2X.V33B1Z+.Bj1FrP5iFrCYCG5EUWSG.hhunHJd.
HJ5hhnng3h9HPj4lud02.1bxGw.
-----------end_max5_patcher-----------

 */

so to answer the question: it turns out there is a different sensor for every different detectable out there....what a nightmare!                             Ammonia - MQ137
Carbon Monoxide - MQ-7
Chlorine - MQ 7
ChlorineDioxide - MQ2
EthyleneOxide - MQ-2
Fluorine - MQ-3
Hydrazine
Hydrogen - MQ-8
HydrogenFlouride - MQ-8
Hydrogen Sulfide - MQ136
NitricOxide - MQ-7
NitrogenDioxide - MQ-4
Oxygen
Grove - Gas Sensor(O2)
SKU: 101020002
Ozone - mq-3
Phosgene mq-7
Phosphine mq-7
Silane - MQ-6
SulfurDioxide MQ-136

It will be more clear what you want answered if you address one topic per post.  What sensor to use; how to set sensitivity; how to plot data – those three issues can be addressed separately.  It wastes time to mash them up together.

What board is it precisely?  Googling "MQ135" shows a discrete part that needs a variable calibration resistance, and it must then be calibrated to your application.  Depending on the board, it might already have some conditioning/amplification.

Thanks Dave, it's just an arduino board, I've twisted the variable pot on it to get some fine tuned readings....i did not see any significant amplification...https://olimex.files.wordpress.com/2015/05/mq-1.jpg

int sensorValue;
int pin8 = 8;
void setup()
{
Serial.begin(9600);
pinMode(pin8, OUTPUT);
}
void loop()
{
sensorValue = analogRead(0); // read analog input pin 0
Serial.print(sensorValue, DEC); //prints the value read
Serial.println("ppm");
if (sensorValue > 500) {
//Activate digital output pin 8 - the LED will light up
digitalWrite(pin8, HIGH);
}
else
{
// Deactivate digital output pin 8 - the LED will not light up
digitalWrite(pin8, LOW);
}
delay(50);

}

"it turns out there is a different sensor for every different detectable out there" and some say: such sensors do indeed detect gas particles, but for cheap sensors you'll never know if they measure what's advertised.

int sensorValue;
int pin8 = 8;
void setup()
{
  Serial.begin(9600);
  pinMode(pin8, OUTPUT);

  }

  void loop()
  {
    sensorValue = analogRead(0); // read analog input pin 0
    Serial.print(sensorValue, DEC); //prints the value read
    Serial.println("ppm");
    if (sensorValue > 500) {
      //Activate digital output pin 8 - the LED will light up
      digitalWrite(pin8, HIGH);
    }
    else
    {
      // Deactivate digital output pin 8 - the LED will not light up
      digitalWrite(pin8, LOW);

    }
    delay(50);

}

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Only return button state once in X amount of time?
I want to detect if a button has been pressed, but what I don't want is for it to keep returning the "pressed" state more than once within a second or two.
For example, with this code:
void loop() {
  passButtonState = digitalRead(passButton);

  if (passButtonState == LOW) {
    Serial.println("PASSED!");
  }
}

Would spit out something like this with a single quick press of the button:
PASSED!
PASSED!
PASSED!
PASSED!
PASSED!
PASSED!
PASSED!
PASSED!
PASSED!

But what I want is for a single button press to just return PASSED! once for that single button press.

To avoid this problem you can use a boolean variable as a flag that permit to enter inside the if only once.
bool flag = true;

void loop() {
  passButtonState = digitalRead(passButton);

  if (passButtonState == LOW && flag) {
    Serial.println("PASSED!");
    flag = false;
  }
}

But this permanently disables that button from then on. I just want it to only return once for each press as opposed to a dozen.

@Shpigford you can reset the flag = true after a period of time.

If I understand the problem correctly, I think the answer might be a pretty common one. Your circuit may be suffering from "bounce" and the solution is called "debounce."
Check out this link for a possible solution:
Software Debounce

void loop() {
  passButtonState = digitalRead(passButton);

  if (passButtonState == LOW) {
    Serial.println("PASSED!");
    while (passButtonState == LOW) delay(1);
  }
}

You can add a delay.
void loop() {
  passButtonState = digitalRead(passButton);

  if (passButtonState == LOW) {
    Serial.println("PASSED!");
    delay(1000);
  }
}

Could you explain why this would be a good solution? While it may be trivial to you and me, it certainly won't be to everyone. Also, you should state that adding a delay will "slow" the whole program. You might even give alternative solutions.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Can I use arduino's 3.3 V output directly to esp8266?
I just bought esp8266 and ftdi usb driver, I want to power the esp8266 with Arduino's 3.3 V output, is that possible?
I saw some tutorial on youtube in that they are suggesting us to use 3.3v regulator ic instead of directly power 3.3 V of Arduino or ftdi driver's 3.3 V output.
If I connect my ftdi or Arduino output directly into esp8266 is there a chance to damage the esp8266?

Which Arduino ?

arduino uno which i bought from amazon

You should search for this data yourself, but since you are saying you are a newbie I'll tell you how to find this.
First of all you should search for a document called "datasheet". On a datasheet the producer writes all the relevant data about his product.
In your case, you should search for the electrical characteristics of the ESP8266. For instance here you have one of the datasheets. On page 13, there is the "Power consumption" chart, which says that the worst case has a typical current of 170mA. I suggest you to raise it a bit; let's say you need 250mA for the ESP.
Now, the arduino. You should search for the schematic of the board or read the part number of the 3.3V regulator. Since it's easier from the schematic and they released it on the web, you can see that the part number of the 3.3V regulator is LP2985. Searching for it on google will lead you to the texas instruments webpage, with the datasheet. Here you can see that the maximum output current is 150mA, so below the required current. Answer: you can't with arduino.
As for the FT232 cable, you should search for it because there are different models. Search on google and pick the first link pointing to the ftdi website.
As an example, the TTL-232RG has this datasheet. On page 9 they say that the TTL-232RG-VSW3V3-WE has an output current of 50mA, so you can't use it. The TTL-232RG-VREG3V3-WE, on the other side, has a maximum output current of 250mA, so you can use it.
If you have further questions, just ask here ;)

The specs for the Uno say that it does not provide as much current on the 3.3V line as the specs for the ESP8266 requires. You will need to provide another regulator that can supply enough current.

Im also have a ftdi usb driver in that there is a 5v and 3.3v out ,is that possible to get that amount of current from ftdi or arduino's 5v (using a voltage devider).Im a software developer im new to arduino and esp so if i say something wrong please forgive me

Voltage dividers are not voltage regulators.

Sorry, is it possible to that by using lm1117 ic and 9v battery ?

Check this for the lm1117: http://i.imgur.com/bD1ZDU2.png

And on a side note, you can also use the lm1117 to the 5v of the Arduino like so: http://3.bp.blogspot.com/--C-w5vILMi0/VTAvOct-fKI/AAAAAAAAO5w/76zXAWUR20c/s1600/ESP8266_arduino_power_lm1117_bb.png

i know It's a delayed reply .but it might help some one else.The answer is yes. I powered up esp8266 with ardino 3.3V directly and it works fine for me.


text:
Upload sketch via Bluetooth using HC-06 module
I'm dealing with an application in which I need to upload sketches remotely to an arduino UNO board. I successufully managed to upload sketches using an HC-06 bluetooth adapter. The only problem is that I am forced to manually press the reset button once the bluetooth link is established. Is there a way to automatically reset the arduino, in a software or hardware way,  so that it will be able to accept and install the incoming and sketch?
Would it be enough to activate a digital pin connected to the reset at the right timing prior the upload process starts?

Use a BJT/FET.
For a NPN, connect RST to COLLECTOR, a digital pin in series with a 220 ohm (or whatever’s appropriate) resistor to BASE, and EMITTER to GND.
Just bring the digital pin HIGH to reset your arduino.

Here's a instructable on how to reset the arduino with software
Instructables link


text:
Resetting millis() and micros()
I want to know how much time has elapsed since a certain event, and I do not want to use any external timers. It seems logical to reset an internal timer whenever the event occurs (using an interrupt). Unfortunately, as far as I can tell, millis() and micros() cannot be manually reset. Obviously, I could save a time stamp whenever the event occurs; however, I want to avoid overflow problems (micros() will overflow every ~71 minutes, and millis() will overflow every ~50 days).
Is there a way to manually reset these built-in counters? If not, how can I manage the overflow?

millis() and micros() overflow periodically. However, this is not a
problem: as long as you compare durations instead of
timestamps you can
forget about the overflows.
The liked answer also gives the trick for resetting millis(). Can be
handy for testing purposes, but you do not need this to handle the
millis() rollover problem. Notice that there is no clean way to reset
micros(): it relies on a static variable, i.e. a variable private to
the file defining it.

Overflow is never really an issue if you always calculate time difference. (Unless the time difference is more that 50 days.)
unsigned long previousTime = millis();
... wait for some event to happen ...
unsigned long elapsedTime =  millis() - previousTime;

Even if previousTime was before the overflow, and millis() is after the overflow (so essentially millis()<previousTime), elapsedTime will still be the correct value.
This is because the calculation itself will also overflow. Since millis()<previousTime, the result would be negative, but the type of the variable is unsigned, so it wraps around. I hope that makes sense.
Just don't ever do something like if( millis() > (previousTime+1000) )
If you still want to reset millis, you can use the following:
extern volatile unsigned long timer0_millis;
unsigned long new_value = 0;

void setup(){
  //Setup stuff
}

void loop(){
  //Do stuff
  //--------

  //Change Millis
  setMillis(new_value);
}

void setMillis(unsigned long new_millis){
  uint8_t oldSREG = SREG;
  cli();
  timer0_millis = new_millis;
  SREG = oldSREG;
}

I haven't tried the SetMillis() example yet, but this would be perfect to test the rollover. I don't see using it in normal circumstances, but to test my rollover code, this would be great, as I don't see having my Arduino set and run for 50 days and get to the part where it rolls over!

It seems logical to reset an internal timer whenever the event occurs (using an interrupt).

No it doesn't. You don't reset your clock to 00:00 when you put a cake in the oven do you?
What you do is note the time. Then periodically you subtract the start time from the current time, giving you the elapsed time. When time is up, you remove the cake from the oven.

Think about it for a minute. What if you wanted to time two events? Setting millis back to zero would hardly work then, would it? Setting it to zero for the second event would corrupt your timing for the first event.
However noting the time each one starts, and comparing the time now to the start time, will work for any number of events.

For more details see my post about millis() overflow ... a bad thing?


text:
How to merge two arduino sketches, one for relay's and one for Servo motor?
Recently I uploaded individual codes for relay's and Servo motor seperately, it all worked fine. But when I combined these two codes and dumped in to the loop there is a delay in functioning of the relay's but the Servo motor is working fine.
I have to control these devices through Bluetooth HC-05 module.
Could you please help me with the code?
/*
simple LED test
*/
#include <Servo.h>
char val;         // variable to receive data from the serial port
int ledpin = 2; // LED connected to pin 2 (on-board LED)
Servo myservo;
int pos = 0;    // variable to store the servo position
int motor = 0;

void setup()
{
  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.print("Arduino control Servo Motor Connected OK");
  Serial.print('\n');
  Serial.begin(9600);       // start serial communication at 115200bps
  digitalWrite(ledpin = 2 ,HIGH);
  digitalWrite(ledpin = 3 ,HIGH);

}

void loop()
{

      if( Serial.read() == 'a' )    // if 'a' was received led 2 is switched off
  {
    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2

  }

  if( Serial.read() == 'A' )               // if 'A' was received led 2 on
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2

  }

  if( Serial.read() == 'b' )        // if 'b' was received led 3 is switched off
  {
    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3

  }

  if( Serial.read() == 'B' )               // if 'B' was received led 3 on
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3

  }

  if (Serial.read() == '\n')
    {

   motor = Serial.parseInt();
    pos = Serial.parseInt();
      myservo.write(pos);
      delay(15);
      Serial.print("Data Response : ");
      Serial.print(motor, DEC);
      Serial.print(pos, DEC);

    }

    }

A couple of things stand out in your code.

Whenever you perform a digital write you assign a value to ledpin:
digitalWrite(ledpin = 3, LOW);

This is not necessary as you do not do anything with the ledpin variable. Instead, just have the digital I/O pin number:
digitalWrite(3, LOW);

Or simply have 2 variables, one for pin 2 and another for pin 3. Eg.
redledpin = 2;
greenledpin = 3;

This also applies to the pinMode function calls in the setup function.
Each one of your  if( Serial.read() == xx) statements will read a serial character off of the serial buffer. Instead store the read character in a local variable:
readChar = Serial.read()
if( readchar == 'a')
...
if( readchar == 'A')
...
if( readchar == 'b')
...
if( readchar == 'B')
...

I would encase all of the code inside loop() with:
if ( Serial.available() )
{
    ...
}

The delay function is blocking and this will cause issues. I suggest deleting the delay altogether.
Due to the fact that you are sending commands to turn digital outputs on and off as well as sending an integer for motor and another for pos, I suggest that you define a packet structure and make your code follow that (with the necessary error handling). As the code currently stands you will miss information, depending on what character it sees first on the serial buffer.
I suggest something like:
A, B, 142, 090

Starting the packet off with a know character is a good idea. So is having a timeout period - in case only a portion of your packet is received.

This will assign the value of 3 to ledpin and because the operation was successful it will evaluate to true. No it won't. It will evaluate to 3.

Which works because true is any value different from 0. If you try to write ledpin = 0 that will evaluate as false


text:
Motor does not move with 4 batteries
I mada a  4wd car with ultrasonic sensors and servo. I use 4 AA 1.5 volt batteries for power. But the motor does not move. What is the problem?

Schematic where?

I just added the above

you have to run a program

The L298 is a horrible chip, if you want to use that you'll probably have to add two cells to the battery pack just to account for its losses.  Note that you seem to be following a guide that recommends 6 cells, while you have only used 4.

When you say "the motor does not move", are you referring to the four DC motors, or the servo motor?

Thank you everyone. I have replaced the battery with 18650 (3.7 v). And it worked

If Aamir's answer helped you please vote it up and/or accept it, so people know that was the issue.

In the future, please detail your attempts at solving the problem so far so we can help you better.
Approach the issue as methodically as possible. I don't know how familiar you are with electronics, so please excuse me if you think some of these questions are basic:

Ensure that the servo motor works first without any other motors or
sensors connected to the Arduino Sensor Shield (have you used this servo motor before?)
Ensure that your GVS wiring is in the correct order. Servos come with a 3 way socket that plug straight onto the Sensor Shield: G goes to the Brown or Black wire, V goes to the (middle) Red wire, S goes to the Orange wire. The good news is as the +5V is in the middle, things will not blow up if you put the 3-pin plug on the wrong way. The servo just will not work until you plug it in correctly.
Is the Arduino Sensor shield working correctly. Does the LED pin work? Do other signals sent from the board work?
Remember that servo motors work differently to normal DC motors. You need to use Pulse Width Modulation to set the position. If you have never done this before, you will find the Arduino Servo Motors page useful. Also, you will get some excellent understanding and code from this Adafruit page. It is for a different Arduino shield, but the principles are the same.

The question seems more likely to be about the drive motors than the servo.

Ah. I hope my effort isn't wasted then. I guess it happens sometime. I've asked the author to clarify. Thanks for your detailed, helpful contributions to StackExchange Arduino. I just read some of your posts, and they are very helpful.

Thank you everyone. I have replaced the battery with 18650 (3.7 v). And it worked

@Riski, if you found any of the answers helpful, feel free to show your appreciation by selecting the answer and upvoting helpful answers. This is how the StackExchange system works: https://stackoverflow.com/help/privileges/vote-up

Use a LiPo battery I.e 2S(7.4V)


text:
Charge 14500 LiFePO4 lithium batteries from an Arduino Nano
I've recently started tinkering with Arduino, and I'm attempting to build a little 2WD robot based on an Arduino Nano.
I was thinking of powering the robot using two 14500 LiFePO4 batteries, which I understand will fit in a standard 2 x AA battery holder, and in series will give me about 6.4V, which should be ideal.
If I were instead going to use AA batteries, I think I'd need 4 of them, which will make my robot a fair bit bulkier.
I would like to be able to charge the batteries simply by plugging a standard USB cable into the Nano's USB socket.
Is there some easy way to safely do this? Do I need a separate charging module board, or is there some way to do it directly from the Nano?

No, you cannot charge a Lithium-Ion battery (of any variant) directly from an Arduino. You require a Lithium-Ion battery charge controller.
The best source for these kinds of things at a small size is retailers of model vehicle parts.

Specifically a  Lithium iron phosphate compatible charger.

Would you happen to know if something like the TP4056 might be OK?


text:
KY-022 IR receiver, LED always on, no output
I've been trying to use a KY-022 to read IR signals. However no output is being produced and the LED on the board is constantly on.
Board: Arduino Uno R3
I followed the procedure found here.
The code:
#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

The output:
Enabling IRin
Enabled IRin

The LED is constantly on, it should come on when there's a signal received. However this is not shown in the output. :/ I don't know what to do.
Pictures:

The first thing to look at is the circuit board. Are they using the resistor and LED to indicate the board is receiving power? The data sheet has a schematic showing several passive components in the "3. ApplicationCircuit" section. Here is a copy of the schematic I have used that worked with the IRremote library (Version 0.1 July, 2009 - Copyright 2009 Ken Shirriff).

I'll be honest with you, I'm completely new to this, I think the LED is connected to Signal and 5V...?

If its any help, if I dont have the reciever plugged in, I still get the same output, that it has been enabled

Let's try something simple to begin with. Add a 10k ohm or 15k ohm resistor between 5V and the circuit board output pin. Try the "IRrecvDump.ino" sketch that comes with the library (this sketch seems to provide more information about the possible type of remote you have).

I think I added the 10k resistor correctly.. nothing, no output, led is still on

I don't think the LED will flash or turn ON when an IR signal is received. Unfortunately I can not see the bottom of the circuit board in the product link you have provided so I can't be 100% certain that the LED is just a "power indicator". Could you edit your question and add a picture showing how you have everything connected?

I added the pictures! sorry for the hold up, had school and stuff, hope that helps you help me

The LED indicates power to the circuit board and will not turn on and off with a incoming IR signal. The only thing missing from your pictures is the 10 - 15k ohm pull-up resistor between 5V and the signal output. Try several different types of remote controls with the "IRrecvDump.ino" sketch. My Apple TV remote and several of my TV/cable box remotes work with the same type of IR sensor you are using. If you have access to an oscilloscope, the IR sensor could be tested for an output signal. It's possible the IR sensor is defective.

I have this IR led, an the led in the ky-022 only turn on when receive data.

Sorry for the very late update, turns out the component itself wasn't working so I got a replacement and all is fine! Slowly beginning to understand electronics, thank you for your help!

This happened to me when I "fried" my IR receiver.
Everything was fine and working until I accidentally reversed ground and +5v when putting my project back together after a tear down.
After correcting the wiring, the LED stayed on, and no reading was coming out.
Did you ever get any pins wrong?
This video show the correct wiring.
https://www.youtube.com/watch?v=iFpAqG90zY0

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Charlieplexing 30 LED sections with a max of 27 LEDs at the same time?
So basically, I'm trying to make a digital wall clock and using digital numbers, I have 7 sections of LED's per number, 4 numbers and one section for the colon in between them. A total of 30 sections. The colon will toggle every second so the the most possible simultaneously glowing sections is 27. That's because of the time 08:08.
Is there any way to make this work with an arduino? Possibly by Charlieplexing the arduino into 30 sections, using 6 pins. Or is there something out there that has 30 pins!?
The problem of course with charlieplexing, is that you need it to become rapid pulses. I'm sure I'm going to need some help with this, and also with laying out a schematic.
To be clear, this is how the led sections are going to be laid out. I also know I'm going to need an npn transistor for every single one of them. the biggest section uses 20 LEDs.

Thanks!

I would consider 74HC595N's. These are shift registers, which can control 8 'outputs' using less pins on your Arduino.
These are very cheap (buy them per 10) and you can daisy chain 4 of them, having 32 outputs, using only 5 pins of your Arduino. This would fit perfectly with your 30 sections.
Each of the 30 outputs can be used to control a transistors to control one LED sections.
See for an example for using shift registers with the Arduino: ShiftOut
Also you might need this: ULN2803 darlington drivers for each output (4 total).

Jij bent Nederlands of niet?

@Hendriks3D True (but it's better to write everything in English here).

Indeed.........


text:
How can I connect nearly 450 LEDs to an arduino without drawing too much current?
The question seems simple, but there's more to it:
I'm connecting 4 74HC595 shift-registers to an arduino pro micro.
28 of the 32 outputs will be used to control LED segments of numbers.
Each segment uses 14-20 LEDs and so I will be using a transistor for each segment.
Now here's my problem: With the maximum amount of LEDs activated (at time 08:08), the LEDs will draw nearly 10A. How can I use another transistor to make the shift-registors work with the arduino even though it shouldn't be drawing all current from the arduino, but from an external power source. I have found a suitable adapter from 230V to 5V 12A. The 12A is just to ensure that nothing goes wrong. The LEDs alone will draw 9.76A.
I know how to connect the arduino to the power source, but how do I run extra wires from the power source around the arduino to provide the LEDs their power?

Consider using MOSFET as transistor of TTL type.

I don't know but I would support nothing. Not even a guess

First you should consider changing your whole idea so that your LEDs don't draw nearly 10A.
I am assuming that for each segment you have 14-20 LEDs wired in parallel, each with its own current limiting resistor. That is very wasteful.
Instead you should be grouping the LEDs in chains of series LEDs which you then place in parallel.
Assuming you have normal red LEDs with a forward voltage of around 2V and a typical current draw for maximum brightness of 20mA, you can connect them up in chains of, say, 5 LEDs with one current limiting resistor, and power them from 12V not 5V.
3 chains of 5 LEDs (15 LEDs) would be 3x20mA = 60mA per segment. 4 chains of 5 LEDs (20 LEDs) would be 4x20mA = 80mA.
With 08:08 displaying that's 26 segments plus dots. Assuming each segment has 20 LEDs that's a total of 26x4 = 104 chains of 5 LEDs, totalling 520mA.
And then you should do away with the resistors as well, and use constant current LED sinks, such as the TLC59116, which can handle the higher input voltage.
If you don't want to do that, then more transistors will be needed:

simulate this circuit – Schematic created using CircuitLab
I have only showed 2 digits, 2 segments, 2 chains per segment, and 2 LEDs per chain to save space.
To drive it you need 1 GPIO per segment in one digit and 1 GPIO per digit. So for 4 digits at 7 segments that's 11 GPIO.

This is a very good Idea! I actually hadn't thought of the difficulty of the programming. Every minute, I need to change one digit and therefore the arduino somehow needs to know what bitcode to write for the new time outcome. Those shift-registers are fun, but not simple. I might consider using an arduino MEGA instead, so I have enough ports to control every segment without complicated code.

simulate this circuit – Schematic created using CircuitLab
Change the 74HC595 to TPIC6B595. Each output can sink 150mA from up to a 50V source. Strings of 3 LEDs in parallel powered from a 12V source (with current limit resistor per string) are easily handled, no extra transistors are needed. The 12V positive goes to the + of each string (the top anode), the - (bottom cathode) goes to the TPIC6B595 output.  Here is a video of 8 TPIC6B595s running displays made two strings of 3 LEDs in parallel for the large digits, one string of 3 LEDs for the small digit.
https://www.youtube.com/watch?v=6HZ0Mr51jUY
Each string draws 25 or so mA.
The board that drives the display holds up to 12 shift register chips and is controlled by an Atmega328P set up like an Arduino.
The shift registers are easy to use as well. I use SPI.transfer to send data to them.
Create an array to map the shift register outputs to the segments:
byte fontArray[] = {
    0b00111111, // 0 with the bits mapped to segments DP-g-f-e-d-c-b-a
    0b00000110, // 1   0 = segment off, 1 = segment on
    etc.
}

The digit layout:
    a
f       b
    g
e       c
    d       and DP if used.

Then to update the display, say you have 4 shift registers all daisy chained:
digitalWrite (ssPin, LOW);
SPI.transfter(fontArray[digit0]);
SPI.transfter(fontArray[digit1]);
SPI.transfter(fontArray[digit2]);
SPI.transfter(fontArray[digit3]);
digitalWrite (ssPin, HIGH); // all outputs update on this rising edge

Dirt simple really. No need for a Mega.

Hmm, spacing in didn't turn on code view mode. Is that supported in this forum?

Just paste in your properly indented code, select it all, and click the '{}' symbol on the exit-box toolbar. That will tell the editor to respect your formatting and highlight the section in light-gray.


text:
Manipulating 3 IR led's on Arduino Uno
I have an Arduino Uno and 3 IR led's. Each of my IR led's works fine individually if I connect them to pin 11.
However I want to connect all 3 of the led's to the Uno and have them send different signals according to pin number.
e.g
IR LED 1 connected to pin 11 - send signal 0xABCDEFGH
IR LED 2 connected to pin 10 - send signal 0xSJKLMNOP
IR LED 3 connected to pin 09 - send signal 0xZXYRWVUG
I tried making my own code below but it does not work. If anyone has any pointers i'll be very happy.
//LED 1

    #include <IRremote.h>

    IRsend irsend;

    void setup()
    {
    }

    void loop() {
        for (int i = 0; i < 11; i++) {
            irsend.sendNEC(0xABCDEFGH, 32); //Settings Menu
            delay(1000);
        }
        delay(1000); //1 second delay
    }

//LED 2

    #include <IRremote.h>

    IRsend irsend;

    void setup()
    {
    }

    void loop() {
        for (int i = 0; i < 10; i++) {
            irsend.sendNEC(0xSJKLMNOP, 32); //HDMI Port
            delay(1000);
        }
        delay(1000); //1 second delay
    }

//LED3

    #include <IRremote.h>

    IRsend irsend;

    void setup()
    {
    }

    void loop() {
        for (int i = 0; i < 9; i++) {
            irsend.sendNEC(0xZXYRWVUG, 32); //Switch Off Monitor
            delay(1000);
        }
        delay(1000); //1 second delay
    }

I don't have time to write a proper answer at the minute, but I hope this will get you started: break the problem down into parts. You have the first part working - you can send a code from one LED on pin 11.  Now try to send a code from one LED on pin 12.  You'll see that nothing in your code mentions the pin, so you need to understand how it's decided, or find another way to deal with using a different pin. Only THEN worry about using three LEDs at the same time.

I suspect 0xABCDEFGH, 0xSJKLMNOP and 0xZXYRWVUG are replaced with some valid hexadecimal numbers. I cannot see how repeating the sent command 11 times, 10 times and 9 times (in a for-loop) correlates to the pin number each LED is connected. There is a setup missing that declares which pin irsend supposed to use. Also that code will not compile because you define irsend, setup and loop three times. You need to combine the functions and perhaps need three instances of irsend (but I don't know for sure about that because I haven't used IRsend, yet).

I believe you don't understand what you are doing and you also don't tell us what you are trying to achieve. From your code I think you are trying to do a sequence of simulated IR remote presses. Why do you think you need 3 LEDs for that? Why can't you achieve that with only one LED? And why are you sending those commands every second unconditionally?

Can you tell us which IR library exactly you are using?

I am using  https://github.com/shirriff/Arduino-IRremote

I think what you have done is a perfectly logical thing to do.  You had three programs that worked and so you pasted them all into the same file and compiled it.  The compiler spat its dummy out of the pram and you didn't understand what the h*ll went wrong.  Is that about right?
// You only need to include each header file once
#include <IRremote.h>

// You need to define objects to represent the leds, we could use an array but for now we'll stick to the basics (makes the code a bit longer)
IRsend irsend_led1;
IRsend irsend_led2;
IRsend irsend_led3;

// This is where you do all the setup, it only gets executed once.
// You might need to assign the pin numbers to the irsend_ledX variables here.
void setup()
{
}

// This function is called repeatedly.  You can only have one of these.
void loop() {
    // I don't understand why you have this for loop, I think you think it may have something to do with pin numbers but I don't think it does.
    // I think the data is being sent multiple times, don't know why though
    for (int i = 0; i < 11; i++) {
        irsend_led1.sendNEC(0xABCDEFGH, 32); //Settings Menu
        delay(1000);
    }
    delay(1000); //1 second delay
    for (int i = 0; i < 10; i++) {
        irsend_led2.sendNEC(0xSJKLMNOP, 32); //HDMI Port
        delay(1000);
    }
    delay(1000); //1 second delay
    for (int i = 0; i < 9; i++) {
        irsend_led3.sendNEC(0xZXYRWVUG, 32); //Switch off monitor
        delay(1000);
    }
    delay(1000); //1 second delay
}

Give that a try, it might not work, but it will be closer to what you need, I hope I have explained it well enough.
Read the manual for the IR library and find out how to set the port numbers and if you can find out what that loop is about that might help.

I don't think he did have three programs which worked - I think he had one which worked. There's no clue in his code that he ever managed to get the second and third LEDs working, and yours won't either.

No, because of the pin assignment, anything else?

That's the main one.  It's also strange to be looping for a number of times equal to the pin number - probably a sign of not understanding something.

The loop is there because I want the signal to continuously pulsate so I can test it without having to repeatedly upload code every time I want to send an IR signal. Obviously it's not perfect but I would like to keep the loop there and in any other code someone modifies and posts. That's why I included it in that format.

That makes sense, when I read it I wasn't sure if it was a requirement of the library.  There is no problem with it being there, if you can separate out the pins you might even be able to do all three signals in the one loop.  However since loop() is a loop it could be that it is unnecessary, but that is up to you, you are testing it and know what is easiest.

@Matt has the main problem resolved, but I do want to add a note.
<IRremote.h> has the default IR led pin as pin 3 (last time I checked, maybe it has changed). I don't know how to change it, but if you are considering to use multiple IR leds, you might have to debug that problem!
So try to make 1 code work before you attempt to stick them togheter


text:
Water pump controlled by soil moisture sensor
I'm just learning to code in Arduino.
The purpose is that first the sensor measures the moist level (I mapped the reading values from 0 to 100). If the value is less than threshold 70, then it will turn on a water pump. As soon as the value goes beyond 70, the pump stops pumping water.
The problem is that even when the value is less than 70, the pump doesn't work.
I tried replacing the pump with a LED, it turns on a the right moment. I tested the pump itself, and it also works perfectly.

//for mapping values
int mostMoist = 100;
int leastMoist = 600;
int percent;

//direct value from sensor
int raw;

//threshold for minimum percentage to turn on pump
const int threshold = 70;

//initial state of water pump
bool dosomething = false;

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

void loop() {
  //if it's not pumping water:
  while (dosomething == false){
  //check sensor value, map out of 100, and display on monitor
  raw = analogRead(A0);
  percent = map(raw,leastMoist,mostMoist,0,100);
  if (percent < 0){
    percent = 0;
  }
  Serial.println(percent);
  Serial.println("dosomething is set to false");

  //check if percentage moist is less than threshold. if so, set dosomething true, orelse, loop dosomething false
  if (percent<threshold){
    dosomething = true;
  } else{
    dosomething = false;
  }
  delay(2);
  }

  //if it's pumping water:
  while (dosomething==true){
  //check sensor value, map out of 100, and display on monitor
  raw = analogRead(A0);
  percent = map(raw,leastMoist,mostMoist,0,100);
  if (percent < 0){
    percent = 0;
  }
  //turn on pump
  digitalWrite(13,HIGH);
  Serial.println("dosomething is set to true");
  //check if percent moist is less than threshold value, if so, loop dosomething true, orelse, set dosomething false
    if (percent<threshold){
    dosomething = true;
  } else{
    dosomething = false;
  }
    Serial.println(percent);
  delay(2);
  }

}

please do not post pictures of text ... post the text itself

I don't see a second power-supply in your photo. If you're trying to run the pump directly from an Arduino pin, it is highly likely that the pump needs way more current than the pin can supply.
It may be possible to power the motor from the USB but 1) the Uno board doesn't make that readily available, 2) it puts your PC at some risk (of back-EMF or of over-drawing the port's capability. But the ideal would be a separate power supply (don't forget to connect that supply's ground to the Uno's ground).
Also, if you tested the pump while dry it may have been able to run, yet with water in it, have been unable pull enough starting current to get going.

To control the pump you will need either a transistor or a relay board to handle the current. The arduinos pins can only drive 20 mA which is not enough for most pumps, even very small ones.
If the pump can run on 5 V and with <400 mA a transistor (FET) may suffice an power could come from VCC or so. Otherwise an extra supply with a relay is one simple solution.
You could start here for instance.
Look for tutorials, there are so many out there to be found with search engine, it's worth :)


text:
Problems with controlling LED with soil moisture sensor
I'm a beginner at Arduino.
I have a soil moisture sensor and I mapped the lowest and highest moisture value to a value in between 0 and 100.
What I was trying to do was if the value was less than 50, then the LED should turn on. But even when the value was less than 50 (e.g 25) the LED doesn't turn on.
The moisture detection or the value mapping works perfectly fine.
Does the issue lie on my code or my LED wiring?

Code:

int mostMoist = 180;
int leastMoist = 600;
int percent;
int raw;
const int threshold = 50;

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

void loop() {
  raw = analogRead(A0);
  percent = map(raw,leastMoist,mostMoist,0,100);

  if (percent < 0){
    percent = 0;
  }

  if (percent < threshold){
    digitalWrite(LED_BUILTIN,HIGH);
  } else {
    digitalWrite(LED_BUILTIN,LOW);
  }

  Serial.println(percent);
  delay(2);
}

load and run LED blink code to test the LED

problem aside: you should only switch on power to the sensor when you're about to do a reading; a constant charge will corrode the sensor's metal very quickly.

A good way to start debugging this sort of problem is to print out debug statements that say what the hardware should be doing. If the debug statements print out as expected then it's probably hardware, if not, then it's probably your code, e.g.
if (percent < threshold){
  Serial.prinln("LED on.");
  digitalWrite(LED_BUILTIN,HIGH);
}
else {
  Serial.prinln("LED off.");
  digitalWrite(LED_BUILTIN,LOW);
}

Thanks, everything's working fine after adding the debug statement, the LED's turning on at the right time!

You're welcome, glad to help. If that answers your question you may want to mark the answer as accepted: https://stackoverflow.com/help/someone-answers


text:
Public IP for Arduino with Ethernet shield and Arduino Uno
I'm new Arduino and I would like you to help me. I would like to have a public IP so that anyone can get access to it, not only from domestic domain. What could I do?. I'm using Arduino Uno, Arduino Ethernet Shield w5500 and a RTC.
My code:

#include <SPI.h>
#include <Ethernet.h>
#include "RTClib.h"
#include <EEPROM.h>

#define time 1
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 0, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
//----------------------------------------------------------------------------------------------------------------
 int i=0;
String hora="";
String readString;

RTC_DS1307 RTC;

void setup() {

  pinMode(2,OUTPUT);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
RTC.begin(); // Inicia la comunicaci¢n con el RTC

RTC.adjust(DateTime(__DATE__, __TIME__)); // Establece la fecha y hora (Comentar una vez establecida la hora)

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Sistemas Digitales");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield no se encontro.  No se puede correr el programa sin el hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("El cable Ethernet no esta onectado.");
  }

  // start the server
  server.begin();
  Serial.print("El servidor esta en: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // listen for incoming clients

delay(1000);
DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC

  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
//---------------------------------------------------------------------------------------------------------------------------------
        char c = client.read();

if(i==11 || i==12 || i==16 || i==17){
 if(i==16){
  hora +=':';
 }
  hora += c;
}

        if(readString.length()< 100){
          readString += c;
        }
        i++;
        //Este escribe el texto en pantalla letra por letra
        Serial.write(c);

        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n') {
            Serial.println("acabo lectura");

            Serial.println(hora);
             Serial.println(readString);

client.println("HTTP/1.1 200 OK"); // Enviar una respuesta tipica
             client.println("Content-Type: text/html");
             client.println("Connection: close");
             client.println("Refresh: 10");
           client.println();
           client.println("<!DOCTYPE HTML>");
          client.println(" ");
          client.println("");
          client.println("<meta charset='UTF-8'><title>Sistemas Digitales</title>");
          client.println("");
          client.println("
");
client.print("
Fecha y hora del servidor:");
client.print(now.day(), DEC);
client.print('/');
client.print(now.month(), DEC);
client.print('/');
client.print(now.year(), DEC);
client.print(' ');
client.print(' ');
int horini;
horini=now.hour();
String horartc = "0";
if(horini<10){
  horartc += horini;
}else{
horartc= String(horini);
}
client.print(horartc);
client.print(':');
int minuto;
minuto=now.minute();
String mainut;
if(minuto<10){
  mainut='0'+ String(minuto);
}else{
mainut= String(minuto);
}
client.print(mainut);
client.println("
");
client.println("<form method='get'>");
client.println("

¿A que horas le quiere dar de comer al chucho?

");
client.println("<input type='time' name='hora'>");
client.println("

que dias lo quiere alimentar?

");
//dias en checkbox
//client.println("<input type='checkbox' name='cbox1' value='?LunesOn'>Lunes
<input type='checkbox' name='cbox2' value='?MartesOn'>Martes
<input type='checkbox' name='cbox3' value='?MiercolesOn'>Miercoles
<input type='checkbox' name='cbox4' value='?JuevesOn'>Jueves
<input type='checkbox' name='cbox5' value='?ViernesOn'>Viernes
<input type='checkbox' name='cbox6' value='?SabadoOn'>Sabado
<input type='checkbox' name='cbox7' value='?DomingoOn'>Domingo
");
client.println("<input type='submit' value='Enviar' id='enviar'> ");
client.println("</form>");
if (readString.length() >0) {
Serial.println("hora del rtc");
String horiux = horartc +':'+ mainut;
Serial.println(horiux);
EEPROM.put(0, hora);

if(EEPROM.get( 0, hora ) == horiux){
digitalWrite(2, HIGH);
delay(10000);
digitalWrite(2, LOW);
delay(60000);
}
readString="";
i=0;
hora="";

          client.println("");
          client.println("");

          delay(1);
    // close the connection:
    client.stop();

        }

      }
    }

  }

  }
}

There it is  a part of the code:
IPAddress ip(192, 168, 0, 177);

I would like to make that IPto be public domain so you can get access anywhere instead of neededing to be in the same ethernet connection.
Any help would be wonderful, thanks for your time.

There is a discussion about the same topic in Arduino's Forum here. The most valuable comment was this:

To get an internet static IP address, contact your ISP. You will probably have to pay extra for that. Most people use a dynamic IP service such as www.noip.com to forward traffic to your current internet IP address. You put your dynamic ip address url in your web page so the browser request get routed properly.

I assume (by the address) that you want to do something like this:

The NAT device might have a port forwarding feature.
  You can use that.
  Assume the WAN ip is 198.51.100.1 and the server's ip is 10.1.1.1, the server is listening on port 80.
  So the port forwarding configuration will be something like :
  198.51.100.1 80 ---> 10.1.1.1 80
  From the outside you connect to the public IP - 198.51.100.1 80
  When the NAT device receives packet, it forwards it to 10.1.1.1.
  more info here

This is direct copy from source. So in your case WAN IP is the static IP (or another else) that is visible about you outside your network and the private one is that 192.168.0.177 which you used. Like stated in first yellow box, you can use dynamic ip service, too.

Thanks you so much!


text:
Should I use a loop instead of an If statement?
I have a simple sketch that tests input from 2 touch sensors and outputs to 2 relays (if a sensor is touched, trigger the respective momentary relay).  It has been a bit quirky to say the least.  perhaps I need to adjust delays or adjust sensitivity of the touch sensors, but I feel that maybe the coding could be more efficient.  Would using a WHILE or DOWHILE loop work better than an IF statement for this?  It seems like there is a timing issue between the relay and the sensor.  When I hit the sensor, the relay triggers immediately, but then it doesn't shut off right away.  Also if both sensors are made at the same time, I am seeing only 1 relay trigger or neither.  I am trying to eliminate the code as my failure point. I have the code printing to the serial monitor to show "Sensor 1 touched" or "Sensor 2 touched", and sometimes that triggers once and sometimes it will print multiple times.
int touchPin1 = 2; //Touch sensor 1
int touchPin2 = 4; //Touch sensor 2
int val_1 = 0;
int val_2 = 0;
int relayPin1 = 8; //Relay 1
int relayPin2 = 9; //Relay 2

void setup()
{
  Serial.begin(9600);
  pinMode(touchPin1, INPUT);
  pinMode(touchPin2, INPUT);
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);

}

void loop() {
  digitalWrite(relayPin1, LOW);
  digitalWrite(relayPin2, LOW);
  val_1 = digitalRead(touchPin1);
  val_2 = digitalRead(touchPin2);
  if(val_1 ==1)
  {
  Serial.println("Pad 1 Touched");
  digitalWrite(relayPin1, HIGH);
  }
  if(val_2 ==1)
  {
  Serial.println("Pad 2 Touched");
  digitalWrite(relayPin2, HIGH);
  }
  delay(100);
  //Serial.println();
}

Basically I am asking if there is a more efficient way to code this.
Touch Sensors: Adafruit Standalone Momentary Capacitive Touch Sensor Breakout Adafruit Part Number: 1374
Relays: SunFounder Relay Module for Arduino and Raspberry Pi 5V DC Trigger by HIGHLO (HIGH Trigger)

As we do not have a crystal ball, we cannot help you debug code we do not see.

For us to be able to help us you will have to share your code. We can't recommend one strategy over another when we don't know what it is your code is doing, or even what sensors you are using and how the code for them works.  You will have to add your code, along with a drawing of your setup (known as a schematic) or at the very least a photograph of your breadboard or whatever you're using, to your question (use the edit button under your question).

What do you want the beahviour to be? As long as the touch pad is pressed, the relay is activated, and as soon as you don't touch it anymore the relay closes? Because I don't understand why you always digitalWrite(relayPin1, LOW); in every loop iteration, and then (depending on val_1) immediately set it HIGH again.

As you stated, I would like the touch pad to activate the relay as long as the pad is touched and then off when no longer touched.  Ideally, I would like any of the relays to only be able to activate for a max of 1 second and not be able to be activated again for 1 second.

that is not what your code does ..... the loop() repeats 10 times a second because of the delay at the end .... look at your code carefully and determine what each line of your code does .... you will see that it does not do what you think it does

the delay is necessary to account for the time it takes for the relay to switch.  If there is no delay then the entire process breaks down.  If I place the delay inside the conditionals, then the relays cannot engage at the same time.  the digital write LOW command is necessary in order to make the relays momentary like the touch sensors.  Otherwise they will permanently latch to the normally open leg.  I have some electronics and programming experience, but brand new to Arduino.  Not used to having to code within the constraints of a forced active loop.

You aren't "forced" to use loop, you know. Just leave it empty if you want, and put all your code into setup. This is effectively what any other programming environment does, you have main which does what you want (possibly looping inside it, and possibly calling other functions).

What you are lacking is the else concept:

If a touch pad is pressed, then

Turn the relay on

else

Turn the relay off

Rather than turn the relay off every iteration, you only turn it off if the touch pad is not pressed.
That can be written as:
val_1 = digitalRead(touchPin1);

if(val_1 ==1)
{
  Serial.println("Pad 1 Touched");
  digitalWrite(relayPin1, HIGH);
} else {
  digitalWrite(relayPin1, LOW);
}

If you want your messages to be more meaningful and not spam, then you can remember the previous state and only do things if the state changes:
static uint8_t oldVal1 = LOW;

uint8_t val1 = digitaRead(touchPin1);

if (val1 != oldVal1) {
    oldVal1 = val1;
    if (val1 == HIGH) {
        Serial.println("Pad 1 Touched");
        digitalWrite(relayPin1, HIGH);
    } else {
        Serial.println("Pad 1 Released");
        digitalWrite(relayPin1, LOW);
    }
}


text:
Resetting I2c Address - MLX90614
I was using my MLX90614 IRTherm sensor flawless and bought two more. I have connected two sensors serial with pull-ups to SDA --> A4 and SCL --> A5. After digging the internet I found out that I should change their default slave addresses to different addresses so that Arduino can recognize their 7-bit slave addresses.
After changing their address, now I can't read either two new serial MLX'es or my old MLX.

I might have messed up with their addresses and don't know how to
reset their addresses.
How can i connect multiple sensors/ how can i change their adress properly?

reading sensor data

#include <Wire.h> // I2C library, required for MLX90614
#include <SparkFunMLX90614.h> // SparkFunMLX90614 Arduino library

IRTherm therm; // Create an IRTherm object to interact with throughout

const byte LED_PIN = 8; // Optional LED attached to pin 8 (active low)

void setup()
{
  Serial.begin(9600); // Initialize Serial to log output
  therm.begin(0x5A); // Initialize thermal IR sensor
  therm.setUnit(TEMP_F); // Set the library's units to Farenheit
  // Alternatively, TEMP_F can be replaced with TEMP_C for Celsius or
  // TEMP_K for Kelvin.

  pinMode(LED_PIN, OUTPUT); // LED pin as output
  setLED(LOW); // LED OFF
}

void loop()
{
  setLED(HIGH); //LED on

  // Call therm.read() to read object and ambient temperatures from the sensor.
  if (therm.read()) // On success, read() will return 1, on fail 0.
  {
    // Use the object() and ambient() functions to grab the object and ambient
    // temperatures.
    // They'll be floats, calculated out to the unit you set with setUnit().
    Serial.print("Object: " + String(therm.object(), 2));
    Serial.write('°'); // Degree Symbol
    Serial.println("F");
    Serial.print("Ambient: " + String(therm.ambient(), 2));
    Serial.write('°'); // Degree Symbol
    Serial.println("F");
    Serial.println();
  }
  setLED(LOW);
  delay(500);
}

void setLED(bool on)
{
  if (on)
    digitalWrite(LED_PIN, LOW);
  else
    digitalWrite(LED_PIN, HIGH);
}

Setting address
#include <Wire.h> // I2C library, required for MLX90614
#include <SparkFunMLX90614.h> // SparkFunMLX90614 Arduino library

IRTherm therm; // Create an IRTherm object to interact with throughout

const byte oldAddress = 0x5A;
const byte newAddress = 0x5B;

void setup()
{
  Serial.begin(9600); // Initialize Serial to log output
  Serial.println("Press a key to begin");
  while (!Serial.available()) ;

  therm.begin(oldAddress); // Try using the old address first

  byte address;
  if (!therm.readID()) // Try reading the ID registers
  {
    // If the read fails, try re-initializing with the
    // new address. Maybe we've already set it.
    therm.begin(newAddress);

    if (therm.readID()) // Read from the ID registers
    { // If the read succeeded, print the ID:
      Serial.println("Communicated with new address.");
      Serial.println("ID: 0x" +
                     String(therm.getIDH(), HEX) +
                     String(therm.getIDL(), HEX));
    }
    else
    {
      Serial.println("Failed to communicate with either address.");
    }
  }
  else
  {
    // If the read suceeds, change the address to something
    // new.
    if (!therm.setAddress(newAddress))
    {
      Serial.println("Failed to set new address.");
    }
    else
    {
      Serial.println("Set the address to 0x" + String(newAddress, HEX));
      Serial.println("Cycle power to try it out.");
    }
  }
}

void loop()
{

}

Edit 1:
Datasheet

what does the datasheet say about resetting the address?

I couldnt find anything about it

edited the question

Page 13 of 35 in the datasheet states:

In order to provide access to any device or to assign an address to a
  SD before it is connected to the bus system, the communication must
  start with zero SA followed by low RWB bit. When this command is sent
  from the MD, the MLX90614 will always respond and will ignore the
  internal chip code information.

Supposedly, all you have to do is to connect only one device and use the address zero to read/write the registers.

I didn't understand  "low RWB bit" part

that is the read/write bit ... see figure 4 ..... the library should take care of it

I am doint what it says but not sure if zero SA = default adress

Maybe the problem is I2C speed. MLX90614 supports only 100KHz i2c. If your i2c is at 400KHz, there would be no response from MLX90614.


text:
2WD robot - logic error
I am making a basic 2WD robot using Arduino Uno with motor shield.
I am getting no compile errors - but something in my logic flow is not working as expected.
Expected Operation:

Ping sensor does distance check.
If distance is less than 5cm.
Turn both Channel A & B motors half-speed for 1 second.
Stop motors.
Take new distance reading ping, start again.

What however is happening, is that channel A works as expected, but channel B motor keeps running??
Where is my code / logic mistake?
Later date I will add to else statement to turn one wheel to change direction.
/*
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v
 GND to arduino GND
 Echo to Arduino pin 7
 Trig to Arduino pin 8
 */

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 1000; // Maximum range needed
int minimumRange = 1; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
  // put your setup code here, to run once:

Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)

  pinMode(12, OUTPUT); /* Motor Channel A RIGHT SIDE*/
  pinMode(9, OUTPUT); /* Motor Channel A */

  pinMode(13, OUTPUT); /* Motor Channel B LEFT SIDE */
  pinMode(8, OUTPUT);

  }

void loop() {

  /* Distance check begins */

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);

 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;

 /* End distance check */

 if (distance >= 5){
 /* Distance great enough to provide room to move */
  Serial.println("Move!");

  digitalWrite(LEDPin, HIGH); /* LED show movement */

  digitalWrite(12, LOW); /*move channel A motor half-speed */
  digitalWrite(9, LOW);
  analogWrite(3, 123);

  digitalWrite(13, HIGH); /*move channel B motor half-speed */
  digitalWrite(8, LOW);
  analogWrite(11, 123);

  delay(1000);

  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
 }

 else {
 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(distance);
 digitalWrite(LEDPin, LOW);
 }

 //Delay 50ms before next reading.
 delay(500);

}

You might add the pins for the motors to your #define statements. This way you could've easily spotted them having the same pin number.
Some other points that might improve your code are:
1.Try increasing the baudrate Serial.begin(115200) in both the code and your terminal (should make it a little quicker). 2. echoPin 7 // Echo Pinis just a too obvious comment. Try to use comments for a purpose. like//This pin receives the echo pulse 3. maximumRangeshould be anunsigned int` it makes no sense to have negative ranges (and you can have a higher max range with unsigned).

I believe that your error is in that you declare LEDpin as pin 13 and then your motor B as pin 13 as well, that to me would result in errors when you write to the led in the else statement at the end of your code. I would recommend that you clean this up, don't use pins for different things. Try this first.
Your logic is ok in terms of functionality.
Also why is there inconsistency at this part on your code:
digitalWrite(12, LOW); /*move channel A motor half-speed */
  digitalWrite(9, LOW);
  analogWrite(3, 123);

  digitalWrite(13, HIGH); /*move channel B motor half-speed */
 digitalWrite(8, LOW);
  analogWrite(11, 123);

Why do you say pin 12 must beLOW and 13 HIGH when moving forward? Is this the way your un-mentioned circuit setup works, if possible could you add this info?

Thanks - think I missed the LED 13 bit. Reason for the inconsistency is that I motors are wired differently (ie by mistake), so to move fwd one needs a HIGH and other needs LOW to maintain direction.

@SvenHansen   thanks for clarifying, try setting all things related to the motors to an "off" setting so when setting the brake pins also set the pwm pins to 0

Indeed, I can still remember one of those controllers that uses 1-pin for CW or CCW rotation. Obviously one has to rotate CW and the other CCW to go forward (since the motors are 180 degree turned).
@SvenHansen you should accept RSM's answer, to let the system (and others) know this question is answered succesfully.

@SvenHansen    glad its working ;)


text:
Random output on decoding time from LTC audio using arduino UNO
I am a newbie in Arduino and I am trying to decode time from ltc audio. For this I got Arduino UNO.
I got a sample code from here.. Here my code:
#define icpPin 8        // ICP input pin on arduino
#define one_time_max          588 // these values are setup for NTSC video
#define one_time_min          422 // PAL would be around 1000 for 0 and 500 for 1
#define zero_time_max          1080 // 80bits times 29.97 frames per sec
#define zero_time_min          922 // equals 833 (divide by 8 clock pulses)

#define end_data_position      63
#define end_sync_position      77
#define end_smpte_position     80

volatile unsigned int bit_time;
volatile boolean valid_tc_word;
volatile boolean ones_bit_count;
volatile boolean tc_sync;
volatile boolean write_tc_out;
volatile boolean drop_frame_flag;

volatile byte total_bits;
volatile byte current_bit;
volatile byte sync_count;

volatile byte tc[8];
volatile char timeCode[11];

/* ICR interrupt vector */
ISR(TIMER1_CAPT_vect)
{
 //toggleCaptureEdge
 TCCR1B ^= _BV(ICES1);
  //Serial.println("Inter");
 bit_time = ICR1;

 //resetTimer1
 TCNT1 = 0;

if ((bit_time < one_time_min) || (bit_time > zero_time_max)) // get rid of anything way outside the norm
 {
   //Serial.println(bit_time, DEC);
   total_bits = 0;
 }
 else
 {
   if (ones_bit_count == true) // only count the second ones pluse
     ones_bit_count = false;
   else
   {
     if (bit_time > zero_time_min)
     {
       current_bit = 0;
       sync_count = 0;
     }
     else //if (bit_time < one_time_max)
     {
       ones_bit_count = true;
       current_bit = 1;
       sync_count++;
       if (sync_count == 12) // part of the last two bytes of a timecode word
       {
         sync_count = 0;
         tc_sync = true;
         total_bits = end_sync_position;
       }
     }

     if (total_bits <= end_data_position) // timecode runs least to most so we need
     {                                    // to shift things around
       tc[0] = tc[0] >> 1;

       for(int n=1;n<8;n++)
       {
         if(tc[n] & 1)
           tc[n-1] |= 0x80;

         tc[n] = tc[n] >> 1;
       }

       if(current_bit == 1)
         tc[7] |= 0x80;
     }
     total_bits++;
   }

   if (total_bits == end_smpte_position) // we have the 80th bit
   {
     total_bits = 0;
     if (tc_sync)
     {
       tc_sync = false;
       valid_tc_word = true;
     }
   }

   if (valid_tc_word)
   {
     valid_tc_word = false;
/*
     timeCode[10] = (tc[0]&0x0F)+0x30;      // frames
     timeCode[9] = (tc[1]&0x03)+0x30;      // 10's of frames
     timeCode[8] =  '.';
     timeCode[7] = (tc[2]&0x0F)+0x30;      // seconds
     timeCode[6] = (tc[3]&0x07)+0x30;      // 10's of seconds
     timeCode[5] =  ':';
     timeCode[4] = (tc[4]&0x0F)+0x30;      // minutes
     timeCode[3] = (tc[5]&0x07)+0x30;      // 10's of minutes
     timeCode[2] = ':';
     timeCode[1] = (tc[6]&0x0F)+0x30;      // hours
     timeCode[0] = (tc[7]&0x03)+0x30;      // 10's of hours
*/

         timeCode[9] = ((tc[0]&0xF0)>>4)+0x30; // user bits 8
       timeCode[8] = ((tc[1]&0xF0)>>4)+0x30; // user bits 7
       timeCode[7] = ((tc[2]&0xF0)>>4)+0x30; // user bits 6
       timeCode[6] = ((tc[3]&0xF0)>>4)+0x30; // user bits 5
       timeCode[5] = '-';
       timeCode[4] = ((tc[4]&0xF0)>>4)+0x30; // user bits 4
       timeCode[3] = ((tc[5]&0xF0)>>4)+0x30; // user bits 3
       timeCode[2] = '-';
       timeCode[1] = ((tc[6]&0xF0)>>4)+0x30; // user bits 2
       timeCode[0] = ((tc[7]&0xF0)>>4)+0x30; // user bits 1

       drop_frame_flag = bit_is_set(tc[1], 2);

     write_tc_out = true;
   }
 }
}

void setup()
{
 Serial.begin(9600);
 pinMode(8, INPUT);                  // ICP pin (digital pin 8 on arduino) as input

 bit_time = 0;
 valid_tc_word = false;
 ones_bit_count = false;
 tc_sync = false;
 write_tc_out = false;
 drop_frame_flag = false;
 total_bits =  0;
 current_bit =  0;
 sync_count =  0;

 Serial.println("Finished setup ");
 delay (1000);

 TCCR1A = B00000000; // clear all
 TCCR1B = B11000010; // ICNC1 noise reduction + ICES1 start on rising edge + CS11 divide by 8
 TCCR1C = B00000000; // clear all
 TIMSK1 = B00100000; // ICIE1 enable the icp

 TCNT1 = 0; // clear timer1
}

void loop()
{
  if (write_tc_out)
   {
     write_tc_out = false;
     //if (drop_frame_flag)
       //Serial.print("TC-[df] ");
     //else
       //Serial.print("TC-[nd] ");
     Serial.print((char*)timeCode);
     //Serial.print("\r");
   }
}

I am generating LTC audio from this link. On running my code I am getting this output:-
Finished setup
?>-00-0000??-??-77=??>-??-;?????-??-?>???>-:?-=????>-??-?=???>-;=-??5>?>-;=-??=7?>-?;-??=>?>-?:-??=7?>-;=-??>??>-;;-??=7??-?=-=7?>?>->7-?????>-;;-??=7?>-;>->??:??-?=-7????>-;?-??5>?>-;?-?=?>??-?=-?7>??>-7:-?67=?>-;?-???5?>-;=-7?==?>-;;-??=7?>-7=-??>>?>-:?-7????>-;=-?;;=??-?=->?=5?>-;=-???=?>-;?-?=5>??-?;->=???>-?>-7>;???-?;->????>-;?-?7=??>-;>-??>;?>-;=-;?5>?>-??-=7;7?>-;=-;?=??>-;=-??=7?>-;=-??:??>->7-=?????-?7-=?>>?>-?6-??;>?>-7;-???=?>-??-;=???>-;=-?7=7?>-?=-??>;?>-:?->??

So, can anyone one tell me where is mistake.

((tc[0]&0xF0)>>4)+0x30

Will generate values in the range x30 to x3F, which are 0 to 9 :;<=>?
This is what you are seeing in you output (because you are adding in x2D '-')
I'm not sure what you are expecting to see, but as far as I can tell there are no mistakes and your code is working fine.
If you are trying to turn tc[0] into a hex digit then I would use this function
char ToHex (const char input)
{
    char output = '0';
    if (input > 9)
    {
        output = (input - 10) + 'A';
    }
    else
    {
        output = input + '0';
    }
    return output;
}
char TCToHex (const char input)
{
    return ToHex(((input & 0xF0) >> 4));
}
char* CharToHex(const char input, char buffer[3])
{
    buffer[0] = ToHex((input & 0xF0) >> 4);
    buffer[1] = ToHex((input & 0x0F));
    buffer[2] = '\0'; // Always null terminate a string
    return buffer;
}

So what you will get if you call the functions is
    char buffer[3];
printf("CharToHex 0x%s\n", CharToHex('A', buffer));  //0x41 65 in decimal, ASCII A
printf("TCToHex = 0x%c \n", TCToHex(0x50)); // 5, because this function only takes the high nibble.
printf("ToHex = 0x%c \n", ToHex(0x0f)); // F

Hope that helps.

I am trying to send time stamp on serial port. But your code is not working. Any idea?

Unless your timestamp is in the same format as the TC array then no it won't.  I'll edit the answer to provide you with a more generic solution too.


text:
ATtiny44 millis() not working with 16 MHz external clock
I'm using ATtiny44 with Arduino IDE according to this tutorial: http://highlowtech.org/?p=1695
I have a problem with millis(). When I use an internal 1 MHz clock it works correctly but when I use external 16 MHz clock it takes millis() much more time than one second to be divisible by 1000.
I tested it with LCD and Hello World sketch, modified to correspond ATtiny's pins. Do millis() actually work with Tiny's?
Why does it work properly with 1MHz and not with 16 MHz which is the same as used in Arduino platform.

Did you forget to unprogram CKDIV8?

Testing whether millis() is divisible by 1000 is a terrible idea. With a 16 MHz clock millis does not count every millisecond: it is updated only every 1024 µs and occasionally jumps by 2 ms.

Please post the Fuses config

If you are specific about 'much more time', that will help people to explain the specific problem you observed. As you can see, there are several possible interpretations of the problem.

Let me guess: "much more time" is about, ohhh, 16 times?
When millis() was written, it had to assume what the input clock was. There is no way to detect the speed of the input clock: to do so would require another clock! So the writers of the function defined a starting constant, set it to 1000000, and required anyone that changed the clock would have to change that constant.
Find the constant, and set it to 16000000. Voilà!
Here's an article on the source code of the function:
https://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/

I think faster clock and F_CPU 1000000UL results in "much less time", not in "much more time".

Except that he's dividing by 1000 - or is he dividing 1000 by it? There's an inversion going on... Or @EdgarBonet is correct, and he's missing the crucial point in time when it is exactly divisible


text:
Point-to-point Communication of Arduinos with RFM LoRa Shield
In this tutorial, it sends a string from a node to the other node. But if I want to send an integer instead of a string, how should I change the code?
Serial.println("Sending to rf95_server");
// Send a message to rf95_server

String radiopacket = "Hello World #";
radiopacket += String(packetnum++);
radiopacket += " from ";
radiopacket += node_id;

Serial.print("Sending "); Serial.println(radiopacket); delay(10);
rf95.send((uint8_t*)radiopacket.c_str(), radiopacket.length()+1);

Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent();

You can either convert it to text (sprintf) or send it as bytes. However you like. How do you want to send it?

i want to send the data generated from the ultrasonic sensor, how can i send the data as byte? sorry i'm new in programming

I can tell...  Data is just data - whether it's a string or a number. It's just data.  An int is just two bytes. You can send it by casting it as bytes (as you already do with the existing code) with a size of 2 bytes. Just remember to cast it using the address of the integer, not the value of the integer.

The simplest way is to just cast the integer into an array of 2 bytes and send that.  Assuming int temperature:
rf95.send((uint8_t *)&temperature, 2);

To make it more portable you can use the size of an integer instead of 2:
rf95.send((uint8_t *)&temperature, sizeof(int));

Reading back, you just cast the buffer you have received as an integer, or combine the data manually (which may be safer since the buffer may be misaligned on a more powerful system than an 8 bit Arduino):
int temperature = buf[0] | (buf[1] << 8);

(Assuming it was sent from a little-endian 8-bit system).
If you want to send the number as plain text, so it can be easily read by a human, you want to print it to a string:
char temp[6];
sprintf(temp, "%d", temperature);
rf95.send((uint8_t *)temp, strlen(temp));

thanks for the help, but i received weird symbol on the server side
. do i need to change anything on the server side so that i can get a proper integer?

Yes. I told you what to change.

Note that the binary methods are only "portable" when the machines on both ends use the same variable size and byte order, as may indeed be the case here.  Otherwise the packing and unpacking will need to be done explicitly, something specified in many network protocols for example.  This would work between two ATmega Arduinos, or two Due Arduinos, but not between a mixed collection without explicit handling.

Just cast the integer to a String before sending and convert the String back to an int when you received. May not be memory friendly considering you are using Strings, but its very easy.
int a = 10;
String s = String(a);

You can then send the String as you would a normal string. Then on the receiving end you cast back to an int.
Assuming you received a String s.
int b = s.toInt();


text:
SIM800L can't send SMS
I have a SIM800L module (green board). I used this to test my module.
In that page, it use a SIM800L red board with a 3.7v LiPo battery. But I directly connected 5v from the Uno to the module.

GND      >>>   GND
RX  10       >>>   TX
TX  11       >>>   RX
5v       >>>   Vin

I see "Message Sent Successfully!" message in COM window but nothing happened.
I can not find the problem.
The SIM800L module (green board) specification is here.
The SIM800L module (red-green-blue boards) is here.

I am using A7 board - also have the same problem.. It might be the UNO boards. Voice call works 50% time, GPS location 100%

What library are you using? check with adafruit fonaLibray

https://github.com/cristiansteib/Sim800l

I used a Power Supply and tested the board and SIM800L with it.
At the beginning, the SIM800L only uses a max of 100mA (V = 5v) and after finding the network only 10mA. In this situation the message is sent. I tested it with 4.2v but no message was sent.
It seems it needs 5v to be applied. The 5v of the Uno will be reduced to reach the SIM800L and so no message is sent.


text:
Connecting Arduino to the ESP8266
I want to run more stepper motors and would like to know if there is a way to connect the Arduino and the ESP8266 NodeMCU together for more functioning.

Do you want to have more stepper motors than one Arduino can control? Or do you want add the NodeMCU to get remote/WiFi function? Or can you please elaborate and change the question to clarify the question?

Absolutely. I'll use the Arduino UNO and the ESP8266-01 WiFi module as an example:

The ESP8266 works with 3.3V and not 5V, so you need to connect the 3v3 pin on the Arduino to the VCC and CH_PD pins on the ESP8266.
Connect the GND pin on the Uno to the GND pin on the ESP.
Connect the RESET pin on the Uno to GND. Grounding the RESET pin
effectively causes your Arduino to work as a dumb USB to serial
connector (which is what we want to talk to the ESP8266).
Connect the CH_PD pin on the ESP8266 to the 3.3V line
Connect the RXD pin on the Arduino Uno to the RX pin of the ESP8266.
Connect the TXD pin on your Arduino Uno to the TX pin of the
ESP8266.

Normally, when you want two things to communicate over serial, you'd connect the TX pin of one to the RX of the other (send --> receive). In this case, however, the Arduino isn't talking to the ESP8266; the computer is talking to the ESP8266 via the Arduino.


text:
LCD is not showing any text
I'm using LCD QC1602A with a 10k potentiometer and changing contrast. It works well but the problem is that no text is appearing.
I'm using the LCD hello world examples and a few other examples. I tried reconnecting wires at least 5 times but every time it's the same problem. I connected it like this but the screen is not displaying any text at any contrast.
PS: It was showing white squares only in the top row, and now it's in both rows.

Two rows of white squares means that the driver chip has been successfully initialised to run in a 2x16 mode (it defaults to 1x16 which was the 1 row of squares you had originally).
So that means that you are configuring the display at least partially correctly.
You should adjust the pot so that you can just about see the squares. The squares are the background and the text would appear over them. If they are too bright you won't see the text. So adjust the contrast until you can just see that there are squares there.
If the wiring is correct and the code is correct then you should be able to see the text.

It works well but the problem is that no text is appearing.

it works well and yet no text is appearing?
so there is or there isn't a problem?

PS: It was showing white squares only in the top row, and now it's in both rows.

when correctly initialized, it should one row of blocks in the first row.
if it shows two rows of blocks, either it is not correctly initialized or the contrast is too much.

Actually, correctly initialised is 2 rows of blocks (it's set it up to be a 2 row display) and 1 row is not initialised (it defaults to a 1 row display). Two rows of blocks usually means the contrast is too high but communication is (at least to a certain extent) working.


text:
ESP8266WiFi library severely slowed down my embedded system project
I am trying to incorporate IoT to my embedded system project. I would call it soft real-time embedded system project.
But because of these 'LAZY' lines,
while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
if (!client) {
  return;  // Wait until the client sends some data
}
Serial.println("new client");
while (!client.available()) {
  delay(1);
}

The rest of the embedded system project has become so slow. If I don't put any of those lines, there will be obnoxious side-effects. How can I run this code along my actual embedded system project and still get done the soft real-time job?
[Edited] Full code:
#include <ESP8266WiFi.h>

const char* ssid = "Linux"; // SSID i.e. Service Set Identifier is the name of your WIFI
const char* password = "0123456789"; // Your Wifi password, in case you have open network comment the whole statement.

int ledPin = 13; // GPIO13 or for NodeMCU you can directly write D7
WiFiServer server(80); // Creates a server that listens for incoming connections on the specified port, here in this case port is 80.

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

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP()); //Gets the WiFi shield's IP address and Print the IP address of serial monitor
  Serial.println("/");

}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") != -1)  {
    digitalWrite(ledPin, HIGH);
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1)  {
    digitalWrite(ledPin, LOW);
    value = LOW;
  }

// Set ledPin according to the request
//digitalWrite(ledPin, value);

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("");

  client.print("Led pin is now: ");

  if(value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("

");
  client.println("<button>Turn On </button>");
  client.println("<button>Turn Off </button>
");
  client.println("");

  delay(1);
  Serial.println("Client disconnected");
  Serial.println("");

}

Write it as a finite state machine with none of those whiles and delays.

Finite state machine? couldn't catch it. any example(s)?

https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/

Dual processors is another idea.

+Look Alterno : I have edited the above question on your demand. :)

Try ESP8266WebServer instead. The following is an example included with the ESP8266 board package.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "........";
const char* password = "........";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp8266!");
  digitalWrite(led, 0);
}

void handleNotFound(){
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void){
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
}

No evidence WiFiClient is slow.If you are doing something else in loop such as animating LEDs code like this brings loop to dead stop.
while(!client.available()){
    delay(1);
}

readStringUntil blocks for up to 1 second waiting for the terminator. Another loop killer.
String request = client.readStringUntil('\r');


text:
Sim800L Uploading issues, HTTPACTION returns 0, 302, 701
I'm using the Sim800L module and the NEO6M GPS Module in combination with an Arduino nano to create a simple tracking device. I get the data from the GPS and try to upload it to my site with some simple PHP scripts. I'm using this code down here:

//the function - which is responsible for sending data to the web server
void sendLocation(String lat, String lon){
 Sim800l.listen();
 //The line below sets the URL we want to connect to
 Sim800l.println("AT+HTTPPARA=\"URL\", \"http://" + ipAddress +  "/log_info.php?dev_id=13&lat=" + lat + "&lon=" + lon + "\"");
 waitUntilResponse("OK");
 //GO
 Sim800l.println("AT+HTTPACTION=0");
 waitUntilResponse("200");
 Serial.println("Location sent");
 gpsPort.listen();
}

Unfortunately, when I try to use this code, in my serial monitor I get this message:
AT+HTTPACTION=0
OK
+HTTPACTION: 0,302,171
error

I Looked it up in the datasheet for the Sim800L, and the number 302 means "Found". I'm expecting the number 200 for "OK". I have no idea what I did wrong, the data is not being send to the web server for some reason. I hope you can help.
Thanks in advance!
EDIT:
The datasheet with all the errors for the Sim800L
https://www.elecrow.com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf

302 is HTTP code returned by the server. it is used for redirection. try to print the response with HTTPREAD. most common redirection is to https on the same server. does the server support unsecured access with http?

The server im using does niet support HTTPS. But how would i go about using this command? AT+HTTPREAD=URL or something else?

page 261 in the manual

Thanks, im trying it now.

I'm a bit of a noob with this stuff, I think I've got the syntax wrong but im not getting any response while trying this command

I figured it out, but HTTPREAD just returns a "1".

with what parameters did you run HTTPREAD?

HTTPREAD=0,1 The manual stated the first digit for start byte (witch i assumed would be byte 0?) and the second one for byte length.

you asked for one character.

ohhh... That makes sense.. lol. I should just make the last one bigger right? like 1024 or something?

I used 1024 now, I indeed see it gets redirected, to https://www.t-mobile.nl/prepaid-data-pass Which is weird because i have 4€ of data left...

redirect to captive portal to enter password before using the network

Thanks, i am an total idiot. thanks alot!

302 is HTTP code returned by the server. It is used for redirection. Print the response with AT+HTTPREAD to see where does it redirectd.


text:
Arduino Every 25k PWM signal
I have written a class for generating a 25khz pwm signal for the Arduino Nano. This works great (pin 9 and 10 only) on the Nano. I want to switch to Arduino Every; this code does no longer work (the registers are unknown ‘not declared in this scope’ is the compiler error). The Every is suppose to be a drop in replacement for the Nano; how to generate a 25KHz PWM on the Arduino Every?

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

HixPinPWM25KHz::HixPinPWM25KHz(int nPinNumber): HixPin(nPinNumber) {
}

void HixPinPWM25KHz::begin() {
  //25KHz PWM only supported on ping 9 and 10
  if ( (m_nPinNumber != 9) && (m_nPinNumber != 10) ) {
    return;
  }
  // Configure Timer 1 for PWM @ 25 kHz.
  TCCR1A = 0;           // undo the configuration done by...
  TCCR1B = 0;           // ...the Arduino core library
  TCNT1  = 0;           // reset timer
  TCCR1A = _BV(COM1A1)  // non-inverted PWM on ch. A
           | _BV(COM1B1)  // same on ch; B
           | _BV(WGM11);  // mode 10: ph. correct PWM, TOP = ICR1
  TCCR1B = _BV(WGM13)   // ditto
           | _BV(CS10);   // prescaler = 1
  ICR1   = 320;         // TOP = 320
  pinMode(m_nPinNumber, OUTPUT);
  analogWrite(50);
}

void HixPinPWM25KHz::analogWrite(float percent) {
  int value = (int) ( (percent * (float)320) / (float)100 );
  switch (m_nPinNumber) {
    case 9:
      OCR1A = value;
      break;
    case 10:
      OCR1B = value;
      break;
    default:
      // no other pin will work
      break;
  }
}

did you try the "Registers emulation" "ATMEGA328" in Tools menu of Arduino IDE? EDIT: I did. It doesn't work for Timer1 registers

A "drop-in replacement" does not mean "exactly the same". It means you get the same footprint and IO pins. It does not mean that you get the exact same internal architecture. Step one must always be read the datasheet for the chip and learn about the internal workings of it.

The Every uses a ATMega4809, which has a very different timers than the nano's ATmega328. The advantage is that it has a mux, so almost every pin can be selected as a output for one of the four timers.

@Juraj also tried emulation "ATMEGA328" (just to confirm), this does not solve the issue. Still getting the same compiler error.


text:
MPU-6050 showing all -1s
I am following this tutorial and have an MPU-6050 connected to an Arduino Micro with the following connections

VCC - 5V/3.3V
  GND - GND
  SDA - A2
  SCL - A3

I'm trying to run the short example sketch:
// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include <Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

But the output keeps showing -1 for all the fields.
Are these values actually correct or am I doing something wrong?

Are you sure, that the address is correct? You can use the I2C Scanner sketch to test, under what address the MPU can be found

the -1 is the same as a binary 11111111 ... that means that the data line never changes


text:
EEPROM write time
I will implements an emergency backup feature before power off, on Arduino Mega 2650.
Arduino is powered by capacitor, for the time (I hope) of the EEPROM write.
On AVR2650 Datasheet is reported that the typical EEPROM writing time is 3.3ms.
But 3.3ms for what? a byte? a word? the whole EEPROM?
I need the data for calculate the capacitors.

On AVR2650 Datasheet is reported that the typical EEPROM writing time is 3.3ms. But 3.3ms for what? a byte? a word? the whole EEPROM?

That is per byte (erase and write 3.4 ms, only write is 1.8 ms). When writing multiple bytes there are a few clock cycles to be gained by preparing for the next byte during an ongoing EEPROM write. Or even better use an ISR for the EEPROM feed. Not faster but allows some additional processing while a block is written. The largest gain is to have the EEPROM erased before the write (1.8 ms per byte instead of 3.4 ms).
Please see http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html,  http://www.atmel.com/images/doc2578.pdf and table 9-1, pp. 35, http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf.
Cheers!

Re “largest gain is to have the EEPROM erased before the write”, note that AVR-level eeprom.h includes a comment,  “All write functions force erase_and_write programming mode”, so having EEPROM erased before the write entails coding EEPROM routines from scratch.  ¶  To some extent, separating erase and write precludes possible time savings from not rewriting cells with unchanged value.

The ATmega2560 needs 4.5V to run at 16MHz. Newer chips allow a lower voltage and also write faster to EEPROM. How many bytes do you need to write ? Arduino has a function to skip the bytes that are the same: https://www.arduino.cc/en/Reference/EEPROMUpdate
Perhaps there are things that you can do in software, to prepare for an emergency backup.
When storing data in EEPROM, you could write it with a checksum, and have the data two times in EEPROM.


text:
Will M2.5 screws fit the holes in the Arduino Uno?
I'm developing a sump pump monitor/alarm setup that will include an Arduino Uno as well as a Raspberry Pi. Both boards will be mounted to a piece of wood. The Arduino is designed to take M3 screws, but the Pi is designed to take M2.5 screws. The difference in these two screw sizes is 0.5mm (2.4mm M2.5 vs 2.9mm M3). Is this going to be close enough to be able to use the smaller M2.5 screws for both? Due to cost reasons, I want to avoid having to purchase two different sizes of screws and standoffs.

With the screw holes for the Arduino being the larger screw holes, the 2.9mm screws would fit, but would probably need a nut and/or a washer to properly secure things. In the end if you intend to be doing more work with Arduinos and Pis in the future that require screwing things together then just go and get proper screw sizes, you won't regret it.

Yep, that sounds like a pretty reasonable approach. I was linked to this http://www.spaenaur.com/pdf/sectionR/R11.pdf by someone else and it looks like the head of the M2.5 is sufficiently wide at 4.5mm to not fall through in any case.