text:
Which connection should I use (preferably wireless)?
For a (for now MIDI only) project I was planning to use multiple Arduinos and send messages around.
However, for the latency, I can have max 10ms (to prevent audible delay).
I hoped to use WIFI modules (ESP-01), however, according to a previous question in Question, one remark that due to HTTP overhead the time/latency would be 15 ms. So that means WIFI is not possible.
My requirements:

Latency of <= 3 ms (rationale: I need at least 5 ms for processing, and want to keep total latency < 10 ms)
Preferably a wireless solution (rationale: I want to add later more Arduinos and want to prevent cabling)
Preferably not using a hardware serial (low prio requirement) (rationale: the MIDI box which is a Mega, would preferably need 4 MIDI inputs, using a hardware serial would reduce one, software serial is unacceptable for MIDI).

Situation:

Arduinos are very close together, probably within centimeters (upto like 50 centimeters)
Messages are short (like 5-10 bytes max)
Burst of messages can be possible, but not so likely

Background/message flow:

Receiving MIDI input by Arduino 1
Sending (filtered/changed) message to Arduino 2
Arduino 2 process the manage, takes <= 5 ms
Arduino 2 sends message back to Arduino 1
Arduino 1 converts it to a MIDI message and sends back

This all needs to be done within <= 10 ms
My thoughts so far:
Wireless solutions:

WIFI: HTTP seems to result in 15 ms delays, which is against my requirement.
RF: probably overkill since my Arduinos will be very near to each other. Also I would need both a receiver and transmitter in both Arduino's.
IR: Due to out-of-sight problems not very convenient.

Wired solutions:

I2C: Might be possible, planning to use later also an I2C display possibly but should not be a problem
SPI: On Arduino 2, I'm already using an SRAM with SPI which I do not want to stress more (also a time-critical resource). Also an SD card via SPI is used (but this is not a time critical resource).
Wire: Not checked yet

Question
Is there any wireless (or wired) solution I can use (probably beyond the ones I analyzed)?
115200 baud is what I need for a Serial connection, probably a SPI/I2C (latter preferred) is also acceptable. Or I might have missed other communication possibilities.

NRF24L01+ transceiver, maybe.

You need a custom solution.  I was looking into wireless flash sync signals years ago and everything off the shelf took too long.  If you do go with Ethernet (I think you shouldn't) you probably need to understand the difference between UDP and TCP.  One is "get it there now no matter what the condition the packet is in" (skype).  The other is "keep trying until it is perfect" (bank transactions).

@Gerben: I checked and it seems 250KBPS is possible ... which is strange, since close WIFI has a max of 115baud... I don't need the long distance, but if the speed/latency is good, it might be a good candidate.

Also, keep in mind I2C and SPI are for chip to chip communications.  Neither were meant to go any distance.  The are really to keep the pin counts low on the integrated circuit packages.  Which is a good way to keep the MTBF (time between failures) down.

@st2000 I heard that default WIFI (and Ethernet probably) using HTTP request takes a lot of overhead. Currently I don't know much bout UDP/TCP and I do not want to spend TOO much time learning that (since my core project also needs to continue).

@st2000 I thought I2C was for connecting (many) devices (so distance is not so much a problem). But if needed, I will keep distance low (but still like 10-30 centimeters).

Yes, Ethernet is way more complex than most people make it out to be.  And on top of everything else, it is very possible that no two Ethernet appliances work alike adding to the frustrations.  Synchronization over Ethernet is not trivial.  I suspect Sonos and Logitech/SqueezBox both use an extensive bag of tricks to synchronize music played at multiple points off an Ethenet network.  I would stick to MIDI and investigate if there are wireless MIDI appliances available.  After all MIDI was created with music in mind.

@st2000 actually I do not want to send MIDI messages wireless, but my own messages (although they contain some of the MIDI info). However, maybe I can use it as a low-latency (using MIDI as protocol to send info, possibly even MIDI messages itself).

I2C can be used for multiple devices. But normally all are on the same board.  For example, you computer mother board may have several I2C temperature sensors all connected to a common I2C bus.

you can use a fiber optic link to connect IR and make it act more like a wire if you have line of sight issues. You can also just do 115200 serial between devices. The ESP8266 can use Serial, and Serial1 (for TX only), these are hardware, so you should be able to daisy-chain at high speed.

@st2000 ah ok ... well in my case I just need commands sending from one Arduino to another, so than I2C is maybe not so good.

@dandavis: a fiber optic link, never thought about that ... and plan 115200 serial might do as well. Do you mean that with an ESP8266 I can skip http and use Serial 'directly'?

that's exactly what i mean; they are very low overhead and latency

Beyond the nRF24L01's I also ordered an extra ESP-01 (ESP8266) so I can try to send messages between them and make the best choice.

I see the anonymous downvoter is back. For everybody else a nice christmas.

I would either use the ESP8266 as a standalone device and directly program it to work with UDP datagrams or a permanently established TCP socket, or the nRF24L01+.
Of the two I would most likely use the nRF24L01+. It's good enough for 99% of wireless keyboards and mice, so plenty good enough for a few MIDI style messages.

Well I might need quite some MIDI messages (like CC messages), but that sounds good ... need to analyze both in more depth (and need to order an nRF24L01+).

You'll want at least two nRF24L01 modules :P

I ordered 5 SE8R01's (they seem to be compatible) and 5 adapter plates (for NRF24L01+) ... together < 4 euro.


text:
replacing #define with typedefs for bracket scope
I have a project in which basically i have to concatenate existing code.
Each code comes with its own #defines.
But defines are not touched by the compiler, but the preprocessor.
Each snippet of the program will exist in its own fucntion.
Is it possible to include the #defines of each program - now each function, inside this function (and visible only to this function's scope)?
The proper way to do it, would be to replace text reassignment from #define to typedef?
I understand typedef is originally for defining types. But can it be used here? Is there another alternative?

What are these macros used for? You can replace them with different things depending on what they are, but you may lose execution efficiency.

The macros are used for text replacement. For example #define value 255

Then you would use const variables.

#define value 255

Can be replaced with
const int value = 255;

It is possible to use "namespace { ... }" to create local defines for a *.cpp file.
In the Arduino IDE all *.ino files are combined in a single *.cpp file, therefor the "namespace" is not very useful.
When you create new tabs in the Arduino IDE and name them *.cpp, then you have different *.cpp files. Then you can use the "namespace" to create defines that are only valid for that *.cpp file.
More info: Hackaday: Using Modern C++ Techniques with Arduino

source: Stack Exchange

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

sort: votes


text:
Atmega2560 USART UDR r/w conflict possible?
I'm having a really weird issue with my project right now. I have an Atmega2560 using hardware serial, and the software on the other side is doing full duplex read/write at 500kbps. If I change it to be single duplex, everything works fine. But the second I try to run everything truly full duplex, I start to have some data transfer over from the transmit stream to receive stream on the device (characters that its trying to write, that it somehow ends up reading again).
I've simplified things as much as possible- disabling buffering on the arduino side, using mutexes on the client software side (to prevent overlapping read/write commands, despite the fact the underlying driver will do whatever it wants).
So, there's obviously a few potential problems here, but it has to boil down to:
a) Client software/drivers misbehaving
b) Hardware serial implementation misbehaving on the device.
I really want to rule out B, and from all my digging around, it really comes down to one question:
Is there any possible way that data written to the UDR register could somehow be read out again? I understand this register is actually 2 different registers, and just splits out reads and writes. But is there any possible way at all this data could be read again? Like, is it possible to even write to UDR and read that byte ever again? I'd really like to rule that out before I start unnecessarily tracing ISRs and all that garbage.
Here's what I've boiled the hardware serial code down to. Interrupt driven on read and direct write on write:
void MarlinSerial::write(uint8_t c) {
  while (!TEST(M_UCSRxA, M_UDREx));

  M_UDRx = c;
}

ISR(M_USARTx_RX_vect) {
  const unsigned char c = M_UDRx;
  store_char(c);
}

UPDATE: I'm an idiot. Found a buffer overrun way downstream in the device code. It just so happened that the temp response buffer for one routine butted up against the receive buffer, so it delightfully just over-ran into there. I'm happily chugging away now with 2 totally async command streams, total about 400kbps.

Not an answer, but are you checking the flag bit that indicates that there is data available, before you try to read the data register?  If that is not indicating that there is data available, it may not be well defined what you would obtain by reading it.

If the bytes you write to the USART came back from it all by themselves, that would be a very serious hardware bug. Hardware bugs do happen, see the Errata section of the datasheet, but that one would be too egregious to go unnoticed.

I am checking the flag before doing a write, im using interrupts for the read so I shouldn't have to check any flags.
As far as hardware bugs, it's a cheap board, supposedly using the same chips as the Arduino 2560, but they could be knockoffs or something, or just bad circuit design.

Is there any possible way that data written to the UDR register could somehow be read out again?

No, there is no possibility. The datasheet says:

The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address
  referred to as USART Data Register or UDRn. The Transmit Data Buffer Register (TXB) will be the destination for
  data written to the UDRn Register location. Reading the UDRn Register location will return the contents of the
  Receive Data Buffer Register (RXB).

Further on it says:

The transmit buffer can only be written when the UDREn Flag in the UCSRnA Register is set. Data written to UDRn
  when the UDREn Flag is not set, will be ignored by the USART Transmitter. When data is written to the transmit
  buffer, and the Transmitter is enabled, the Transmitter will load the data into the Transmit Shift Register when the
  Shift Register is empty. Then the data will be serially transmitted on the TxDn pin.

And for reception it says:

The receive buffer consists of a two level FIFO. The FIFO will change its state whenever the receive buffer is
  accessed. Due to this behavior of the receive buffer, do not use Read-Modify-Write instructions (SBI and CBI) on
  this location. Be careful when using bit test instructions (SBIC and SBIS), since these also will change the state of
  the FIFO.

So the only thing it is possible to read is data that has been received via the RX pin (and then once and once only). All written data (assuming there is room in the TX buffer) is sent out of the TX pin.
If you are getting TX data appearing in the RX buffer then somewhere there must be some kind of connection between the TX and RX pins - either in software at the remote end (the remote device echoing everything it receives, which is perfectly possible depending on what the remote device is), or though a fault in the cabling or circuit design.

Damn it all. Believe it or not, that rules out the "easy" answer to my problem.
The board is an Elegoo Mega 2560- Should have the same USB chip and everything, but it was cheap as dirt and I definitely would not rule out a bad circuit design somehow allowing cross talk between the lines.
The client side software is run on OSX, and just uses the standard open/ioctl/read/write access to the TTY. So if there's something wrong on the client side, it has to be something with the USB serial drivers (not even sure what drivers its uses for this USB UART).

Just tried a different computer, running Linux this time, and got rid of ALL other USB devices besides this one, still the exact same issue =\ So it's not looking like its the client drivers fault...

@ColinGodsey: Are you sure echo is not enabled on the Unix side?

@EdgarBonet Yea, no echoing. If I simplify the test to just "call and response" (no actual simultaneous r/w), it works fine. Even running a CRC on the other end, I can push about 400kbps of data with 0 errors. It just becomes an issue when I start reading while writing and vice versa.

arg, see note above. was just some downstream buffer overrun issues

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


text:
Powering multiple (separately enclosed) Arduinos by one adapter
I currently use one Arduino, but my plan is to use multiple Arduinos.
These Arduinos will be relatively close together (within one meter or less), and depending on the configuration I want 2 to 5 Arduinos, all in separate enclosures.
I don't expect a high power consumption from all of them, but I don't want to use batteries. So I would like to use a 9V or 12V adapter with 2A (cannot find higher amperage).
My questions:

Can I just split the cable, and add extra plugs for the other Arduinos? (so like a parallel circuit of Arduinos)?
Is it a problem if I only would connect 1 Arduino? (I don't think so)
Is there a maximum Amperage I can divide this way? (I mean what if I would find a 5A adapter?)
I see 9V or 12V adapters ... why would this matter, since the Arduino works on 5V anyway. I don't need to drive external motors, just like 5 small LEDs, some ICs (optocouplers, SRAM) and some basic connectors (like MIDI, later DMX, Audio etc), an RF or ESP01 module.

The difference between Vin and 5V is all dissipated in the linear regulators of the Arduinos. Thus a 9V adapter would be more energy-efficient and generate less heat on the regulators.

@EdgarBonet Thanks ... that means a 9V should be enough, and probably with 2A I can support (hopefully) 5 Arduinos ... I guess I can measure the amps usage currently if I probe at the right positions (have to find out where)

using just 5v would be even better; cooler, cheaper, more efficient, allows more sensor capacity, etc. basically, removing any extra source of heat from the MCU itself.

For the annoying personal downvoter: please mention why you voted my question down.

more than 2500 views and -1 score... interesting.

Can I just split the cable, and add extra plugs for the other Arduinos? (so like a parallel circuit of Arduinos)?

Yes.

Is it a problem if I only would connect 1 Arduino? (I don't think so)

No.

Is there a maximum Amperage I can divide this way? (I mean what if I would find a 5A adapter?)

You can draw, in total, whatever the power supply can provide. If 10 Arduinos need 500mA and you have a 5A power supply you can power 10 Arduinos from it.
If they draw just 50mA you could power 100 Arduinos from it. It's all just a matter of managing the wiring in a suitable manner (connecting hundreds of wires together gets tiresome).

I see 9V or 12V adapters ... why would this matter, since the Arduino works on 5V anyway. I don't need to drive external motors, just like 5 small LEDs, some ICs (optocouplers, SRAM) and some basic connectors (like MIDI, later DMX, Audio etc), an RF or ESP01 module.

12V will cause more heat dissipation from the linear regulator in the Arduino than 9V will, since the 12V has to lose more of the voltage as heat.

Thanks for the answer ... seems that 9V is enough (actually even less, but less than 9V is not possible).
I did a small calculation and I think I can be under 2A (which some adapters provide).


text:
Sending information via USB/Serialport
Am I able to send instruction from my computer, from another compiler, via the Arduino USB port?
To put this in context, I'm doing some vision processing on my computer, with Visual Studio, and I want to send some motor output via USB for the Arduino to execute.

I imagine Code Gorilla's given you the proper, specific answer you needed. I simply wanted to address your first (more general) ask,

Am I able to send instruction from my computer, from another compiler, via the Arduino USB port?

... and mention some other ways I've done this before. As long the Arduino's listening to the serial port for some specific (or any) input coming in, you can use whatever you'd like to send a message to the COM port your Arduino's using.
You absolutely are not hemmed into using solely the Arduino IDE (or it's serial monitor) for serial communication.
For instance, I wrote a Python script that communicated with an Arduino R3 (Rx/Tx) via the COM port it was assigned via the PySerial library - before coming to Python, I'd been doing this through a MS Visual C# WPF that was connected to the COM port and communicating with the Arduino (Rx/Tx) (you might need to adjust baud rates here or there, if I recall). Just to give you some ideas.

You can do it in a number of ways, but essentially your PC is going to open a serial connection to the Arduino and send data to it which will be interpreted into state changes of the digital ports of the Arduino.  The content of the messages is up to you, as long as both ends know what it means.
Step 1 would be to learn how to drive the motors on the Arduino by writing a program that drives the correct ports.
Step 2 is to modify that program so that when you type 1180 in to the serial monitor the Arduino turns motor 1 180 degrees, etc.
Step 3 Start Visual Studio, press F1 and search MSDN for a Serial console program that you can 'borrow'.
Step 4 Check your new serial program can replace the serial monitor and you can still turn motor 1 to 180 degrees.
Step 5 Put a flowery GUI over you serial console and polish your turd. :)
It doesn't matter what the GUI does, its still just a serial client talking to the Arduino.  You could offer Bluetooth or Wi-Fi connections, but its essentially the same beast.

Assuming your project is along the lines of "finding something and pointing at it".
This youtube video shows an eye mounted on a stalk apparently controlled by servo motors (a type of positioning motor).  The title infers an Arduino controls the motors and is in turned controlled by desktop computer running a program making use of OpenCV libraries.  However no details are given.
An Arduino Uno is perfect for controlling servo motors as it contains a dedicated Atmel embedded processor. And there are Arduino servo libraries which make use of the Arduino processor's PWM hardware. This means controlling a servo can be as simple as several line of Arduino sketch code.
myservo.attach(2);  // attaches the servo on pin 2 to the servo object
myservo.write(0);   // sets the servo position to 0
delay(1000);        // waits for a second
myservo.write(90);  // sets the servo position to 90
delay(1000);        // waits for a second
myservo.write(180); // sets the servo position to 180

The USB port of an Arduino Uno normally implements serial port protocol layer inside the USB layer.  Many computers can deal with this easily.  So sending messages to an Arduino Uno is possible.  Here is a project (Arduino Playground - Simple Servo Control tutorial) where a (desktop) computer is controlling servo motors connected to an Arduino over the Arduino's USB port.

Could you provide the key points from the link you mention. Thanks.

Merely posting a link dose not constitute an answer under the rules of the stack exchange system.  If that's all you are going to do, you should post a comment.

I did not know that.  Thought direct was better.  Ok, changing.


text:
Battery Status notifier
I am new to Arduino, and I am aware that unlike Raspberry Pi you do not have a full blown OS with many custom applications running concurrently.
I plan to start an Arduino project with an Arduino NANO that will need to be portable, and include batteries. How may I get the battery status information without disrupting the rest of the functionality?

What do you mean "without disrupting the rest of the functionality"?

@AndrewPaes Well. I am new to Arduino, so I dont know if I can run more than one scripts concurrently

Use analogRead to measure the voltage on the battery. You might have to use the internal 1.1V reference to get a good reading.
Don't write any blocking code and the processes won't interfere with each other. That means no long for or while loops waiting for something to complete and absolutely no delay.

To read the battery voltage using the 1.1V reference, you need to put the battery voltage through a resistor divider, to lower the voltage to between 0V and 1.1V. To prevent these resistors from draining the battery too hard, you need to select an appropriate high value. High enough, to not drain the battery to fast, low enough to not get influenced by the sample-and-hold capacitor and the input impedance of the ADC. Adding a small capacitor will also help with high value resistors.

Or, if the battery is powering the ATMega directly you just read the 1.1v reference using the battery as the ADC reference then calculate what the battery voltage must be to give the reading you got for the 1.1v reference.


text:
error using String class to convert a double to a string
i wanted to convert a double to a string i tested several examples online i allawys get the same error.
the code :
void setup()
{
  Serial.begin(9600);

}
void loop()
{
  double val =3.2222;
  String stringOne =  String(val, 3);
  Serial.print(stringOne);
}

the errors :
sketch_jun02c.ino: In function ‘void loop()’:
sketch_jun02c.ino:10:36: error: call of overloaded ‘String(double&, int)’ is ambiguous
sketch_jun02c.ino:10:36: note: candidates are:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from sketch_jun02c.ino:2:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:70:11: note: String::String(long unsigned int, unsigned char)
  explicit String(unsigned long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:69:11: note: String::String(long int, unsigned char)
  explicit String(long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:68:11: note: String::String(unsigned int, unsigned char)
  explicit String(unsigned int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:67:11: note: String::String(int, unsigned char)
  explicit String(int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:66:11: note: String::String(unsigned char, unsigned char)
  explicit String(unsigned char, unsigned char base=10);
           ^

Which IDE version are you using? The fact it's showing /usr/share/arduino tells me you installed it with apt-get (or similar), so you're probably on something ridiculously ancient.

Yes i used apt-get, the version i am using is: ARDUINO 1.0.5 - 2013.05.15, is there a way to update it without deleting the old version ?

Download the new version from the website, extract it, and run it.

Yea I have done that already thanks Majenko ;)

The current Arduino SDK version is 1.8.2.  So 1.0.5 is really old.  Package managers do not necessarily stay up to date.  Especially with packages that don't make up the core of the OS.  In C++ the types of the arguments are just as important as the name of the function you are calling.  No (perfect) match means no function will be called.  So it does not look like there is a matching "Strings()" function.  That is, a "Strings()" function where the type of the argument is a double.

Yea thank you, after upgradign the IDE to 1.8.2 the program worked fine !

Post your own solution as an answer and accept it to close this question

@LookAlterno Thank you for telling me it is done

I had installed arduino using apt-get and I didnt notice that I had an old version. I upgraded my arduino and it worked fine.


text:
WiFiClient::connected() not working
I use an ESP32 to open an access point and listen for TCP connections over a WiFiServer object.
When I get a client on the server I want to know when it has disconnected.
Currently I have a simple piece of code on both the client and the server side. I connect using a TcpClient in C#.
When I call client.close() on the client side, the client.connected() loop on the server just continues forever.
Here is the ESP code:

void setup()
{
   WiFi.mode(WIFI_AP);

   WiFi.softAP("test");

   WiFi.softAPConfig(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0));

   Serial.println(WiFi.localIP());

   server.begin();
}

void loop()
{
    while (!client)
    {
        client = server.available();

        delay(10);
    }

    while (client.connected())
    {
        Serial.println("ok");

        delay(1000);

        client.read();
    }
}

C# code:
static void Main(string[] args)
{
     TcpClient client = new TcpClient("192.168.4.1", 222);

     client.Close();
}

Welcome to Arduino SE.  I don't really see a question here.  I see a statement of the problem but no attempts at resolution nor a question about why such an attempted fix didn't work.    I recommend you take the tour at https://arduino.stackexchange.com/Tour to get the most out of this site.  Perhaps you can flesh it out enough to prevent closure of this one.  Or, if it does get closed, perhaps you can repost it with the elements necessary to present a question that can attract useful answers.

@SDsolar I'm absolutely aware on how to write on this site, because I'm on stackoverflow as well. Furthermore my question is clear when you read the title and the second line. I'm explaining my intention there and with a little bit of think you can guess that I need help with this function. Instead of writng pointless comments spend the time writing some answers.

I just don't see a question here, that's all.  This is a Q&A site.  Without one you can't have the other.   I voted to leave this one open when it came up in review, thinking a little nudge was all you needed.

This is a bug in a previous version of the library as mentioned on
https://github.com/bportaluri/WiFiEsp/issues/14
You can alternatively use WiFi.softAPgetStationNum() to get the count of stations connected to the AP interface.

WiFiEsp isn't the library I'm using, is it? Unfortunately WiFi.softAPgetStationNum() does't help me, because I need to know when the socket has disconnected and not a Station.

Whether you're using the WiFiEsp library is not a question I know the answer to.

I've seen the client.connected() function in WiFiEsp only

This one's WiFiEspClient::connected() and not WiFiClient::connected()

My actual answer
You can try to inquire client.status() as a workaround. When no one is connected it should return 0.
Context
What are you building on? I tried to reproduce your problem but everything works as expected, the serial stops printing "ok" when I disconnect.
Also, what libraries are you using exactly? I included ESP8266WiFi.h and WiFiClient.h.
I used platformio v3.4 on an ESP8266-01 module and a simple Android netcat app as client.

ESP8266WiFi.h is for an ESP8266 which is the wrong plattform, I have an ESP32 Development Board. I included #include <WiFi.h>.

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


text:
Is it possible to use Serial window for debug statements while using the hardware serial port for GPS module?
I am using the hardware serial ports of Atmega 328 to connect to a GPS module . A GSM SIM900 module is connected via Software serial . Is it possible to print the debug statements in the Serial window while the GPS module is connected to the hardware serial ports? Both my module and the Serial window is set to 9600 bps baud rate .
Also I want to read the GSM responses from the Software serial and print the same in the Serial window for debugging. Is this possible?

I am using the following statements for the latter function:

I am using the following statements for printing the GSM responses :  Serial.print (softserial.read()) . Is this possible while I am connecting GPS module to the hardware serial ports?

You can edit your question. No need to add additional info into the comments.

Is it possible to print the debug statements in the Serial window while the GPS module is connected to the hardware serial ports?

Yes, that works.  If you connect the Arduino TX pin 1 to the GPS RX, then everything you print to Serial goes to both the Serial Monitor window and the GPS device.
This works, because:

It's ok if you see the GPS configuration commands (if any) on the Serial Monitor window.  Your debug prints will appear after them.
The GPS device ignores anything that doesn't start with a '$' character; it ignores all your debug prints.

Just make sure the debug information never includes a $ at the start!

If you don't ever need to send anything to the GPS module then you don't need to connect the Arduino's TX pin to it.

@ Gerben .. Thanks.. @ Majenko .. will it do any harm if the pins are connected? My code is using only the commands to read from the gps. What are the possible data / commands that can be sent to the gps other than these?

@Vj1989, no harm to the pins (there are resistors on board to allow this).  As for other data and messages from the GPS, my NeoGPS library has a nice table here.  It's the smallest, fastest, most reliable and most accurate GPS library out there.  Commands that you can send to the GPS would be documented in the spec for your device.

While I agree with slash-dev, I feel unless you're really struggling with pin real state, you don't really need to have both the GPS serial and UART on the same pins (unless I'm missing some point or convention, in which case please do correct me).
When I was using a GPS module (GTOP013) with an Atmega328p, I just used the SoftwareSerial library to configure some unused pins (12 and 13 I think? it's been a while) as a dedicated RX/TX lines to the GPS, whilst the atmega's RX/TX remained reserved for a USB connection. Any time I needed anything sent to or from the GPS, I had a function to handle that. Also allowed me to keep polling the lines for data from the GPS to be printed onto the Serial.Console as desired for debugging.

@ Zaeche .. I'm using software serial pins for a GSM device and the program is not working when GPS is also connected to another set of Software serial pins. That's the reason why I'm using hardware serial ports for GPS.

Ah, I understand--thanks for clearing that up. I assume you'd prefer to Rx/Tx from the GSM and GPS simultaneously, as well as being able to debug using the hardware serial (thus, 1 hardware serial port + 2 software serial port).
As per this, serial ports can't be heard in tandem so I see why you had to reuse the hardware port for the GPS as well (the Mega has two hardware ports but honestly isn't as portable as the 328p).


text:
Don't Print After decimal point in
In my code, I have  float Hz = 0.00; I want to display values to my user in RPM as
Serial.print("Speed = ");
Serial.print(round(Hz*60);
Serial.println(" RPM);

The only hangup is that this displays as Speed = XX.00 RPM is there an easy way to get the Arduino to only print out Speed = XX RPM?

From the documentation:
Serial.print(round(Hz*60), 0);


text:
How do I load an image using fopen()?
I am trying to write a program that fopen()s an image so I can use it later.
I've wired my SD card adapter exactly the way shown here:
[![enter image description here][1]][1]
And I'm using the following code to fopen():
FILE *streamIn;
streamIn = fopen("pic.bmp", "r");

When  I compile, I get the following error:

In function main:
ccA5H011.ltrans0.o:(.text.startup+0x29a): undefined reference to `fopen'

I have the most up-to-date Arduino software.
I am using the Arduino MEGA.
The image "pic.bmp" is 100x100 and is not in any folder of the SD card, it is located right in it instead (If I click on the SD Card in "My Files" when it is plugged into my computer, pic.bmp is there).

Where did you find fopen() in here?

You need to use the SD library and its functions instead.

Simple answer: use the SD library provided by the IDE.
Long answer: fopen etc are designed for use with an operating system. While it is possible to 'bend' them to work without a kernel or filesystem abstraction layer, it's not easy. The AVR compiler and libraries don't provide the facilities for doing it.
So you need to use the method that is specific to the Arduino, which is contained in a library supplied with the IDE called SD.h. It has examples with it to show you how to use it.
There are other alternatives, as well, such as the much better written FatFS that has been ported to many platforms, Arduino included.


text:
Help needed to add and extra sensor
I am new to Arduino, and already tried to edit this many time. But I cant figure out whats wrong.
The following code has a PIR sensor, 1 LED and 1 buzzer.
I want to add one more PIR sensor, but it should trigger a separate LED , and the same buzzer. In serial monitor.
I have searched many sketches, but all of them seems to have a different method , cant figure out the basics!
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);
      if (pirState == HIGH){
      // we have just turned off
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

What have you tried?  You basically just need to copy and paste the parts of the code that deal with the pir sensor and change the variable names in the copy to something else.  How much of the code that you have now do you actually understand?  If you understand what that code is doing, then repeating it for a second sensor should be trivial.

@Delta_G, I tried to add duplicate code inside 'loop' for different pins, but it didn't work. I was doing it virtually in https://circuits.io/

Please post your update (solution) as an answer, then accept it after a while, so we keep the usual question/answer(s) split of the site.

@jfpoilpret, OK

Well, after playing with the code for some time, I just did it!!
pasting the updated code here, may be useful for someone else like me..
int ledPin = 13;                // choose the pin for the LED
int ledPinB = 12;               // choose the pin for the LED 2
int inputPin = 2;               // choose the input pin (for PIR sensor)
int inputPinB = 4;              // choose the input pin (for PIR sensor 2)
int pirState = LOW;             // we start, assuming no motion detected
int val1 = 0;                  // variable for reading the pin status
int val2 = 0;                  // variable for reading the pin status
int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(ledPinB, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(inputPinB, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  val1 = digitalRead(inputPin);  // read input value
  val2 = digitalRead(inputPinB);  // read input value
  if (val1 == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  }
  else if (val2 == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPinB, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  }

  else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      digitalWrite(ledPinB, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);
      if (pirState == HIGH){
      // we have just turned off
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

Link to circuit and virtual demo

Good job.  Thank you for sharing so we have this in the database.


text:
Writing your own Arduino flashing tool
I want to make Arduino flashing tool only for a nano, a simple flashing application which could run on windows taking input as a .hex file.
I know how to do this in Linux environment using Makefiles and writing script to automate it but have no idea what all are the things which I need to know and consider before I proceed with any windows application for such cases (implementing light GUI).
Any initial guide or read through would be a great help!

....... Why on earth....?!?!

I wish to give a support for a firmware upgrade for a product wherein I would be giving a .hex file and enable flashing on customer side. IDE can be used but I wish to provide a minimal complexity for the unskilled user.

So you don't want an IDE then, and it has nothing to do with Makefiles. You just want to run avrdude, maybe from a little wrapper GUI.

May be yes. @Majenko please suggest the steps that would be involved in wrapping the avrdude with the GUI. Thanks!

Write a windows application that asks for a file. 2. Add that file name to a predefined string for executing the command. 3. Execute the command. Maybe add options to select the com port. If you're clever and your chosen windows programming language allows it you may be able to feed the output of avrdude back to the user.

Or just use this https://blog.adafruit.com/2013/02/19/avrdudess-a-gui-for-avrdude/

This application already exists. It's called AVRDUDE:
http://www.nongnu.org/avrdude/
You can download it compiled for Windows at the link above. This is the very flashing tool that the Arduino IDE uses for the AVR boards such as Nano. You can get the AVRDUDE command the Arduino IDE uses to upload to the Nano by following these steps:

Start the Arduino IDE
File > Preferences > Show verbose output during: > upload (check) > OK
Tools > Arduino Nano
Sketch > Upload
After the process completes scroll the black console window at the bottom of the Arduino IDE window up to the start of the upload output and you will see the command generated by the Arduino IDE, which you can adapt to your needs.

If you want to use Makefiles you can get make compiled for Windows from this package:
http://winavr.sourceforge.net/
Note that it's incorrect to call what you're trying to do an IDE. IDE stands for Integrated Development Environment, which this is certainly not.


text:
Why we can wake Arduino Uno from sleep using only pin 2?
Can we use other pin as an interrupt to wake Arduino Uno from sleep ?

It's not just Pin 2 that can wake from sleep. Depending on which sleep mode you are in different interrupts (both internal and external) can wake the chip up.
The datasheet contains this helpful table:

The external interrupts (pins 2 and 3 on the Uno, and only "Level" trigger mode), pin change interrupts, I2C address matching, and the watchdog are the only interrupts that can wake the chip from any sleep mode. Other interrupts only work in certain sleep modes since they require parts of the chip to still be running in order for the interrupt to fire.
So that means that yes you can use any pin you like (using the "Pin Change" Interrupts) to wake the chip.

Thank you Majenko for your answer. Actually, in my project, I'm using the EnableInterrupt library (https://github.com/GreyGnome/EnableInterrupt) which enable to extend the interrupt functionality to multiple pins in the Uno, do you think that this will help to use other pins in the Uno to wake up using interrupts ?

That is just a fancy wrapper for the Pin Change interrupts, so yes, it will wake the chip.

I think you also can use pin 3 (INT1), see link
There are two interrupts:

INT0, pin 2
INT1, pin 3

According to the link (among other techniques), an external interrupt can be used, so both INT0 and INT1 should be valid.


text:
Two PIR sensors not working properly, help needed
I a just beginning with Arduino, I need some hellp here!!
I have added two PIR sensors to this circuit with an LCD.
Both PIR sensors are working fine and LCD is showing the correct PIR - only if a single PIR is active.
Problem-1. If the PIR1 and PIR2 gets active at the same time, and PIR1 goes off - it will still work as both PIRs are on, both LED will be on and buzzer will sound!!
In short when both sensors are active, Arduino cant sense which one went off later!!
Problem-2. second issue is the LCD is not displaying some text correctly.
If possible, it will be great if the system can display PIR1 status on line 1 and PIR2 status on line 2.
Can anyone help please to  fix the two problems and add the extra feature ?
Here is a Link of virtual circuit to see the sketch and connections.
Here is the code
#include <LiquidCrystal.h>

int ledPin = 13;                // choose the pin for the LED
int ledPinB = 12;               // choose the pin for the LED 2
int inputPin = 6;               // choose the input pin (for PIR sensor)
int inputPinB = 7;              // choose the input pin (for PIR sensor 2)
int pirState = LOW;             // we start, assuming no motion detected
int pirStateB = LOW;            // we start, assuming no motion detected PIR2
int val1 = 0;                  // variable for reading the pin status
int val2 = 0;                  // variable for reading the pin status
int pinSpeaker = 10;           // Set up a speaker on a PWM pin (digital 9, 10, or 11)

LiquidCrystal lcd(9, 8, 5, 4, 3, 2);

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(ledPinB, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(inputPinB, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  Serial.begin(9600);

  lcd.setCursor(0, 0);           // Set LCD cursor position (column, row)
  lcd.print("Security");         // Print text to LCD
  lcd.setCursor(0, 1);           // Set LCD cursor position (column,row)
  lcd.print("System");           // Print text to LCD
  delay(1000);                   // wait 1s  Delay to read text
  lcd.clear();                   // clear LCD display
  lcd.setCursor(0, 0);           // Set LCD cursor position (column, row)
  lcd.print("System Booting");
  delay(1000);                   // Delay to read text
  lcd.clear();                   // Clear LCD
  lcd.setCursor(0, 0);
  lcd.print("Processing...");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Waiting For");
  lcd.setCursor(0, 1);
  lcd.print("Motion");
}

void loop(){
  val1 = digitalRead(inputPin);  // read input value
  val2 = digitalRead(inputPinB);  // read input value
  if (val1 == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    if (pirState == LOW) {
      // just turned on
      Serial.println("Motion detected!");
      lcd.clear() ;
      lcd.setCursor(0, 0);   // Set LCD cursor position (column 0, row 0)
      lcd.print("PIR 1 Active!!");
      // only want to print on the output change, not state
      pirState = HIGH;
    }
  }
  else if (val2 == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPinB, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    if (pirStateB == LOW) {
      // just turned on
      Serial.println("Motion detected!");
      lcd.clear() ;
      lcd.setCursor(0, 1);      // Set LCD cursor position (column 0, row 0)
      lcd.print("PIR 2 Active!!");
      // only want to print on the output change, not state
      pirStateB = HIGH;
    }
  }

  else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      digitalWrite(ledPinB, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);
      if (pirState == HIGH){
      // just turned off
      Serial.println("Motion ended!");
      lcd.clear() ;
      lcd.setCursor(3, 0);
      lcd.print("Waiting For");
      lcd.setCursor(3, 1);
      lcd.print("Motion.");      // only want to print on the output change, not state
      // only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

Your problem is with the entire structure of your program. Pretty much everything is dependent on something else not having happened. Instead you need to make things more independent.
You should separate out your PIR sensor code into discrete chunks. One sensor isn't dependent on the other one having triggered or not, so there is no call to "link" them with an "else if". Also naming variables better will help understand the flow of code easier.
uint8_t savedStatePIR1 = LOW;
uint8_t savedStatePIR2 = LOW;

bool motionDetectedPIR1 = false;
bool motionDetectedPIR2 = false;

void loop() {
    uint8_t currentStatePIR1 = digitalRead(inputPinPIR1);
    uint8_t currentStatePIR2 = digitalRead(inputPinPIR2);
    bool haveChanged = false;

    if (currentStatePIR1 != savedStatePIR1) {
        savedStatePIR1 = currentStatePIR1);
        haveChaged = true;
        if (currentStatePIR1 == HIGH) { // Activated
            motionDetectedPIR1 = true;
        } else { // Deactivated
            motionDetectedPIR1 = false;
        }
    }

    // Exact duplicate with PIR1 changed to PIR2
    if (currentStatePIR2 != savedStatePIR2) {
        savedStatePIR2 = currentStatePIR2);
        haveChanged = true;
        if (currentStatePIR2 == HIGH) { // Activated
            motionDetectedPIR2 = true;
        } else { // Deactivated
            motionDetectedPIR2 = false;
        }
    }

    // Now, if either state changed this iteration through loop()
    // update the LEDs and the display, and play a tone if you
    // need to. Note that there is already a tone() function so
    // you really don't need to write your own.
    if (haveChanged) { // Something changed, so update things.
            digitalWrite(ledPin, motionDetectedPIR1);
            digitalWrite(ledPinB, motionDetectedPIR2);
            lcd.clear();

            if (motionDetectedPIR1 || motionDetectedPIR2) {
                tone(pinSpeaker, 300, 160);
                if (motionDetectedPIR1) {
                    lcd.setCursor(0, 0);
                    lcd.print("PIR 1 Active!!");
                }
                if (motionDetectedPIR2) {
                    lcd.setCursor(0, 1);
                    lcd.print("PIR 2 Active!!");
                }
            } else {
                lcd.setCursor(3, 0);
                lcd.print("Waiting For");
                lcd.setCursor(3, 1);
                lcd.print("Motion.");
            }
        }
    }
}

Note: this code isn't tested at all (it'll be full of errors). The basic principle, though, is:

First look for motion in PIR 1 and record if there is or not.
Repeat for the second PIR.
If there has been any change in state then (and only then) update the outputs.

Thanks for the reply, but I have no Idea were to paste this code!!

You don't paste code. You read code, learn how it works, then write your own.

OK, I will try .

,Tried it and failed, if you have time plz try to give me a full sketch. I will not be doing lots of Arduino project often, so it will not be that useful for me to learn Arduino in days...

You didn't try for very long did you?  Try harder.  You'll get it.  This isn't a place to get someone to write your code for you for free.

@Delta_G 1, I did tried atleast an hour on the script Majenko posted, but I don't know much about Arduino programming. It is not easy for me. Also, I have other things to do, time is precious and I will not be doing Arduino project in a daily basis in the future, so I think a copy paste will work me . ;-)
Please check the code I posted as an answer and tell me if there is anything wrong - it works, but I haven't tested it with a real Arduino.

So your time is too valuable to be spent trying to learn how to do what you want to do, but my time is just free to go debug your code for you while you put in almost no effort at all?  I think not.  Have a little bit of respect.

Thanks for the reply @Majenko, But as I said in the question, I am just a beginner. I couldn't figure out how to use it. I did change the pin number, but I dont know what is "haveChanged". So I did changed the code I already have and it seems to be working virtually. But it does take time to respond sometimes, may be in real world conditions, it will be better ?
Here is the link to virtual demo, please check and tell me if it is going to work.https://circuits.io/circuits/5142920-two-pir-project-1-0
Did spend some time, and made this code.
#include <LiquidCrystal.h>
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 5;

int NpirPin = 2;    //the digital pin connected to the PIR sensor's output
int SpirPin = 3;
int NledPin = 13;
int SledPin = 12;
int buzzerPin = 10;

LiquidCrystal lcd(9, 8, 7, 6, 5, 4);                          // initialize the library with the numbers of the interface pins

//SETUP
void setup(){
  Serial.begin(9600);
  pinMode(NpirPin, INPUT);
  pinMode(SpirPin, INPUT);
  pinMode(NledPin, OUTPUT);
  pinMode(SledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(NpirPin, LOW);
  digitalWrite(SpirPin, LOW);
  digitalWrite(buzzerPin, LOW);
  lcd.begin(16, 2);
  lcd.setCursor(3, 0);
  lcd.print("Waiting For");
  lcd.setCursor(3, 1);
  lcd.print("Motion....");

  //give the sensor some time to calibrate
  Serial.print("calibrating sensors ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(500);
      }
    Serial.println(" done");
    Serial.println("SENSORS ACTIVE");
    delay(50);
  }
 ////////////////////////////
//LOOP
void loop(){

     if(digitalRead(NpirPin) == HIGH){
       digitalWrite(NledPin, HIGH);   //the led visualizes the sensors output pin state
       playTone(300, 300);
       delay(150);
         Serial.println("---");
         Serial.print("motion at NORTH");
        lcd.clear() ;
      lcd.setCursor(0, 0);                                           // Set LCD cursor position (column 0, row 0)
      lcd.print("PIR1 Active!");
         delay(500);
       }

     else if(digitalRead(NpirPin) == LOW){
       delay (300);
       digitalWrite(NledPin, LOW);
       digitalWrite(buzzerPin,LOW);}

     if(digitalRead(SpirPin) == HIGH){
       digitalWrite(SledPin, HIGH);   //the led visualizes the sensors output pin state
       playTone(300, 300);
       delay(150);
         Serial.println("---");
         Serial.print("motion at SOUTH");
        lcd.clear() ;
      lcd.setCursor(0, 0);                                           // Set LCD cursor position (column 0, row 0)
      lcd.print("PIR2 Active!");
         delay(150);
       }

     else if(digitalRead(SpirPin) == LOW){
       delay (300);
       digitalWrite(SledPin, LOW);
       digitalWrite(buzzerPin,LOW);}

}

// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(buzzerPin,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(buzzerPin, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}


text:
My Arduino Uno buzzer isn't working
/*

*/

void setup() // Built in initialization block
{
    Serial.begin(9600);
    Serial.println("Beep!");
}

void loop() // Main loop auto-repeats

{

//   Serial.println("Beep!");

   tone(4, 3000, 1000); // Play tone for 1 second

   delay(1000); // Delay to finish tone
}

Does this buzzer work when voltage is applied to it directly?  If so, then have you tried just turning it on with an output pin and then delaying while it buzzes?  Is it really a buzzer, or is it a piezo transducer?  I see a statement of the problem in the title, then a code snippet which is obviously your attempt to make it work, but I do not see a question.  Plus, as @Majenko and Delta_G point out, there are other questions that may answer this.  So I suggest you do some more research on this before posting.  This will need to explain why it is not a duplicate, at the very least.

This question is no longer a duplicate. The OP had an original question, https://arduino.stackexchange.com/questions/39087/why-is-the-piezo-buzzer-not-looping-making-sound, which was answered. Then they (incorrectly) modified that original question, to be the same as the original answer. Obviously they should not have done that. Then, they asked the same modified question again here, thereby making a duplicate of the original question (after it had been modified). Now that I have rolled back the original question, this question is no longer a duplicate, and as such should be reopened.

First, take a look at the two links provided in the comments to your question and explain why your question is different from them.  Start by describing your "buzzer."  If your question is not significantly different then it will attract downvotes instead of answers, or it may be marked as duplicate or just simply closed.
Here is one solution, making the assumption you are writing about a piezo beeper:
void setup() {
  pinMode(4,OUTPUT);
}
void loop() {
  digitalWrite(4,HIGH);
  delay(1000);
  digitalWrite(4,LOW);
  delay(1000);
}

Alternatively, take the first example program from your IDE, called blink, and hook your beeper to pin 13 (positive) and GND (negative) while that runs.  It does basically the same thing.

The two links go to the same question, that the OP has already asked... The problem is probably active/passive buzzer


text:
How to get code to respond to a certain time from the DS3231 RTC?
I am trying to make a program that runs when it gets to five in the afternoon, so 17:00:00.
I am using this DS3231 library, but I can't figure out a way to get it to send "Woooopp" to the serial monitor at the specified time.
On the DS3231, the pin labeled SCL is connected to A5 on the Arduino and the pin labeled SDA is connected to A4 on the Arduino.
SCL -> A5
SDA -> A4
My code:
#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc (SDA, SCL);

void setup() {
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}

  // Initialize the rtc object
  rtc.begin();

  // The following lines can be uncommented to set the date and time
  // rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
  // rtc.setTime(19, 48, 50);     // Set the time to 12:00:00 (24hr format)
  // rtc.setDate(3, 6, 2017);   // Set the date to January 1st, 2014
}

void loop() {
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());

  // Wait one second before repeating :)

  if (rtc.getTimeStr() == "19:58:12") {
    Serial.println("Woooopp");
  }
  delay (1000);
}

No errors are thrown, however, the code simply does not work.
Any help would be greatly appreciated!

Which RTC library do you use ? It seems to be this one: http://www.rinkydinkelectronics.com/library.php?id=73

Yes, I used that one. Sorry I forgot to link it, I will edit the question now.

Try using a shorter delay. All the other stuff also takes time to run, so you are checking slightly less than once per second. So certain seconds will be skipped.

Thanks for your answer, I tried that and it worked along with me also declaring the time in a variable beforehand and then comparing that instead. Have a great day!

When you look at the serial output, is the string you are getting from getTimeStr the same as what you expect?

You could use the DS3231 RTC built-in alarm function(s) to power-on the Arduino Uno.

@Delta_G I managed to find out that the problem lay with not declaring a variable to store the current time. Before, I was directly comparing the output from the function to the desired time. Thank you for your help though!

@MikaelPatel Thank you, I will try to use this as well, to see if it will work more efficiently than the method I found in the end.

Please, post your own answer to the question, for the benefits of others, and accept it to close the question.

How to get code to respond to a certain time from the DS3231 RTC?

the easiest is to set up the alarm in rtc.
alternatively, keep reading the rtc until the desired time has passed. not terribly efficient.


text:
The LCD doesn't display the words typed
I've tried this code on an LCD, and instead of displaying "Hello World!" it displays what is shown on the picture.
Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  lcd.print("Hello World!");
  delay(500);
  lcd.clear();
  delay(500);
}

You probably listed the wrong pin numbers in  LiquidCrystal lcd(12, 11, 5, 4, 3, 2); but haven't supplied a wiring diagram so who can say.

I've doublechecked the wiring

Sure, the wiring may be fine ... but you might have the wrong numbers within lcd(12, 11, 5, 4, 3, 2), or have them in the wrong order

Try the following

Double-check the LCD soldering
Double-check your wiring
Ensure that the pins you are using for your LCD are not assigned to some other function. This caused jumbled, random characters here.

From the attached I can see that you are connecting D7 to digital 2 of arduino. And I assume the pins D6 D5 D4 are also connected to 3, 4, 5 pins respectively, which is correct for your code.
But make sure the R/W pin is connected to proper ground. Verify that by measuring voltage if possible.
Also serial print whatever you are giving the lcd  to make sure it is not an encoding issue.

Don't take this the wrong way but some of those solder joints looks a little rough. I'm not sure this is your issue but you need some soldering practice. Solder joints should be bright and shiny and should completely cover the pad.
I can tell by the joint on pin 16 you didn't get it hot enough or the solder would have flowed to cover the entire pad. Some of the other joints look like they were overheated. Does your soldering iron have a temperature control? Experience will help you know when to turn it up and when you can get by with a lower temperature. Is your tip too large or needs replacing?
There's lot's of soldering how-to videos out there but no substitute for practice, practice, practice and then practice some more. :)


text:
How to use AtMega328P-PN
I am making an AC (the summer kind) control circuit with an AtMega328P chip. I bought the AtMega328P-PN instead of the P-PU. I followed the instructions on how to burn the bootloader, but nothing seems to work on the P-PN. I searched on Google for it and could find nothing anywhere.
Thanks in advance,
Iain

I followed the instructions -- which instructions? Did they also include instructions on setting the right fuses for your clock source?

And what do you mean nothing seems to work...? What doesn't work about it? Does the bootloader fail to flash? Does it flash but fail to be identified by avrdude? What...?

The ATmega328P-PN differs from the ATmega328P-PU essentially only in being rated over a wider temperature range.
It is for all ordinary purposes a direct substitute for where an ATmega328P-PU could be used, and has the same signature word.
Whatever your actual problem is, it is elsewhere.
(The chips that do require some special accommodation if ordered are the ATmega328 without a "P" before the dash and the ATmega328PB)


text:
How does one set attributes for SD files?
How does one set file attributes, e.g., creation date, for a file being created on an SD?

The Arduino SD library, is based on Github: greiman/SdFat, by William Greiman.
From SD Created File Attributes:

The basic SD.h library doesn't set the attributes. You notice everything has the same creation date? The library doesn't have any way of knowing what the date is.

However, you need to use a callback function. The following information is from file creation date and time in sd card ?:

Install the SdFat library - there is an example called Timestamp.ino describing in detail how to do it...
// after your rtc is set up and working you code just needs:

void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = rtc.now();

  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}

//put that outside of any functions, before your 'setup'

//Then inside your 'loop' or 'setup'

void loop(void)
{

  //Other code that does stuff

  //put this next line *Right Before* any file open line:
  SdFile::dateTimeCallback(dateTime);
  dataFile = SD.open(datafilename, FILE_WRITE);

  //other code that does stuff

}

There is another way of achieving this, in a sketch without having to convert to SDFat:

@donald0000 wants the Date Modified field to show an actual time stamp
  when you look at the files present on the card using Windows Explorer.
  As Billy Ho says, the callback function is the way to do it. You can
  indeed use this function with SD.h  if you don't want to convert to
  SDFat. Here is an example of the function in a sketch. Notice the
  timing of when the date modified time stamp is written, it is when
  file.close() writes the actual data to the card.
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <RTClib.h>

File file;  // test file
const uint8_t SD_CS = 10; // SD chip select
RTC_DS1307 RTC;  // define the Real Time Clock object

 char timestamp[30];

//------------------------------------------------------------------------------
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
 DateTime now = RTC.now();
 sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", now.hour(),now.minute(),now.second(),now.month(),now.day(),now.year()-2000);
 Serial.println("yy");
 Serial.println(timestamp);
 // return date using FAT_DATE macro to format fields
 *date = FAT_DATE(now.year(), now.month(), now.day());

 // return time using FAT_TIME macro to format fields
 *time = FAT_TIME(now.hour(), now.minute(), now.second());
}
//------------------------------------------------------------------------------
void setup() {

 Serial.begin(9600);
 Wire.begin();
 if (!RTC.begin()) {
   Serial.println("RTC failed");
   while(1);
 };
 // set date time callback function
 SdFile::dateTimeCallback(dateTime);

  DateTime now = RTC.now();
  sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", now.hour(),now.minute(),now.second(),now.month(),now.day(),now.year()-2000);
  Serial.println("xx");
  Serial.println(timestamp);

 if (!SD.begin(SD_CS)) {
   Serial.println("SD.begin failed");
   while(1);
 }
 file = SD.open("TEST_SD.TXT", FILE_WRITE);
 file.println("Testing 1,2,3...");

 delay(5000);
 file.close();
 Serial.println("Done");
}
//------------------------------------------------------------------------------
void loop() {}

Quite simply FAT16 only supports 1 date, normally Modified Date. FAT32 has (limited) support for 3 dates (but AFAIK there is no Arduino library which supports FAT32).
Even then not all OS even support Creation Date. Windows has 2 different interpretations depending on application, Linux natively only supports Change Date, although extensions provide support for more dates.

the latest SDFAT library supports FAT32.


text:
Purpose of capacitors in this project
I'm currently working on a project where I am making a wheeled robot using the Hack-e-bot library on the arduino. The circuit board which I have planned to put together through soldering will eventually look similar to this:

Here is a schematic:
I understand my circuit quite well but my mentor recommended using a capacitor for this and although I have got it on my schematic, I've never actually worked with capacitors before. Why should they be used in this project?

Using a capacitor for what purpose???

From the schematic, it seems to be a decoupling capacitor.

C1 is connected to Vcc and GND of the microcontroller, but it is hard to see. Since motors are used, an extra larger capacitor might reduce the noise and voltage dips caused by the motors. @Utsav, could you redraw the schematic ? Use GND symbols and put them at the bottom; don't try to make the picture small; If possible, keep the VCC in the top; Put labels for the pins of J1 and J2; Write the values for the capacitors and resistors; Write the type/name of the microcontroller in the schematic; A good schematic shows clearly the path of the sensor signals via the microcontroller to the motors.

I am assuming by the wording of the question that you are being advised to add another capacitor somewhere in your circuit in addition to the existing one? It's hard to know, since you are saying you have been advised to add a capacitor, yet your circuit already has a capacitor...  Also, I really pity D1's chances in life...

Oh, and "here's a random picture of a circuit board, and here's a plate of spaghetti" doesn't really help us much. I am not sure what you hoped to achieve by showing us some other circuit board, and you really need to read a few tutorials on how to lay out a schematic properly so that people can read it (though kudos for not making us suffer another Fritzing doodle...)

@Majenko sorry but I'm no expert at this, I tried to make sense, but guess not. I'll make sure I learn from my mistakes here and will try not to repeat them again! :)

Are you asking what the purpose of C1 is in your schematic, or are you asking about an additional capacitor somewhere else?

@Majenko I am asking what the purpose of C1 is in my schematic yes. But as Edgar pointed out this might be a decoupling capacitor?

Yes, that is what it is. But your schematic is lacking the required resistor inline with the LED "D1", without which you will either burn out your LED or make the circuit malfunction through clamping of the battery voltage.

See The care and feeding of LEDs

No. R2 is an LDR which is half of a voltage divider with R1. Nothing to do with the LED.

@Majenko wow yeah nevermind I noticed that too, I'll make sure to add a resistor inline with D1. Thank you

A capacitor is a device that can store (and release) charge. It is made up of 2 metallic electrodes (or plates) that are separated by a thin dielectric material.

When you apply a voltage over the two plates, an electric field is created. Positive charge will collect on one plate and negative charge on the other. - build-electronic-circuits.com

In short, a capacitor lets the AC component through and blocks the DC component.

Capacitors can be used in the following ways:
Decoupling Capacitors
(Also called Bypass capacitors)

A decoupling capacitor’s job is to supress high-frequency noise in power supply signals. They take tiny voltage ripples, which could otherwise be harmful to delicate ICs, out of the voltage supply.

Image reference http://www.seattlerobotics.org/encoder/jun97/basics.html

In a way, decoupling capacitors act as a very small, local power supply for ICs (almost like an uninterupptable power supply is to computers). If the power supply very temporarily drops its voltage (which is actually pretty common, especially when the circuit it’s powering is constantly switching its load requirements), a decoupling capacitor can briefly supply power at the correct voltage. This is why these capacitors are also called bypass caps; they can temporarily act as a power source, bypassing the power supply.
Decoupling capacitors connect between the power source (5V, 3.3V, etc.) and ground. It’s not uncommon to use two or more different-valued, even different types of capacitors to bypass the power supply, because some capacitor values will be better than others at filtering out certain frequencies of noise.
  - sparkfun.com

Power Supply Filtering
DC power supplies can be quite noisy on their own. Take the output of a bridge rectifier for example, there is a lot of ripple on the output. Capacitors are a perfect solution for reducing the ripple/noise of power supplies.

Image Reference: http://www.electronics-tutorials.ws/diode/diode_6.html

Capacitors are stubborn components, they’ll always try to resist sudden changes in voltage. The filter capacitor will charge up as the rectified voltage increases. When the rectified voltage coming into the cap starts its rapid decline, the capacitor will access its bank of stored energy, and it’ll discharge very slowly, supplying energy to the load. The capacitor shouldn’t fully discharge before the input rectified signal starts to increase again, recharging the cap. This dance plays out many times a second, over-and-over as long as the power supply is in use.

Also see Keelan's answer over at electronics stack exchange.
Signal Filtering

You can also combine capacitors and resistors to form filters that target specific frequencies. - build-electronic-circuits.com
They can block out low-frequency or DC signal-components while allowing higher frequencies to pass right through. They’re like a bouncer at a very exclusive club for high frequencies only. - sparkfun.com
For example in an audio system you can target the high frequencies to remove them (e.g. in a sub-woofer). This is called a low-pass filter.  - build-electronic-circuits.com

Image Reference: Wikipedia

Back to your application.
Motors are notoriously noisy. Your mentor has recommended a capacitor to decouple the noise of the motors and protect the IC from voltage drops/spikes.
Side note: D1 in your schematic is a power indication LED. It needs a current limiting resistor in series with the LED to limit the current and prevent the LED from burning out.

Resources:

https://learn.sparkfun.com/tutorials/capacitors
https://www.build-electronic-circuits.com/how-does-a-capacitor-work/
Basic Circuits - Bypass Capacitors
wikipedia.org/wiki/Capacitor
wikipedia.org/wiki/Decoupling_capacitor
Youtube - How a Capacitor Works - by Dr. Oliver Winn
explainthatstuff.com/capacitors

Based on the schematic shown, the capacitor acts as a decoupling or smoothing capacitor. When the circuit components such as a motor require a sudden source or produce a sudden spike of energy, this would help filter out the noise and balance the power line.
More info regarding decoupling capacitor may be found on wikipedia here.


text:
Scheduling and BLE Read on demand
I'm building a data logging device with BLE capability using RFduino.
Sensors are read using timer interrupt to a buffer. When the buffer is full, then the whole buffer is written to SD card.
At the same time, I have BLE_Receive to set time of the RTC clock on the device. Also BLE_send that transmit the current time of the necklace, and the freespace available (heartBeat or HB). Calculation of free space in particular might take a long time since it's IO operation.
Of course, reading sensors and writing data to SD card has highest priority, then transmitting heart beat only when the processor is free.

#include <Wire.h>
#include <Adafruit_VCNL4010.h>
#include <SPI.h>
#include <SdFat.h>
#include <TimeLib.h>
#include <RFduinoBLE.h>
#include "PCF8563RTC.h"

#define number_of_ms 100
#define NUM_SAMPLE_BUF    3        // number of data samples in buffer
#define SAMPLESIZEINCHAR 24        // verify at line 104, include null character
#define BUFLEN NUM_SAMPLE_BUF*SAMPLESIZEINCHAR + 1

volatile boolean connectFlag = false;
volatile boolean readSensorFlag = false;
volatile boolean heartBeatReadFlag = false;

// RTC variables
PCF8563RTC rtc;
tmElements_t tm;
time_t epoch;

// SD card variables
#define CHIPSELECT 2
SdFat SD;
File myFile;

// Proximity sensor
Adafruit_VCNL4010 vcnl;
uint16_t proximity;
uint16_t ambientLight;

// Double buffers to transfer data between sensors and SD card
char buffer[2][BUFLEN];
volatile uint16_t bufferCounter;
volatile int inBuf = 0;
volatile bool outBufHasData = false;

void timer_config(void) {
  NRF_TIMER2->TASKS_STOP = 1;  // Stop timer
  NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;  // taken from Nordic dev zone
  NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
  NRF_TIMER2->PRESCALER = 9;  // 32us resolution
  NRF_TIMER2->TASKS_CLEAR = 1;  // Clear timer

  // With 32 us ticks, we need to multiply by 31.25 to get milliseconds
  NRF_TIMER2->CC[0] = number_of_ms * 31;
  NRF_TIMER2->CC[0] += number_of_ms / 4;

  NRF_TIMER2->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
  NRF_TIMER2->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos)
                        & TIMER_SHORTS_COMPARE0_CLEAR_Msk;

  attachInterrupt(TIMER2_IRQn, TIMER2_Interrupt);
  NRF_TIMER2->TASKS_START = 1;  // Start TIMER
}

void setup() {
  bufferCounter = 0;
  inBuf = 0;
  outBufHasData = false;

  // BLE stack
  RFduinoBLE.deviceName = "andrey";
  RFduinoBLE.begin();

  rtc.init();
  setSyncProvider(rtc.get);
  setSyncInterval(3600);

  // start SD card
  pinMode(CHIPSELECT, OUTPUT);
  if (!SD.begin(CHIPSELECT)) {
    return;
  }

  // Start sensors
  if (!vcnl.begin()) {
    return;
  }

  timer_config();
}

void loop() {
  // Reading data from sensors to a buffer
  if (readSensorFlag) {
    readSensorFlag = false;
    heartBeatReadFlag = true;

    if (bufferCounter < BUFLEN - SAMPLESIZEINCHAR + 1) {
      epoch = now();
      proximity = vcnl.readProximity();
      ambientLight = vcnl.readAmbient();

      // format to be fixed length as opposed to variable length
      // sacrifice overhead in written data with simpler and more robust code
      // since we know exactly how much to increment after each write
      int written = snprintf(&buffer[inBuf][bufferCounter], SAMPLESIZEINCHAR,
            "%10lu,%5d,%5d\n",
            epoch, proximity, ambientLight);

      if (written > 0) {
        bufferCounter += written;
      }
    } else {
      // only switch buffer if out buffer is written to SD card
      if (!outBufHasData) {
        inBuf = inBuf? 0:1;
        bufferCounter = 0;
        outBufHasData = true;
      }
    }
  }

  // write buffer to SD card
  if (outBufHasData) {
    // create folder if not exist
    char folderPath[3];
    snprintf(folderPath, sizeof(folderPath), "%02d", day());
    if (!SD.exists(folderPath)) {
      SD.mkdir(folderPath);
    }

    // Write buffer to SD card
    char filePath[19];
    snprintf(filePath, sizeof(filePath), "%02d/%02d%02d%02d%02d.csv",
        day(), month(), day(), hour(), minute());
    myFile = SD.open(filePath,  FILE_WRITE);
    if (myFile) {
      myFile.print(buffer[1 - inBuf]);
      myFile.close();
    }
    outBufHasData = false;
  } else {
    if (connectFlag && heartBeatReadFlag) {
        heartBeatReadFlag = false;
        transmitHeartBeat();
    }
  }
}

void transmitHeartBeat(void) {
  uint32_t heartBeat[8];
  heartBeat[0] = rtc.get();
  heartBeat[1] = SD.vol()->freeClusterCount() * SD.vol()->blocksPerCluster();
  RFduinoBLE.send((char*)&heartBeat, 8);

}

// read sensors periodically at 20Hz
void TIMER2_Interrupt(void) {
  if (NRF_TIMER2->EVENTS_COMPARE[0] != 0) {
    NRF_TIMER2->EVENTS_COMPARE[0] = 0;
    readSensorFlag = true;
  }
}

void RFduinoBLE_onConnect() {
  connectFlag = true;
}

void RFduinoBLE_onDisconnect() {
  connectFlag = false;
}

void RFduinoBLE_onReceive(char* data, int len) {
  memcpy(&epoch, data, sizeof(time_t));
  rtc.set(epoch);
}

Currently my solution is as following: reading happens at the beginning of every interval of 100ms. Every 3 interval, the buffer is full and is written to SD card. During other 2 intervals, the processor is free thus I can get HB and transmit it.
Is there a better way? Could I have transmit HB on demand, i.e. transmit HB only when there's a request for it? How could I represent a request in Bluetooth LE? By setting a bit of BLE_receive?

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


text:
How does Arduino IDE 'Get Board Info'?
I want my C# application to automatically select the correct COM port by way of a string equality check against a 'GetInfo'-type request to the Arduino board.
I know the Arduino IDE can get info from the board;
Tools > GetBoardInfo

But I don't know how to get it using a sketch or if it is even possible for that matter.
Is this something that can be read from the board, or is it a USB-thing. If it's a USB thing, I'd have to get the info from GetUSBDevices.DeviceID or whatever, then get the serial port used by the USB Device, which would probably work, but I'd rather do it all via a serialPort.

I think you want the USB vendor and device IDs.  That is likly how operating-systems pick drivers for different USB devices.  But you may want more if you have several similar USB (for example FTDI chips) connected to the same operating-system/computer.  I assume that is why you are asking about the "Arduino board information"?

if you change the com port for a board in windows, it will persist, then you don't need to search

I'm voting to close this question as off-topic because it's about a C# program running on PC.

@LookAlterno I don't know, it's a question Arduino users seem to come across at some point. I'm not bothered if it gets closed, but I genuinely think it's a helpful question for Arduino users specifically, as it has good viewing numbers on here. At it's core, it's an Arduino question, even if the answer is more generalized. It's up to the com and any precedence though.

Looking at the source code of the Arduino IDE on github, it looks like they call an executable (listComPorts.exe). So I would guess you can't get that info through serial.
Here's a C# app using WMI that can get port, vid, and pid:
namespace PortTest
{
    class Program
    {
        // Helper function to handle regex search
        static string regex(string pattern, string text)
        {
            Regex re = new Regex(pattern);
            Match m = re.Match(text);
            if (m.Success)
            {
                return m.Value;
            }
            else
            {
                return null;
            }
        }

        static void Main(string[] args)
        {
            // Use WMI to get info
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
                "SELECT * FROM Win32_PnPEntity WHERE ClassGuid=\"{4d36e978-e325-11ce-bfc1-08002be10318}\"");

            // Search all serial ports
            foreach (ManagementObject queryObj in searcher.Get())
            {
                // Parse the data
                if (null != queryObj["Name"])
                {
                    Console.WriteLine("Port = " + regex(@"(\(COM\d+\))", queryObj["Name"].ToString()));
                }
                //PNPDeviceID = USB\VID_1A86&PID_7523\5&1A63D808&0&2
                if (null != queryObj["PNPDeviceID"])
                {
                    Console.WriteLine("VID = " + regex("VID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                    Console.WriteLine("PID = " + regex("PID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                }
            }
            Console.WriteLine("Done");
            int c = Console.Read();
        }
    }
}

From there, it looks like it searches an online database for more info. See: getBoardWithMatchingVidPidFromCloud() function.

IMHO Since Arduino IDE 1.6.8 listComPorts is no longer part of the arduino IDE

@jantje They may be using JNI now, but I'm guessing the underlying process is the same. Platform.java has 2 native functions resolveDeviceAttachedToNative and listSerialsNative but I can't find the source for them.

edit: I  misunderstood your comment. I think this is the code https://github.com/arduino/Arduino/blob/master/arduino-core/src/processing/app/Platform.java#L231 they are using resolveDeviceAttachedToNative

I have looked into this many times and it looks like it is this https://github.com/arduino/libserialport but then again it doesn't

Thanks Johnny; I was actually looking into using WMI to get the info, so it's nice to see it laid out just how I need it :)))) This will work on any version of windows, right?

@jantje If that's what they are using it uses lower level calls than WMI to get the data. Since Java's serial port handling is not very good, it would make sense to use that.

@n00dles It should. WMI has been around since Win2K.

Please look here https://todbot.com/blog/2012/03/02/listcomports-windows-command-line-tool-for-usb-to-serial/
The article is right about what you are seeking.
Thanks to @Johnny Mopp, searching "listComPorts" keyword helped me.
Quote from that article:

How it works
The C and the VBS versions both utilize the WMI
infrastructure that’s been around since Windows 2000 to query the
machine about its configured PnP devices. The WMI is a huge data
structure of just about any information in Windows. Except, it seems,
good information about COM ports. While there is a “Win32_SerialPort”
table in WMI, that only contains information about hardware serial
ports, not USB-to-serial adapters. Instead, these two tools look at
the “Win32_PnPEntity” table. While this table does list USB-to-serial
adapters, it does not contain a proper mapping of the adapter’s USB or
PnP ID to COM port. Instead, these tools do a string search on the
“Caption” field for the string “(COMn)” where “n” is a number. It’s an
incredible hack but seems to work.


text:
Getting the "Device has problem: 0x0a: CM_PROB_FAILED_START." error code 10 while installing device driver for Arduino Uno
After uninstalling and reinstalling Arduino IDE, my Arduino Uno is not recognized by my PC. When I connect it to my PC all lights are glowing in my board but my PC is not showing anything connected to USB.
When I tried to install drivers manually I'm getting the error device cannot start code 10. I have used the default drivers for Arduino, which I downloaded with the IDE. I tried installing them manually. I don't have any idea about chipset interface whether it is CH or FTDI. I have looked at all the possible solutions but my problem wasn't solved.

I don't do MSWindows but anyhow imagine nobody can answer the question without knowing the interface chip part # (probably starts with FTD or CH) and links to the drivers you tried to install.  Please edit your question (click "edit") and add that info

I have modified the question with some details. Please help me

Read the interface chip part # by looking at at your Uno with a magnifier (eg a magnifying glass, a camera, a webcam, etc) then edit the  part # into the question.  Also, did the board formerly work, and stopped working when you reinstalled the IDE, or did it never work?

the board is switching on and orange colored led is also blowing well

sorry i did not found anything on board which starts with FTD or CH. I'm totally new to arduino and sorry for the inconvenience

Error code 10 mean Bad Environment.  I would guess that you are using the wrong driver, probably 64 bit on a 32 bit OS, etc.
This does not look like a Arduino fault, it looks like a windows Driver fault, so unlplug the board, reboot the PC logon as admin and download the latest drivers for you device and see if that fixes it.  You might be able to get better help on a Windows admin forum I think.

no  I'm using latest drivers for windows 8.1 64 bit and i'm modifying the question with error

Are you plugging the USB cable from the PC straight into the Arduino?  Is it a real Arduino or is it a clone or fake?

i bought it from amazon and it is arduino uno R3 , I'm directly connecting arduino to my pc. Main problem i dentified now is, my PC is not at all responding for that usb,It even not showing usb plugged in but the power is supplying to arduino

Amazon doesn't mean its real :)  https://docs.microsoft.com/en-us/windows-hardware/drivers/install/cm-prob-failed-start   You will need to Google for that error and see.  It looks like it could be something simple like a PATH environment problem.  You need to look up the rest of the error message and see if that helps.  If you can, try a different PC.

Have you tried "Run as admin"?

i have tried run as admin, another problem is when i move arduino or usb cable power is not supplying to arduino.I think it may be hardware problem. I'm totally fed up with this :(


text:
Need help with calculator logic
I am trying to build a calculator with an Arduino, an LCD display, and a keypad. Getting inputs from the keypad is not the issue. Before I can add, subtract, multiply, or divide any two numbers, I want to make sure the calculator registered the given number. I am trying to program it (so far) so that I type in a number and press enter (the @ sign I assigned to my keypad) and the LCD prints out that number. As you will see, I attempted to devise a logic mechanism for the Arduino to recognize the typed number.
I thought since as you type more numbers the value of the first number typed increases by 10 fold each time (if you start by pressing 4 then if you press another number such as 5 following it, that 4 will become 40, and 400 if another number is pressed, etc...) I could multiply that number (and every following number) by 10, 100, 100, etc...
But it doesn't work and I need help so that the number can be collected by the Arduino.
Here's my attempt at it:
    #include <LiquidCrystal.h>
    #include "Arduino.h"
    #include "Keypad.h"

    int count = 0;
    int row = 0;
    int column = 0;

    //const int buzzer = 0;

    int value1;
    int value2 = 0;

    int spot1 = 0;
    int spot2 = 0;
    int spot3 = 0;
    int spot4 = 0;
    int spot5 = 0;
    int spot6 = 0;
    int spot7 = 0;
    int spot8 = 0;

    LiquidCrystal lcd(1, 2, 3, 4, 5, 6 );

    const byte ROWS = 4; //four rows
    const byte COLS = 3; //three columns
    char keys[ROWS][COLS] = {
      {'1','2','3'},
      {'4','5','6'},
      {'7','8','9'},
      {'%','0','@'}
    };
    byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the
    keypad
    byte colPins[COLS] = {13, 12, 11}; //connect to the column pinouts of
    the keypad
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS
    );

    void setup() {
      //pinMode(buzzer, OUTPUT);
      lcd.begin(16,2);
      lcd.print("---Calculator---");
      delay(2000);
      lcd.clear();
      lcd.print("Value1: ");
      lcd.blink();

    }

    void loop() {
char key = keypad.getKey();

if(key != NO_KEY){
  lcd.print(key);
  if(key != '%' && key != '@'){
    count++;
  }
  else if(count == 1){
    spot1 = key;
  }
  else if(count == 2){
    spot2 = key;
  }
  else if(count == 3){
    spot3 = key;
  }
  else if(count == 4){
    spot4 = key;
  }
  else if(count == 5){
    spot5=key;
  }
  else if(count == 6){
    spot6=key;
  }
  else if(count == 7){
    spot7=key;
  }
  else if(count == 8){
    spot8=key;
  }

  if(key=='@'){
    if(count == 1){
      value1 = spot1;
    }
    else if(count == 2){
      value1 = (spot1*10)+(spot2);
    }
    else if(count == 3){
      value1 = (spot1*100)+(spot2*10)+spot3;
    }
    if(count == 4){
      value1 = (spot1*1000)+(spot2*100)+(spot3*10)+spot4;
    }
    if(count == 5){
      value1 = (spot1*10000)+(spot2*1000)+(spot3*100)+(spot4*10)+spot5;
    }
    if(count == 6){
      value1 = (spot1*100000)+(spot2*10000)+(spot3*1000)+(spot4*100)+(spot5*10)+spot6;
    }
    if(count == 7){
    }
    if(count == 8){
    }
    lcd.print(value1);
  }

  if(key  == '%'){
    count = 0;
    lcd.clear();
    lcd.print("Value1: ");
    lcd.blink();
  }
}

}

PS: If you know any better way to accomplish this goal, I would love to hear it.

Instead of storing all the different digits in a whole bunch of variables, why not keep one int variable and keep track of everything in it.  Instead of the count++ you just multiply the int by 10 and get ready to add the next digit.

Please be more explicit about what "doesn't work". Your method, while perhaps not very elegant should work, for small numbers anyway. I didn't spot a mistake from a quick glance at the code, but I don't know what I'm looking for.

the issue is that the calculator outputs 64 regardless of what I entered

I agree with @Delta_G - accumulate the value as you go instead of collecting digits then assembling them afterwards.  I'm not sure why you would get 64 from this, ...   Have you tried the accumulator approach?

If your keypad setup results in '%' and '@' arriving correctly, then it probably also results in the characters '0', '1', ... '9' arriving when number keys are pressed, rather than digit values 0, 1, ... 9 arriving.
Be that as it may, there's a far simpler approach to building value1 which does not use a big set of spot values like your method does.  Here is an illustration of it.
// ... Before number input, zero out a number-accumulator variable
long int nin = 0;

do {
  key = keypad.getKey();
  if (key != NO_KEY) {
    lcd.print(key);
    // As number keys are pressed, add them to tail of number
    if (key >= '0' && '9' >= key) {
      nin = 10*nin + (key & 0xF);   // Get low 4 bits of key
    }
  }
  if (key == '@') {
    lcd.print("Value = ");
    lcd.print(nin);
    // ... do whatever else with value
    // ... then get ready for next value
    nin = 0;
  }
} while (1);

if(key != '%' && key != '@'){
  count++;
}
else if(count == 1){
  spot1 = key;
}
else if(count == 2){
  spot2 = key;
}

You've got a problem here.  If key isn't '%' and isn't '@' then you increase count but since all the rest are else if to that then it skips over all of them and never actually puts the digit int the spot.

I tried removing the else's but it still does not appear to work

Define doesn't work.  What happens?  How does that compare with what you expect?

That may not be the only logical flaw in your program.  It's just the one that jumped out at me first.

The calculator spits out 64 no matter the input

Interesting. 64 is the ascii code for '@'.  If you press something that is not % or @ then you're not storing anything. But when you get @ then the first if isn't true and it goes to one of the else if where count is whatever and stores the 64 in one of the spots.

I can see that my method may not be the most effective. Any suggestions?


text:
Using the SD library with the ESP8266 DevKit
The situation is as follows, I've connected a SPI TFT screen to the ESP8266 DevKit, set my own MISO,MOSI, CD, SCK pins and it works fine, wanted to do the same for using the SD card reader, but then I realized that the SD library is using the pre-defined pins with no visible way override this.. There must be a way, no?
I did try editing the pins_xxx files:
static const uint8_t SS   = 10;
static const uint8_t MOSI = D7; //11;
static const uint8_t MISO = D5; //12;
static const uint8_t SCK  = D6; //13;

But it did not work, I'm not that well familiar about the build process..
So, is there a way to accomplish this? Maybe a different library?
P.S. I am using the Arduino IDE for the ESP.

Do you have a reason to not share the SCK, MISO, MOSI lines between the two devices?

on nodeMCUs, you really want to use the native (SPECIAL) pin modes when you can, especially on a device like a screen. in other words, get the SD working, then share with the TFT sans CS, which remaps.

@JamesWaldby-jwpat7 & dandavis I just got familiar with the SPI interface and did not know about sharing the pins, now I do though, thanks!

After some trial and error got both the screen and sd card reader working sharing the MISO and SCK lines.
I was using a display wit the Adafruit ST7735 driver (and their library), worked fine with both hardware and software, but the SD card reader (generic, not even a part number on it) was able to work only with hardware SPI as the standard SD library does not support software SPI for some reason.
The most important takeaway is this: The SD library internally uses the predefined MOSI,MISO and SCK pins, but fot the ESP8266 dev kit they were mapped to pins labeled HMOSI, HMISO and HSCLK - D7, D6 and D5. Now that I think about it, the H must stand for "Hardware", if only I had this epiphany sooner.


text:
I2C on ATtiny85 and Si4703 radio
I've got an Si4703 breakout from Sparkfun, which communicates via I2C. I have gotten it to work very easily using a regular 3.3V Arduino Pro Mini, but am now trying to move everything over to an ATtiny85. It seems this should be possible, but my I2C knowledge is basically zero.
SETUP
I have everything laid out on a breadboard:

ATtiny chip with 3.3V power and ground from a good power supply
Si4307 on the breadboard too
SDIO on digital pin #0 (pin 5 on the chip) with a 4.7K pull-up running to 3.3V and out to the breakout
SDLK on digital pin #2 (pin 7 on the chip), same as SDIO
A reset pin for the breakout, running from digital pin #1

I've verified this with the Pro Mini and it works great, so I'm doubtful the problem is here.
SOFTWARE
My ATtiny is set up using the TinyWireM library for I2C, and using a customized version of the Sparkfun Si4703 library. <-- if I had to guess, this is where the problem probably is... I think
My modded library files are here (too long to paste in the forum):
https://gist.github.com/jeffThompson/5e48c8915148e6e0bac7d85c9a3da948
https://gist.github.com/jeffThompson/10934cf8f07b3000e7e61601266b2b2c
And my Arduino code:

#include <TinyWireM.h>
#include <Si4703_ATtiny.h>

int SDA =   0;       // I2C data pin on ATtiny85
int SCK =   2;       // I2C clock pin on ATtiny85
int reset = 1;       // can probably be any digital pin

Si4703_ATtiny radio(reset, SDA, SCK);

void setup() {
  TinyWireM.begin();    // need this?
  radio.powerOn();
  radio.setChannel(937);
}

void loop() {
  radio.setVolume(15);
  delay(1000);
  radio.setVolume(0);
  delay(1000);
}

TESTING
I've tested both the Pro Mini and ATtiny85 version using my scope, but I'm pretty new to that tool, especially for I2C. I see similar clock and data patterns from both versions, and can see that there is readable I2C data from the ATtiny on my scope (it is finding readable hex data and sees it is ACK-ed, at least some of the time). I have programmed ATtiny chips through the Arduino IDE before, so I'm pretty familiar with that process, and double-checked things are outputting using an LED.
TLDR
I'm not anywhere near an I2C expert, and have never built an Arduino library, so I'm guessing I need some help with my modded library (unless I'm missed something else obvious).

Why all this trouble ? The ATtiny85 is not officially supported by Arduino and a ATmega328p in a small package is also very small.

You haven't explained your problem!

@Jot – the ATtiny85 is still cheaper, and doesn't require an external crystal.

@Gerben – the problem is it doesn't work! Since the ATtiny85 doesn't have serial, I can't easily see what the problem is. Was hoping someone with more knowledge could help find where the issue might be (the modded library code, etc).

Try adding an led for debugging.

@Gerben – I did (it's in the post, but there's a lot of info). I put one on the SDIO and SCLK lines, just to see if stuff is coming out. I can see I2C-looking data on my scope too, so I think the problem is code, not circuit.

The Si4703 has an approach that I'm not used to. It reads for example 32 bytes, and waits for ever after the requestFrom. You can remove that wait loop, it has no use. It uses millis in the wrong way. I think that the TinyWireM can do only 16 and not 32 bytes with requestFrom. Could you try other Si4703 code that is more "normal" ?

Thanks @Jot – it's basically the library from Sparkfun, replacing references to the Wire library. But if the TinyWireM library can't do 32 bytes, then I'm probably out of luck, right? (I don't know enough about I2C or the Si4703 chip to write any interface code myself, I'm afraid.)