text:
Using case statement with IR emitter reciever
I am trying to use two "infrared obstacle avoidance modules" to work with the following sketch.  From all my research, I believe, a case statement is my best option because, (I understand) the sketch will not continue until the case is satisfied, however, I'm getting a weird outcome. When using two sensors with sketch below, the leds blink in an alternating pattern without any near the ir sensors.
If I use only one module the led will light until the sensor sees something, then the led turns off for the programmed delay then turns back on.
The outcome I'm looking for is eventually three modules, that will randomly light, when one lights it waits until something breaks the beam, then another will light and wait...
Does anyone have any ideas how to make this work?
int ledselect;
int led1 = 2;
int led2 = 3;
int ir1 = 4;
int ir2 = 5;
int s1 = A0;
int s2 = A1;

void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(ir1, OUTPUT);
  pinMode(ir2, OUTPUT);
  pinMode(s1, INPUT);
  pinMode(s2, INPUT);

}
void loop() {
  ledselect = random(2);
  switch (ledselect) {

    case 0:
      digitalWrite(led1, HIGH);
      digitalWrite(ir1, HIGH);
      delay(50);
      while (analogRead(s1) >= 100)
      {
        delay(50);
        digitalWrite(led1, LOW);
        digitalWrite(ir1, LOW);
      }
      break;

    case 1:
      digitalWrite(led2, HIGH);
      digitalWrite(ir2, HIGH);
      delay(50);
      while (analogRead(s2) >= 100)
      {
        delay(50);
        digitalWrite(led2, LOW);
        digitalWrite(ir2, LOW);
      }
      break;
  }
}

the sketch will not continue until the case is satisfied ... that is not quite correct ... the case statement is just a decision structure that branches to different sections of the code depending on the value of a parameter .... it is similar to a series of if statements

What happens is:

A random number is selected
A light goes on
It goes off when nothing is near (assuming a low value of an analog sensor means nothing near?)
The same light or another light goes on (depending on the random led)
Continue with 3.

Some reasons why this might fail:

Check the value (should it be higher or lower than 100?)
Maybe the sensor is not so accurate and sometimes give 0 or max values which are incorrect. To change this, read multiple times the sensor and take the average, or remove the lowest and highest few (to remove spikes) and take the average.

UPDATE
The body of the case statements are almost equal, make it a function called from both case statements:
Your code will look like:
void loop() {
  ledselect = random(2);
  switch (ledselect) {
    case 0:
      process(led1, ir1, s1);
      break;

    case 1:
      process(led2, ir2, s2);
      break;
  }
}

void process(int led, int sw, int ir)
{
  digitalWrite(led, HIGH);
  digitalWrite(ir, HIGH);
  delay(50);
  while (analogRead(sw) >= 100)
  {
    delay(50);
    digitalWrite(led, LOW);
    digitalWrite(ir, LOW);
  }
}

If you use the ternary operator ( x ? y : z, meaning if x than y else z), than your loop function will be:
void loop() {
  ledselect = random(2);
  process(ledselect == 0 ? led1 : led2,
          ledselect == 0 ?  ir1 :  ir2,
          ledselect == 0 ?   s1 :   s2);
}

An even more elegant way, is to use an array for the parts (not sure what better name can be), instead of all variables naming 0 and 1, put them in arrays, and you get the following code below. If you make more parts, you just have the change the beginning of the code.
int ledselect;

const int NrOfParts = 2;

int leds     [NrOfParts] = {  2 , 3 };
int irs      [NrOfParts] = {  4,  5 };
int switches [NrOfParts] = { A0, A1 };

void setup() {
  Serial.begin(9600);
  for (int part = 0; part < NrOfParts; part++)
  {
    pinMode(leds    [part], OUTPUT);
    pinMode(irs     [part], OUTPUT);
    pinMode(switches[part],  INPUT);
  }
}

void loop()
{
  ledselect = random(2);
  process(leds[ledselect], irs[ledselect], switches[ledselect]);
}

void process(int led, int sw, int ir)
{
  digitalWrite(led, HIGH);
  digitalWrite(ir, HIGH);
  delay(50);
  while (analogRead(sw) >= 100)
  {
    delay(50);
    digitalWrite(led, LOW);
    digitalWrite(ir, LOW);
  }
}

Update 2
An even better way is to create a structure (so you keep all information of one 'part' together).
This solution uses the & (dereference) operator, meaning it is like a variable pointing to a part.
int ledselect;

const int NrOfParts = 2;

struct Part
{
  int led;
  int ir;
  int sw;
};

Part _parts[NrOfParts] =
{
  { 2, 4, A0 },
  { 3, 5, A1 }
};

void setup() {
  Serial.begin(9600);
  for (int partNumber = 0; partNumber < NrOfParts; partNumber++)
  {
    Part& part = _parts[partNumber];
    pinMode(part.led, OUTPUT);
    pinMode(part.ir , OUTPUT);
    pinMode(part.sw ,  INPUT);
  }
}

void loop()
{
  process(_parts[random(2)]);
}

void process(Part& part)
{
  digitalWrite(part.led, HIGH);
  digitalWrite(part.ir, HIGH);
  delay(50);
  while (analogRead(part.sw) >= 100)
  {
    delay(50);
    digitalWrite(part.led, LOW);
    digitalWrite(part.ir, LOW);
  }
}

Thank you Michel for your response. I used your suggestion to clean the sketch and greatly appreciate you taking the time to analyze my question and answer.

I added some more alternatives, do not use them if you don't feel comfortable.


text:
How to connect Arduino with ESP8266-11 WiFi module to 000webhost (free webhosting)
I want to know how to connect my Arduino to my website on 000webhost.com (free webhosting account). I'm using ESP-11 WiFi module and it is connected to the internet.
This is my Arduino code:
#include <SoftwareSerial.h>
SoftwareSerial ESP11 = SoftwareSerial(10,11); // RX, TX
#define DEBUG true

// WIFI SHIELD DECLARATION
String ssid = "\"SampleSSID\"";
String pass = "\"SamplePass\"";
String tcp = "\"TCP\"";
String remoteip = "\"jvystocksystem.000webhostapp.com\"";
String portnum = "80";

void setup(){
  ESP11.begin(9600);
  Serial.begin(9600);
  sendData("AT+CWMODE=1\r\n",2000,DEBUG); // configure as access point and Client
  sendData("AT+RST\r\n",2000,DEBUG); // reset module
  sendData("AT+GMR\r\n",2000,DEBUG); // View version Info
  sendData("AT+CWLAP\r\n",5000,DEBUG); // List all available AP's*/
  sendData("AT+CWJAP=" + ssid + "," + pass + "\r\n",10000,DEBUG); // Connect to AP
  sendData("AT+CIFSR\r\n",2000,DEBUG); // get ip address
  sendData("AT+CIPMUX=0\r\n",2000,DEBUG); //Single TCP Connections
  sendData("AT+CIPSTART="+ tcp +"," + remoteip + "," + portnum + "\r\n",3000,DEBUG); // Start connecting to localhost <link id>,<type>,<remote IP>,<Port Number>

  String getStr = "GET /getCpno.php?user_type=admin HTTP/1.0"; // Getting info from my online database through my online website
  getStr += "\r\n\r\n";
  String cmd;
  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  sendData(cmd + "\r\n",1000,DEBUG);
  sendData(getStr,3000,DEBUG);
}

void loop() {
  // put your main code here, to run repeatedly:
// For ESP8266
  if(ESP11.available()) // check if the esp is sending a message
  {

    if(ESP11.find("+IPD,"))
    {
     delay(1000); // wait for the serial buffer to fill up (read all the serial data)
     // get the connection id so that we can then disconnect
     int connectionId = ESP11.read()-48; // subtract 48 because the read() function returns
                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48

     ESP11.find("pin="); // advance cursor to "pin="

     int pinNumber = (ESP11.read()-48)*10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10
     pinNumber += (ESP11.read()-48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number

     digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin

     // make close command
     String closeCommand = "AT+CIPCLOSE=";
     closeCommand+=connectionId; // append connection id
     closeCommand+="\r\n";

     sendData(closeCommand,1000,DEBUG); // close connection
    }
  }
}

/*
* Name: sendData
* Description: Function used to send data to ESP8266.
* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)
* Returns: The response from the esp8266 (if there is a reponse)
*/

String sendData(String command, const int timeout, boolean debug)
{

    String response = ""; // ESP8266 sendData String
    ESP11.print(command); // send the read character to the esp8266

    long int time = millis();

    while( (time+timeout) > millis())
    {
      while(ESP11.available())
      {

        // The esp has data so display its output to the serial window
        char c = ESP11.read(); // read the next character.
        response+=c;
      }
    }

    if(debug)
    {
      Serial.print(response);

    }
    return response;
}

But my code is not returning the value I want from the database, instead I'm getting this in my serial monitor:

I hope you guys can help me with my code.

Why are you using software serial on an Arduino Mega? It has 4 hardware serial ports.

i dont know how to use the other ports, eh

https://www.arduino.cc/en/Reference/Serial

its work for me thanks you master you save my life

The web server is using virtual hosts. Unless you tell it to which virtual host are you making a request, the server won't know where to send the request and generate an error.
You need to add the required header Host, which tell it just that.
Make the proper request like this:
String getStr = "GET /getCpno.php?user_type=admin HTTP/1.1\r\n";
getStr += "Host: jvystocksystem.000webhostapp.com\r\n"; // add the required header
getStr += "\r\n";

You are setting up a single socket mode by AT+CIPMUX=0, therefore all commands(TX/RX) should not be contain connection id. So you could close the connection using sendData("AT+CIPCLOSE\r\n",1000,DEBUG);, and the code which related connection id also could be remove. The number which following the +IPD, is the total response bytes, which counted by following :.

source: Stack Exchange

license: 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/

sort: votes


text:
Arduino force feedback vibration gamepad
I'm projecting a gamepad with Arduino Micro. I'm using the Arduino Joystick Library.
I'm building this gamepad for racing games so I need to catch signal like hit_the_wall, hit_another_car.
I wonder how the PC game output the signal of the vibration/force feedback and send throw USB to the gamepad.
I already know that the gamepad drivers and the game have to support this function, but I'm completely lost about how I can catch the input to trigger the vibration engine with Arduino.
I was thinking something about (pseudocode):
input = Serial.read();

if(input == hit_something_signal){

   digitalWrite(engine, HIGH);

}

Now my question is which is this magic hit_something_signal?
UPDATE
I'm reading the PID document and I notice on page number 24 the register addresses to implement the force feedback.
;Start Force Feedback command definitions
USAGE_PAGE (Physical Interface) 05 0F
;Effect Report Definition
 USAGE (Set Effect Report) 09 21
 COLLECTION (Logical) A1 02
 USAGE (Effect Block Index) 09 22
 LOGICAL_MAXIMUM (127) 25 7F
 REPORT_SIZE (7) 75 07
 REPORT_COUNT (1) 95 01
 OUTPUT (Data,Var,Abs)
 .......

In the Joystick.cpp file I notice the HID implementation:
// USAGE_PAGE (Generic Desktop)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x05;
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01;

// USAGE (Joystick - 0x04; Gamepad - 0x05; Multi-axis Controller - 0x08)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x09;
tempHidReportDescriptor[hidReportDescriptorSize++] = joystickType;

// COLLECTION (Application)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0xa1;
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01;

// REPORT_ID (Default: 3)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x85;
tempHidReportDescriptor[hidReportDescriptorSize++] = _hidReportId;
.......
......

Do you think should be possible to implement the force feedback part? I do not need to catch all the forces, but run the vibrator engine every time the game sends and input of every kind of force.
The problem is that I'm not an expert about low-level programming and drivers. Do you have any idea?

existing games, like dirt 4 or F1 2017

That library has no support for vibration.
The HID report descriptor has to include the correct OUTPUT items for the PC to send the vibration instructions to the Arduino - and of course the library has to be able to handle that incoming data - none of which is implemented.
So you can't unless you massively expand that library. And that takes intimate knowledge of USB and HID protocols.

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


text:
Can't retrieve data from X-NUCLEO-IKS01A1 using I2C protocol
So I bought this nucleo expansion board, the X-NUCLEO-IKS01A1, and on the package it says it is compatible with Arduino Uno.
My goal here is to read data from any sensor on this board. (When I can read one, I can probably read the others too using the same structure)
Here's my code.
#include <Wire.h>

#define ADDRESS 0x1E
#define REGISTER 0x16

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

void loop() {
  // put your main code here, to run repeatedly
  Serial.println(I2CreadByte(ADDRESS, REGISTER));
  delay(5000);
}

uint8_t I2CreadByte(uint8_t address, uint8_t subAddress)
{
  uint8_t data; // `data` will store the register data

  Wire.beginTransmission(address);
  Wire.write(subAddress);
  Wire.endTransmission(true);
  Wire.requestFrom(address, (uint8_t) 1);

  data = Wire.read();
  return data;
}

This should return the temperature in 2's complement. But all it returns is a 1 (I can guarantee you it's not that cold in my room).
I have the board plugged on my Arduino.
Can anyone tell me what I'm doing wrong?
Here's the datasheet for the sensor I'm trying to communicate with.
Datasheet
The sub addresses are on page 33 and the I2C explantation on 27. It's called the LSM6DS0.
Thanks sooo much in advance.

You're using a wrong slave address. From the datasheet:

The Slave ADdress (SAD) associated to the LSM6DS0 is 110101xb. The SDO/SA0 pin can be used to modify the less significant bit of the device address. If the SDO/SA0 pin is connected to a voltage supply, LSb is ‘1’ (address 1101011b), else if the SDO/SA0 pin is connected to ground, the LSb value is ‘0’ (address 1101010b). This solution permits to connect and address two different inertial modules to the same I2C bus.

This means your sketch should contain:
#define ADDRESS 0x6A  // if SDO pin is pulled down

or:
#define ADDRESS 0x6B  // if SDO pin is pulled up

It's also a good idea to check if there's actually anything in the Wire buffer (with Wire.available()) before you attempt reading.
Finally, I suggest you read both OUT_TEMP_H and OUT_TEMP_L registers, in order to calculate the temperature correctly. The datasheet says the temperature output is zero at 25 degrees Celsius and that the sensitivity is 16 LSB/C. This means you have to read both registers, combine their results to get a 16-bit signed integer (OUT_TEMP_H is the MSB), divide it by 16 to get the temperature offset, and add the result to 25 degrees Celsius to get absolute temperature.

Where did you find the offset and precision? I can't seem to find them.

@CasperVranken Its all in a table in the datasheet. I dont remember the page but search the pdf for "LSB" and you should come across the 3-row table. The offset is mentioned below the table in a note.


text:
Arduino Uno: how to increase distance of serial communication to PC
Does Arduino Uno's serial communication to  PC has the same distance as USB communication? (if I'm not mistaken 5m) If it is, what are the options for me to be able to communicate from Arduino Uno to PC with a longer distance? Thank you for any help!

One alternative is to use a Bluetooth module.

There are many options of varying complexities, pros, cons and prices.
The simplest method is to use powered USB hubs to extend the range. It's 5m per run of cable between powered hubs, so if you have access to power at 5m intervals (or can provide power at 5m intervals) you can chain hubs together to increase your distance. That rapidly becomes unwieldy and expensive though.
Assuming you want to keep the ability to directly program your Arduino from the PC without having to mess with swapping cables around, etc, other options include:

USB over CAT5 adapters (up to 100m length)
Bypass the USB altogether and use RS-232 (MAX-232 chips, about 15m length)

There are also some bluetooth adaptors that allow programming of the Arduino, but that gets a bit tricky.
If you're not too worried about programming there are far more options:

Radio options, such as using XBees, nRF24L01 modules, etc.
Networking - connect to an Ethernet or WiFi network
GSM modem
RS-485 / RS-422 - similar to RS-232 but longer distance, and without the signals needed for rebooting the Arduino for programming

The "distance" of the fully networked options is, literally, global. Once on a network you have the option of arranging access from anywhere on the globe with an internet connection
It all depends, really, on what you want to be able to do over the connection.
(I am sure there are many more options I have forgotten - feel free to suggest them in comments, or even go ahead and edit this answer to add them if you like.)

Thank you for such comprehensive answer! I find the USB over CAT5 adapters more appropriate to what I'm trying to do, since I'm trying on sticking to wired and don't really know how to use rs232 communication for arduino and USB hubs are expensive. When you mean USB over CAT5 adapters is this what you mean? If I'm going to use this, will the power from my computer's usb enough?

I can't tell from that image. If it is the same as this then yes - up to 50m or something. Note that you (usually) need to power the Arduino separately.

oops sorry, yes the image I sent is the same as that. Ok noted, thanks for your help! now I gained hope in finishing my project


text:
SPIFFS image does not fit in flash (offset 108MB)
I'm trying to upload an empty SPIFFS image to my ESP32's flash memory via the ESP32 sketch data uploader but I'm getting the following error:
[SPIFFS] data   : /path/to/my/data
[SPIFFS] start  : 108068864
[SPIFFS] size   : 1596
[SPIFFS] page   : 256
[SPIFFS] block  : 4096
[SPIFFS] upload : /tmp/arduino_build_145856/firmware.spiffs.bin
[SPIFFS] address: 108068864
[SPIFFS] port   : /dev/ttyACM1
[SPIFFS] speed  : 921600
[SPIFFS] mode   : dio
[SPIFFS] freq   : 80m

esptool.py v2.8-dev
Serial port /dev/ttyACM1
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 84:0d:8e:18:a8:b4
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 8MB

A fatal error occurred: File /tmp/arduino_build_145856/firmware.spiffs.bin (length 1634304) at offset 108068864 will not fit in 8388608 bytes of flash. Use --flash-size argument, or change flashing address.
SPIFFS Upload failed!

I have chosen the correct flash-size (8MB) and the default partition scheme which worked before and I have also compiled/uploaded a version for 4MB flash size and the corresponding default partition scheme, but the data uploader still wants to write at the illegal address. I also erased the flash before uploading - no effect.
Why does it want to write to an offset of 108MB ?! Is there a bug in the data uploader? To odd things out I'd like to have a look at the partition scheme, but I can't find the directory where those are located (I'm on linux).
Has anyone experienced this before?
EDIT: this is the partition table I read back from the ESP32:
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,20K,
otadata,data,ota,0xe000,8K,
app0,app,ota_0,0x10000,3264K,
app1,app,ota_1,0x340000,3264K,
eeprom,data,153,0x670000,4K,
spiffs,data,spiffs,0x671000,1596K,

EDIT 2: I found that the partition table has to be stored at address 0x9000 on newer devices (while it was 0x8000 on older ones). Could this be the root of the problem? The program I uploaded worked fine, though (except for SPIFFS features).
Where can I configure the partition table's offset when using the arduino IDE?

It's interesting that 108068864 is 0x6710000 whereas the partition table is for 0x671000. It's uploading at exactly a factor of 10 out. Something somewhere is calculating or obtaining a completely wrong value. What version of the ESP32 core are you using?

Looking at your partition table it must be a bit old, since the eeprom partition is obsolete now. EEPROM data is stored in nvs these days.

Oh, and the location of the partition table is controlled by the bootloader, not the age of the device.

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


text:
Arduino & ARM - Replacement for avr-libc?
There is very cool avr-libc library that provides direct access for all functions of AVR microcontrollers. I'm writing a project for Arduino Due and I want to use timers and ISRs directly. Is there a library like avr-libc for ARM Cortex M3?

I found the official library here: http://www.atmel.com/tools/atmel-arm-toolchain.aspx
UPDATE:
I have finally understood understand how exactly Arduino accesses specific ARM features. It includes sam.h file which in turn contains Cortex Microcontroller Software Interface Standard. With this cool interface anyone can use so many cool features:

Timers
Advanced interrupts
Power saving mode
SIMD instructions
And many other

I think newlib is the one you want.
howto

Thanks, looks good. But it's more like a replacement for Arduino. May be there is something that could be imported to Arduino project like avr libc?


text:
How would I use Arduino microcontroller separately?
I'm learning Arduino. I use Arduino Uno board with ATMEGA328-PU. I tried basic codes like LED blink, control of DC motor etc. Arduino board is used only when we program microcontroller, right? I mean, when we finish programming it, we can use microcontroller separately? If it can be used separately, we must have some "external" circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used? I'm new in this field so don't blame me because of amateur questions.

Assuming you are going to upload the program into the ATmega328 on the Arduino, then take the ATmega328 out of the socket, and use it in your circuit, then a simple answer is to search for "minimal Arduino circuit"
An example returned by that search is "From Arduino to a Microcontroller on a Breadboard".
It lists:

a 16 MHz crystal,
a 10k resistor, and
two 18 to 22 picofarad (ceramic) capacitors

That is enough to run the chip at the same speed as the Arduino, and the code used on the Arduino to initialise its clock will work unchanged.
This should run okay directly from a battery supply of about 4.5V or 4.8V, or a good 5V power supply.
A better circuit, which runs at the same 16MHz speed as the Arduino is 'Shrimp It'. That shows a similar minimal circuit and a better 'protected' circuit which has a more reliable approach for its power supply. This is all you need to run off a 4.5V (e.g. 3 1.5V) battery power supply.
However, if you don't care about running at 16MHz, you could ditch the crystal and capacitors, and use the internal 8MHz oscillator, that will need the code to be slightly different. For example, the 8MHz clock is 1/2 the speed of the Arduino's standard 16MHz, so code like delay() will take 2ms instead of 1ms.
Further, the RESET button can be set up so it doesn't need the 10k pullup.
So, with some software changes (search the web for details), an ATmega328 could be used with no external components.
Alternatively, you might want to use a better power supply, for example a voltage regulator with the circuit of the protected 'Shrimp It', and be able to load the program onto the ATmega while on its board.
There are products which bundle that 'standard' set of parts (voltage regulator, plugs and sockets and protected 'Shrimp It' running exactly like an Arduino at 16MHz) with a very compact PCB. They are able to plug directly into a breadboard, and so can be used with veroboard/stripboard (or a PCB) to make the rest of the circuit.
One is a kit called 'Boarduino'from adafruit. That web site gives some details to sow how to do this yourself. It is a convenient-to-use version of the 'Shrimp It', on a compact PCB.
An alternative kit is the "Really Bare Bones Board (RBBB) kit". However it is available as the PCB only, which is the "Really Bare Bones board (RBBB)", though the same supplier as the RRRB kit.
Neither Boarduino nor RRRB has on-board USB upload circuit. However, you can use your Arduino to do that, for example "Using an Arduino as an AVR ISP (In-System Programmer)". Or you could buy a USB to UART cable.

Without some capacitor(s) between Vcc an GND the ATMega can sometimes behaving erratic.

There are two approaches to this.  One is to simply use the Arduino Uno board in your final product!  However, if you're making a large number of boards, it may be more cost efficient to develop a custom board with only the features you need.  It may be nothing more than a few GPIO pins and a power regulator!
Another thing which can be important in these final products, no matter what board you are using, is that you can permanently burn your program into memory so that it always starts up when power is applied.

Look at the schematics and see which bits you don't need. Leave those out and what's left is what your require. You then would need to design a circuit board for these parts.

Now, who should we blame for your amateur questions? ;^)

Your English isn't too bad! For one or two projects the ready-made Arduino boards are good value because everything is tested. Building your own circuits is good fun but is expensive and difficult if using surface mount components. If you are going to make, maybe, 20 + of the same device then making your own board might be a good idea. I don't think you are ready for that yet.

If you want to buy a cheap almost bare minimum Atmega breadboard, consider a chinese clone of Arduino pro mini. Difficult to fabricate one cheaper yourself.

Arduino board is used only when we program microcontroller, right?

Not necessarily. The Arduino board is useful not only for programming, but because it provides required peripheral circuitry such as power regulation, USB-serial interface, convenient headers, and a crystal.
However, it is perfectly fine to use the Arduino board to program your ATmega328 and then take it out and use it in another circuit.

If it can be used separately, we must have some "external" circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used?

All the ATmega328 really needs is a stable power supply. If you're alright running it at 8MHz, you don't need an crystal. If you don't need in-circuit programming, you don't need an ISP connection or any USB-serial stuff.
For more powerful microcontrollers, you might require clock generation circuitry, multiple power rails, debug/programming connections, etc.


text:
Why use .h files with .cpp?
At school, our teacher always taught us to use .hpp (C++ Header files) with our .cpp (C++ files). But Arduino seems to use .h files (with .cpp links?).

When someone is programming in C (without C++ compiler) they have the chance to get linked to a .cpp file through a .h file?

So why isn't a .cpp file always with a .hpp file?
What are the drawbacks of using .hpp files with your .cpp files?

This is not to start a discussion on what's best, please provide an answer with arguments that are not based on "what you like to do more".

The extension you use for a header file doesn't technically matter because the compiler never sees it. You could name it with the extension .this-is-a-header-file and it would probably still work.
The compiler only handles the C/C++ source files, typically named .c and .cpp. However, before that happens, the preprocessor goes through and looks for any #include lines. When it sees one, it basically copies the entire contents of the included file into the source file before it gets compiled.
This is normally used to include header files. However, the preprocessor doesn't know or care about different programming languages. All it does is process the raw text so there's nothing stopping you from including any text file you like, with any name or extension.
Choosing to use .h or .hpp is mostly just personal preference. You could certainly argue that it lets you (as a programmer) distinguish between C/C++ code more easily.
However, the reason why .h is more common is probably that C and C++ code is mixed so freely. You can generally compile C code as C++ without any problems, in which case it's the context (rather than the file itself) that tells you if it's C or C++. It's also possible to write a library in C++ which only exposes a C interface, meaning it could be used by C programs.
You could definitely include a C++-specific header file in a C program by mistake. All that would happen is that the compiler wouldn't understand the contents of that header file. Sensible development environments don't link to a project/library when it sees a #include directive (the Arduino IDE is the only one which does this, as far as I'm aware).

So there isn't really a standard for this? Or well, it defines that it doesn't really matter wethether it's a .hpp or .h... interesting...

Also .cxx and .hxx. I've seen those too. Because they look like pluses that fell over, or something.

It doesn't matter which one you use in most cases, but there are conventions.  For example, many libraries have both C and C++ bindings.  You can't put the C++ syntax into a C header, because it wont compile.  In such situations, it is common to have the .h file contain the C header, and a matching .hpp containing the C++ interface (which often, includes the .h and then wraps it in more C++ friendly notation)

@MarkAllen using xx instead of ++ seems to prevent problem with special char is some obscure fs. Maybe there is no real problem, but someone decided to not risk.


text:
HC-05 to low cost AB shutter 3
I'm trying to connect a HC-05 to AB Shutter3 module. However, when I try to search AB Shutter3 address via AT commands (AT+INQ) I could not find AB Shutter3.
I want to integrate both, so that I can send commands from an AB Shutter button click to HC-05.
I also want to know whether the HC-05 needs to be in master or in slave mode.

I agree with Majenko. According to here you can not do it with hc-05. You need a hc-06 for this at least.

Why is the HC-06 sufficient while the HC-05 not? AFAIK the HC-06 is a reduced version of the 05 (only slave instead of master/slave)

I rather suspect the AB Shutter 3 is a Bluetooth HID device (like a keyboard or a mouse). The HC-05 can only communicate with Bluetooth Serial devices, such as the HC-06 or systems that can emulate a serial device (such as a computer or a smartphone).
You won't get them to communicate no matter how hard you hit them.


text:
nRF24L01+ (RF24) radio with Arduino Micro
I purchased several nRF24L01+ (RF24) radios to use with my Arduino Uno and Micro.
Using the GettingStarted sketch and nRF24L01+ connected to my Uno, I get nice debugging info in my serial monitor. However when I connect the nRF24L01+ to my Micro, upload the sketch and open the serial monitor I get no debugging information. There is no info displayed in the serial monitor.
Also the Arduino Uno when set to Transmit, does not see the other nRF24L01+. Any help would be appreciated.
Here is my pinout to connect the nRF24L01+ to the Micro:
Line    From Arduino Pin    To nRF24L01+
GND     GND                 1
3V3     3V3                 2
CE      9                   3
CSN     10                  4
SCK     SCK                 5
MOSI    MOSI                6
MISO    MISO                7

Here the nRF24L01+

Sketch
/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10

RF24 radio(9,10);

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

//
// Role management
//
// Set up role.  This sketch uses the same software for all the nodes
// in this system.  Doing so greatly simplifies testing.
//

// The various roles supported by this sketch
typedef enum { role_ping_out = 1, role_pong_back } role_e;

// The debug-friendly names of those roles
const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};

// The role of the current running sketch
role_e role = role_pong_back;

void setup(void)
{
  //
  // Print preamble
  //

  Serial.begin(57600);
  printf_begin();
  printf("\n\rRF24/examples/GettingStarted/\n\r");
  printf("ROLE: %s\n\r",role_friendly_name[role]);
  printf("*** PRESS 'T' to begin transmitting to the other node\n\r");

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
  radio.setPayloadSize(8);

  //
  // Open pipes to other nodes for communication
  //

  // This simple sketch opens two pipes for these two nodes to communicate
  // back and forth.
  // Open 'our' pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

  if ( role == role_ping_out )
  {
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
  }
  else
  {
    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1,pipes[0]);
  }

  //
  // Start listening
  //

  radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

  radio.printDetails();
}

void loop(void)
{
  //
  // Ping out role.  Repeatedly send the current time
  //

  if (role == role_ping_out)
  {
    // First, stop listening so we can talk.
    radio.stopListening();

    // Take the time, and send it.  This will block until complete
    unsigned long time = millis();
    printf("Now sending %lu...",time);
    bool ok = radio.write( &time, sizeof(unsigned long) );

    if (ok)
      printf("ok...");
    else
      printf("failed.\n\r");

    // Now, continue listening
    radio.startListening();

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    // Describe the results
    if ( timeout )
    {
      printf("Failed, response timed out.\n\r");
    }
    else
    {
      // Grab the response, compare, and send to debugging spew
      unsigned long got_time;
      radio.read( &got_time, sizeof(unsigned long) );

      // Spew it
      printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
    }

    // Try again 1s later
    delay(1000);
  }

  //
  // Pong back role.  Receive each packet, dump it out, and send it back
  //

  if ( role == role_pong_back )
  {
    // if there is data ready
    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      unsigned long got_time;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &got_time, sizeof(unsigned long) );

        // Spew it
        printf("Got payload %lu...",got_time);

        // Delay just a little bit to let the other unit
        // make the transition to receiver
        delay(20);
      }

      // First, stop listening so we can talk
      radio.stopListening();

      // Send the final one back.
      radio.write( &got_time, sizeof(unsigned long) );
      printf("Sent response.\n\r");

      // Now, resume listening so we catch the next packets.
      radio.startListening();
    }
  }

  //
  // Change roles
  //

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == role_pong_back )
    {
      printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");

      // Become the primary transmitter (ping out)
      role = role_ping_out;
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
    }
    else if ( c == 'R' && role == role_ping_out )
    {
      printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");

      // Become the primary receiver (pong back)
      role = role_pong_back;
      radio.openWritingPipe(pipes[1]);
      radio.openReadingPipe(1,pipes[0]);
    }
  }
}

I assume you do see the first few printfs in the serial console, as they are called even before the RF24 is initialized.

Changing the pins to 2 and 3 and setting them with RF24 radio(2,3);, works. However the info to be displayed when setup() is run never displays. Even though this does not display the 2 radios are talking to each other. The other weird thing I noticed is that when connected to the Micro, the radio drops. I don't seem to have this issue with the Uno or when I have it connected to a Raspberry Pi.

@bersch - Make it an answer and its yours. I was able to fix the issue with the radio drops by testing with my Mac and not an old PC. Not sure if that was this issue, but I am not having issues now

Of course, 9 means D9 and not A9.
Everytime Arduino projects assign a pin with no prefix, it is denoted as data I/O and if the Analog pins are used then it would say A9.
The nRF24L01 handles data I/O and not analog input.

Some good, but not necessarily obvious, points made...


text:
Arduino Nano with Arduin Nano Ethernet shield ENC28J60
I have connected the Arduino Nano with the Arduino Nano ENC28J60, and then I connect the Ethernet cable with the laptop and also the Arduino nano with my laptop to load the code and it works just fine.
I was wondering if I want to disconnect the Arduino Nano with the laptop and run the same code then, how should I put the external power supply on ENC28J60 and what should be, and in general, what should be the right wiring?

use a phone charger

phone charger is not functional, I want to use for example, power supply, is it possible;

phone charger is power supply. why is it "not functional"? you can use the Vin pin of Nano as it is documented on the shop page. https://store.arduino.cc/arduino-nano


text:
Upgrading NRF module for drone
Hello I am trying to make a drone by using Arduino as a microcontroller both for remote controller and the drone. And I have thought for using NRF module. But I came to know it only can transmit data to 1000 m maximum but I need the range around 8 km maximum. What can I do for increasing the range of my drone? Or is there some way to increase range of NRF module?

This is silly. You won't be able to see the drone that far. How are you going to control what you can't see? You will have to pick transciever that operate at a much lower frequency. Thus limiting the bandwidth. Don't even think about streaming live video on those.

Most countries have laws about operating drones out of line of site, or over a few hundred meters away, etc. An nRF24L01+ is more than adequate if you want to remain within the law...

I have managed all the settings there would be ground controlled station only i need to increase maximum range. And I already own drone license.

If I search I see plenty of examples of RF with 40 miles, e.g.:

XTend 900 1W RPSMA - 40 Mile Range
XBee-900-Datasheet

Possibilities to increase the range:

More powerful transmitter
External / better antenna(s)
Better receiver
Using directional communication (might be hard with a drone which flies/moves)

@Juraj ... I meant actually 1000 m, but probably that's his currently used nRF.

I need a arduino compatible device


text:
Which is better millis() or timer?
I want to create a 30 minutes delay in my program (Arduino).
which is better millis() or timer for this purpose?
please give me an example to clarify my doubt ...
Thanks.

sleep is best for 30 minutes

the same question with more info https://forum.arduino.cc/index.php?topic=627149.0

It depends on your need:
1. No other activities / main power
If during those 30 minutes (I guess), the MCU does not have to do anything else (except maybe handling some short interrupts), than you can use a delay. You can use this if your power source is an adapter, but you waste a lot.

Advantage: Easy to program
Disadvantage: Power will continue to be used.

2. No other activities / battery
If you have the same conditions as above, but using a battery, than as Juraj mention, use the sleep functionality of the Arduino. You need an (external) real time clock or other circuitry to activate the wakeup signal after 30 minutes.

Advantage: Very less power used during the 30 minute delay
Disadvantage: Slightly more programming

3. Other activities
If you want to do now (or later) other code to be executed during the 30 minute wait, use millis(). For example, when you want to extend your project using other libraries that needs a faster than 30 minute response.

Advantage: You can do other tasks meanwhile
Disadvantage: More power usage, slightly more programming

esp8266 has built-in RTC with deep sleep wake-up option

for example blink a LED to show that it is alive

interrupts to keep the WiFi connected

@Juraj thanks for the extra comments .. offtopic:. btw congratulations with your 10K reputation. I removed my other answer so you don't need to downvote it anymore).


text:
nRF24L01 with antenna transmitter and receiver

I am trying to use nRF24L01 with antenna  in my project, but when I do test with getting start from rf24 master is showing a serial monitor like in the picture abov e. What is the problem here?

Does your serial monitor Baud-Rate match the one of the sketch?

Thank you very much you find it i checked now and look ok!

Search in the code for the line Serial.begin(###) where ### is a number representing the serial speed, also known as baud rate.
This number must match with the baud rate of your serial monitor, otherwise all you get is garbage.
BTW, this has nothing to do with nRF24, this is plain Arduino serial connection.


text:
Matrix keyboard and 7segment display countdown combination
I'm working on an escape room for my university with an Arduino Mega.
The last part consists of a 7segment display representing a time countdown, and the participants have to introduce the correct number in a matrix keyboard before it reaches zero.
My problem comes when for representing the seconds in the countdown, I have to use a delay, and this stops the matrix keyboard from getting the numbers.
The code I have so far:
char keys[4][4] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[4] = { 5, 4, 3, 2 };
byte colPins[4] = { 9, 8, 7, 6 };

int pinA = 26; //2
int pinB = 34; //3
int pinC = 31; //4
int pinD = 27; //5
int pinE = 25; //6
int pinF = 28; //7
int pinG = 33; //8
int D1 = 24; //9
int D2 = 30; //10
int D3 = 32; //11
int D4 = 35; //12

Keypad mykeypad = Keypad( makeKeymap(keys), colPins, rowPins, 4, 4);

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

pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(D1, OUTPUT);  //Turns the first digit on.
pinMode(D2, OUTPUT);  //Turns the second digit on.
pinMode(D3, OUTPUT);  //Turns the third digit on.
pinMode(D4, OUTPUT);  //Turns the forth digit on.
}

//
void showTime(){

  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);

 //3
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  delay(1000);

//2
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  delay(1000);

  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  delay(1000);

  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  delay(1000);

}

//Receives the chars from the matrix keyboard.
void getCode(){
   char key = mykeypad.getKey();
  if(key){
     Serial.print(key);
  }
}

void loop()
{

  showTime();

}

Any idea on how can I archieve this combination? Have been trying to find something similiar to a Thread, but Arduino doesn't support it.
Thanks in advance.

You do not have to use delay(), however. Take a look at some examples of how to set up timed actions without using delay() https://learn.adafruit.com/multi-tasking-the-arduino-part-1/using-millis-for-timing

Try using millis(), it returns the number of milliseconds passed since the Arduino board began running the current program.
When you start the countdown you set a variable for a beginning time
int millisBegin = millis(); //put this at the end of your setup() {}.
You will also need a "border" to know when one second is over, so
int millisBorder = 1000; //one second border
Every time your the loop() {} starts over you can check if one second has passed so far
int millisNow = millis();
if(millisNow - millisBegin >= millisBorder){} //if one second over, do {}

Now I would work on the segment showing thingy. In the {} I would put a new variable, let's call it counter = 4; //4 because I found 3 numbers in your sketch. Every time the if() {} is being executed, you go through more if () {} statements, checking what number to display next.
if (counter == 3)
{
  //show number 3
}

if (counter == 2)
{
  //show number 2
}

if (counter == 1)
{
  //show number 1
}

if (counter == 0)
{
  //show number 0
}
counter = counter - 1;

At the end we take one off the counter, so the next time we enter the if(one second over) the number displayed will get lower
And well now there are multiple ways of doing the keyboard thingy. You can keep checking if there is a key available, and if so you can safe it as a String (most people hate strings, but I never had a problem with them to be honest).
After you've saved the key as a String you can use the strcmp(); method to compare the string with the solution/answer strcmp(key,answer);. If the key and the answer are the same, it will return 1.
if(strcmp(key,answer) == 1)
{
  Serial.println("you made it");
}

Use the "blink without delay" examples in the IDE, whereby you perform an action and then basically watch the clock until and let the rest of the code run until the time elapes.  For example, this blinks the onboard LED on and off, you can add to it for your keypad reading and time outputs.
unsigned long currentTime;
unsigned long previousTime;
unsigned long elapsedTime;
const byte ledPin = 13;
byte ledState = 0;

void setup(){
pinMode (ledPin, OUTPUT);
previousTime = millis();
}
void loop(){
currentTime = millis();  // capture the 'time' now
elapsedTme = currentTime - previousTime; // how much 'time' has passed
if (elapsedTime >= 1000){  // at least one second?
ledState = 1 - ledState; // results in 1,0,1,0,1,0 ...
digitalWrite (ledPin, ledState); // toddle the L led
previousTime = currentTime;   // set up for the next pass thru loop
// update the to display, and output it
}
// now add keypad reading stuff
}


text:
I have problem in sketch compiling error message is 'printNormalModeMessage' is not declared so what I can do
/* a,rduino door look project */
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>
#include <Servo.h>

#define RST_PIN  9
#define SS_PIN 10

byte readCard[4];
char* myTags[100] = {};
int tagsCount = 0;
String tagID = "";
boolean successRead = false;
boolean correctTag = false;
int proximitySensor;
boolean doorOpened = false;

//Creat instance
MFRC522 mfrc522(SS_PIN, RST_PIN);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//Parameters : (rs, enable, d4, d5, d6, d7)
Servo myServo;

void setup() {
  //Initiating
  SPI.begin();
  mfrc522.PCD_Init();
  lcd.begin(16,2);
  myServo.attach(8);

  myServo.write(10);

  lcd.print("-No Master Tag!-");
  lcd.setCursor(0,1);
  lcd.print("   SCAN NOW");

  while (!successRead) {
    successRead = getID();
    if (successRead == true) {
      myTags[tagsCount] = strdup(tagID.c_str());
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("-Master  Tag Set!-");
      tagsCount++;
    }
  }
  successRead = false;
  printNormalModeMessage();
}
void loop() {
  int proximitySensor = analogRead(A0);
  // if door closed
  if (proximitySensor > 200) {
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
      return;
    }
    if ( ! mfrc522.PICC_ReadCardSerial()) {
      return;
    }
    tagID = "";
    for ( unit8_t i = 0; i < 4; i++) {
      readCard[i]  = mfrc522.uid.uidByte[i];
      tagID.concat(String(mfrc522.uid.uidByte[i],HEX));
    }
    tagID.toUpperCase();
    mfrc522.PICC_HaltA();

    correctTag = false;
    if (tagID == myTags[0]) {
      lcd.clear();
      lcd.print("Program mode:");
      lcd.setCursor (1,0);
      lcd.print("Add/ Remove Tag");
      while (!successRead) {
        successRead = getID();
        if (successRead == true) {
          for (int i = 0; i < 100; i++) {
            if (tagID == myTags[i]) {
              myTags[i] = "";
              lcd.clear();
              lcd.setCursor(0,0);
              lcd.print("   Tag Removed!");
              printNormalModwMessage();
              tagsCount++;
              return:
            }
          }
        myTags[tagsCount] = strdup(tagID.c_str());
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print(" Tag Added!");
        printNormalModeMessage();
        return;
        }
      }
    }
    successRead = false;
    for (int i = 0; i < 100; i++) {
      if (tagID == myTags[i] ) {
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print( "Access Granted!");
        myServo.write(170);
        printNormalModeMessage();
        correctTag = true;
      }
    }
    if (correctTag == false) {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(" Access Denide!");
      printNormalModeMessags();
    }
  }
  else {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(" Door opeded!");
    while (!doorOpened) {
      proximitySensor = analogRead(A0);
      if (proximitySensor > 200)  {
        doorOpened = true ;
      }
    }
    doorOpened = false;
    delay(500);
    myServo.write(10);
    printNormalModeMessage();
  }
}
uint8_t getID() {
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return 0;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) {
     return 0;
  }
  tagID = "";
  for ( unit_8 i = 0; i < 4; i++) {
    readCard[i] = mfrc522.uid.uidByte[i];
    tagID.concat(String(mfrc522.uid.uidByte[i],HEX));
  }
  tagID.toUpperCase();
  mfrc522.PICC_HaltA();
  return 1;
}
void printNoramalModeMessage() {
  delay(1500);
  lcd.clear();
  lcd.print("-Access Control-");
  lcd.setCorsor(0,1);
  lcd.print( " Scan Your Tag!");
}

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries D:\arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\pc\AppData\Local\Temp\arduino_build_303473 -warnings=none -build-cache C:\Users\pc\AppData\Local\Temp\arduino_cache_499902 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -verbose D:\Arduino\dooropened.ino\dooropened.ino.ino
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries D:\arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\pc\AppData\Local\Temp\arduino_build_303473 -warnings=none -build-cache C:\Users\pc\AppData\Local\Temp\arduino_cache_499902 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -verbose D:\Arduino\dooropened.ino\dooropened.ino.ino
Using board 'uno' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\rfid-master\src\MFRC522.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\rfid-master\src\MFRC522Debug.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\rfid-master\src\MFRC522Extended.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\rfid-master\src\MFRC522Hack.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\Servo\src\avr\Servo.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\Servo\src\nrf52\Servo.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\Servo\src\sam\Servo.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\Servo\src\samd\Servo.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Program Files\Arduino\libraries\Servo\src\stm32f4\Servo.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files\Arduino\libraries\rfid-master\src" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Servo\src" "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp" -o "C:\Users\pc\AppData\Local\Temp\arduino_build_303473\sketch\dooropened.ino.ino.cpp.o"
D:\Arduino\dooropened.ino\dooropened.ino.ino: In function 'void setup()':

dooropened.ino:49: error: 'printNormalModeMessage' was not declared in this scope

   printNormalModeMessage();

                          ^

D:\Arduino\dooropened.ino\dooropened.ino.ino: In function 'void loop()':

dooropened.ino:62: error: 'unit8_t' was not declared in this scope

     for ( unit8_t i = 0; i < 4; i++) {

           ^

dooropened.ino:62: error: 'i' was not declared in this scope

     for ( unit8_t i = 0; i < 4; i++) {

                          ^

dooropened.ino:84: error: 'printNormalModwMessage' was not declared in this scope

               printNormalModwMessage();

                                      ^

dooropened.ino:86: error: expected primary-expression before ':' token

               return:

                     ^

dooropened.ino:86: error: expected ';' before ':' token

dooropened.ino:86: error: expected primary-expression before ':' token

dooropened.ino:93: error: 'printNormalModeMessage' was not declared in this scope

         printNormalModeMessage();

                                ^

dooropened.ino:105: error: 'printNormalModeMessage' was not declared in this scope

         printNormalModeMessage();

                                ^

dooropened.ino:113: error: 'printNormalModeMessags' was not declared in this scope

       printNormalModeMessags();

                              ^

dooropened.ino:129: error: 'printNormalModeMessage' was not declared in this scope

     printNormalModeMessage();

                            ^

D:\Arduino\dooropened.ino\dooropened.ino.ino: In function 'uint8_t getID()':

dooropened.ino:140: error: 'unit_8' was not declared in this scope

   for ( unit_8 i = 0; i < 4; i++) {

         ^

dooropened.ino:140: error: 'i' was not declared in this scope

   for ( unit_8 i = 0; i < 4; i++) {

                       ^

D:\Arduino\dooropened.ino\dooropened.ino.ino: In function 'void printNoramalModeMessage()':

dooropened.ino:152: error: 'class LiquidCrystal' has no member named 'setCorsor'

   lcd.setCorsor(0,1);

       ^

Using library SPI at version 1.0 in folder: C:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI
Using library rfid-master at version 1.3.6 in folder: C:\Program Files\Arduino\libraries\rfid-master
Using library LiquidCrystal at version 1.0.5 in folder: C:\Program Files\Arduino\libraries\LiquidCrystal
Using library Servo at version 1.1.2 in folder: C:\Program Files\Arduino\libraries\Servo
exit status 1
'printNormalModeMessage' was not declared in this scope

You had typos in the title and you have an awful lot of typos in your code.

void printNoramalModeMessage() {
  delay(1500);
  lcd.clear();
  lcd.print("-Access Control-");
  lcd.setCorsor(0,1);
  lcd.print( " Scan Your Tag!");
}

You can't spell "Normal".

See :
dooropened.ino:49: error: 'printNormalModeMessage' was not declared in this scope

printNormalModeMessage();
You didn't implement this function.
(please align your code correctly to make it readable)

(it seems now the code is formatted, the function can be seen easier), See Majenko's answer


text:
Arduino Micro serial communication is not working after wake from power down
I'm trying to use the power down state for a battery application, but I'm having issues with the serial communication.
I'm using the lowpower.h library to put the Arduino Micro into power down mode.
When it wakes I flash an LED, which is working, so I know it's is waking up. And I also re-establish serial communication and send a message. This is not working. I receive nothing on the serial monitor, however the TX LED does flash.
I think the Arduino may be working correctly, but for some reason the serial monitor can't handle it. Perhaps there is a better serial monitor application?
#include "LowPower.h"

void setup()
{
    //20sec delay added to make uploading easier (cant upload in power down state)
    Serial.begin(115200);
    Serial.println("20");
    delay(5000);
    Serial.println("15");
    delay(5000);
    Serial.println("10");
    delay(5000);
    Serial.println("5");
    delay(5000);
    Serial.println("START");
    pinMode(LED_BUILTIN, OUTPUT);
    delay(1000);
    Serial.end();
}

void loop()
{
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

    Serial.begin(115200);
    delay(100);
    Serial.println("BLINK");
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(5000);                       // wait for a second
    Serial.println("BLINK_stop");
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(5000);                       // wait for a second

    Serial.end();

}

Serial monitor output:
20
15
10
5
START

and then nothing...

There may not be a lot of point to the operation behind this question: if the device is connected via USB, what do you gain by putting it into a low power mode?   Theoretically, with a lot of care to fully implement all specifications you could have the host computer and the device both enter low power mode, but it isn't really apparent that you are doing that here.  Perhaps it only makes sense for your device to enter a lower power mode when not connected via USB.  If you need brief debug messages between intermittent sleep, consider an external USB UART that remains powered.

I found the answer on this related question: Starting usb on pro micro after deep sleep (ATmega32u4)
Which itself was a link to a sparkfun forum
Note: it requires you to close and open the serial monitor at proper timings.
// disable the USB prior going to sleep
USBCON |= _BV(FRZCLK);  //freeze USB clock
PLLCSR &= ~_BV(PLLE);   // turn off USB PLL
USBCON &= ~_BV(USBE);   // disable USB

// and wake it up after
//routine to properly wake up
sleep_disable();
delay(100);
USBDevice.attach(); // keep this
delay(100);
Serial.begin(9600);
delay(100);

Can you accept your own answer please, so that the system here recognizes that the question has a valid answer?


text:
Keypad password check issue
I am working on a school project, basically I have to create a lock system that opens a fictive gate when the correct code is entered. We have been asked to simulate our system before actually building it. So, I made the following circuit in Proteus(Labcenter Electronics' simulation software):

Here's what my system should do: A variable contains the correct code and the user must type a code on the keypad, and if it is correct, a green LED turns on and the LCD screen displays "Acces Granted!" if the code is wrong, the screen will display "Access refused!". It's a basic system, but I'm trying to make it as simple/short as possible(I have to explain it in an oral presentation, so the simpler the better) and for some reason, I can't get my code to work. Ideally, I'd like to have the LCD display a * for each character typed, liked on a real security system, but I haven't managed to do that either. I've been working on it for hours, trying different variants and etc.. but nothing seems to work the way I want to. BTW, my circuit works perfectly fine and the initialisation part of my code is therefore correct as well. Can anyone help me figure out what's wrong with my code and how I can make it better?
Here's my code so far:
#include <LiquidCrystal.h>
#include <Keypad.h>

//define LED pins
#define redLED 11
#define greenLED 10

String codeSerrure = "87362";   //correct code that opens the imaginative gate
String enteredCode = "";
int keyPressed;

const byte rows = 4;
const byte cols = 3;

char touches_digicode [rows] [cols] = {

  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins [rows] = {25, 26, 27, 28};
byte colPins [cols] = {24, 23, 22};

Keypad leDigicode = Keypad( makeKeymap(touches_digicode), rowPins, colPins, rows, cols);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup(){
  lcd.begin(16, 2);
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  digitalWrite(redLED, HIGH);
}

void loop(){
  lcd.setCursor(0,0);
  lcd.print(" Entrez le code");

  keyPressed = leDigicode.getKey();
  enteredCode += String(keyPressed);
  if(enteredCode.length() >= 5){
    if(enteredCode == codeSerrure){
      digitalWrite(greenLED, HIGH);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("  Acces autorise!");
      delay(4000);
      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, HIGH);
      enteredCode = "";
    }
    else{
      digitalWrite(redLED, HIGH);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("  Acces refuse!");
      delay(4000);
      enteredCode = "";
    }
  }
  if(keyPressed == "#"){
    lcd.clear();
    enteredCode = "";
  }
}

The problem is that when I run this code in the simulation software, the LCD displays "Acces refuse!" and the red LED is on. No matter what keys I press (on the keypad) nothing happens. So the problem is that my code jumps straight to the else statement, inferring that the password typed is wrong (although no password was actually typed). I think the error is in here:
keyPressed = leDigicode.getKey();
  enteredCode += String(keyPressed);
  if(enteredCode.length() >= 5){
    if(enteredCode == codeSerrure){

Btw, forgive the french words, I am french. Also, I forgot to say, the # key should, clear the entered code. Any explanations, code samples or links would help.

Don't cross post. You already asked this on SO.

print enteredCode to serial right after this line ... enteredCode += String(keyPressed);

Your code does not compile in the Arduino IDE (1.0.6.2). There is an issue with this line: if(keyPressed == "#"). If I replace the double quotes with single ones, it compiles. Are you sure the variable keyPressed should be an int? Perhaps it's suppose to be a char?

@jsotola I will try that and report back, thank you!

@VE7JRO When I clicked the verify button in the Arduino IDE and it compiled fine for me. And I'm not sure which data type to use although char is probably better, because I have tried different ideas with both int and char and neither have worked.

i know this is a hobby project, but in real-world security: you would want to do a constant-time compare on the entered code, not a quick string compare, you want to rate-limit the rate at which guesses are accepted: i can brute-force the C++ shown in seconds; how? I reset the unit instead of waiting 4000ms if the green LED doesn't go off after the keys are entered; delay() on setup().

@dandavis Thanks for the advice man, but as I said in the title this is a school project, and if I can't even get the basic version to work, how the heck am I going implement your idea. However, if I manage to get it all working how I want, I might try this if it's not too complicated. Thank you for explaining anyway man!

The getKey() Funktion returns the define NO_KEY if no key was pressed, which is set in Keys.h as the NULL char (char with the value 0). In every loop cycle you are adding one character with value 0 to your string. But all functions, that handle strings, will stop, when they find a character with value 0 (it is the delimiter of C strings). Also a string with many NULL chars in it will not be matched to a string only consisting oft digits.
So you should check the return value of getKey for the NO_KEY define:
if(keyPressed != NO_KEY){
  enteredCode += String(keyPressed);
}

This avoids adding NULL chars to your string.

Yes, getKey() is not blocking which seems to be what the OP is assuming.

I hadn't thought of this. I will integrate it in my code and check for errors, thank you!

After reading all of your comments, I made some changes to my code and I was able to figure out a few other things that weren't working before. I think, because of the way I had coded my password checking function it made all the rest more complicated. I have also implemented the erase key feature, so a press of the * or # keys, erase the entered code. I still need to implement the feature that displays a * on the lcd each time the user presses a key, but I a not sure of what way to do this. Anyways, here's my working code if you're interested:
#include <LiquidCrystal.h>
#include <Keypad.h>

//define LED pins
#define redLED 11
#define greenLED 10

String codeSerrure = "87362";
String enteredCode = "";
char keyPressed;

const byte rows = 4;
const byte cols = 3;

char touches_digicode [rows] [cols] = {

  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins [rows] = {25, 26, 27, 28};
byte colPins [cols] = {24, 23, 22};

Keypad leDigicode = Keypad( makeKeymap(touches_digicode), rowPins, colPins, rows, cols);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup(){
  lcd.begin(16, 2);
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  digitalWrite(redLED, HIGH);
}

void loop(){
  lcd.setCursor(0,0);
  lcd.print(" Entrez le code");

  keyPressed = leDigicode.getKey();
  if(keyPressed != NO_KEY){
    if(keyPressed == 0x23 || keyPressed == 0x2A){
      lcd.clear();
      enteredCode = "";
    }
    else{
      enteredCode += String(keyPressed);
    }
  }

  if(enteredCode == codeSerrure){
      digitalWrite(greenLED, HIGH);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("  Acces autorise!");
      delay(4000);
      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, HIGH);
      enteredCode = "";
      lcd.clear();
  }
  else if(enteredCode.length() >= 5){
      digitalWrite(redLED, HIGH);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("  Acces refuse!");
      delay(4000);
      enteredCode = "";
      lcd.clear();
  }
}

Thank you to everyone for the help (I'm a noobie)! I'm aware that my code is problably not the best way to do what I'm trying to do, so any suggestions and upgrades to the code you could give me are very welcome. Thanks again!
The final version of my code with all the features working can be found in this thread, for those interested.

For the * for every digit, you can use an integer variable, that gives you the position in the entered code (so if enteredCode is empty, pos = 0; if you enter a digit, you do pos++;) And directly after you added the new digit to your enteredCode string, you can use lcd.setCursor(1,pos);lcd.print("*"); to print your * to the LCD. Of course you have to set the position right for your LCD (I haven't looked for how many rows and columns you have in your display)

And since your main question (why your code wasn't working) is now answered, you should mark one question as correct, either mine or yours, depending on what you think is better.


text:
Arduino Problem with using SoftwareSerial and SPI
I am using an external ADC (via SPI) and also a GPS receiver (Software Serial). I tried each one of them and it's working fine. Now, when I try to integrate both of them in one sketch, I can only make the ADC work, the GPS is not receiving something.
void setup()
{
  pinMode(ADS1220_CS_PIN, OUTPUT);
  pinMode(ADS1220_DRDY_PIN, INPUT);

  Serial.begin(115200);
  ss.begin(9600);

  //while(!Serial);
  //SPI.begin();                           // wake up the SPI bus.
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setDataMode(SPI_MODE1);

  //ADS1220.begin();
  Wire.begin();
  delay(1000);  // Give things time to "warm-up"

  delay(1000);
  pre_time = millis(); //store current time to be used as "previous" time
}

I found out that in the setup(), when I comment out all those SPI functions, the GPS returns something. What seems to be wrong with this? thank you so much for any help

I suggest  editing your question to include a Minimal, Complete, and Verifiable example of code, not just snippets.  Also part numbers, datasheet links, and circuit diagram showing terminators etc, and photo of project and scope traces if layout matters.

@jwpat7 i'm sorry for my post, but I managed to solve it already just by changing the Rx pin from 10 to digital pin 4. Thanks for the information by the way, will do better next time

Ralph, it may often happen that if you try to provide all the info, you solve the problem :)

SoftwareSerial is very inefficient.  AltSoftSerial is best.  See this answer for a complete list of alternatives.
You may want to look at my NeoGPS library.  It is smaller, faster and more accurate than all other libraries.  The examples are structured better.  You don't show your whole sketch -_-, but the loop structure could be your real problem.  Be sure to read the Troubleshooting page for more suggestions.

thanks for the advice! I managed to solve my problem already just by changing the Rx pin from 10 to 4, will give AltSoftSerial a try and see the performance difference, thanks!

hey just wanna say thanks for introducing me to AltSofSerial, apparently I've had some issues and was guessing if the problem was the softwareserial library, and it really was since i'm transmitting data and for some moment receiving too. And it really is faster!

You're welcome! Would you mind pressing the green triangle (Accept) to indicate that this is the answer that worked for you? Thanks!

is there a way to print more than 2 decimal places in altsoftserial? i tried altSoft(float_num,4); but it doesn't work

Did you mean altSoft.print( float_num, 4 );?

digital pin 10 is slaving pin for SPI on the arduino, maybe that is why.

I managed to solve this just by changing the Rx pin to digital pin 4 from digital pin 10, I don't know what causes the problem but it did the job for me

For the Arduino to be SPI master, the SS pin (D10) must be an output. Using it as software serial input (Rx) is no good. If you had used it as the Output, Tx, you would likely have been ok.  I try to use 10 as SS for the first SPI device I have connected all the time to avoid that pitfall.


text:
Are there fixed connectors for gpio?
Curently I am using these connectors for my prototype:
Ebay link
However, I need something more reliable so I can deliver the prototype to a user without to risk that the cables fall out of their pins.
Is there something else to use? I would like to avoid soldering.. :(

Unless you want to replace the headers with something else, which means soldering, then you will be soldering.
The options are:

Solder different connectors in the place of the existing headers
Remove the existing headers and solder wires directly in their place
Get a prototyping shield and solder wires in to that
Get a prototyping shield and solder different connectors to it.

Whatever you choose you will be soldering.
Don't be scared of soldering - it's the most basic thing you need to be able to do when you are working with electronics.

The cables you link are supposed to be assembled by crimping rather the soldering.  The risk of them falling out is mostly because the housing are only for a single contact.
If you instead get multi-contact housings the width of the headers you are matching, and insert contacts into those in the desired positions, the risk of things falling out will be greatly reduced.  You can add a label to indicate correct insertion direction.
Of course, a much better result would be to make either a custom shield with terminations for the signals you need to route elsewhere, or to replace the Arduino itself with a custom ATmega board that handles application-appropriate polarity-keyed wiring harnesses.


text:
Reducing Clock Speed increases sketch size?
I just lowered the clock speed of my arduino promini 3.3v - 328p from 8Mhz to 1Mhz on the external clock disabling the brounout detection and when I compiled I my old sketch it wouldn't upload any more because suddenly the size has increased from 31KB to 35KB.
Does anyone know why this could happen. I didn't make any changes in the code and it still loads into the 8Mhz Arduino without any problems.
I used these low power config files: https://github.com/joe-speedboat/Arduino-LowPower

Compare the platform.txt from the Arduino IDE with the one in the low power config files above. There is a vital difference in compiler/linker setting.

@MikaelPatel: You mean -flto?

Does your code have delays in it? If you changed the clock speed, then the compiled assembly for the delays may require more NOP instructions or something similar to achieve the same real-time delay. As a result, the size of the compiled sketch could increase.

Delays are implemented by loops, not by long strings or nops.


text:
Printing elements of char array from PROGMEM
Given:
const char* PROGMEM names[] = {"Foo","Bar"};
Serial.print(names[0]);

I get garbage output. Is there some function that will print the string from PROGMEM? E.G.:
Serial.print(<function name>(names[0]);

That's not how you use PROGMEM. You need to use the functions pgm_read_***_near

your strings are not in progmem. only the array of pointers to strings is there https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

Among many others, check out pgmspace.h utilities at
AVR-libc

const char PROGMEM b0 = pgm_read_dword(&(names[0]));
Serial.print(b0);

PROGMEM does nothing here


text:
How do I use two PulseIn() functions simultaneously in Arduino?
I want to connect multiple Ultrasonic sensors to my Arduino board. For that, I need multiple pulseIn() functions to work at the same time. How can I do that?

As it stands, the question could be migrated to the Arduino stackexchange.

You can't use pulseIn() if you want to use both ultrasonic sensors at the same time.
So either:

don't use pulseIn, and instead do that part yourself using
eg. digitalRead,
use the ultrasonic sensors sequentially, one then the other, or
use pin-change interrupts to sense the signal pulse return.

The easiest approach is to use the ultrasonic sensors sequentially. In that case use the form pulseIn(PIN, value, timeout);, where timeout, in microseconds sets the maximum time to wait for a pulse.
This is practical if you know the realistic range is within a couple of metres. The speed of sound is 343.2 metres per second, or 0.3432 metres per millisecond. So if timeout is set to 3000 microseconds (3 milliseconds), then it will wait for an echo up to (roughly) 0.5 metres away.
Edit:  The distance to the object, measured by timing the delay, is half the total distance travelled because the sound travels to the object, then bounces back to the sensor.
Ie. distance to object = total distance travelled by sound / 2
An alternative is to do what pulseIn does, but for more than one pin.
This is simpler than the real pulseIn code, but illustrates the idea:
int inPin1 = ...;
int inPin2 = ...;

void setup() {
  // ... other stuff, then set up the pins
  pinMode(inPin1, INPUT);
  pinMode(inPin2, INPUT);
}

void loop() {
  // start ultrasound 1
  // start ultrasound 2
  // wait for ultrasound 1 to send pulse
  // wait for ultrasound 1 to send pulse
  long startTime = micros();
  while (digitalRead(inPin1)==LOW && digitalRead(inPin1)==LOW) {
    ; // do nothing
  }

  long stop1st = micros();
  int firstBack = -1;
  while (digitalRead(inPin2)==LOW) { // wait for the other if it was 1 first
    firstBack = inPin1; // remember pin 1 returned first
  }
  while (digitalRead(inPin1)==LOW) { // wait for the other if it was 2 first
    firstBack = inPin2; // remember pin 2 returned first
  }
  long stop2nd = micros();

  // now have the two return times, and the pin which returned first
}

You could read the source of pulseIn() and write better code than this.
The third option, to use external or pin-change interrupts, depends on which Arduino you are using. A normal ATmega328 has a couple of pins, 2 and 3, which have their own 'external' interrupt service routines (ie. each pin has a 'function' which is called when the hardware detects a signal change on a pin). To see how to attach them, see attachInterrupt.
Other pins can also be used with a 'pin change' interrupt, but each interrupt has to figure out which of a port (up to 8 pins) has triggered it, so it isn't as quick and simple.
The idea here is to start the ultrasonic sensors exactly as before, save the time they are started, exactly as before, but let a short interrupt routine capture the time that the returning echo pulse triggers the pin.
There is a little bit of care in making sure the times are captured and the main loop signalled.
You might choose to dedicate a timer to measuring the ultrasounds round trip, if you want higher resolution and lower jitter than the normal 4 microsecond timer. A microsecond is about 0.34mm, so 4 microsecond is about 1.3mm error.

"So if timeout is set to 3000 microseconds (3 milliseconds), then it will wait for an echo up to (roughly) 0.5 metres away."  It should be close to ~1.02 meters away. Am I right?

@Mat_python - sound travels 0.3432m/millisecond, so in 3 milliseconds it will travel about 1 metre. An ultrasound sensor works by bouncing sound, so sound has to travel to the object, and then return. So you are measuring round-trip time, hence the distance to the object is total distance/2.

Thank you. I thought so. I am trying to detect a moving object. i.e, a soccer ball. I am working on building a goal counter. The problem with an ultrasonic sensor is it misses the ball sometimes. I used two ultrasonic sensors to detect a soccer ball, which could be moving really fast, but it detected 8 times out of 10. what could be the problem? Is there any other sensors I can use to detect the soccer ball passing between 0-1.5 meters of distance from the sensor. I also tried PIR sensor, but it does not work well for non-living objects.

@Mat_python - if all you want to make is a soccer ball counter, would detecting something crossing a line do? That could be easy to make. Or do you mean drive around a field counting balls? You'll need to be clear about the problem, and it may be worth writing a new question.

Yes. I want to make a soccer ball counter, and detecting something crossing a line will work. I tried using ultrasonic sensor. But, it misses if the ball is too fast. what are other alternatives? I also wrote new question thread on this here : http://arduino.stackexchange.com/questions/29748

here is how i fixed the problem for my self -5 years later im doing this on my own, running the pulsein code twice within the same loop function WILL NOT WORK, i got around it by adding a second separate part, idk the name if its a function or library...but here is my example code simply creating a distance measuring from 2 different sensors. i hope this help
const int trigPin =6;
const int echoPin =5;
const int trigPin2 = 11;
const int echoPin2 = 10;

long duration2;
long distance2;
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
Serial.begin(9600); // Starts the serial communication
}
void loop() {
digitalWrite(trigPin, LOW);// Clears the trigPin
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
Serial.println(distance2);
test();
}

void test()
{
digitalWrite(trigPin2, LOW);// Clears the trigPin
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration2 = pulseIn(echoPin2, HIGH);
distance2= duration2*0.034/2;
}

my code only prints the second sensor distance not both as you can see...not perfect this was a quick sketch i did


text:
Nth-Light LED Strip power connections
Based on this question on the Adafruit forum for Nth-Light Narrow LED Flexible Strip Light (https://www.adafruit.com/product/3683) and the image below is it safe to connect from the 12v source + a wire to the Vin (orange wire) or it is better to connect to another DC barrel?

If your 12V power supply has enough current to drive your LED strip at its maximum power, plus the Arduino's power supply, plus about 10-20% of "wiggle room" you should be fine. As the LED strip draws spikes of current the voltage from your power supply might bounce around a little, but the Arduino's voltage regulator would be fine with as little as 7.5V input.
Note that your Arduino's voltage regulator will get hot if you use much current from the Ardunio's 5V rails, since it has to regulate 12V down to 5V and the linear regulator on the Arduino converts the extra voltage to heat.

Thanks. any alternative solution in order to avoid the heat issue? The LED is intend to be in a close space.

If you aren't driving much load from the Arduino's 5V pin it might not be a problem. Total power converted to heat will be ≈total_current • (12V-5V)

If you're really sensitive to heat, drive the Arduino with a separate switching 5V supply fed into the USB port. That bypasses it's regulator entirely


text:
Problem: "stray '#' in program"
I got a sketch from the internet (http://www.instructables.com/id/How-to-build-an-8x8x8-LED-cube-and-control-it-with/) for controlling the display of an 8x8x8 LED cube. The program won't compile and the error says "stray '#' in program". I looked it up on google but nothing appears to be relevant.
Here's a part of the code. (The error occurs at the baseColor = color(#222222); line)
int rectX, rectY;      // Position of square button
int ROWX, ROWY;
int rectSizeX = 80;     // Width of rect
int rectSizeY = 20;     // Height of rect
int circleSize = 20;   // Diameter of circle
color rectColor, circleColorOff, circleColorOn, baseColor;
color rectHighlight, circleHighlight;
color circleCurrentColor;
color rectCurrentColor;
boolean rectOver = false;

// State of LEDs
boolean[][] circleOn;

// Position of LED buttons
int[][] circlePos;

// Mouse Over LED buttons?
boolean [][] circleOver;

int delayedby = 50;

void setup() {
 //number of rows and columns
 ROWX= 8;
 ROWY= 8;

 size((ROWX*40+10), (ROWY*44+30));
 noStroke();
 frameRate(10);
 smooth();
 rectX = ROWX*20-30;
 rectY = ROWY*44+5;

 // Colors
 rectColor = color(#FF0000);
 rectHighlight = color(#FFFF00);
 circleColorOff = color(#444444);
 circleColorOn = color(#ff0000);
 circleHighlight = color(#CCFF00);
 baseColor = color(#222222);
 circleCurrentColor = circleColorOff;
 rectCurrentColor = rectColor;

circleOn = new boolean[ROWX][ROWY];
for(int i=0; i<=(ROWY-1); i++) {
 for(int j=0; j<=(ROWX-1); j++) {
   circleOn[j][i] = false;
    }
}
circlePos = new int[2][(ROWX*ROWY+1)];

// X Posistions
for(int i=0; i<(ROWX*ROWY-(ROWX-1)); i=i+ROWX) {
int Xpos = 25;
  for(int ii=0; ii<ROWX; ii++) {
     circlePos[0][i+ii] = Xpos;
     Xpos += 40;
  }
}

// Y Positions
int Ypos = 40;
 for(int i=0; i<(ROWX*ROWY-(ROWX-1)); i+=ROWX) {
  for(int ii=0; ii<ROWX; ii++) {
     circlePos[1][i+ii] = Ypos;
  }
        Ypos += 40;
 }

circleOver = new boolean[ROWX][ROWY];
for(int i=0; i<=(ROWY-1); i++) {
 for(int j=0; j<=(ROWX-1); j++) {
   circleOver[j][i] = false;
 }
}
}

It turns out that the code was compiled in the earlier beta versions of the Arduino IDE, and now I don't know what I need to do for it to be compiled by my 1.6.5 version.

That is not C/C++ syntax. Replace # with 0x (to start with). Then you will have to reduce the size of the data structures. Check the sizeof(boolean).

I think this code is obsolete. I'm getting new errors like non existent data types and other syntax errors

Some of that looks more like java than C to me...

The code you have posted is a processing file, you haven't posted all the code and stated that its processing related, leaving it to the community to figure this out. This is more suited to stackoverflow or the Processing IDE

From the Instructable you linked:

matrix8x8.pde is a program in Processing to build your own displays.

You downloaded the Processing code, not the Arduino code. See above that:

cube8x8x8.pde is the Arduino code.

So basically you are compiling the wrong code. Go back and re-read that page.