text:
Exporting an html for esp8266
EDIT: Added "web page source" ("In the end", :D )
(Please, sorry if this question isn't in the right place, feel free to move it to that place)
Here I have a problem:
In my house I have a self-arming alarm (through hour(RTC) ) made by me, using an Arduino Nano, an RTC1307 and some sensors (PIRs and magnetic). It works well, with its buttons, relays and LEDs to indicate.
All right, now I want to pass it to a esp8266, to be able to manage the alarm from the local network of my house using HTML and some  structures. I'm stuck in the construction part of the website, I mean: I already have the web page, at least opening the website from the browsers of the PC and my smartphone (locally), the question comes when I put the site inside the esp8266, It does not do what it has to do.
I have my webpage sectioned into 3 pieces using the HTML tags   and some CSS styles, to see the sections in the form of tabs but when I load them to the esp8266 it is as if I do not recognize the tabs, it does not let me click them.
I leave you the code here... please help:

String getPage(){
  String page = "<!DOCTYPE HTML>";
  page += "";
  page += "";
  page += "<meta charset=\"utf-8\">";
  page += "<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0\">";

  page += "<title>Alarma</title>";
  ///////////////
  ////ESTILOS////
  //////////////
  page += "";
  page += "";

  ///////////////
  ////BODY  ////
  //////////////
  page += "";
  page += "
";
  page += "
";
  page += "
Página de configuración de la Alarma
";
  page += "
";

  page += "
";
  page += "<input class=\"input\" id=\"sensores\" type=\"radio\" name=\"tabs\" checked>";
  page += "Sensores activados";

  page += "<input class=\"input\" id=\"hora_interna\" type=\"radio\" name=\"tabs\">";
  page += "Hora Interna";

  page += "<input  class=\"input\" id=\"hora_activacion\" type=\"radio\" name=\"tabs\">";
  page += "Hora de Auto-Armado/Desarmado";

  page += "
";
  //Formulario para sensores
  page += "<FORM action=\"/\" method=\"post\">";
  page += "Sensores activados
";
  page += "
<input type=\"checkbox\" name=\"M1\" id=\"M1\"";
  if (m1 == true){
    page += "checked";}
  page += "> M1
";
  page += "<input type=\"checkbox\" name=\"M2\" id=\"M2\"";
  if (m2 == true){
    page += "checked";}
  page += "> M2
";
  page += "<input type=\"checkbox\" name=\"M3\" id=\"M3\"";
  if (m3 == true){
    page += "checked";}
  page += "> M3
";
  page += "<input type=\"checkbox\" name=\"M4\" id=\"M4\"";
  if (m4 == true){
    page += "checked";}
  page += "> M4
";
  page += "<input type=\"checkbox\" name=\"PIR\" id=\"PIR\"";
  if (pir == true){
    page += "checked";}
  page += "> PIR
";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";

  page += "
";
  //Formulario para PONER la hora
  page += "<FORM action=\"/\" method=\"post\">";
  page += "
Hora interna: <input type=\"time\" name=\"poner_hora\" id=\"poner_hora\" value=\"";
    if (hora_interna < 10){
      page += "0";
      }
  page += hora_interna;
  page += ":";
    if (minutos_interna < 10){
      page += "0";
      }
  page += minutos_interna;
  page += ":00\" size=\"5%\" max=\"23:59\" min=\"00:00\">";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";

  page += "
";
  //Formulario para hora de auto-armado
  page += "<FORM action=\"/\" method=\"post\">";
  page += "
";
  page += "
Activación: <input type=\"time\" name=\"ontime\" id=\"ontime\" value=\"";
    if (hora_activacion < 10){
       page += "0";}
   hora_activacion;
   page += ":";
    if (minutos_activacion < 10){
       page += "0";}
   minutos_activacion;
   page += ":00 size=\"5%\" max=\"23:59\" min=\"00:00\">
";
   page += "
Desactivación: <input type=\"time\" name=\"offtime\" id=\"offtime\" value=\"";
    if (hora_desactivacion < 10){
       page += "0";
      }
   hora_desactivacion;
   page += ":";
    if (minutos_desactivacion < 10){
      page += "0";
      }
   minutos_desactivacion;
   page += ":00 size=\"5%\" max=\"23:59\" min=\"00:00\">

";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";
  page += "
";
  page += "
";

  page += "";
  page += "";
  return page;
  }

What I see in my browser locally:

What I see in my browser when I load the page from the esp8266:

I already check for the "checked" tag, in the  tag...
The "web page source" (apparently the browser put some "3D" before the quotes ("), any reason for that?)
From: <Saved by Blink>
Subject: Alarma
Date: Wed, 5 Jun 2018 21:28:15 -0000
MIME-Version: 1.0
Content-Type: multipart/related;
    type="text/html";
    boundary="----MultipartBoundary--T8oNZJiKHmz7Uqtp7zBLZVTRAAqlj41o9li9KHDGiV----"

------MultipartBoundary--T8oNZJiKHmz7Uqtp7zBLZVTRAAqlj41o9li9KHDGiV----
Content-Type: text/html
Content-ID: <frame-2-73f97ce7-1d30-423c-a8b1-c57104e83c66@mhtml.blink>
Content-Transfer-Encoding: quoted-printable
Content-Location: http://192.168.43.5/

<!DOCTYPE html><meta http-equiv=3D"Content-Type" content=3D"tex=
t/html; charset=3DUTF-8"><meta name=3D"viewport" content=3D"width =3D devic=
e-width, initial-scale =3D 1.0"><title>Alarma</title></he=
ad>

P=C3=A1gi=
na de configuraci=C3=B3n de la Alarma

<input class=3D"input" id=3D"sensores" type=3D"radio" name=3D"tabs" checke=
d=3D"">Sensores activados<input class=3D"in=
put" id=3D"hora_interna" type=3D"radio" name=3D"tabs">Hora Interna<input class=3D"input" id=3D"hora_activacion" ty=
pe=3D"radio" name=3D"tabs">Hora de Auto-Arma=
do/Desarmado
<f=
orm action=3D"http://192.168.43.5/" method=3D"post">Sensores activados
<=
p><input type=3D"checkbox" name=3D"M1" id=3D"M1" checked=3D""> M1
<input=
 type=3D"checkbox" name=3D"M2" id=3D"M2" checked=3D""> M2
<input type=3D=
"checkbox" name=3D"M3" id=3D"M3" checked=3D""> M3
<input type=3D"checkbo=
x" name=3D"M4" id=3D"M4" checked=3D""> M4
<input type=3D"checkbox" name=
=3D"PIR" id=3D"PIR" checked=3D""> PIR
<input class=3D"btn" type=3D"submi=
t" value=3D"Enviar"> <input class=3D"btn" type=3D"reset" value=3D"Resetear"=
>
</form>

<form =
action=3D"http://192.168.43.5/" method=3D"post">
Hora interna: <input typ=
e=3D"time" name=3D"poner_hora" id=3D"poner_hora" value=3D"10:40" size=3D"5%=
" max=3D"23:59" min=3D"00:00"><input class=3D"btn" type=3D"submit" value=3D=
"Enviar"> <input class=3D"btn" type=3D"reset" value=3D"Resetear">
</form=
>

<form action=
=3D"http://192.168.43.5/" method=3D"post">

Activaci=C3=B3n: <input type=3D"time" name=3D"ontime" id=3D"o=
ntime" value=3D"10:40" size=3D"5%" max=3D"23:59" min=3D"00:00">

Desactivaci=C3=B3n: <input type=3D"time" name=3D"offtime=
" id=3D"offtime" value=3D"=08:40"" size=3D"5%" max=3D"23:59" min=3D"00=
:00">

<input class=3D"btn" type=3D"submit" value=3D"Env=
iar"> <input class=3D"btn" type=3D"reset" value=3D"Resetear"></form></secti=
on>

------MultipartBoundary--T8oNZJiKHmz7Uqtp7zBLZVTRAAqlj41o9li9KHDGiV------

I´ll add my entire code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

//Definir el led
#define LED 2

//Variables de apoyo
bool m1 = true;
bool m2 = true;
bool m3 = true;
bool m4 = true;
bool pir = true;

//SSID and Password of your WiFi router
const char* ssid = "asd";
const char* password = "12345678";

ESP8266WebServer server(80);

//////////////////////////////////////////////
//                 Index                    //
/////////////////////////////////////////////
String getPage(){
  String page = "<!DOCTYPE HTML>";
  page += "";
  page += "";
  page += "<meta charset=\"utf-8\">";
  page += "<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0\">";

  page += "<title>Alarma</title>";
  ///////////////
  ////ESTILOS////
  //////////////
  page += "";
  page += "";

  ///////////////
  ////BODY  ////
  //////////////
  page += "";
  page += "
";
  page += "
";
  page += "
Página de configuración de la Alarma
";
  page += "
";

  page += "
";
  page += "<input class=\"input\" id=\"sensores\" type=\"radio\" name=\"tabs\" checked>";
  page += "Sensores activados";

  page += "<input class=\"input\" id=\"hora_interna\" type=\"radio\" name=\"tabs\">";
  page += "Hora Interna";

  page += "<input  class=\"input\" id=\"hora_activacion\" type=\"radio\" name=\"tabs\">";
  page += "Hora de Auto-Armado/Desarmado";

  page += "
";
  //Formulario para sensores
  page += "<FORM action=\"/\" method=\"post\">";
  page += "Sensores activados
";
  page += "
<input type=\"checkbox\" name=\"M1\" id=\"M1\"";
  if (m1 == true){
    page += "checked";}
  page += "> M1
";
  page += "<input type=\"checkbox\" name=\"M2\" id=\"M2\"";
  if (m2 == true){
    page += "checked";}
  page += "> M2
";
  page += "<input type=\"checkbox\" name=\"M3\" id=\"M3\"";
  if (m3 == true){
    page += "checked";}
  page += "> M3
";
  page += "<input type=\"checkbox\" name=\"M4\" id=\"M4\"";
  if (m4 == true){
    page += "checked";}
  page += "> M4
";
  page += "<input type=\"checkbox\" name=\"PIR\" id=\"PIR\"";
  if (pir == true){
    page += "checked";}
  page += "> PIR
";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";

  page += "
";
  //Formulario para PONER la hora
  page += "<FORM action=\"/\" method=\"post\">";
  page += "
Hora interna: <input type=\"time\" name=\"poner_hora\" id=\"poner_hora\" value=\"";
    if (hora_interna < 10){
      page += "0";
      }
  page += hora_interna;
  page += ":";
    if (minutos_interna < 10){
      page += "0";
      }
  page += minutos_interna;
  page += ":00\" size=\"5%\" max=\"23:59\" min=\"00:00\">";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";

  page += "
";
  //Formulario para hora de auto-armado
  page += "<FORM action=\"/\" method=\"post\">";
  page += "
";
  page += "
Activación: <input type=\"time\" name=\"ontime\" id=\"ontime\" value=\"";
    if (hora_activacion < 10){
       page += "0";}
   hora_activacion;
   page += ":";
    if (minutos_activacion < 10){
       page += "0";}
   minutos_activacion;
   page += ":00 size=\"5%\" max=\"23:59\" min=\"00:00\">
";
   page += "
Desactivación: <input type=\"time\" name=\"offtime\" id=\"offtime\" value=\"";
    if (hora_desactivacion < 10){
       page += "0";
      }
   hora_desactivacion;
   page += ":";
    if (minutos_desactivacion < 10){
      page += "0";
      }
   minutos_desactivacion;
   page += ":00 size=\"5%\" max=\"23:59\" min=\"00:00\">

";
  page += "<INPUT class=\"btn\" type=\"submit\" value=\"Enviar\"> <INPUT class=\"btn\" type=\"reset\" value=\"Resetear\">";
  page += "</FORM>";
  page += "
";
  page += "
";
  page += "
";

  page += "";
  page += "";
  return page;
  }

//////////////////////////////////////////////
//          REDIRECCIONAMIENTO             //
/////////////////////////////////////////////
void handleNotFound(){
  server.sendHeader("Location", "/",true);   //Redirect to our html web page
  server.send(302, "text/plane","");
}

//////////////////////////////////////////////
//      handleSubmit                        //
/////////////////////////////////////////////
void handleSubmit(){
  //Atencion a sensores
  if (server.arg("M1") == "on"){
      m1 = !m1;
      Serial.println("Se activo el sensor M1");
      }
  if (server.arg("M2") == "on"){
      m2 = !m2;
      Serial.println("Se activo el sensor M2");
      }
  if (server.arg("M3") == "on"){
      m3 = !m3;
      Serial.println("Se activo el sensor M3");
      }
  if (server.arg("M4") == "on"){
      m4 = !m4;
      Serial.println("Se activo el sensor M4");
      }
  if (server.arg("PIR") == "on"){
      pir = !pir;
      Serial.println("Se activo el sensor PIR");
    }

  //Atencion a establecimiento de la hora
//  if (server.hasArg("poner_hora")){
//    Serial.println(server.arg("poner_hora"));
//    }

  server.send(200, "text/plain", getPage());       //Response to the HTTP request

}

//////////////////////////////////////////////
//      handleRoot                          //
/////////////////////////////////////////////
void handleRoot() {
 Serial.println("You called root page");

  if (!server.args() ) {
    Serial.println("Hay algun argumento valido");
    handleSubmit();
    } else {
      server.send(200, "text/html", getPage());
      }
}

//////////////////////////////////////////////
//                SETUP                     //
/////////////////////////////////////////////

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println("Sistema iniciando");

  //Initialize AP Mode
  WiFi.begin(ssid, password);     //Connect to your WiFi router
  Serial.println("");

  //Onboard LED port Direction output
  pinMode(LED,OUTPUT);
  //Power on LED state off
  digitalWrite(LED,HIGH);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  server.on("/", handleRoot);
  server.onNotFound(handleNotFound);

  server.begin();
  Serial.print("Conectate a ");
  Serial.println(WiFi.localIP());
}

//////////////////////////////////////////////
//                LOOP                      //
/////////////////////////////////////////////
void loop() {
  server.handleClient();         //Handling of incoming requests
}

But have you checked the page source?

Yeap, at first I see some garbage (I also checked other webpage to make sure), something like "ContentType" and stuff like that...

please post the "web page source" from the esp8288

Don't use Strings. Save the file in the SPIFFS. Make it static, and fetch dynamic data using JavaScript.

What is SPIFFS? Let me do some research

Does the webserver on the ESP support all the features you are trying to use?  0x3D is the ASCII code for =, is there some encoding issue with you code?

@CodeGorilla I really don't know. How can I know if my ESP (Wemos D1 R1) has support for these CSS code? And why I see the 3D ASCII code? I have reviewed the entire code once and once again, with the same result. Rigth now I continue working without the CSS code... pure HTML, but is ugly!!!

It looks like you page source that is being rendered is email content. The 3D is from the email encoding and I have seen that on Gmail a lot(presumably Gmail parses the = out). What is the way in which you are delivering the webpage from the ESP to an end user? As a reference: https://en.m.wikipedia.org/wiki/Quoted-printable

Hi @RSM, I don't understand your question: what do you mean when you say: "What is the way in which you are delivering the webpage from the ESP to an end user?"? And why the navigator from my phone can even think that the content of the webpage is some kind of email?
(Sorry for the late answer, I don't have a free internet access)

@k.Cyborg The web page source you pasted in has the headers of an email. So at some point, the web page is being made into an email. What why are you using to access the webpage from your phone. Are you using a library to show the page.    Or did you email a copy of the webpage source to be able to past it on the website.  Would you be able to post your code you running ?

HI @RSM, the web page "source" that I pasted is what the navigator (Chrome) from my cell-phone (Xioami RedMi Note4) see, the way I found to "see" what I pasted here (the "source") is downloading the page from my phone and opening it with SublimeText(3.x). I post me entire code, but I'm no using any specific library, just the standart ESP8266WebServer, ESP8266WiFi and the WiFiClient... all of them (and the code, obviosuly) is using the Arduino IDE 1.8.5... any more information that you need? I appreciate any help!

@k.Cyborg Sorry for not replying earlier. Can you try change all the server.send() to use "text/html" and see if that shows anything as you have set it to plain text so the browser might not be interpreting it properly


text:
Minimal Arduino using ATmega32U4
I am a newbie and I would like to build my own minimalistic ATmega32U4 based arduino compatible board. Can anyone please tell me which parts resistors/capacitors (and maybe one status led) I need to connect it over usb to my computer? Thanks in advance.

It's all in the datasheet.

Several Arduinos and Arduino-compatible boards use the ATmega32U4.
Many of them have published open-source plans that show exactly what components are used and how they are connected. They may not be the absolute minimal number of components, but it seems clear that you don't need more components than a known-working board:

1 ATmega32u4
1 16 MHz crystal
2 22pF ceramic caps (for crystal)
1 uF decoupling cap
1 pushbutton
1 10 KOhm pull-up resistor (for pushbutton)
1 LED
1 220 Ohm resistor (for LED)
1 USB socket
2 22 Ohm resistors (between USB socket and ATmega32u4)

Alas, there are two unnecessarily difficult hurdles between newbies and getting a new ATmega32u4 device connected over USB to a computer:

The ATmega32u4 and nearly every other device that communicates over USB is only available in SMT packages with pins at 0.8 mm pitch or even closer together.
Most people find packages with pins at 2.54 mm pitch easier to handle and plug into a breadboard.
Installing a bootloader into any new processor chip is often tricky.

As Russel already pointed out, you can save a lot of time by starting out with an Arduino or Arduino-compatible board that already has the chip soldered on and the bootloader programmed in, bypassing the above unnecessarily difficult hurdles.
A few Arduinos and Arduino-compatibles (with links to schematics, etc.) that use the ATmega32u4:

Bootloading an ATmega32u4 with Arduino
Teensy 2.0 (ATmega32u4 USB dev board)
Arduino Leonardo; Arduino Leonardo
Arduino MICRO
SparkFun Pro Micro (Arduino-compatible)
FLORA - Wearable electronic platform: Arduino-compatible
Adafruit Feather 32u4 Basic Proto
Installing Arduino Bootloader on an ATmega32u4; Installing Arduino Bootloader on an ATmega32u4

One other crucial factor to consider: USB's timing requirements are pretty precise. That requires that the crystal oscillator create quite a precise frequency. Breadboards and precise frequencies do not go together due to the massive capacitance they impose on the circuitry. That makes it very very hard to get USB actually working from a breadboarded chip.

@Majenko: I agree that breadboards add a huge amount of capacitance, with bad effects on timing circuits. However, Jeff Murchison and many of the people commenting on his blog (first link) somehow got USB working on a breadboard, so apparently it's not very very hard.

Building your own may be worthwhile from a learning point of view, but makes minimal sense otherwise. You can buy Arduino clones (legal) from China for under $US5 each - good enough quality, assembled, working.
You cannot build one for that.
A DIY minimalist Arduino requires a running processor - see datasheet for the processor of choice as Ignacio says.Probably decoupling capacitors and maybe one or two resistors and maybe 1 or 2 small capacitors. If you cannot derive the needed information from a datasheet you do not know enough to sensibly do it by yourself. There are many on-web ~= minimalist implementations to copy.
If you want onboard USB you'd usually use a USB-serial converter but this can be done by "bit bashing" if you truly want a minimalist implementation>
BUT - just buy one and use the large amount of time gained to learn related things of more immediate use.

The '32U4 has built-in USB device support, so a USB-UART bridge isn't required unless you want to connect the hardware UART to a second computer.

source: Stack Exchange

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

sort: votes


text:
Difference between these two relays (D1 Mini Relay Shield and Single 5V Relay)
I've setup my NodeMCU v3 with this relay and I got this:

When using 3V to power the relay, I can hear coil when I turn on the board and I can only turn it on once. Then I can no longer hear the coil, but LED turns on and off.
When using VU pin (5V) to power the relay, I get the same coil sounds (when turning on board and on first toggle), then nothing. But the LED stays on, just slightly dims itself when turning on. Barely noticeable.

Alright, but I had a D1 Mini relay shield* laying around and I decided to give it a try. And it worked when powering the shield with VU pin (5V).
So my question is what is the difference? Does the D1 Mini Relay Shield have a transistor to pull up pin voltage from 3V to 5V and the other relay doesn't? If I had a logic level converter 3V-5V between the NodeMCU GPIO and the relay IN, would it work?
Thanks in advance.
*must say mine is a clone, but it works

what does this mean? I can only turn it on once

Have you used a multimeter to check if the contacts are switching?

it he relay expects 5 V as HIGH signal, that it is possible that it doesn't read 3.3 V as HIGH. the D1 shield is made for 3.3 V signal

a logic level converter would likely work in your situation (too low of a high voltage to trigger)

in my previous comment "it he" is "if the"

@jsotola I can toggle it once right after I power up the NodeMCU.

@sa_leinad I did. the pin goes from 0V to 3V.

@Juraj I saw people commenting they triggered the relay with 2.5V. So I guess it should work with 3V. But..you never know.

@dandavis I'm definitely getting myself a logic level converter as soon as Monday and I'm gonna try it out.

More than likely it is a faulty board.
The schematic for the D1 Mini relay shield can be found here.
I couldn't find a schematic for the relay that is having the problems but you can see from the picture below that it has 2 LEDs (power and relay signal), a flyback diode and a FET or transistor.

As you can see the circuits are pretty much the same. So my conclusion is that you have a faulty relay board.

that could be tested by giving the trigger pin 5v instead of 3.3. i bet it works fine like that...

Yeah, I don't know much about schematics. But I guessed it was similar to the d1 shield. But I'll surely try what @dandavis suggested and apply 5V to the trigger pin. I'm also getting another relay just like that to see if I can reproduce the issue or if it works with 3V.

@BrunoCardosoDantas did you test it with 5V as per DanDavis' comment?

@sa_leinad sorry for the delay. took a while to get everything. I did tho. Didn't work. I've got a logic level converter and also another relay just as the one that I had the issue. The first mentioned relay didn't work with 3V nor 5V. The new relay didn't work with 5V on VCC and 5V on the INPUT. Yeah, I know. But it did work with 3V on both of them. Don't ask me why tho. It just did.

Ok, so:

I've bought a logic level converter.
Bought another relay.

Now to the results:

With the first relay, no joy with 5v or 3v in any combination (3v on VCC / 3v on IN; 5v VCC / 5V IN; 3V VCC / 5V IN; 5v VCC / 3V IN)
With the second relay (the new one), funny enough.. Didn't work with 5V on VCC and 5V on input. But it did work with 3v on both of them.

I measured every output voltage to make sure everything was working fine and it wasn't a problem with power supply.
I guess it should work with 5v...? Right?
Anyway, it was indeed a faulty relay. And 3V on VCC and Input is what worked for me, even though it is a 5V relay. Thank you all for the assistance.

The D1 Mini relay shield would make sense that it works at 3V as that is what the both the Wemos and nodeMCU boards output for a logic high.

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


text:
How to save a float variable to the EEPROM?
This is my first post here and I'm hoping there are some Arduino hobbyists here to help me.
Does anyone here know how to save a float variable directly to the EEPROM? If so, could you have a look at the program I wrote and hopefully explain how it would be set up to work with the other 2 variables I'm saving to the EEPROM?
The program I wrote displays a voltmeter to the LCD. The program has an adjustable alarm set point as to when to sound an alarm when the voltage drops below a user-set alarm set point. I want to be able to declare the alarm set point as a float variable and save it directly to the EEPROM. I can't seem to find any programs that I could use as an example to try and figure out how to do that.
I did manage to get my program working to save my Volt_Alarm_Set_Point by declaring it as an int var and then comparing it to my Volt_Set_Point (declared as a float var) to 165 if statements to save the right Volt_Alarm_Set_Point value. And it works a treat but uses up 4956 bytes of program space. That's ok if I'm using an Arduino Mega but I'd like to be able to have my program run on an Arduino Nano which could cause problems with some bigger programs.
If anyone here could show me how to do this it would be greatly appreciated and I would be in your dept. Here is my code below. I don't understand how the code is suppose to be put here? Other forums are dead easy to post code but I can't figure this one out. Sorry about that...
Thanks
jessey
 #include <EEPROM.h>
 #include <LiquidCrystal_I2C.h>
 LiquidCrystal_I2C lcd(0x27, 20, 4);

//----------Volt Meter Code----------//
    int analogInput = A6;
    float vout = 0.0;
    float vin = 0.0;
    float R1 = 99300.0;
    float R2 = 9970.0;
    int value = 0;
//----------Volt Meter Code----------//

  int Volt_Alarm_Set_Point; // this works
  float Volt_Set_Point;
//  float Volt_Alarm_Set_Point; // this dosen't work
  int s = 0;
  int a = 0;
  int b = 0;

 int Button_1 = 5;
 int Button_2 = 6;
 int Button_3 = A1;
 int Button_4 = A0;
 int Alarm_Relay_1 = A3;
 int Relay_2 = A2;
 int Relay_3 = 8;
 int Blinking_Led = 3;// this one is ready to be used anytime

 #define VOLT_ALARM_SET_POINT_ADDR 0
 #define A_ADDR VOLT_ALARM_SET_POINT_ADDR + sizeof(int)
 #define B_ADDR A_ADDR + sizeof(int)

 #define Is_Pressed  0  // used for pushbuttons
 #define Is_Turned_On 1  // used for the relays
 #define Is_Turned_Off 0 // used for the relays

 //|---------void setup---------void setup---------|//
void setup() {

    pinMode(Alarm_Relay_1, OUTPUT);
    pinMode(Relay_2, OUTPUT);
    pinMode(Relay_3, OUTPUT);
    pinMode(Blinking_Led, OUTPUT);
    pinMode(Button_1, INPUT); // on pin 5
    pinMode(Button_2, INPUT); // on pin 6
    pinMode(Button_3, INPUT); // on pin A1
    pinMode(Button_4, INPUT); // on pin A0
//-----------Volt Meter Code--------------//
    pinMode(analogInput, INPUT);
//-----------Volt Meter Code--------------//

    lcd.begin();

    lcd.setCursor(0, 0);
    lcd.print(F("  This Program Is   "));
    lcd.setCursor(0, 1);
    lcd.print(F("to try and save a   "));
    lcd.setCursor(0, 2);
    lcd.print(F("float variable      "));
    lcd.setCursor(0, 3);
    lcd.print(F("to the eeprom       "));
    delay(500);

    lcd.clear();

    EEPROM.get(VOLT_ALARM_SET_POINT_ADDR, Volt_Alarm_Set_Point);
    EEPROM.get(A_ADDR, a);
    EEPROM.get(B_ADDR, b);
//  EEPROM.put( VOLT_ALARM_SET_POINT_ADDR, Volt_Alarm_Set_Point);
//  EEPROM.put(A, a);
//  EEPROM.put(B, b);

}// end of the void setup()

//|---------void setup---------void setup---------|//
//|---------void loop---------void loop---------|//

void loop() {

    delay(50);
  //increment & decrement Volt_Alarm_Set_Point
    if (digitalRead(Button_1)==Is_Pressed
      ||digitalRead(Button_2)==Is_Pressed)
      {Adjust_The_Volt_Alarm_Set_Point();}

    Read_Volt_Meter();
    //Multiply_By_0_Point_1;
    Display_A_Float_Voltage_Reference();

    lcd.setCursor(0, 0);
    lcd.print(F("This is the Volt adj"));
    lcd.setCursor(0, 1);
    lcd.print(F("Volt Set Pnt = "));

    if (Volt_Alarm_Set_Point<=9){
    lcd.setCursor(16, 1);
    lcd.print(" ");}
    lcd.setCursor(15, 1);
    lcd.print(Volt_Set_Point);

    lcd.setCursor(0,2);
    lcd.print(F("VoltageX= "));
    lcd.setCursor(10, 2);
    lcd.print(vin);

    if (Volt_Alarm_Set_Point<=9){
    lcd.setCursor(17, 2);
    lcd.print(" ");}
    lcd.setCursor(16, 2);
    lcd.print(Volt_Alarm_Set_Point);

    if (vin < Volt_Set_Point){digitalWrite(Relay_3, Is_Turned_On);}
    if (vin > Volt_Set_Point){digitalWrite(Relay_3, Is_Turned_Off);}

    lcd.setCursor(0, 3);lcd.print("A = ");lcd.setCursor(4, 3);lcd.print(a);
    lcd.setCursor(6, 3);lcd.print("B = ");lcd.setCursor(11, 3);lcd.print(b);

    if (a==0) {digitalWrite(Relay_2, Is_Turned_Off);}
    if (a==1) {digitalWrite(Relay_2, Is_Turned_On);}

    if (b==0) {digitalWrite(Alarm_Relay_1, Is_Turned_Off);}
    if (b==1) {digitalWrite(Alarm_Relay_1, Is_Turned_On);}

    if (digitalRead(Button_4)==Is_Pressed){
      if (a==0){a=1;}else{a=0;}
      while (digitalRead(Button_4)==Is_Pressed){
      if (a==0) {digitalWrite(Relay_2, Is_Turned_Off);}
      if (a==1) {digitalWrite(Relay_2, Is_Turned_On);}
      lcd.setCursor(0, 3);lcd.print("A = ");lcd.setCursor(4,3);lcd.print(a);
      lcd.setCursor(6, 3);lcd.print("B = ");lcd.setCursor(11,3);lcd.print(b);
      }
      EEPROM.put(A_ADDR, a); EEPROM.put(B_ADDR, b);
    }

    if (digitalRead(Button_3)==Is_Pressed){
     if (b==0){b=1;}else{b=0;}
     while (digitalRead(Button_3)==Is_Pressed){
     if (b==0) {digitalWrite(Alarm_Relay_1, Is_Turned_Off);}
     if (b==1) {digitalWrite(Alarm_Relay_1, Is_Turned_On);}
     lcd.setCursor(0, 3);lcd.print("A = ");lcd.setCursor(4,3);lcd.print(a);
     lcd.setCursor(6, 3);lcd.print("B = ");lcd.setCursor(11,3);lcd.print(b);
     }
     EEPROM.put(A_ADDR, a); EEPROM.put(B_ADDR, b);
    }
  }// end of the void loop()

//|---------void loop---------void loop---------|//
//======= Subroutine Area ======= Subroutine Area =======//
///*
void Display_A_Float_Voltage_Reference()
{
if (Volt_Alarm_Set_Point==0){Volt_Set_Point=0.00;}// this code uses 165 if statements for 4956 bytes of program space and 4 bytes of dynamic memory.
if (Volt_Alarm_Set_Point==1){Volt_Set_Point=0.10;}
if (Volt_Alarm_Set_Point==2){Volt_Set_Point=0.20;}
if (Volt_Alarm_Set_Point==3){Volt_Set_Point=0.30;}
if (Volt_Alarm_Set_Point==4){Volt_Set_Point=0.40;}
if (Volt_Alarm_Set_Point==5){Volt_Set_Point=0.50;}
if (Volt_Alarm_Set_Point==6){Volt_Set_Point=0.60;}
if (Volt_Alarm_Set_Point==7){Volt_Set_Point=0.70;}
if (Volt_Alarm_Set_Point==8){Volt_Set_Point=0.80;}
if (Volt_Alarm_Set_Point==9){Volt_Set_Point=0.90;}
if (Volt_Alarm_Set_Point==10){Volt_Set_Point=1.00;}

if (Volt_Alarm_Set_Point==11){Volt_Set_Point=1.10;}
if (Volt_Alarm_Set_Point==12){Volt_Set_Point=1.20;}
if (Volt_Alarm_Set_Point==13){Volt_Set_Point=1.30;}
if (Volt_Alarm_Set_Point==14){Volt_Set_Point=1.40;}
if (Volt_Alarm_Set_Point==15){Volt_Set_Point=1.50;}
if (Volt_Alarm_Set_Point==16){Volt_Set_Point=1.60;}
if (Volt_Alarm_Set_Point==17){Volt_Set_Point=1.70;}
if (Volt_Alarm_Set_Point==18){Volt_Set_Point=1.80;}
if (Volt_Alarm_Set_Point==19){Volt_Set_Point=1.90;}
if (Volt_Alarm_Set_Point==20){Volt_Set_Point=2.00;}

if (Volt_Alarm_Set_Point==21){Volt_Set_Point=2.10;}
if (Volt_Alarm_Set_Point==22){Volt_Set_Point=2.20;}
if (Volt_Alarm_Set_Point==23){Volt_Set_Point=2.30;}
if (Volt_Alarm_Set_Point==24){Volt_Set_Point=2.40;}
if (Volt_Alarm_Set_Point==25){Volt_Set_Point=2.50;}
if (Volt_Alarm_Set_Point==26){Volt_Set_Point=2.60;}
if (Volt_Alarm_Set_Point==27){Volt_Set_Point=2.70;}
if (Volt_Alarm_Set_Point==28){Volt_Set_Point=2.80;}
if (Volt_Alarm_Set_Point==29){Volt_Set_Point=2.90;}
if (Volt_Alarm_Set_Point==30){Volt_Set_Point=3.00;}

if (Volt_Alarm_Set_Point==31){Volt_Set_Point=3.1;}
if (Volt_Alarm_Set_Point==32){Volt_Set_Point=3.2;}
if (Volt_Alarm_Set_Point==33){Volt_Set_Point=3.3;}
if (Volt_Alarm_Set_Point==34){Volt_Set_Point=3.4;}
if (Volt_Alarm_Set_Point==35){Volt_Set_Point=3.5;}
if (Volt_Alarm_Set_Point==36){Volt_Set_Point=3.6;}
if (Volt_Alarm_Set_Point==37){Volt_Set_Point=3.7;}
if (Volt_Alarm_Set_Point==38){Volt_Set_Point=3.8;}
if (Volt_Alarm_Set_Point==39){Volt_Set_Point=3.9;}
if (Volt_Alarm_Set_Point==40){Volt_Set_Point=4.0;}

if (Volt_Alarm_Set_Point==41){Volt_Set_Point=4.1;}
if (Volt_Alarm_Set_Point==42){Volt_Set_Point=4.2;}
if (Volt_Alarm_Set_Point==43){Volt_Set_Point=4.3;}
if (Volt_Alarm_Set_Point==44){Volt_Set_Point=4.4;}
if (Volt_Alarm_Set_Point==45){Volt_Set_Point=4.5;}
if (Volt_Alarm_Set_Point==46){Volt_Set_Point=4.6;}
if (Volt_Alarm_Set_Point==47){Volt_Set_Point=4.7;}
if (Volt_Alarm_Set_Point==48){Volt_Set_Point=4.8;}
if (Volt_Alarm_Set_Point==49){Volt_Set_Point=4.9;}
if (Volt_Alarm_Set_Point==50){Volt_Set_Point=5.0;}

if (Volt_Alarm_Set_Point==51){Volt_Set_Point=5.1;}
if (Volt_Alarm_Set_Point==52){Volt_Set_Point=5.2;}
if (Volt_Alarm_Set_Point==53){Volt_Set_Point=5.3;}
if (Volt_Alarm_Set_Point==54){Volt_Set_Point=5.4;}
if (Volt_Alarm_Set_Point==55){Volt_Set_Point=5.5;}
if (Volt_Alarm_Set_Point==56){Volt_Set_Point=5.6;}
if (Volt_Alarm_Set_Point==57){Volt_Set_Point=5.7;}
if (Volt_Alarm_Set_Point==58){Volt_Set_Point=5.8;}
if (Volt_Alarm_Set_Point==59){Volt_Set_Point=5.9;}
if (Volt_Alarm_Set_Point==60){Volt_Set_Point=6.0;}

if (Volt_Alarm_Set_Point==61){Volt_Set_Point=6.1;}
if (Volt_Alarm_Set_Point==62){Volt_Set_Point=6.2;}
if (Volt_Alarm_Set_Point==63){Volt_Set_Point=6.3;}
if (Volt_Alarm_Set_Point==64){Volt_Set_Point=6.4;}
if (Volt_Alarm_Set_Point==65){Volt_Set_Point=6.5;}
if (Volt_Alarm_Set_Point==66){Volt_Set_Point=6.6;}
if (Volt_Alarm_Set_Point==67){Volt_Set_Point=6.7;}
if (Volt_Alarm_Set_Point==68){Volt_Set_Point=6.8;}
if (Volt_Alarm_Set_Point==69){Volt_Set_Point=6.9;}
if (Volt_Alarm_Set_Point==70){Volt_Set_Point=7.0;}

if (Volt_Alarm_Set_Point==71){Volt_Set_Point=7.1;}
if (Volt_Alarm_Set_Point==72){Volt_Set_Point=7.2;}
if (Volt_Alarm_Set_Point==73){Volt_Set_Point=7.3;}
if (Volt_Alarm_Set_Point==74){Volt_Set_Point=7.4;}
if (Volt_Alarm_Set_Point==75){Volt_Set_Point=7.5;}
if (Volt_Alarm_Set_Point==76){Volt_Set_Point=7.6;}
if (Volt_Alarm_Set_Point==77){Volt_Set_Point=7.7;}
if (Volt_Alarm_Set_Point==78){Volt_Set_Point=7.8;}
if (Volt_Alarm_Set_Point==79){Volt_Set_Point=7.9;}
if (Volt_Alarm_Set_Point==80){Volt_Set_Point=8.0;}

if (Volt_Alarm_Set_Point==81){Volt_Set_Point=8.1;}
if (Volt_Alarm_Set_Point==82){Volt_Set_Point=8.2;}
if (Volt_Alarm_Set_Point==83){Volt_Set_Point=8.3;}
if (Volt_Alarm_Set_Point==84){Volt_Set_Point=8.4;}
if (Volt_Alarm_Set_Point==85){Volt_Set_Point=8.5;}
if (Volt_Alarm_Set_Point==86){Volt_Set_Point=8.6;}
if (Volt_Alarm_Set_Point==87){Volt_Set_Point=8.7;}
if (Volt_Alarm_Set_Point==88){Volt_Set_Point=8.8;}
if (Volt_Alarm_Set_Point==89){Volt_Set_Point=8.9;}
if (Volt_Alarm_Set_Point==90){Volt_Set_Point=9.0;}

if (Volt_Alarm_Set_Point==91){Volt_Set_Point=9.1;}
if (Volt_Alarm_Set_Point==92){Volt_Set_Point=9.2;}
if (Volt_Alarm_Set_Point==93){Volt_Set_Point=9.3;}
if (Volt_Alarm_Set_Point==94){Volt_Set_Point=9.4;}
if (Volt_Alarm_Set_Point==95){Volt_Set_Point=9.5;}
if (Volt_Alarm_Set_Point==96){Volt_Set_Point=9.6;}
if (Volt_Alarm_Set_Point==97){Volt_Set_Point=9.7;}
if (Volt_Alarm_Set_Point==98){Volt_Set_Point=9.8;}
if (Volt_Alarm_Set_Point==99){Volt_Set_Point=9.9;}
if (Volt_Alarm_Set_Point==100){Volt_Set_Point=10.0;}

if (Volt_Alarm_Set_Point==101){Volt_Set_Point=10.1;}
if (Volt_Alarm_Set_Point==102){Volt_Set_Point=10.2;}
if (Volt_Alarm_Set_Point==103){Volt_Set_Point=10.3;}
if (Volt_Alarm_Set_Point==104){Volt_Set_Point=10.4;}
if (Volt_Alarm_Set_Point==105){Volt_Set_Point=10.5;}
if (Volt_Alarm_Set_Point==106){Volt_Set_Point=10.6;}
if (Volt_Alarm_Set_Point==107){Volt_Set_Point=10.7;}
if (Volt_Alarm_Set_Point==108){Volt_Set_Point=10.8;}
if (Volt_Alarm_Set_Point==109){Volt_Set_Point=10.9;}
if (Volt_Alarm_Set_Point==110){Volt_Set_Point=11.0;}

if (Volt_Alarm_Set_Point==111){Volt_Set_Point=11.1;}
if (Volt_Alarm_Set_Point==112){Volt_Set_Point=11.2;}
if (Volt_Alarm_Set_Point==113){Volt_Set_Point=11.3;}
if (Volt_Alarm_Set_Point==114){Volt_Set_Point=11.4;}
if (Volt_Alarm_Set_Point==115){Volt_Set_Point=11.5;}
if (Volt_Alarm_Set_Point==116){Volt_Set_Point=11.6;}
if (Volt_Alarm_Set_Point==117){Volt_Set_Point=11.7;}
if (Volt_Alarm_Set_Point==118){Volt_Set_Point=11.8;}
if (Volt_Alarm_Set_Point==119){Volt_Set_Point=11.9;}
if (Volt_Alarm_Set_Point==120){Volt_Set_Point=12.0;}

if (Volt_Alarm_Set_Point==121){Volt_Set_Point=12.1;}
if (Volt_Alarm_Set_Point==122){Volt_Set_Point=12.2;}
if (Volt_Alarm_Set_Point==123){Volt_Set_Point=12.3;}
if (Volt_Alarm_Set_Point==124){Volt_Set_Point=12.4;}
if (Volt_Alarm_Set_Point==125){Volt_Set_Point=12.5;}
if (Volt_Alarm_Set_Point==126){Volt_Set_Point=12.6;}
if (Volt_Alarm_Set_Point==127){Volt_Set_Point=12.7;}
if (Volt_Alarm_Set_Point==128){Volt_Set_Point=12.8;}
if (Volt_Alarm_Set_Point==129){Volt_Set_Point=12.9;}
if (Volt_Alarm_Set_Point==130){Volt_Set_Point=13.0;}

if (Volt_Alarm_Set_Point==131){Volt_Set_Point=13.1;}
if (Volt_Alarm_Set_Point==132){Volt_Set_Point=13.2;}
if (Volt_Alarm_Set_Point==133){Volt_Set_Point=13.3;}
if (Volt_Alarm_Set_Point==134){Volt_Set_Point=13.4;}
if (Volt_Alarm_Set_Point==135){Volt_Set_Point=13.5;}
if (Volt_Alarm_Set_Point==136){Volt_Set_Point=13.6;}
if (Volt_Alarm_Set_Point==137){Volt_Set_Point=13.7;}
if (Volt_Alarm_Set_Point==138){Volt_Set_Point=13.8;}
if (Volt_Alarm_Set_Point==139){Volt_Set_Point=13.9;}
if (Volt_Alarm_Set_Point==140){Volt_Set_Point=14.0;}

if (Volt_Alarm_Set_Point==141){Volt_Set_Point=14.1;}
if (Volt_Alarm_Set_Point==142){Volt_Set_Point=14.2;}
if (Volt_Alarm_Set_Point==143){Volt_Set_Point=14.3;}
if (Volt_Alarm_Set_Point==144){Volt_Set_Point=14.4;}
if (Volt_Alarm_Set_Point==145){Volt_Set_Point=14.5;}
if (Volt_Alarm_Set_Point==146){Volt_Set_Point=14.6;}
if (Volt_Alarm_Set_Point==147){Volt_Set_Point=14.7;}
if (Volt_Alarm_Set_Point==148){Volt_Set_Point=14.8;}
if (Volt_Alarm_Set_Point==149){Volt_Set_Point=14.9;}
if (Volt_Alarm_Set_Point==150){Volt_Set_Point=15.0;}

} // end of void Display_A_Float_Voltage_Reference()
//*/

  void Adjust_The_Volt_Alarm_Set_Point()
 { s=0;
  // push button to increase this Alarm Set Point
  if (digitalRead(Button_2) == Is_Pressed)
     { s=1;
      if (Volt_Alarm_Set_Point <= 150)
      {
       Volt_Alarm_Set_Point = Volt_Alarm_Set_Point  + 1;// this line is using a int variable
       if (Volt_Alarm_Set_Point > 150)
          {Volt_Alarm_Set_Point = 150;}
      }
     }
 // push button to decrease this Alarm Set Point
  if (digitalRead(Button_1) == Is_Pressed)
    { s=1;
     Volt_Alarm_Set_Point = Volt_Alarm_Set_Point  - 1;// this line is using a int variable
     if (Volt_Alarm_Set_Point <= 0)
     {Volt_Alarm_Set_Point = 0;}
    }
    if (s==1){EEPROM.put( VOLT_ALARM_SET_POINT_ADDR,Volt_Alarm_Set_Point);}
 }

void Read_Volt_Meter()
{
   //-------------------------------Volt Meter Code-------------------------------//
   //-----------------------------------// This code reads the value at analog
   value = analogRead(analogInput);//---// input A6 and this is where we can change
   vout = (value * 4.72) / 1024.0;//----// the volts value to what the actual supply
   vin = vout / (R2/(R1+R2));//---------// voltage is equal to by checking it with an
   if (vin<0.09) {//--------------------// accurate Digital Votl Meter then entering
   vin=0.0;//---------------------------// it here-->(value * 4.79) changing the 4.79
   }//----------------------------------// to whatever your meter reads...
   //-------------------------------Volt Meter Code-------------------------------//
}
//======= Subroutine Area ======= Subroutine Area =======//
// end the Subroutine Area
// end of the program...

Looks like Volt_Set_Point = Volt_Alarm_Set_Point/10.0; :)

Why don't you just EEPROM.put() and EEPROM.get() your float?

@EdgarBonet - That's a new one to me. Thanks!

Since your floating point value always uses only 1 digit after the comma, why not multiply it by 10 and put it in an integer? For a value up to 15.0 (resulting in 150 int), you can use a simple byte and store it in EEPROM directly.
Then you can get rid of all if statements. To make a better formula, you can even add rounding (so adding + 0.5 before converting to an int).
Thus:
EEPROM.put(VOLT_ALARM_SET_POINT_ADDR, (byte) (value * 10.0 + 0.5);

And to retrieve the value:
EEPROM.get(VOLT_ALARM_SET_POINT_ADDR, f);
f = (float) (f / 10.0);

@Michel Keijzers
I tried to use the code suggestion you sent but I couldn't get it set up properly to work with-in my code. I do thank you for your answer though. I did manage to figure out a way to save the value of my float variable to an integer and it works good. I'm including the working program below so if anyone ever googles the question I was asking they will find this and hopefully it'll be helpful to them because this works...
    {
        // this program uses 6986 bytes of program space
    // the old program with all the if statements used 11872 bytes
    // This program uses 4,886 less bytes of program space to accomplish the same thing

     #include <EEPROM.h>
     #include <LiquidCrystal_I2C.h>
     LiquidCrystal_I2C lcd(0x27, 20, 4);

    //----------Volt Meter Code----------//
        int analogInput = A6;
        float vout = 0.0;
        float vin = 0.0;
        float R1 = 99300.0;
        float R2 = 9970.0;
        int value = 0;
    //----------Volt Meter Code----------//

      int Volt_Alarm_Set_Point; // this works
      float Volt_Set_Point;
      int s = 0;
      int a = 0;
      int b = 0;

     int Button_1 = 5;
     int Button_2 = 6;
     int Button_3 = A1;
     int Button_4 = A0;
     int Alarm_Relay_1 = A3;
     int Relay_2 = A2;
     int Relay_3 = 8;
     int Blinking_Led = 3;// this one is ready to be used anytime

     #define VOLT_ALARM_SET_POINT_ADDR 0
     #define A_ADDR VOLT_ALARM_SET_POINT_ADDR + sizeof(int)
     #define B_ADDR A_ADDR + sizeof(int)

     #define Is_Pressed  0  // used for pushbuttons
     #define Is_Not_Pressed  1  // used for pushbuttons
     #define Is_Turned_On 1  // used for the relays
     #define Is_Turned_Off 0 // used for the relays

     //|---------void setup---------void setup---------|//
    void setup() {

        pinMode(Alarm_Relay_1, OUTPUT);
        pinMode(Relay_2, OUTPUT);
        pinMode(Relay_3, OUTPUT);
        pinMode(Blinking_Led, OUTPUT);
        pinMode(Button_1, INPUT); // on pin 5
        pinMode(Button_2, INPUT); // on pin 6
        pinMode(Button_3, INPUT); // on pin A1
        pinMode(Button_4, INPUT); // on pin A0
    //-----------Volt Meter Code--------------//
        pinMode(analogInput, INPUT);
    //-----------Volt Meter Code--------------//

        lcd.begin();

        lcd.setCursor(0, 0);
        lcd.print(F(" This Program Is an "));
        lcd.setCursor(0, 1);
        lcd.print(F("example on how to   "));
        lcd.setCursor(0, 2);
        lcd.print(F("save a float. Named "));
        lcd.setCursor(0, 3);
        lcd.print(F("Save_Float_Using_Int"));
        delay(3500);

        lcd.clear();

        EEPROM.get(VOLT_ALARM_SET_POINT_ADDR, Volt_Alarm_Set_Point);
        EEPROM.get(A_ADDR, a);
        EEPROM.get(B_ADDR, b);

    }// end of the void setup()

    //|---------void setup---------void setup---------|//
    //|---------void loop---------void loop---------|//

    void loop() {

        delay(50);
      //increment & decrement Volt_Alarm_Set_Point
        if (digitalRead(Button_1)==Is_Pressed
          ||digitalRead(Button_2)==Is_Pressed)
          {Adjust_The_Volt_Alarm_Set_Point();}

        Volt_Set_Point = Volt_Alarm_Set_Point*0.1;// this math displays the correct float value to the Lcd

        Read_Volt_Meter();

        lcd.setCursor(0, 0);
        lcd.print(F("This is the Volt adj"));

        if (Volt_Set_Point<10.00)// this if statement gets rid of leftover unwanted #'s
        {lcd.setCursor(19, 1);   // while decrementing the Volt_Set_Point variable
        lcd.print(" ");}
        lcd.setCursor(0, 1);
        lcd.print(F("Volt Set Pnt = "));
        lcd.setCursor(15, 1);
        lcd.print(Volt_Set_Point); // 2nd line of Lcd (displays float variable)

        lcd.setCursor(0,2);
        lcd.print(F("Voltage = "));
        lcd.setCursor(10, 2);
        lcd.print(vin);
        if (Volt_Alarm_Set_Point<10)//this if statement gets rid of leftover unwanted #'s
        {lcd.setCursor(17, 2);      // while decrementing the Volt_Alarm_Set_Point variable
        lcd.print(" ");}
        if (Volt_Alarm_Set_Point<100)// this if statement gets rid of leftover unwanted #'s
        {lcd.setCursor(18, 2);       // while decrementing the Volt_Alarm_Set_Point variable
        lcd.print("  ");}
        lcd.setCursor(16, 2);
        lcd.print(Volt_Alarm_Set_Point);  // 3rd line of Lcd (displays saved integer variable)

        if (vin <= Volt_Set_Point){digitalWrite(Relay_3, Is_Turned_On);}
        if (vin > Volt_Set_Point){digitalWrite(Relay_3, Is_Turned_Off);}

        lcd.setCursor(0, 3);lcd.print("A = ");lcd.setCursor(4, 3);lcd.print(a);
        lcd.setCursor(6, 3);lcd.print("B = ");lcd.setCursor(10, 3);lcd.print(b);

        if (a==0) {digitalWrite(Relay_2, Is_Turned_Off);}
        if (a==1) {digitalWrite(Relay_2, Is_Turned_On);}

        if (b==0) {digitalWrite(Alarm_Relay_1, Is_Turned_Off);}
        if (b==1) {digitalWrite(Alarm_Relay_1, Is_Turned_On);}

        if (digitalRead(Button_4)==Is_Pressed){
          if (a==0){a=1;}else{a=0;}
          while (digitalRead(Button_4)==Is_Pressed){
          if (a==0) {digitalWrite(Relay_2, Is_Turned_Off);}
          if (a==1) {digitalWrite(Relay_2, Is_Turned_On);}
          lcd.setCursor(0, 3);lcd.print("A = ");lcd.setCursor(4,3);lcd.print(a);
          }
          EEPROM.put(A_ADDR, a); EEPROM.put(B_ADDR, b);
        }

        if (digitalRead(Button_3)==Is_Pressed){
         if (b==0){b=1;}else{b=0;}
         while (digitalRead(Button_3)==Is_Pressed){
         if (b==0) {digitalWrite(Alarm_Relay_1, Is_Turned_Off);}
         if (b==1) {digitalWrite(Alarm_Relay_1, Is_Turned_On);}
         lcd.setCursor(6, 3);lcd.print("B = ");lcd.setCursor(10,3);lcd.print(b);
         }
         EEPROM.put(A_ADDR, a); EEPROM.put(B_ADDR, b);
        }
      }// end of the void loop()

    //|---------void loop---------void loop---------|//
    //======= Subroutine Area ======= Subroutine Area =======//

      void Adjust_The_Volt_Alarm_Set_Point()
     { s=0;
      // push button to increase this Alarm Set Point
      if (digitalRead(Button_2) == Is_Pressed)
         { s=1;
          if (Volt_Alarm_Set_Point <= 150)
          {
           Volt_Alarm_Set_Point = Volt_Alarm_Set_Point + 1;// this line is using a int variable
           if (Volt_Alarm_Set_Point > 150)
              {Volt_Alarm_Set_Point = 150;}
          }
         }
     // push button to decrease this Alarm Set Point
      if (digitalRead(Button_1) == Is_Pressed)
        { s=1;
         Volt_Alarm_Set_Point = Volt_Alarm_Set_Point - 1;// this line is using the int variable
         if (Volt_Alarm_Set_Point <= 0)
         {Volt_Alarm_Set_Point = 0;}
        }// the s variable here insures we save once & only when a button is pressed
        if (s==1){EEPROM.put( VOLT_ALARM_SET_POINT_ADDR,Volt_Alarm_Set_Point);}
     }

    void Read_Volt_Meter()
    {
       //-------------------------------Volt Meter Code-------------------------------//
       //-----------------------------------// This code reads the value at analog
       value = analogRead(analogInput);//---// input A6 and this is where we can change
       vout = (value * 4.72) / 1024.0;//----// the volts value to what the actual supply
       vin = vout / (R2/(R1+R2));//---------// voltage is equal to by checking it with an
       if (vin<0.09) {//--------------------// accurate Digital Votl Meter then entering
       vin=0.0;//---------------------------// it here-->(value * 4.79) changing the 4.79
       }//----------------------------------// to whatever your meter reads...
       //-------------------------------Volt Meter Code-------------------------------//
    }
    //======= Subroutine Area ======= Subroutine Area =======//
    // end the Subroutine Area
    // end of the program...
    }

Here, these are universal functions you should be able to use anywhere.
Call this function by using SaveFloat(your float); eg SaveFloat (12.34);
or call float yourfloat = LoadFloat();
void SaveFloat (float input) {

  String valstring = String(input);

  int digitcount = 0;

  for (int index = 0; index < valstring.length(); index++) {

    if (String(valstring.charAt(index)) != ".") {

      String temp = String(valstring.charAt(index));
      int digit = temp.toInt();

      EEPROM.update(index + 10, digit); // Change + 10 to whatever address you want to be the starting address. eg + 11 will be EEPROM.read(11);

    } else {

      EEPROM.update(index + 10, 254); // Change + 10 to whatever address you want to be the starting address. eg + 11 will be EEPROM.read(11);

    }

    digitcount++;

  }

  EEPROM.update(9, digitcount); //This address is important, so set it to an address you arent using.

}

float LoadFloat () {

  String output = "";

  for (int index = 0; index < EEPROM.read(//where you stored "digitcount"); index++) {

    if (EEPROM.read (index + 10) < 10) { // Change + 10 to whatever address you want to be the starting address. eg + 11 will be EEPROM.read(11);

      output += EEPROM.read (index + 10); // Change + 10 to whatever address you want to be the starting address. eg + 11 will be EEPROM.read(11);

    } else {

      output += ".";

    }

  }

  return output.toFloat();

}

Why are you doing all these useless and complex binary ↔ text ↔ BCD conversions just for storing the value? Why not store it as-is, in binary? E.g. void SaveFloat(float x){EEPROM.put(10,x);} and float LoadFloat(){float x;return EEPROM.get(10,x);}

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:
How to control 6 servo motors with an Arduino Mega board?
I am trying to make autonomous hexapod with an Arduino Mega board. I have followed tripod mechanism of hexapod movement. First I could control simultaneously legs (0, 2, 4) and (1, 3, 5) separately but whenever I tried to combine both i.e control 6 legs at a time I could not see any movement in the hexapod. Even in the IDE I am not getting any error.
I have connected the legs (0 to 5) to signal pins (2 to 7) respectively. I have connected a common +5v voltage and common ground voltage to individual legs using a breadboard. Can anyone give me a proper solution to overcome this issue and further would like to know how to control multiple servos and source code for it?
Here is my Arduino source code for controlling 6 servo motors.
#include <Servo.h>
Servo myservo[6];
int f=0;// create servo object to control a servo
//[0] -tibia , [1] -femur , [2] -coxa motors
void setup() {
  myservo[0].attach(2);
  myservo[1].attach(3);
  myservo[2].attach(4);
  myservo[3].attach(5);
  myservo[4].attach(6);
  myservo[5].attach(7);
}

void loop() {
  //alternatively making hexapod stand at its place
  //f is just flag variable to make it stop
  if(f==0) {
    myservo[0].write(130);
    myservo[2].write(130);
    myservo[4].write(90);
    myservo[1].write(130);
    myservo[3].write(90);
    myservo[5].write(0);
    f=1;
  }
}

Note the values that are added above are calculated separately for individual legs to mount legs on ground.

If you set your code to control 6 servos, does it work when you only connect 3 servos? If it does, then the problem may just be that your power supply is not strong enough to power 6 servos.

@EdgarBonet thank you it works fine when it connected to external power supply

I want to control 18 servos and based on your code I would add in 14 more servo objects. Is there a final code that you already finished with the 6 servos?

The Arduino Mega can handle at most 40mA on the I/O pins, and 200mA on the 5V/GND pins. Six servos will draw far more current than the max of 200mA. You could try hooking up the servo power to a separate power source and the data pins to the Arduino. Hope this helps!

in the odd case that you are actually powering your (small?) servo's directly through the arduino : you'll need an external power source for your servo's.


text:
How to read ASCII values from AT24C32 IC using Arduino? And what is serial.begin(?) in that EEPROM?
#include<Wire.h>
#include<Eeprom24C32_64.h>
#define EEPROM_ADDRESS 0x000

void setup() {
  Serial.begin(9600);
  eeprom.initialize();
  const word address = 0x000;
  const byte count = 94;
  byte inputBytes[count] = { 0 };
  byte outputBytes[count] = { 0 };
  Serial.println("Read bytes from EEPROM memory...");
  eeprom.readBytes(address, count, outputBytes);
  Serial.println("Read bytes:");
  for (byte i = 0; i < count; i++) {
    Serial.write(outputBytes[i]);
    Serial.print(" ");
  }
  Serial.println("");
}

void loop() {
}

Next code... I have tried many sketches.
#include <EEPROM.h>

void setup () {
  Serial.begin (115200);
  Serial.println ();
  for (int addr = 0x0000; addr < 0x0010; addr++) {
    Serial.print ("Address = ");
    Serial.print (addr, HEX);
    Serial.print (", value = ");
    Serial.println (EEPROM.read(addr), HEX);
  }
}  // end of setup

void loop () {
}

And most of the sketches check the internal EEPROM of the Arduino, not the external, stored on address 0x000. I want to read data from external AT24C32.

And what have you tried...?

@IHaveQuestion Please don't post code in the comments. Edit your question and add the code there.

@Majenko done code added plz help to solve this

@sempaiscuba done all codes

You have to know what the I2C address of your EEPROM is. Right now you have
#define EEPROM_ADDRESS 0x000

The example from the library you cite has this:
/**************************************************************************//**
 * \def EEPROM_ADDRESS
 * \brief Address of EEPROM memory on TWI bus.
 ******************************************************************************/
#define EEPROM_ADDRESS 0x50

Then, you have to create an instance of the Eeprom24C32_64 object:
static Eeprom24C32_64 eeprom(EEPROM_ADDRESS);

That sets up the object for the EEPROM on the right I2C address, so you can later use the eeprom object to read and write.

Your picture shows an LCD display. Are you expecting output to that?


text:
Using a pushbutton to power Arduino on and off
I need help adding a pushbutton to provide power to an Arduino to save power, as I am using a battery and the same button to power it off. This is the circuit I wish to implement.

Thanks.

Use a toggle button. Mechanical. No fancy electronics needed and 100% efficient.

you posted a useless picture of a bunch of components that have absolutely nothing to do with powering the Arduino, and you did not include the battery, which does.

If you want advice on how to power an Arduino circuit, then the circuit diagram you provide should SHOW THE POWER SOURCE!

Also, you need a flyback diode to protect your transistor from back EMF from the motor.

You can use the button as a switcher for the Arduino power. Just wire up the button between the battery + out and the Arduino's Vin port.

This would totally work for a high-power toggle button or switch, as opposed to a momentary push button. It is a simple solution, so I give it an upvote. For a solution which could use a low-power momentary push-button plus a transistor or relay, see my answer here: https://arduino.stackexchange.com/a/77428/7727.

You can attach an interrupt and just turn the arduino in sleep mode. If one of your mudules drain power while beeng inactive and drains less than 20mah while working than connect the VCC to one of the digital pins and when the arduino wakes up just turn the pin to HIGH.

This is a hardware/software "bootstrapping" problem: you need a power switch to be controlled by an Arduino, but the power switch also feeds power to, or turns ON the Arduino, which means the Arduino can't control the power switch until the Arduino is ON, and the Arduino can't be ON until the power switch is ON. Each relies on the other, so you must "bootstrap" it to turn it on and get the cycle started.
The process will look like this: you mechanically press a button with your finger, which controls either the Gate of a MOSFET transistor or the Base of a BJT transistor (or it could even power ON a normally-off relay), momentarily turning it ON. This split-second of ON time is just enough to turn on the Arduino, which now commands a signal to the Gate or Base to keep the transistor ON. Now, the Arduino maintains its own power, continually sending the necessary signal to the transistor to keep the transistor ON, which in turn powers the Arduino to keep the Arduino ON. Now, you can press another button to turn the Arduino OFF. This other button press will be read simply as a button press and the Arduino will then command the digital output pin to stop sending the signal which keeps the transistor ON, thereby turning the transistor OFF, which then turns the Arduino OFF. Now, the whole system is 100% OFF. The Arduino isn't even in sleep mode, it's just 100% not powered anymore. You use your finger press on the ON button again to bootstrap the whole system and start the process over again.
As for all of the details, this is an interesting problem I've been wanting to implement for years. I suspect it could be done with a single button, but haven't gone through the design to prove it yet. Meanwhile, for simplicity's sake, just use two separate buttons: one for ON and one for OFF, as I describe above.


text:
Controlled power-down for automotive application
I'm working on an automotive project that uses an Arduino Mega 2560.
What I need is a circuit that allows the unit to sense when the external power feed drops (triggering an interrupt?) so that the software can preserve state to the non-volatile memory and then shut down.
I was thinking some sort of capacitor/battery to run it once the eternal feed drops, but the hardware side of things is not my strong skillset - I'm more of a software kinda person.

I have been working with the new 47L16 from Microchip for this kind of thing - save state on power loss. It does it all for you (available in DIP for those that don't like surface mount).

That looks like just what I need! Do you know of any tutorials/examples I can look at for hooking it up the the Mega?

No, I don't know of any. I just worked from the datasheet - it has all you need to know, you just have to understand it.

Consider a battery backup for low power devices.  This article from allaboutcircuits.com discusses how to build a 12 to 5 volt power supply with its own battery backup.
In your specific case, run a second 12 to 5 volt regulated signal to one of the processor's digital inputs.  When the 12 volts shuts off, the signal to the processor's digital input will go low.  Poll this input and when you see it go low shutdown the processor or put the processor into a deep sleep mode to draw as little current as possible from the back up battery.
The ATmega2560 processor may not be the best chose for this. There are processors that can drop down into the nA range and still wake up periodically to check if they should be powered all the way back up.

Thanks, I'll do some experiments with my board to see how long it takes to actually shut down after power is cut.

I found a thread about this.  Unfortunately it discounts the built in ATmega2560 brownout circuit for the reasons I gave above.  If so, I really think the ATmega2560 design is flawed with respect to this feature.

There is also this rather involved thread in the Arduino forums.  At one point someone is talking about re-flashing the Arduino boot loader.

The AVR brownout detector only does the minimum needed: It re-sets the AVR and keeps it in reset while VCC is under a certain level to prevent programs going wild - It's not capable to trigger any safety action in the software.

Oh, wait - in almost all cars there is a power supply from the battery which is not shut down.  This is used for features like car-stereo-theft-prevention and the car-alarms.  You could use this as a power source and use your switched-car-power supply to trigger a controlled shutdown.  But be very very careful about drawing minimal or no current when shut down.  As I doubt there is anything preventing you from draining your car's battery.  (I'll change may answer in light of this.)

I am going to change my answer for the 2nd time. While I feel you are competent, I also feel that answers that could cause problems should not be left up for all time.  Instead I found a battery back up article for low power devices that may be a better fit.

You are right, cars have "live on ignition" and "always live" circuits. But the device I'm building is plug-in (using the car's aux power socket) and so whether this is always live, or live on ignition will depend on the car it's plugged into (most are live on ignition though)


text:
My serial Monitor of the Arduino ide does not show up when running Gui?
I have created an gui in python using pyserial to communicate with Arduino but my serial monitor does not show up it says (Serial port busy) whenever I run the gui.
The gui works fine but when I want to see the printed data for that, I am using an external LCD but I was wondering if there was a way to see the data in serial monitor. If not could you explain why? I have no idea whatsoever why is this happening.

AFAIK each serial port can only be open from at most one program at a time. are you sure that arduino IDE or another application is not using this port whan you try to open it?
have you tried opening this serial port from a program like hyperTerminal? what happened?
have you tried opening with your python application another serial port?
what happened?

The problem is simple, you are dealing PySerial using the serial communication port arduino, so you can not communicate with Arduino IDE and python at the same time.
Solution:
In the program you should print python q values you need, with the Print command, so you'll see in the CMD same as you see in the Arduino serial monitor.

If an application is already using the serial port then you won't be able to reopen it.  In this case you Python GUI is communicating with the Arduino over the serial port, so the IDE can't.  Think back to when you are just using the IDE, the serial monitor is closed whenever you upload a new version of the code to the board.
So, how do you solve it.  The simplest answer is to use another serial port for the Python app to talk to the Arduino and leave the default port free for the Arduino IDE/Serial monitor.  Software serial should work, you might need to print to both serial ports from the Arduino, but you can do that by adding another function.
An alternative might be to modify your python app to rebroadcast the debug data to another serial port and then connect to this via hyper terminal.
Hope that helps.


text:
Trying to start a timer to change lights when a button is pressed
I am trying to setup a series of lights (traffic lights) that change based on a timer that begins when a button is pressed.  The goal is to use the lights to track how long its been since you pressed the button.
The issue I am running into is trying to use the "TimeAlarms" library.  I am getting an error
'Timer' was not declared in this scope
I think it may be an issue with the version of Arduino I am using (1.6.8) but I am not sure.
Board: Arduino Leonardo
Here the code:
#include <TimeAlarms.h>
#include <Time.h>
#include <TimeLib.h>

int redPin = 2;
int yellowPin = 3;
int greenPin = 4;
int buttonPin = 5;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  while (!Serial) ;
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  // set timers in seconds, yellow = 24 hours, red = 48 hours)
  // http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
  Alarm.timerOnce(86400, YellowTimer);
  Alarm.timerOnce(172800, RedTimer);

}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(buttonPin))
  {
      setLights(LOW, LOW, HIGH)
      void YellowTimer(){
         setLights(LOW, HIGH, LOW)
         }
      void RedTimer(){
         setLights(HIGH, LOW, LOW)
         }
  }
  delay (1000);
  }

void setLights(int red, int yellow, int green)
{
  digitalWrite(redPin, red);
  digitalWrite(yellowPin, yellow);
  digitalWrite(greenPin, green);
}

Any help would be greatly appreciated.

Please use "code sample" button to display the code. It is very hard to read like you pasted now.

thank you Mattia,  I am brand new here and appreciate the formatting help.

@Chris no problem welcome in the community. Also remember that if you want to write something to someone (as you just did in the comment with my name) it's better to mention the name with [at] in order to reach the attention to the particular person (i.e., @Mattia) ;-)

You must first declare your timer functions. I have placed them above so they are visible when you call the timer. Also in the loop() you want probably to call timer.
I have changed the code to reflect what I told above. I do not have ability to test this, so please try. There may be some syntax errors, but I think you can handle it.
#include <TimeAlarms.h>
#include <Time.h>
#include <TimeLib.h>

int redPin = 2;
int yellowPin = 3;
int greenPin = 4;
int buttonPin = 5;

void YellowTimer()
{
    setLights(LOW, HIGH, LOW)
}

void RedTimer()
{
    setLights(HIGH, LOW, LOW)
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  while (!Serial) ;
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  // set timers in seconds, yellow = 24 hours, red = 48 hours)
  // http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
  Alarm.timerOnce(86400, YellowTimer);
  Alarm.timerOnce(172800, RedTimer);

}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(buttonPin))
  {
      setLights(LOW, LOW, HIGH)
      Alarm.timerOnce(86400, YellowTimer);
      Alarm.timerOnce(172800, RedTimer);
  }
  delay (1000);
  }

void setLights(int red, int yellow, int green)
{
  digitalWrite(redPin, red);
  digitalWrite(yellowPin, yellow);
  digitalWrite(greenPin, green);
}


text:
Problem related to Arduino ip address
Can anyone explain to me why my output ip is: 15.16.17.18?
I configured my addresses as follows:
Arduino :
gateway 192.168.1.1
ipaddress 192.168.1.8
subnet 255.255.255.0

My local network:
gateway 192.168.1.1

ipaddress 192.168.1.3

subnet 255.255.255.0

Then when I print it, it shows
15.16.17.18
Arduino code:
#include <SPI.h>
#include <Ethernet.h>

// network configuration. dns server, gateway and subnet are optional.

// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// the dns server ip
IPAddress dnServer(192, 168, 1, 1);
// the router's gateway address:
IPAddress gateway(192, 168, 1, 1);
// the subnet:
IPAddress subnet(255, 255, 255, 0);

//the IP address is dependent on your network
IPAddress ip(192, 168, 1, 8);

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

  // initialize the ethernet device
  Ethernet.begin(mac, ip, dnServer, gateway, subnet);
  //print out the IP address
  Serial.print("IP = ");
  Serial.println(Ethernet.localIP());
}

void loop() {
}

My output is:
IP = 15.16.17.18
Please help, thank you.

Possible reasons: counterfeit board or chip, not a wiznet based board, faulty components...

@Majenko ok.its already working now..pins are not properly placed

USER ERROR: Replace user and press any key...


text:
What is pulseIn in programming Arduino?
I have seen some tutorials on ultrasonic range detector sensor.
In that, what is the meaning of the word pulseIn?

pulseIn() is used to Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or 0 if no complete pulse was received within the timeout.
The timing of this function has been determined empirically and will probably show errors in shorter pulses. Works on pulses from 10 microseconds to 3 minutes in length. Please also note that if the pin is already high when the function is called, it will wait for the pin to go LOW and then HIGH before it starts counting. This routine can be used only if interrupts are activated. Furthermore the highest resolution is obtained with short intervals.
Syntax
pulseIn(pin, value)
pulseIn(pin, value, timeout)

Parameters
pin: the number of the pin on which you want to read the pulse. (int)
value: type of pulse to read: either HIGH or LOW. (int)
timeout (optional): the number of microseconds to wait for the pulse to be completed: the function returns 0 if no complete pulse was received within the timeout. Default is one second (unsigned long).
Returns
The length of the pulse (in microseconds) or 0 if no pulse is completed before the timeout (unsigned long).
For additional information and example code, visit: https://www.arduino.cc/en/Reference/PulseIn, hope this help you to understand the meaning of pulseIn().

Why are you copying directly from the reference page? What is the added value?

@MikaelPatel you are right, there isn't any added value. Anyway, I believe that the information contained in my answer can better help people inside the community to have knowledge of the function explained.

But you have simply copied the text directly from the reference page. And skipped the important example code!

@MikaelPatel you can edit the answer if you want to improve it with additional information. Or if you prefer you can also write a new answer.


text:
RDM6300 continuous RFID tag read
I have an RDM6300 connected to an Arduino Mega and code that can read the tag just fine:

// Function prototypes
void setup(void);
void loop(void);

// RDM6300 packet details
#define RDM6300_PACKET_SIZE  14
#define RDM6300_PACKET_BEGIN 0x02
#define RDM6300_PACKET_END   0x03

// Globack for reading RFID data
char buff[RDM6300_PACKET_SIZE];
uint32_t tag_id;
uint8_t checksum;

void setup(void) {
  Serial.begin(9600);
  Serial.println("Setting up...");

  // RFID board setup
  Serial1.begin(9600);

  Serial.println("READY. Scanning tags...");
}

void loop(void) {
  while (Serial1.available() > 0) {
    if (Serial1.peek() == RDM6300_PACKET_BEGIN || Serial1.read()) {
      Serial1.readBytes(buff, RDM6300_PACKET_SIZE);
      if (buff[13] != RDM6300_PACKET_END) {
        Serial.println("Bad1");
      }
      else {
        buff[13] = 0;
        checksum = strtol(buff + 11, NULL, 16);
        buff[11] = 0;
        tag_id = strtol(buff + 3, NULL, 16);
        buff[3] = 0;
        checksum ^= strtol(buff + 1, NULL, 16);
        for (uint8_t i = 0; i < 32; i += 8) checksum ^= ((tag_id >> i) & 0xFF);
        if (checksum) {
          Serial.println("Bad2");
        }
        else {
          Serial.println(tag_id);
        }
      }
    }
    else {
      Serial.println("Bad3");
      Serial.println(Serial1.peek(), HEX);
    }
    Serial.println("END");
  }
}

However, the output stops after reading the tag around 28 times sometimes (more, sometimes less...) . If I remove the tag from the "read" area and put it back on it start reading again for a number of times and then stop.
I have an LED connect to the RDM6300 board that is supposed to show when it detects a tag and it does blink while I hold the tag over the antenna but also stops when the Arduino stops receiving data.
As the RDM6300 is supposed to be a continuous RFID reader I was expecting to receive data for the duration I kept the tag over the antenna.
Anyone faced this same thing and found a solution ?
Thanks for any hints.

only guessing here ...... that may be normal behavior for RFID tags ..... maybe repeated reads drain the power from the tag faster than it can be refilled ..... what happens if you introduce a 1 second delay between scans??

@jsotola Unfortunately there is no "read" trigger. The module (https://www.seeedstudio.com/125Khz-RFID-module-UART.html) just starts spitting out data as soon as a tag is within reading distance of the antenna.

Ok, so it seems to be related to the tags. The "standard" keychain and credit-card type cards when used with the RDM360 only emit a single time their ID.
The same tags when used with the RDM3600 module will emit their tags a few times, but at some point the antenna can not provide enough power for the tag to emit again and the flow stops.
Fortunatly the tags I use for this project are very small tags made for birds (https://eccel.co.uk/product/3-3mm-em4102-pit-bird-tag-grey/) and when used with the RDM360 will continuoisly retransmit. I guess they need less power and the antenna is able to provide enough.
If you want to use continuous reading using regular tags, I believe there is still a way... If you "reset" the RDM360 or RDM3600 it forces "re-energize" of the tag and transmission resumes. So one could use a simple transistor to switch on and off the power to the RFID module using an Arduino I/O.

It's OK to accept your own answer as the solution to the problem. I think you get 15 rep for it.


text:
Implementing interrupts and timers on an Arduino Uno board
I am trying to implement interrupts on an Arduino Uno board.  My goal is to synthesize waves and play them via a 3.5 mm jack.  This is what I have so far, based on some code I was provided.  I have stripped it down to a somewhat barebones version in order to isolate what is wrong.  I have the audio jack plugged in to pin 9, which is what I was told is the PWM pin for this board.  However, nothing plays out of the audio jack at all.  I would really appreciate any advice or help! :)
#include "avr/pgmspace.h"
#define NUM_OSC 1    // number of oscillators
#define MAXVOL 255   // maximum volume of each oscillator

const byte sine256[256] PROGMEM = {
  128,131,134,137,140,143,146,149,152,156,159,162,165,168,171,174,
  176,179,182,185,188,191,193,196,199,201,204,206,209,211,213,216,
  218,220,222,224,226,228,230,232,234,236,237,239,240,242,243,245,
  246,247,248,249,250,251,252,252,253,254,254,255,255,255,255,255,
  255,255,255,255,255,255,254,254,253,252,252,251,250,249,248,247,
  246,245,243,242,240,239,237,236,234,232,230,228,226,224,222,220,
  218,216,213,211,209,206,204,201,199,196,193,191,188,185,182,179,
  176,174,171,168,165,162,159,156,152,149,146,143,140,137,134,131,
  128,124,121,118,115,112,109,106,103,99, 96, 93, 90, 87, 84, 81,
  79, 76, 73, 70, 67, 64, 62, 59, 56, 54, 51, 49, 46, 44, 42, 39,
  37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 18, 16, 15, 13, 12, 10,
  9,  8,  7,  6,  5,  4,  3,  3,  2,  1,  1,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,  3,  4,  5,  6,  7,  8,
  9,  10, 12, 13, 15, 16, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35,
  37, 39, 42, 44, 46, 49, 51, 54, 56, 59, 62, 64, 67, 70, 73, 76,
  79, 81, 84, 87, 90, 93, 96, 99, 103,106,109,112,115,118,121,124
  };

const byte square256[256] PROGMEM = {
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  };

const byte* const wave_table[] = {sine256, square256, triangle256, sawtooth256};

// information about the current state of a single oscillator
struct OscillatorState
{
   unsigned int phaseStep;  // frequency of this oscillator
   unsigned int volume;     // volume multiplier for this oscillator
   unsigned int phaseAccu;  // accumulator that steps through this oscillator
                            // high byte = current sample index
   const byte* waveform;    // which waveform
};

volatile OscillatorState oscillators;
volatile byte valOut;

//********* interrupt routines ******

// set up timer 1 to do phase correct PCM at a nominal frequency of 31372.549
void setupTimer()
{
// Timer1 Clock Prescaler to : 1, set WGM22 to zero, and WGM12,13 for phase     correct PCM
  TCCR1B = (TCCR1B & 0b11100000) | 0b00001;

// set it to clear compare match mode on both pins, and phase correct PCM     (WGM21 and WGM20)
  TCCR1A = (TCCR1A &0b00001100)| 0b10100001;

// set overflow interrupts enabled for timer 1
  TIMSK1 |= (1<<TOIE1);

  Serial.println("hello");
}

// each timer 1 overflow, set the next sample value for the PWMs
ISR(TIMER1_OVF_vect)
{

  oscillators.phaseAccu += oscillators.phaseStep;
  valOut = highByte(pgm_read_byte(oscillators.waveform +     highByte(oscillators.phaseAccu)) * oscillators.volume);

  OCR1A = valOut; // replaced ... = valOut[0];  // write to pin 9
}

unsigned int hzToPhaseStep(float frequency)
{
  float phaseStep = frequency * 2.0886902978652881446683197032183;    // (pow(2,16) * frequency) / 31376.6
  return (unsigned int)phaseStep;
}

void setup()
{
  delay(1000);
  Serial.begin(9600);
  OCR1A = 0;
  oscillators.waveform = wave_table[2];
  oscillators.phaseAccu = 0;
  setupTimer();
  oscillators.volume = 200;
  oscillators.phaseStep = hzToPhaseStep(440.00);
}

void loop()
{

}

I have the audio jack plugged in to pin 9 ... However, nothing plays out of the audio jack at all.

As you are relying on the timer changing the pin you need to make pin 9 output in setup:
 pinMode (9, OUTPUT);

When I did that I heard stuff - I wouldn't exactly call it pretty but I heard stuff.


text:
How do I lock out a push button input with a selectable delay?
I have a program i am working on where a relay is turned on -> waits a delay -> then turns off after either one of two things happen: 1) A set timer is reached OR 2) someone pushes a push button to trigger it.
Right now 90% of my code is working and i am stuck on how i go about "locking out" the push button from triggering the relay, for a select-able amount of delay time.
The timer portion of the code, with select-able times, is working. Depending on what analog 1 see's, it will trigger the relay appropriately after the selected time.
I tried to implement this same approach for the lock out timer, using analog 2 , to determine how long of a delay. I used a variable i called LOK to either read the button if it is unlocked (LOK = 0) or if it is locked (LOK =1) to wait the allotted delay time before unlocking and allowing the button to be read again.
I've tried all sorta of things and it still isn't functioning right. Maybe there is a better or simpler way to do this but I've racked my brain, and key word searching isn't helping.
Code below - please forgive random comments. I've been chopping up and moving things around i haven't edited any comments , so some may be from other snippets of codes from other projects.
int DUMP = 2; // Pin connected to big dump relay
int BUTTON = 3; // Pin connected to manual dump push button.
int BUTTONlight = 4; // Pin connected to push button light.

int BUTstate; // Current reading from BUTTON pin
int lastBUTstate = LOW; // Previous reading from BUTTON pin

long lastDebounce = 0; // Last time output was changed
long Delay = 50; // Debounce Time

unsigned long DUMPTIME;
unsigned long LOT;

unsigned long prevTIME;

int a=0;
int d=0;

int LOK = 0;

void setup()
{
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);

  pinMode (BUTTON, INPUT);
  pinMode (BUTTONlight, OUTPUT);
  pinMode (DUMP, OUTPUT);

  digitalWrite(DUMP, HIGH);
  delay(10000);
  digitalWrite(DUMP, LOW);
  digitalWrite(BUTTONlight, HIGH);
}

int readTselector(int pin)
// returns the button number pressed, or zero for none pressed
// int pin is the analog pin number to read
{
  int b,c = 1;
  c=analogRead(pin); // get the analog value
  if (c>1000)
  {
    b=0; // buttons have not been pressed
  }
  else
    if (c<1000 && c>600)
    {
      b=1; // button 1 pressed
    }
    else
      if (c<520 && c>400)
      {
        b=2; // button 2 pressed
      }
      else
        if (c>100 && c<400)
        {
          b=3; // button 3 pressed
        }
        else
          if (c<100)
          {
            b=4; // button 4 pressed
          }
  return b;
  }

void loop()
{
  int DUMPTIME = DTselect();
  int LOT = LOselect();

  int reading = digitalRead(BUTTON);

  unsigned long currTIME = millis();

  if ((currTIME - prevTIME) >= DUMPTIME) // Count to 2 minutes
   {
     LOK = 1;
     digitalWrite(BUTTONlight, LOW);
     digitalWrite(DUMP, HIGH);
     delay(10000);
     digitalWrite(DUMP, LOW);
     prevTIME = currTIME;
   }

  if (reading != lastBUTstate)
  {
    lastDebounce = millis();
  }

  if (LOK == 1)
  {
    delay(LOT);
    digitalWrite(BUTTONlight, HIGH);
    LOK = 0;

  }
  if ((millis() - lastDebounce) > Delay && LOK == 0)
  {
    BUTstate = reading;
  }

  if (BUTstate == HIGH)
  {
    digitalWrite(BUTTONlight, LOW);
    digitalWrite(DUMP, HIGH);
    delay(10000);
    digitalWrite(DUMP, LOW);
    prevTIME = currTIME;
  }
  lastBUTstate = reading;
}

int DTselect()
{
  a=readTselector(1);
  if (a==0) // no buttons pressed
  {
    DUMPTIME = 210000;
  }
  else
    if (a==1) // someone pressed a button!
    {
      DUMPTIME = 180000;
    }
    else
     if (a==2) // someone pressed a button!
     {
       DUMPTIME = 150000;
     }
     else
      if (a==3) // someone pressed a button!
      {
        DUMPTIME = 120000;
      }
     else
       if (a==4) // someone pressed a button!
       {
         DUMPTIME = 90000;
       }
  return DUMPTIME;
 }

int LOselect()
{
  d=readTselector(2);
  if (d==0) // no buttons pressed
  {
    delay(20000);
  }
  else
    if (d==1) // someone pressed a button!
    {
      delay(15000);
    }
    else
     if (d==2) // someone pressed a button!
     {
       delay(10000);
     }
     else
      if (d==3) // someone pressed a button!
      {
        delay(5000);
      }
      else
       if (d==4) // someone pressed a button!
       {
         delay(0);
       }
 }

what happened to the account of the OP?

I took your code and did a bit of an edit. You had some useless variables and you where redefining DUMPTIME and LOT in a wierd way. I also define some of your constants as #define's because thats the way you should always do it.
#define DUMP 2          // Pin connected to big dump relay
#define BUTTON 3        // Pin connected to manual dump push button.
#define BUTTONlight 4   // Pin connected to push button light.
#define DELAY 50        // Debounce Time

int BUTstate;           // Current reading from BUTTON pin
int lastBUTstate = LOW; // Previous reading from BUTTON pin

long lastDebounce = 0;  // Last time output was changed

unsigned long DUMPTIME;
unsigned long LOT;
unsigned long prevTIME;

int LOK = 0;

int readTselector(int pin)
// returns the button number pressed, or zero for none pressed
// int pin is the analog pin number to read
{
    int c = analogRead(pin); // get the analog value
    if (c > 1000){
        return 0; // buttons have not been pressed
    }
    else if (c<1000 && c>600){
        return 1; // button 1 pressed
    }
    else if (c<520 && c>400){
        return 2; // button 2 pressed
    }
    else if (c>100 && c<400){
        return 3; // button 3 pressed
    }
    else if (c<100){
        return 4; // button 4 pressed
    }
    else return 0; // just in case
    }

long DTselect()
{
    switch(readTselector(1)){
        case 0: return 210000; // no buttons pressed
            break;
        case 1: return 180000; // someone pressed a button!
            break;
        case 2: return 150000;
            break;
        case 3: return 120000;
            break;
        case 4: return 90000;
            break;
        default: return 210000; // default
            break;
    }
 }

int LOselect()
{
  switch( readTselector(2) ){
        case 0:  return 20000; // no buttons pressed
            break;
        case 1:  return 15000; // someone pressed a button!
            break;
        case 2:  return 10000;
            break;
        case 3:  return 5000;
            break;
        case 4:  return 0;
            break;
        default: return 20000; // default
            break;
    }
 }

void setup()
{
    pinMode(A1, INPUT);
    pinMode(A2, INPUT);

    pinMode (BUTTON, INPUT);
    pinMode (BUTTONlight, OUTPUT);
    pinMode (DUMP, OUTPUT);

    digitalWrite(DUMP, HIGH);
    delay(10000);
    digitalWrite(DUMP, LOW);
    digitalWrite(BUTTONlight, HIGH);
}

void loop()
{
    DUMPTIME = DTselect();
    LOT = LOselect();

    int reading = digitalRead(BUTTON);

    unsigned long currTIME = millis();

    if ((currTIME - prevTIME) >= DUMPTIME){// Count to 2 minutes
        LOK = 1;
        digitalWrite(BUTTONlight, LOW);
        digitalWrite(DUMP, HIGH);
        delay(10000);
        digitalWrite(DUMP, LOW);
        prevTIME = currTIME;
    }

    if (reading != lastBUTstate){
        lastDebounce = millis();
    }

    if (LOK){
        delay(LOT);
        digitalWrite(BUTTONlight, HIGH);
        LOK = 0;
    }

    if ((millis() - lastDebounce) > DELAY && !LOK){
        BUTstate = reading;
    }

    if (BUTstate == HIGH){
        digitalWrite(BUTTONlight, LOW);
        digitalWrite(DUMP, HIGH);
        delay(10000);
        digitalWrite(DUMP, LOW);
        prevTIME = currTIME;
    }
    lastBUTstate = reading;
}

A different version with a BUTflag variable to keep track of the button press and release. I have not dealt with the DUMPTIME variable but hopefully this will give you an idea of how to use flags so the logic doesn't fail.
#define DUMP 2          // Pin connected to big dump relay
#define BUTTON 3        // Pin connected to manual dump push button.
#define BUTTONlight 4   // Pin connected to push button light.
#define DELAY 50        // Debounce Time

int BUTstate;           // Current reading from BUTTON pin
int BUTflag = 0;
int go = 0;
long lastDebounce = 0;  // Last time output was changed

unsigned long DUMPTIME;
unsigned long LOT;
unsigned long prevTIME;

int LOK = 0;

int readTselector(int pin)
// returns the button number pressed, or zero for none pressed
// int pin is the analog pin number to read
{
    int c = analogRead(pin); // get the analog value
    if (c > 1000){
        return 0; // buttons have not been pressed
    }
    else if (c<1000 && c>600){
        return 1; // button 1 pressed
    }
    else if (c<520 && c>400){
        return 2; // button 2 pressed
    }
    else if (c>100 && c<400){
        return 3; // button 3 pressed
    }
    else if (c<100){
        return 4; // button 4 pressed
    }
    else return 0; // just in case
    }

long DTselect()
{
    switch(readTselector(1)){
        case 0: return 210000; // no buttons pressed
            break;
        case 1: return 180000; // someone pressed a button!
            break;
        case 2: return 150000;
            break;
        case 3: return 120000;
            break;
        case 4: return 90000;
            break;
        default: return 210000; // default
            break;
    }
 }

int LOselect()
{
  switch( readTselector(2) ){
        case 0:  return 20000; // no buttons pressed
            break;
        case 1:  return 15000; // someone pressed a button!
            break;
        case 2:  return 10000;
            break;
        case 3:  return 5000;
            break;
        case 4:  return 0;
            break;
        default: return 20000; // default
            break;
    }
 }

void setup()
{
    pinMode(A1, INPUT);
    pinMode(A2, INPUT);

    pinMode (BUTTON, INPUT);
    pinMode (BUTTONlight, OUTPUT);
    pinMode (DUMP, OUTPUT);

    digitalWrite(DUMP, HIGH);
    delay(10000);
    digitalWrite(DUMP, LOW);
    digitalWrite(BUTTONlight, HIGH);
}

void loop()
{
    DUMPTIME = DTselect();
    LOT = LOselect();

    BUTstate = digitalRead(BUTTON);

    unsigned long currTIME = millis();
/*
    if ((currTIME - prevTIME) >= DUMPTIME && !LOK){
        LOK = 1;
        digitalWrite(BUTTONlight, LOW);
        digitalWrite(DUMP, HIGH);
        delay(10000);
        digitalWrite(DUMP, LOW);
        prevTIME = currTIME;
    }
    else */
    if (LOK){
        delay(LOT);
        digitalWrite(BUTTONlight, HIGH);
        LOK = 0;
    }
    else if(!LOK){
        if(!go && BUTstate && !BUTflag){
            lastDebounce = millis();
            BUTflag = 1;
        }
        else if (!go && BUTstate && BUTflag==1 && (millis() - lastDebounce) > DELAY){
            BUTflag = 2;
        }
        else if (!go && !BUTstate && BUTflag==2){
            BUTflag = 0;
            go = 1;
        }
        else if (go){
            digitalWrite(BUTTONlight, LOW);
            digitalWrite(DUMP, HIGH);
            delay(10000);
            digitalWrite(DUMP, LOW);
            prevTIME = currTIME;
            go = 0;
            LOK = 1;
        }
    }
}

Thanks, but it still isn't functioning right when any other case but 0 on A2 is selected. It seems the push button locks out completely from being triggered at all.

What do you mean by A2? I didnt change any of the logic though. Just tidied up the functions and varibles. The code should look a little more compact now.

Ah ok, and what i meant by A2 was analog 2 input. Now what's happening is if any other value than 0 is read from A2 it seems to cycle through the process twice after each button press. So with LOT being 5000 or 5 seconds, it cycles, waits 5 secs, and instead of resetting the LED and waiting for a new button press, it cycles a second time, waits 5 secs, then resets the LED. Also it will sometimes keep getting stuck in the cycle and resetting.

@AdamAlexander I have added a different version

I can't thank you enough! I need to logically think the flag through a bit more to grasp the concept, but the flags work great! I was able to just editted the DUMPTIME logic a bit to use flags and it is now also working in conjuction with the LOT delay time! Kudos!

No problem. Using a state machine model is really the way to it though in the long run. You should look up state machine theory to get the idea. Don't forget to vote me up cheers.


text:
AVR-Toolchain for Arduino crashes on Mac OSX 10.11.6: Hints or debugging help needed
My Arduino IDE does not compile any project since I updated from Mac OSX 10.6.8 to 10.11.6.
I even tried reinstalling and also manually installing the original AVR-toolchain. But the behaviour did not change.
I still get the following error messages
signal: bus error
Fehler beim Kompilieren für das Board Arduino/Genuino Uno.

English translation of the error message is:
Error compiling for board Arduino/Genuino Uno.

Is this problem known? I could not find information about it.
Are there any known solutions to it?
Can I start Arduino IDE in debug
mode to give some usefull output what exactly causes the crash?

EDIT
I am using the current IDE 1.8.5 and also tried the nightly builds. I also tried some older versions down to 1.6.0.
EDIT 2:
Arduino 1.0.5 produces the following error:
cc1plus: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Thanks for your help!
EDIT 3
After installing UECIDE (what went smoothly) I am facing the same problem. The error happens in the AVR toolchain when calling the avr-gcc 4.9.2 compiler. In UECID the output tab shows the following output (I added linebreaks for readability):
~/Library/uecide/compilers/avr-gcc/bin/avr-g++
  -c /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-faf1be1e-2186-438b-9e1a-c56f50ce26d1/MySource.cpp
  -o /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-faf1be1e-2186-438b-9e1a-c56f50ce26d1/MySource.cpp.o
  -mmcu=atmega328p -g -std=gnu++11 -fno-threadsafe-statics
  -fno-exceptions -ffunction-sections -fdata-sections
  -DF_CPU=16000000L -DARDUINO=106 -DARDUINO_UNO -DARDUINO_ARCH_AVR
  -I~/Library/uecide/cores/arduino/arduino
  -I~/Library/uecide/boards/Arduino/arduino-uno
  -I/var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-faf1be1e-21
86-438b-9e1a-c56f50ce26d1
  -I~/pro/Arduino/MySource -Os -w

The status tab of UECID only shows Compiling Failed.
EDIT 4
After starting UECID from console with --debug --verbose options specified it did print the failing command to console:
~/Library/uecide/compilers/avr-gcc/bin/avr-g++
   -c /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-5ccb5f12-fcd1-4893-8c41-39fc056ec544/MySourve.cpp
   -o /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-5ccb5f12-fcd1-4893-8c41-39fc056ec544/MySourve.cpp.o
   -mmcu=atmega328p -g -std=gnu++11 -fno-threadsafe-statics
   -fno-exceptions -ffunction-sections -fdata-sections
   -DF_CPU=16000000L -DARDUINO=106 -DARDUINO_UNO -DARDUINO_ARCH_AVR
   -I~/Library/uecide/cores/arduino/arduino
   -I~/Library/uecide/boards/Arduino/arduino-uno
   -I/var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-5ccb5f12-fcd1-4893-8c41-39fc056ec544
   -I~/pro/Arduino/MySourve -Os -w

This command is identical to the one created by Arduino.
I found another hint on a bug in gcc 4.8 that seems not to be AVR specific.
After reducing the command line to
~/Library/uecide/compilers/avr-gcc/bin/avr-g++
  -c /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-5ccb5f12-fcd1-4893-8c41-39fc056ec544/MySource.cpp
  -o /var/folders/2h/8pdnzj197tq906bzs81ksn6m0000gn/T/build-5ccb5f12-fcd1-4893-8c41-39fc056ec544/MySource.cpp.o

the crash stays the same: Segmentation fault 11

I run 10.13.3 without any problem. Suggest to update the IDE. You can read also this article to use TextWrangler or BBEdit as editor with direct link to compile, assemble and so on. https://feroce-lapin.blogspot.com.br/2017/12/arduino-et-bbedit-textwrangler.html

I just tried the arduino web IDE. Strangely this crashes on uploading the sketch with avrdude. If I copy paste the command to a terminal window it runs and program is flashed to arduino board.

@Look Alterno: I am using the current IDE 1.8.5 and also tried the nightly builds. I also tried some older versions down to 1.6.0

There are a lot of older versions of the IDE on the Arduino web site. I don't think it particularly matters which one you use. Try using an earlier one.

When you try re-installing the IDE, make sure you clear out any old preferences that may be referencing any manually installed toolchain that may not be correct. Especially at /Users/(username)/Library/Arduino15

I have done so.

Do you happen to have any anti-virus software running which might be blocking the compiler?

I also thought about this possibility. I use Intego VirusBarrier. I deactivated the real time protection, no change.

What about your source? Does it have any multi-byte characters (Unicode)? Call any external libraries?

It seems to happen with any source. e.g "blink" example from arduino