Arduino IDE says fcould not convert 'pinMode(buttons[((inti)], 0u)' from 'void' to 'bool'. How do I fix

There is very little about the code you are producing at the moment that could be classified as "right".

You are like a child who has been playing with LEGO® being let loose on the workings of a nuclear reactor.  You're sticking things together without a) knowing what they do and b) knowing how they are supposed to work, and it's all going to end in tears.

I suggest that, for the time being, you forget this game project of yours and go back to the basics.  Start by learning how to make an LED light up when you press a button.  That will teach you both how to read the state of a button and how to control an LED.  Then move on to doing it with multiple LEDs and multiple buttons.

As it stands you are just going to end up getting frustrated and annoyed.  You're asking questions without either knowing just what it is you are asking or how to understand the answers when you are given them.  And that is going to end up reflecting badly on the rating of your various users (hint: if you ask reasonable questions you get reasonable answers, and that means upvotes and reputation, which then means you can ask more questions so you don't have to keep creating new users to ask more questions where you don't actually understand what you're asking).


Since this is going to be a long post, I'll post the summary above the fold to save some of you the effort of scrolling...

tl;dr: No, it's not possible to do so with GPIO pins. There is another way to do this, but IDK if the rest of the Galileo will be a bottleneck (and it's pretty pricey). The stereotypical AVR Arduino is simply too underpowered (both from a MCU and amperage standpoint) to host USB 3.0. You need a shield to host USB 2.0, and even with that, I doubt that you can use 2.0 at it's full potential.

Basic corrections/things to note (before I begin):

Note: I'm no expert on the Galileo, I'm just doing this all from what I remember from what I've read in the past. If you spot an error, feel free to post a comment with a little explanation and I'll fix my post. However, I doubt that there will be any major errors, and the overall content (i.e. the tl;dr) should be fine.
These figures are maximum that I'm posting:

Speed: if speed is near maximums, or even 10%, what's the point of 3.0?
Power: you never know with this one, so account for it being near limits, unless externally powered. Still, don't risk it.

If it's a USB thumb drive, you're going to either get a breakout board for 3.0 and/or break open your device and solder wires onto it. Note that there doesn't seem to be a USB 3.0 breakout board (from a very quick search on Google). I'm also concerned that the wires you would use might not be high enough grade for extreme data transmission.
Only 7 of the 9 lines are used for data. The other two are 5V and GND.
On a Galileo, you'll have to use the 5V selection for the IO pins.
On a Galileo, there's a Mini-PCIe port (although I can't seem to find it in the photos myself). You could add a Mini PCIe to USB 3.0 card. However, that will cost you almost $50 to do so, and by that time it might be better just to seek out another solution.

Photo of it:

Ask yourself do I really need the speed?

No: don't waste the money and the headache.
Yes: consider either another platform or buying this product.

Keep in mind that, although it fits, it probably won't be able to get enough power for true USB 3.0 that your disk needs and drivers will be rare. You for sure will want to research this more before shelling out the cash to buy this card.

Galileo doesn't run a full OS, so I'm highly doubtful that there's drivers.

Like I mentioned before, I'm not quite sure about the Galileo supplying enough power... again you need to check into this and maybe add an external voltage regulator (if all the other issues are resolved). USB 3.0 can provide up to 2x the power per port of 2.0, so when I say almost an amp, it's technically almost two amps (although I think at this point you'll just have to remember not to use the second port and call it one amp).

Technical problems:

I stated this before in the post:

  The stereotypical AVR Arduino is simply too underpowered to host USB 3.0. You need a shield to host USB 2.0, and even with that, I doubt that you can use 2.0 at it's full potential.

The Galileo has native 2.0 support, so I'd recommend just getting a fast USB drive and using that.

Anyway, think about it: the Galileo can handle roughly 400,000 instructions per second. USB 3.0 can send up to 5,000,000 bits in the same amount of time! Like mentioned before, it is the maximums, but still. AFAIK on the AVR boards it it takes multiple instructions to read one GPIO pin (for some reason I want to say 3, but that seems too low). I'd imagine that it'd be the same situation on the Galileo. I'm not quite sure about the instructions it takes to read a pin, correct me if I'm wrong anyone. Anyway, assume it takes four instructions per pin, and your device only sends 1 Gbps. That's still 1,000,000 times that a pin needs to be read when you can only read 100,000 in that time. Even so, you can't even use the data, nor can you implement a loop or other code that combines bytes to read the data in the first place! Plus, you wouldn't have enough RAM!

I'm not a USB expert, but IIRC it only asks the device for data as needed, but still, that'd be pointless to create your code for this and spend the extra money for 3.0 cables and devices. This paragraph is all from memory, I don't really know; don't cite this paragraph.

Also, you'd have to implement your own code for sending data to/from the device. No such code exists without hardware for 2.0, let alone 3.0.

Conclusion:

It's near impossible to do so, and you'd need a lot of extra parts and have to read up on the USB 3.0 specs. I think it would take a great engineer 50+ years to accomplish this without developing an IC (which would cost money). Do you really need the speed? If not, you can buy USB 2.0 host shields and communicate via SPI. That isn't very fast, but still, it's possible.

Sources:

Info and photos are scattered on the following sources:

http://en.wikipedia.org/wiki/USB
http://arduino.cc/en/ArduinoCertified/IntelGalileo
http://www.amazon.com/StarTech-com-Express-SuperSpeed-Adapter-MPEXUSB3S2/dp/B004NO0LK8


typedef function pointer array declaration problem

Try replacing

taskDefinition _tasks [ ] [4] = {

by

taskDefinition _tasks [ ] = {

In short, you have defined _tasks as a 2D array of objects (an array
of arrays of objects) while you intend to use it as a 1D array.

Note that the error message is quite explicit if you take the time to
parse it:

  request for member 'task' in '_tasks[((int)i)]',

You are requesting _tasks[i].task,

  which is of non-class type

but _tasks[i] is not an object.

  type 'taskDefinition [4]'

It is instead an array of four taskDefinition objects.

Edit: Fixing the answer to match the latest version of the question.

Your code works, but not quite as you expect it to work. You wrote:

complexTaskDefinition tasks [ ] [4] = ...;

Here you are defining a 2D array of objects, while your intention was to
define a one-dimensional array (why do I feel like I am repeating
myself?).

complexTaskDefinition tasks [ ] [4] = {
    {taskC1, true, -1, 1000 },
    {taskC2, true, 10, 2000 },
    {taskC3, false, 3, 3000 },
};

This definition, although syntactically correct, is awfully wacky. You
are defining tasks as an array of 3 items. Each item is itself an
array of 4 objects, where the first object of the array is explicitly
initialized, and the three others are implicitly initialized to
all-bits-zero. So basically your definition is equivalent to this
explicit version:

complexTaskDefinition tasks [3] [4] = {
    {{taskC1, true, -1, 1000 }, {nullptr, false, 0, 0},
     {nullptr, false, 0, 0},    {nullptr, false, 0, 0}},
    {{taskC2, true, 10, 2000 }, {nullptr, false, 0, 0},
     {nullptr, false, 0, 0},    {nullptr, false, 0, 0}},
    {{taskC3, false, 3, 3000 }, {nullptr, false, 0, 0},
     {nullptr, false, 0, 0},    {nullptr, false, 0, 0}}
};

Then you wrote:

task = tasks [ i ];

Here, tasks[i] is a row of the 2D array, i.e. a 1D array of 4 objects,
whereas task is a pointer to object. The assignment is legit because
here, like in most contexts, the array “decays” to a pointer to its
first element. The above line is equivalent to the explicit version:

task = &tasks[i][0];

Quite fortunately, this happens to point to one of the elements of the
array that has been explicitly initialized!

As an illustration of the above, here is a modified version of
showComplexTaskList() that loops over all the tasks in the array:

void showComplexTaskList () {
    Serial.println ( F ( "\nComplex Task List:" ) );
    Serial.print(F("number of tasks: "));
    Serial.println(sizeof tasks / sizeof(complexTaskDefinition));
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        for (uint8_t j = 0; j < 4; j++) {
            task = &tasks[i][j];
            Serial.print ( '[' );
            Serial.print ( i );
            Serial.print ( F ("]["));
            Serial.print ( j );
            Serial.print ( F ( "] REPEAT:" ));
            Serial.print ( ( task->repeat ) ? "YES" : "NO" );
            Serial.print ( F ( ", DELAY:" ) );
            Serial.print ( task->delay );
            Serial.print ( F ( ", ITERATIONS:" ) );
            Serial.print ( task->iterations );
            Serial.println ();
        }
    }
}

Its output is:

Complex Task List:
number of tasks: 12
[0][0] REPEAT:YES, DELAY:1000, ITERATIONS:-1
[0][1] REPEAT:NO, DELAY:0, ITERATIONS:0
[0][2] REPEAT:NO, DELAY:0, ITERATIONS:0
[0][3] REPEAT:NO, DELAY:0, ITERATIONS:0
[1][0] REPEAT:YES, DELAY:2000, ITERATIONS:10
[1][1] REPEAT:NO, DELAY:0, ITERATIONS:0
[1][2] REPEAT:NO, DELAY:0, ITERATIONS:0
[1][3] REPEAT:NO, DELAY:0, ITERATIONS:0
[2][0] REPEAT:NO, DELAY:3000, ITERATIONS:3
[2][1] REPEAT:NO, DELAY:0, ITERATIONS:0
[2][2] REPEAT:NO, DELAY:0, ITERATIONS:0
[2][3] REPEAT:NO, DELAY:0, ITERATIONS:0

So your program works almost by chance: an error in the way you define
the array cancels an error in the way you use it. This kind of cancelled
error method is very bad programming practice. You are wasting memory in
unused complexTaskDefinition objects. More importantly, your code
doesn't express your intent, which makes the program way harder to
understand and to debug.

The fix is to declare a 1D array, as this has always been the intention:

complexTaskDefinition tasks [ ] = {
    {taskC1, true, -1, 1000 },
    {taskC2, true, 10, 2000 },
    {taskC3, false, 3, 3000 },
};

Now, you can check that this array does only have three tasks, as
reported by sizeof tasks / sizeof(complexTaskDefinition). To use the
array, you can use a pointer if you want:

task = &tasks[i];
// ...
Serial.print ( ( task->repeat ) ? "YES" : "NO" );

Or you can directly request a member of tasks[i], as in

void showComplexVersion () {
    Serial.println ( F ( "\nComplex Version:" ) );
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        tasks[i].task();
    }
}

Now I have a question for you. Since I already explained your 1D vs. 2D
array mistake in the first iteration of my answer, why did you persist
with this in your edited question? If you are going to blatantly ignore
the answers you get, at least say so in the question. This could save
time to those who might consider helping you.


Arduino serial plotter with independent Y axis, is it possible?

No. The Arduino Serial Plotter only supports one Y axis.

An alternative would be to capture the data into a file as CSV data and use some other software to plot it - you could import the data into Excel / LibreOffice, or (as I prefer for quick graphing) use something like GnuPlot (or whatever is similar for your chosen OS).

For instance, this is a GnuPlot configuration for plotting two independent axis datasets and the results:

set datafile separator ","
set terminal png enhanced size 1360,768
set output 'testCharge.png'
set ytics nomirror
set ylabel "Current (A)"
set y2label "Voltage (V)"
set y2tics nomirror
plot "testCharge.csv" using 3 smooth bezier title "Current" w l, \
     "testCharge.csv" using 4 title "Cutoff" w l dashtype 2, \
     "testCharge.csv" using 2 smooth bezier title "Voltage" w l axes x1y2

The data I use is formatted thus:

Phase,Voltage,Current,Cutoff
0,3.58,1.098,0.033
0,3.59,1.098,0.033
0,3.59,1.098,0.033
0,3.59,1.098,0.033
0,3.6,1.098,0.033
0,3.6,1.098,0.033
0,3.6,1.098,0.033
0,3.61,1.098,0.033
0,3.61,1.098,0.033
... etc ...

And the results:

Incidentally, that's me charging a Li-Ion battery and monitoring the voltage and current.


Kind of yes and kind of no.

It requires external circuitry, but that circuitry isn't a "driver board" in the traditional sense.

An e-Ink display requires high voltages to charge the electrostatic cells. Traditionally that would be provided using an external "driver" circuit - a boost voltage converter.

However this display has that boost converter built in - though it doesn't have all the components, because they just won't fit.

You need to provide the diodes, switching MOSFET, and inductor, etc as shown on page 18 of the datasheet.  Nothing less will do.


If you want to use the Console monitor and the GSM at the same time, you need to use different pins to separate the communication streams.

Typically the console serial monitor is attached to Serial.*, while GSM modules are attached using SoftwareSerial to other pins.  See https://arduino.stackexchange.com/a/1195/6628 for an example.


Is it possible to connect 2 ultra sonic sensors to 1 arduino?

Yes, you can, as long as you serialize the send/receive pulse cycles, to avoid interferences.
basically, you attach the Trig/Echo lines to a different pair of pins, then do the reading on one sensor, then do the reading on the other.


Calculating the time between the signal when its ON and when it gets OFF

I suspect secs is 0 sometimes, because of _rise being 0? In that case unsigned int subtraction causes this: secs(0) - 4 = -4 % 2^32, resulting in your 4294967292


Run HEX program from SD with another program

Not with an Uno, no, it's not possible. Or it's very very hard and the results would be less than desirable. You need a proper MCU with lots of RAM and the ability to run code from it, which you can't with an Uno.
It would be less work to write your own scripting language to control things from a text file.


Connecting (SD or HD) TV screen to Arduino

I'm just going to post things that I found thanks to comment by Juraj.

"TV Text" library - PAL, SECAM, NTSC
"VGAX" library - VGA

And with large dedication to everyone who wrote that "it's impossible" I give you a blog post of someone who actually did create he's own NTSC console and a game from scratch (called "The Box") using ATmega328P with external 16Mhz crystal. And he did it in 2013.

http://petenpaja.blogspot.com/2013/11/toorums-quest-ii-retro-video-game.html

Original sources were deleted, but I think they can be found when looking for Toorum Quest 2

I think I'll try analyzing the VGAX. It looks promising.

EDIT:

There actually is HDMI shield for Arduino!

https://github.com/techtoys/HDMI-Shield/tree/master/Ra8876_Lite

And a nice and very easy VGA tutorial here:

http://www.pyroelectro.com/tutorials/arduino_basic_vga/


if/else statements without comparison operators and curly braces

About the missing conditions, e.g.:

if (pressed[i])

If is supposed to be a boolean, this is the prefered way, as long as the boolean has value zero (0) when false and nonzero when true. It is the same as writing:

if (pressed[i] != 0)

It is not usual to do this for integers, only for booleans.

About the brackets: If you have only one statement the brackets can be omitted. But it is quite a bad programming practice, since sooner or later you add a statement, without the brackets added and you have a bug introduced.

If you really want to shorten it than instead of

if (justpressed[i])
  digitalWrite(led, HIGH);
else
  digitalWrite(led, LOW);

use

digitalWrite(justpressed[i] ? HIGH : LOW);

This is called the Ternary operator.

update

Using the remark of wondra but with the ternary operation your code can be

for (int i = 0; i < 15; i++)
{
    lcd.setCursor(i, 1);
    lcd.print   (     pressed    [i] ? "X"  : " ");
    digitalWrite(led, justpressed[i] ? HIGH : LOW);
}


Sim800L's library can not compile on Arduino Due

First we must delete the SoftwareSerial and SIM800L libraries, then define Sim800l and assign it to Serial 3 on pins 14 and 15. In setup, call Sim800l.begin() and the rest of the code is unchanged.

#define SIM800l Serial3

void setup () {
  Serial.begin (9600);
  SIM800l.begin (9600);
  while(!Serial);
  SIM800l.write ("AT+CMGF=1\r\n");
  delay (1000);
  SIM800l.write("AT+CMGS=\"5432154552"\"\r\n");
  delay(1000);
  Serial.println("send SMS");
  SIM800l.write ("test send SMS");
  delay (1000);
  SIM800l.write ((char)26);
  delay(1000);
}

void loop (){}


Arduino DUE deadlock problem, watchdog not working

Found people suffering with the same problem on Arduino's official forum. It turned out that the problem arises from the schematic of Arduino Due, that fails to hold 'reset' pin high for long enough period of time on power-on.

There are multiple solutions involving adding some capacitance between reset pin and ground pin, but this might damage circuit in long run (at power-off), so I managed to find other way around it: there is an ATmega16U2 used as USE-to-TLL serial chip that have access to reset pin of AT91SAM3X8E.

The ATmega16u2 can be reprogrammed so that on power-on it provide short "HIGH" period to AT91SAM3X8E reset pin. The program for ATmega16U2 can be found here:
https://forum.arduino.cc/index.php?action=dlattach;topic=167492.0;attach=52901

The updating precision is given here:
https://www.arduino.cc/en/Hacking/Upgrading16U2Due

I've performed the given precision using Arduino UNO as programmer and can confirm that it worked properly.The problem's gone now.


The Arduino IDE can’t find my Arduino Uno

It can have many reasons, but you can try the following:

First time use?

Check if you need to install a special driver for CH340

Environment/Software problems

Try another USB port
Change USB cable
Restart Arduino IDE
Restart computer
Reinstall Arduino IDE

Hardware problems

Test using another Arduino
Test using another computer/laptop
Replace USB cable
The Arduino is (partly) broken, nothing much to do here


I made a binding IP and MAC and now I see my ESP)


How to alter joystick values with Arduino Uno?

if (voltageX >= 4.55) {
  voltageX == 2.5;
  successPin==HIGH;

The last two lines (and all similar ones later) are wrong. == is for comparing, = is for assigning. So change it to:

if (voltageX >= 4.55) {
  voltageX = 2.5;
  successPin = HIGH;

You did that in a lot of places, so fix that up and get back to us.

const int successPin = 13;
...
  successPin = HIGH;

Assuming you fix the compare to an assign you will get an error message here. You define successPin as 13, and then try to change it to 1 (which is what HIGH is defined as). Do you mean, to write to that pin? Like this?

digitalWrite (successPin, HIGH);

You will need to change all those as well. And if you are hoping to see an LED on the pin flash, 1 ms is quite a small interval.


Concern myself with current draw from digital pins used as INPUT with internal pullups?

You are right. The current through digital inputs is so low, that you can normally ignore it.

And the 0.5mA, that you calculated don't flow all the time, just, when the corresponding button is pressed and thus shorted to ground, because only then a current will flow through the pullup resistor. The current into the actual input hardware is even smaller. So, as long as not all buttons are pressed at once, the current will be even lower as calculated.

Buttons are somewhat voltage devices. They don't need a specific amount of current, just of voltage. So the actual value of pullup/pulldown resistors are not critical. LEDs in contrast are current devices. They need a specific current to light up, which is often higher, than the maximum output current of a digital pin. Thus they are often driven with an additional transistor.


Measuring the peak-to-peak current and scaling the result will get you an answer which will at least go up and down with the magnitude of your average AC current, so yes it is NOT incorrect.  As you suggested it will be sensitive to noise from the sensor - in fact as you are taking the highest and lowest single readings the noise will always cause the measurement to be higher than actual.

However, I think you could do better.  Given that the code is already having to take many samples (basically as fast as it can) for 100mS (which will sample 5 cycles of the waveform if it is 50Hz and 6 if it is 60Hz, depending on where you are in the world), then you could actually do the maths to measure the RMS value and by basing this on all of the signal the effect of the noise will be reduced.

You need to know the ADC reading when there is no current rZero (which should be around 511 but could be off a bit due to offset errors) - you could measure this with nothing connected to calibrate the sensor, or take a long term average even with the AC signal present.

As the henrysbench tutorial points out it is important that the Arduino samples the signal at a high enough frequency (say 1000Hz - hence 100 samples for your 100mS sample duration)- the count of the number of times that the while loop executes sampleCount will confirm if this still the case even with the extra computation time of this code.

Also if you increase the sample time please be careful that the unsigned long rSquaredSum can't overflow, but I would avoid use of doubles within the while loop as they will definitely slow it down a LOT.

void ac_read() {
  int rVal = 0;
  int sampleDuration = 100;       // 100ms
  int sampleCount = 0;
  unsigned long rSquaredSum = 0;
  int rZero = 511;                // For illustrative purposes only - should be measured to calibrate sensor.

  uint32_t startTime = millis();  // take samples for 100ms
  while((millis()-startTime) < sampleDuration)
  {
    rVal = analogRead(A0) - rZero;
    rSquaredSum += rVal * rVal;
    sampleCount++;
  }

  double voltRMS = 5.0 * sqrt(rSquaredSum / sampleCount) / 1024.0;

  // x 1000 to convert volts to millivolts
  // divide by the number of millivolts per amp to determine amps measured
  // the 20A module 100 mv/A (so in this case ampsRMS = 10 * voltRMS
  double ampsRMS = voltRMS * 10.0;
  Serial.println(ampsRMS);
}


As mentioned, the problem is the gamepad you have uses communicates over USB, which requires a USB Host chip to communicate with. However, USB Host shields can be found on eBay (under "arduino USB Host shield") from US$10, and they come with a USB socket, so you could use it easily with another gamepad that hadn't had the connector snipped. This also would allow use with HID devices such as mice and keyboards if you wished, so a worthwhile shield to own.


Current mouse pointer position with Digispark attiny85

There is no way for a mouse of any kind (especially not one as minimal as DigiMouse.h) to know the current cursor position - USB just doesn't provide that kind of facility.

Instead you need to implement an "absolute" mouse (aka a "tablet").  However DigiMouse doesn't implement such a facility. So you would have to implement your own tablet driver.

A normal mouse sends a "delta" for the position. That is, a difference in position from whatever the current position is.  An absolute mouse, or tablet, sends the position on the screen as a proportion of some maximum set of dimensions.  Ideally that would be the same dimensions as your screen, but doesn't have to be.

The main differences between DigiMouse and whatever you would implement for a DigiTablet would be the "HID Report Descriptor". This defines what the data that is sent means and how the computer should interpret it.


How to repair or work around a damaged usb port on the Arduino?

You would need to replace the whole socket in order to repair it. For that you would need:

Soldering iron
Solder sucker
Solder wick
Patience and experience

Or you just connect an FT232 breakout board to TX, RX and RESET as if you were making a breadboard arduino and program the board through that.


How to update a variable in an ISR using Timers

In CTC mode the top is OCR3A, not OCR3B!

After that TIMSK3 |= (1 << OCIE3B); should also be changed to TIMSK3 |= (1 << OCIE3A);, and ISR(TIMER3_COMPB_vect) to ISR(TIMER3_COMPA_vect)

For 3Hz, OCR3A should be 5208, not 20.

Technically TCCR3B |= (1 << WGM12); should be TCCR3B |= (1 << WGM32);


After countless Trial/error attempts, I was able to put together the proper sequence.

AT+CIPSEND=0,40  \\Set this for your current connection ID and payload length.
HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n
AT+CIPCLOSE=0  \\Set this for your current connection ID

Send these commands with the arduino, and it should exit successfully.  You can also flush out the HTTP line with any other information you would like to include, as defined in the rfc2616 (HTTP/1.1) standard


Upload a .hex file, using a standalone ISP, without overwriting bootloader

To preserve the bootloader, you should use the -D option in the ISP command line just as it was used in the bootloader upload command line. This will disable usage of full-chip erase.

I expect you would end up with something like

avrdude -c avrisp2 -p atmega328p -D -U flash:w:_build/image.hex

However, it is important to add something which I overlooked when first posting this answer, which is that the ATmega series cannot do a partial flash erase via the ISP interface in the way that it can when the bootloader causes the chip to program itself.  This effectively means that you only get one shot at loading a program to an already blank area of the chip this way - after that, to load a different one to the same area you will have to do a mass erase of the entire chip and reload both the bootloader and the sketch, or else command the bootloader to erase the blocks where the sketch would reside.

Of course you will also need a hex file for your sketch with no contents that conflict with the bootloader, as while the bootloader would refuse to overwrite any of its own blocks when programming a sketch, the ISP is perfectly happy to try to write over the top of the bootloader, which would likely result in a logical AND of the bits of two different pieces of code, and cause the chip to boot to nonsense.  A typical Arduino board configuration reserves space for the expected bootloader, so if the one you are using matches the size reserved in the chosen configuration, you should not have a conflict.

Another option could be to combine the bootloader and sketch hex files, literally concatenating their contents one after the other into the same file.


SPI Arduino Due conflict with pinMode(), bug?

It might have something to do with the internal pull up resistor. According to the SAM3X/A datasheet,

Control of the pull-up resistor is possible regardless of the
configuration of the I/O line.
After reset, all of the pull-ups are enabled.

If you dig through all the include files you find:
../Arduino/hardware/arduino/samd/cores/arduino/wiring_digtal.c

Line 124 defines the pinMode(uint32_t ulPin, uint32_t ulMode) function. Examining the switch/case statement for INPUT vs INPUT_PULLUP vs OUTPUT you see the following:

INPUT sets a register to reg = PORT_PINCFG_INEN.
INPUT_PULLUP sets a register to  reg = (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)
OUTPUT sets a register to reg &= ~PORT_PINCFG_INEN.

The 'register' in each case is the same. I cannot for the life of me find what value PORT_PINCFG_INEN or PORT_PINCFG_PULLEN are defined as, but they're no doubt just 8-bit masks (they're cast to uint8_t when they're assigned to the 'register'). Thus, we can assume that whichever bit controls input/output is active when asserted, as is the pullup bit. For example:
 PORT_PINCFG_INEN   = b'00000001';
 PORT_PINCFG_PULLEN = b'00000010';
~PORT_PINCFG_INEN   = b'11111110';

If pull-ups are enabled after reset, we can say that on reset:
 reg = b'xxxxxx1x';

Point (3) above strongly implies that the instruction is:
 reg = b'xxxxxx1x' & 'b11111110';
   so
 reg = b'xxxxxx10'; // pull-up is enabled!

Therefore, if you call pinMode(X, OUTPUT) before anything else you will end up with the pullup resistor enabled. Setting the pin to an input will clear the pullup enable bit, after which you can set the pin to an output and the bit will remain clear.
However, the whole arguement falls down with the simple fact that if you don't call pinMode() at all, the problem doesn't occur...


I2C to UART bridge as breakout or in DIP package

Perhaps what you're looking for:

http://sandboxelectronics.com/?product=sc16is750-i2cspi-to-uart-bridge-module

From that page:

  SC16IS750 I2C/SPI to UART Bridge Module

  This module is designed to enable I2C/SPI to UART conversion. It works in I2C/SPI slave mode and interfaces with devices working in I2C/SPI master mode. There are also 4 extra GPIOs for IO expansion. NXP SC16IS750 is used as the key component on this module. Flow control and modem signals are also supported.

  This module is useful when extra UART interface is needed. Due to the multi-slave characteristics of I2C and SPI, many UART interfaces could be added to the system at the same time.


motor shield directly to PC? WITHOUT ARDUINO!

To a normal PC? No. You can't. A PC doesn't have the GPIO pins etc that are needed.

You could wire it to a Pi though.


Arduino and reading from multiple USB connections

The FTDI should be showing up as /dev/ttyUSB0 on the Pi.

If you connect an Arduino as well it will show up as /dev/ttyACM0.

If you don't have enough USB sockets then just add a USB hub.


How to program Arduino LCD shield with Python?

It's like @chrisl wrote in the comments. You cannot program Arduino with python.

You can however upload an open source Firmata protocol implementation onto the Arduino and then write python code on your PC that will send commands to the Arduino by USB cable to tell it what to do.

This way you actually execute your code on PC, but control Arduino pins. Only drawback is that you need to have a PC connected to the Arduino at all times. This is not very practical.

There is a really nice tutorial here

Example python code looks like this:

import pyfirmata
import time

board = pyfirmata.Arduino('/dev/ttyACM0')
while True:
    board.digital[13].write(1)
    time.sleep(1)
    board.digital[13].write(0)
    time.sleep(1)

I'm afraid that only solution to controlling LCD shield this way without writing any C is to write the entire LCD library in python basing on pyfirmata calls to control the Arduino pins. It's not as hard as it sounds, and even a beginner could easily succeed.


It gives some glitching on 7 segment display

These can all be byte instead of int to save on memory:

int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8};
int num_array[11][7] = {
  { 1, 1, 1, 1, 1, 0, 1 }, // 0
  { 0, 1, 1, 0, 0, 0, 0 }, // 1
  { 1, 1, 0, 1, 1, 1, 0 }, // 2
  { 1, 1, 1, 1, 0, 1, 0 }, // 3
  { 0, 1, 1, 0, 0, 1, 1 }, // 4
  { 1, 0, 1, 1, 0, 1, 1 }, // 5
  { 1, 0, 1, 1, 1, 1, 1 }, // 6
  { 1, 1, 1, 0, 0, 0, 0 }, // 7
  { 1, 1, 1, 1, 1, 1, 1 }, // 8
  { 1, 1, 1, 0, 0, 1, 1 }, // 9
  { 0, 0, 0, 0, 0, 0, 0 }  //nothing
};

int pin = 2;
int button = 12;
int buttonVal;
int randVal;

In addition, the array can be reduced to 11 bytes:

0bFD, // 0
0bC0, // 1
0bDE, // 2
etc.

Then your functions can do direct port manipulation to send bits 0-5 to the Port for D2 to D7, and bit to D8.

As written, these functions probably need some hold time so they don't just flash the LED and disappear:

void one()
{
  for(int i = 0; i < 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);
  }
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin, num_array[1][j]);
    pin++;
  }
}


The HC-05 modules use bluetooth 2.0. Certain apps would only be compatible with bluetooth 4.0 devices (BLE - Bluetooth Low Energy), such as an HM10 or AT09.

It could be that your app requires the device to use v4.0+. Are you able to find, and pair with the device using your android's default bluetooth device scanning/pairing features?

Assuming that your app does not require v4.0+, have you removed the connection from 'en'/'ch_pd' to 3.3v? If that was still connected (which is a required connection to enter AT command mode), then your bt module would not be able to accept incoming pair requests etc.

hope this has helped. :)


How to send an email via Arduino without an email account?

You may be able to do this by running the SMTP transaction yourself. You don't actually need a valid from address (though I probably shouldn't be saying that). There are a number of resouces for how to do this, here's a quick list:

Arduino Playground Email Client page
Adafruit
How to send an email with Arduino and a WiFi shield?

If you read an article telling you how to do SMTP in a generic sense (not using a particular provider's infrastructure) and it looks like they want a "real" e-mail address, you can try with a fake one. Chances are decent that it may work.

There are some fine points that may cause you grief if you go for the most simple of implementation (for example, just because my e-mail address is foo@bar.org doesn't mean that bar.org will accept an SMTP connection, the "right" way to do it is to check DNS for an MX record for bar.org).

It would be best to do (and log) any errors that you encounter. There are plenty of things that can go wrong, so tracking where it blows up will help you – or anybody who's trying to help you debug.

If you don't want to roll your own SMTPClient and FullIP look worth checking out.


What is the rise time of an output pin of atmega328 changing its state?

Last time I measured on a circuit (it was an i2c network master and with a 2560), it was about 0.3us, so that gives you a high value for that. Also, I believe it cannot be faster than one/half of a CPU cycle which takes: 1/(16E6)=62.5ns/2 = 31.25ns, so here's the lower boundary.

And there you got a possible range.

Then the rise time will definitely depend on the configuration of the circuit. It might be less or more depending on pull ups, capacitance attached at the pin out exit. It might also depend on the configuration of the pin (PWM? Internal Pull-up?…)

Finally, I believe there should some nominal values given in the datasheet.

Edit: Useful knowledge from the datasheet, but there's no definitive answer for any pin:

P311: 29.4.3 External Clock Drive

| Symbol | Parameter | Min | Max   | Min | Max   | Min | Max   |
| ------ | --------- | --- | ----- | --- | ---   | --- | ----- |
| tCLCH  | Rise Time |     | 2.0µs |     | 1.6µs |     | 0.5µs |

P313: 29.6 SPI Timing Characteristics

| Description    | Mode      | Min | Typ   | Max    |
| -------------- | --------- | --- | ----- | ------ |
| Rise/Fall time | Master    |     | 3.6ns |        |
| Rise/Fall time | Slave     |     |       | 1600ns |

P315: 29.7 Two-wire Serial Interface Characteristics

| Symbol | Parameter                      | Condition | Min        | Max   |
| ------ | ------------------------------ | --------- | ---------- | ----- |
| tr     | Rise Time for both SDA and SCL |           | 20 + 0.1Cb | 300ns |

HTH


I fried the AMS1117 voltage regulator on my Arduino Clone, is this the cause?

The "problem" with the AMS1117 voltage regulator is the amount of current they can safely provide drops as the input voltage rises. I'm a Arduino noob, so I looked at the data sheet for the AMS1117 series of voltage regulators. There is a formula: PD=(VIN-VOUT)(IOUT) and Note 2: which says the maximum power dissipation for the SOT-223 package is 1.2 W.

The best case scenario is to use an input voltage of 6.5 volts. (6.5-5)(0.8)=1.2W. This gives you 0.8 amps maximum output. If you use a 12 volt power supply: (12-5)(0.1714)=1.2W. This only gives you 0.1714 amps maximum output.

I'm not sure what kind of power jack you are using, so I'll give you an example of one that I used in a project. It says input 120VAC, output 12VDC, 200ma. The problem is, it actually puts out 20VDC open circuit with no load.

The data sheet gives a maximum input voltage of 15 volts but that would only provide a maximum of 120 mA output.


Where can I find the source codes for the various classes and methods used in Arduino Primo?

The Arduino Primo is supported by Arduino nRF52 boards package. The boards packages can contain libraries special for boards handled by the package. The BLE library for Arduino Primo is included in the board package.

The location of boards packages on Windows is in hidden folder AppData in user's home directory. On my Windows computer it is

C:\Users\andrassy\AppData\Local\Arduino15\packages\arduino\hardware\nrf52\1.0.2\libraries\BLE

On Linux the 'Arduino 1.5' folder is .arduino15 in users home folder.


String generator not working as expected

Your first mistake is to use String. Don't. Instead use a char array.

char mystr[18]; // Room for 17 characters plus the NULL terminating character

Your string constants should also be char arrays, not String variables. And better to put them in PROGMEM:

const char characters[] PROGMEM = "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz";
const char numbers[] PROGMEM = "0123456789";
const char other[] PROGMEM = "<>!.,()?|=&%¤#";

Now filling your target array becomes:

for(int i=0 ; i < 12 ; i++){
  mystr[i] = pgm_read_byte_near(characters + random(0, 50));
}

mystr[12] = pgm_read_byte_near(numbers + random(0, 10));
mystr[13] = pgm_read_byte_near(numbers + random(0, 10));
mystr[14] = pgm_read_byte_near(other + random(0, 14));
mystr[15] = pgm_read_byte_near(characters + random(0, 50));
mystr[16] = pgm_read_byte_near(characters + random(0, 50));
mystr[17] = 0; // Don't forget the NULL...

Your second problem is the use of EEPROM.writeInt and EEPROM.readInt.  Those are for writing integer values, not characters.  Instead just use EEPROM.read and EEPROM.write:

for (int i = 0; i < 17; i++) {
    EEPROM.write(i, mystr[i]);
}

Then to read back:

for (int i = 0; i < 17; i++) {
    mystr[i] = EEPROM.read(i);
}
// And don't forget to terminate the string...
mystr[17] = 0;


How can I use separate power source for the Arduino and the motors

That motor driver has an optional on-board 5V regulator. It can be enabled / disabled with a jumper.
With that regulator enabled you just need to connect a ground and your control signals (ENA/IN1/IN2 or ENB/IN3/IN4).
If you disable that regulator (remove the jumper) then you need to provide power from the Arduino's 5V pin to the +5V screw terminal.
The ENx pin(s) (after removing any jumpers that may be on them) connect to any PWM capable pin (this is the speed control pin). IN1/IN2 or IN3/IN4 connect to any IO pin since these are just used to set the direction or control the braking modes.  ENA controls the speed of motor 1, and IN1/IN2 control the direction of motor 1. ENB and IN3/IN4 are likewise for motor 2.


Add a watermark to text message in an Arduino

"Robustness", in the context of digital watermarking, specifies the ability to detect the watermark after some signal processing modification (for images, this might be translation, rotation, scaling, compression, etc.) Some digital watermarking techniques are robust against some operations but not against others. The classifications are:

Robust: The watermark should be able to survive against any and all
modification. This is often used in copyright protection, for
example.
Fragile: This kind of watermark is designed to be destroyed by any
modification to the original. This allows any manipulation, even
slight changes, to be detected. Fragile watermarks are generally used
to enable authentication and integrity verification.
Semi-fragile: The watermark should be "robust" against certain,
defined, modifications, but "fragile" against others. In other words,
the watermark should survive intact under the operations you want to
allow, but be destroyed by anything else. Again, these are used to
enable authentication.

For more information, you might find the 2005 paper A Review Study on Digital Watermarking by L. Jian and H. Xiangjian (in the journal Information and Communication Technologies) useful.


What do the charactors " '/2' " mean in the variable declaration?

The '\2' and '\3' are characters with octal code 2 and 3. Which is nothing more then 2 and 3 in octal and in decimal. The author could simply write const byte STX = 2; const byte ETX = 3;.

Characters with ASCII code 2 and 3 are control characters STX (start of text) and ETX (end of text). Control characters are invisible characters used to control the terminal or as mark characters in communication.


ATTiny85 and DHT11 - Sensor always returning 0

Ok i tried something like that for myself and thanks to this and ..many other posts and forums/videos i could make myself something that works but with a little other setting like in the start post (other libs ect)

in my case the main reason for the "1" output on the oled was this:

  float hu  = (DHT.humidity, 1);    //original

  hu  = (DHT.humidity);       //what worked for me

Maybe you can figure out more Problems, my code is shure not perfekt! But maybe it helps someone for a vew steps

#include <dht.h>
#include <U8x8lib.h>
#define DHT11_PIN 1
dht DHT;
int temp = 0;
int humi = 0;
char strTemp[4];
char strHumi[4];

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE);         // Digispark ATTiny85 Pin 0 Data, Pin 2 clock

void setup(void)
{

  u8x8.begin();
  u8x8.setPowerSave(0); //enegergiesparen 0 aus

}

void loop(void)
{

  int chk = DHT.read11(DHT11_PIN);

  temp = (DHT.temperature);
  humi = (DHT.humidity);

  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.drawString(0,0,"~~~~~~~~~~~~~~~~");
  u8x8.drawString(0,1,"Temperatur");
  u8x8.drawString(1,2,( itoa(int(temp), strTemp, 10)));
  u8x8.drawString(4,2,"Grad Celsius");
  u8x8.drawString(1,3,"--------------");
  u8x8.drawString(0,4,"Luftfeuchtigkeit");
  u8x8.drawString(1,5,( itoa(int(humi), strHumi, 10)));
  u8x8.drawString(4,5,"Prozent");
  u8x8.drawString(0,6,"~~~~~~~~~~~~~~~~");
  delay(200);
}


Compute SHA256 of string and output to string

I suggest the following function. That replaces a string by its hash.
It's done in place in order to save memory. Make sure the buffer you
give it is at least 65 bytes long. Warning: not tested.

#include <Crypto.h>
#include <SHA256.h>

#define HASH_SIZE 32

SHA256 sha256;

/*
 * Replace a string by its hash, in place.
 * `data' should point to a buffer at least 65 bytes in length.
 */
hash_in_place(char *data)
{
    uint8_t value[HASH_SIZE];

    sha256.reset();
    sha256.update(data, strlen(data));
    sha256.finalize(value, sizeof(value));

    // Convert to hex into the original buffer.
    data[0] = '\0';
    for (size_t i = 0; i < HASH_SIZE; i++) {
        data += sprintf("%02x", value[i]);
    }
}


Looking at the pin configuration, the SPI pins are not in the same location as the UNO. Remove the Shield from Due and use cables to connect to the SPI pins


Coding Arduino's samples/period and cycles/sample configurations for input signal

The limitation is in the ADC which by default takes 104 µs to make a sample. Now you can speed up the ADC, sacrificing accuracy, but even then you can probably practically only reach a sampling time of 13 µs. Plus you would have the issue of where to put these 400,000 samples in the 2KB of RAM you have.

To sample at 400,000 times a second you would need to sample every 2.5 µs, which you can see is way shorter than 13 µs.

Plus, you not only need space to put these 400,000 samples, but it would take time to store them.

For more information see my page about the ADC which has a lot of details about sampling times, frequencies, accuracy, etc.


const int p1=7;//pwm pin for motor 1

const int p2=8; //pwm pin for motor 2

PWM pins on a '168 are 3,5,6,9,10,11


How do I receive more that 64 bytes with Arduino

Instead of blocking the loop for 500 ms, you should be actively
reading the data as it comes. Otherwise the internal buffer of the
Serial object will overflow after only 64 bytes are received.

Here is an example that copies the incoming bytes into a larger buffer
(256 bytes) and, upon receiving an end-of-line character, echoes
back the whole line.

void loop() {
    static char buffer[256];
    static size_t pos;              // position of next write

    while (Serial.available() && pos < sizeof buffer - 1) {

        // Read incoming byte.
        char c = Serial.read();
        buffer[pos++] = c;

        // Echo received message.
        if (c == '\n') {            // \n means "end of message"
            buffer[pos] = '\0';     // terminate the buffer
            Serial.print(buffer);   // send echo
            pos = 0;                // reset to start of buffer
        }
    }
}


In the parameter list of the #define for the macro, separate the second argument from the first with only a comma.  For example:

#define wrEE(speed,var) writeToEE((etc))

The "void value not ignored as it ought to be" error message is a consequence of trying to store the void result of writeToEE.  The solution is to not try to store it.

In C, variable, parameter, and constant names are case-sensitive.


Code example SPI multiple slaves Arduino DUE

Everything you need is given here - you just need to know how to put it together:

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

There are variants of all the major methods that take an extra parameter - that parameter is the first parameter in the parameter list and defines the SS Pin to use for that function.  That includes the .transfer() function.

To use it you have to begin() all the pins you want to use SPI with. Then you can use .transfer() with those pins:

void setup() {
    SPI.begin(10);
    SPI.begin(4);
}

void loop() {
    // Receive using pin 10 as SS
    byte byteFromTen = SPI.transfer(10, 0x00);
    // Transmit 123 using pin 10 as SS
    SPI.transfer(10, 123);
    // Both directions:
    byte otherByteFromTen = SPI.transfer(10, 123);

    // Receive using pin 4 as SS
    byte byteFromFour = SPI.transfer(4, 0x00);
    // Transmit 123 using pin 4 as SS
    SPI.transfer(4, 123);
    // Both directions:
    byte otherByteFromTen = SPI.transfer(4, 123);
}

Doing multi-byte transfers is slightly more complex since you don't have control over the SS pin, so you have to use yet another version of the transfer() function that tells it to "continue" the transaction:

// Receiving 3 bytes using pin 4:
byte firstByte = SPI.transfer(4, 0x00, SPI_CONTINUE);
byte secondByte = SPI.transfer(4, 0x00, SPI_CONTINUE);
byte thirdByte = SPI.transfer(4, 0x00);

Of course, mixing reading and writing is pretty much the same as usual. For instance, to read the port A values from an MCP23S17 would look like:

SPI.transfer(4, 0x41, SPI_CONTINUE); // Address 0, read bit set
SPI.transfer(4, 0x12, SPI_CONTINUE); // Select register 0x12 (GPIOA)
byte porta = SPI.transfer(4, 0x00);

The SPI_CONTINUE tells the SPI system to keep the SS pin LOW. It is only then raised once it gets a .transfer() without the SPI_CONTINUE. This is the same as the traditional way of using digitalWrite() to lower SS before the first transfer and raise it after the last transfer.


Increasing range of a DC-offset signal (software)

You can't magic more resolution out of thin air (well, you can, but it slows down your sampling - you would "oversample" and average a number of sequential samples).

Instead you need to boost your signal before it gets to the ADC using an op-amp.  The simplest circuit (which also inverts the signal, but you don't really care about that I suspect) is:

simulate this circuit – Schematic created using CircuitLab

That circuit will both invert the signal (if you care, just do a little bit of maths in your program to flip the signal, but for FFT you don't really care) and double the amplitude around the mid-point. The doubling is controlled by the ratio of R1 to R2 (20000:10000 = 2:1 = doubled). The mid-point offset is created by R3/R4 - you don't need to manually add your own offset.


Couldn't connect to local server using Ethernet Shield and Arduino Mega 2560

I had this problem for quite a long time and then I did a little bit of research!
Here it is in an easy explanation-

When you connect your Ethernet Shield to the Laptop the laptop takes the Ethernet Shield as a source of internet and tries to get an IP Address and other network stuff FROM the shield! BUT what we want is the other way round.

We want the Ethernet shield to take the laptop as a source of internet and get itself an IP assigned by the laptop!

What I do is I make a Laptop-Ethernet Shield network and a Laptop-WiFi network.(Simply means that I connect my laptop to WiFi and Ethernet shield)

Then I JOIN the two networks!

This joining of networks is called network bridging and is done easily, I'll tell you how-

If you're using linux then follow this link here.

else if you're running windows-

1) Connect your Ethernet Shield (With Arduino attached obviously) to the laptop and make sure that your laptop is connected to the WiFi.

2) Go to Network and Sharing Center.

3) Go to Change adapter settings.

4) Select your Wifi adapter and the Ethernet adapter together.

5) Right click on any of the selected adapter and click Bridge connections.

6) Wait till a new network bridge is connected and is done verifying after it's creation.

7) Upload the sketch again on Arduino and you'd be connected.

NOTE

DHCP may not always work as it's a feature of your router/WiFi and not your laptop so try assigning a mannual IP by calling Ethernet.begin(mac,ip) instead of using DHCP by caling Ethernet.begin(mc);

AND do change your ip to 192.168.1.XXX I mean change the last tuple so it does not clash with the ip of any other device.(XXX any number less than 255, generally 100-200)

Do let me know the outcome after trying this out! :D


ESP8266 - One server sending data to multiple clients

Your server doesn't handle clients. It is only a listening TCP socket. You must handle incoming TCP connections by checking if the server has a client available.

This is from ChatServer example. A telnet server to connect to with telnet terminal.

void loop() {
  // wait for a new client:
  WiFiClient client = server.available();

  // when the client sends the first byte, say hello:
  if (client) {
    if (client.connected()) {
      if (!alreadyConnected) {
        Serial.println("We have a new client");
        client.println("Hello, client!");
        alreadyConnected = true;
      }

      if (client.available() > 0) {
        // read the byte incoming from the client:
        char c = client.read();
        // echo the byte back to the client:
        client.write(c);
        // echo the byte to the server as well:
        Serial.write(c);
      }
    } else {
      alreadyConnected = false;
      client.disconnect();
    }
  }
}


Correlated signal from two sensors in one circuit

If I've found the same humidity sensor, it has pretty big output impedance and the maximum input impedance for the ADC input is 10kOhms. According the the datasheet the recommended minimum load for the sensor is about 80kOhms (?). That means readings of humidity sensor will be highly affected by sampling capacitor initial charge (= the value of previous reading).

Basically reading GND between sensor readings helps to separate the results from each other, but the humidity sensor won't be able to charge sampling capacitor to its output voltage without amplifying the current (you'll get values much lower than it should be).

Or you can repeat the readings on humidity sensor channel several times until the value is more "stable".


How to push two values to the same key from Arduino to Firebase

@hcheung thanks for your help! It solved the problem. This is my code now:
StaticJsonBuffer<256> jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
array.add(timeStampObject);
array.add(temp1);
Firebase.push("Sensors", array);


Using strings inside mBlock extensions code

If that is a JSON format you could try using single quotes instead of double quotes:

"work":'Serial.print("Hello world");'

Alternatively you could escape the internal quotes:

"work":"Serial.print(\"Hello world\");"


DMX on the Arduino without additional driver chip

The physical layer of a DMX interface is based on differential signaling over an RS485 link.  This is exactly what is said here on the DMX Arduino.cc page.

A differential signal (like RS485 or USB) can travel greater distances than signals which reference ground (like RS232, I2C or SPI).  This is because noise, which affect both sides of a differential signal, can be canceled out at the far end when one of the signals is inverted then added to the other by the differential receiver.

Connecting one side of a differential receiver to ground and driving the other side with logic level voltage is not recommended.  Even if it worked and did not cause harm to the transmitting processor nor the differential receiver the signal will likely be susceptible to undesirable noise.

RS485 is a ubiquitous standard and likely several easily sourced designs exist for the Arduino.


Cannot connect to mBot after using Arduino IDE

I received some really good piece of advice on the official forum and it solved my problem, it now works:

  When you go back to using the mBlock (Scratch) environment you will
  need to reload the firmware (Upgrade firmware from the Connect menu
  item). At least that’s what I’ve had to do. Oh, and make sure that you
  have shut down the Arduino environment to release the serial port.


Getting a truly random number in Arduino

The Entropy library uses:

  the watchdog timer's natural jitter to produce a reliable stream of true random numbers

I like this solution because it doesn't use up any pins of your microcontroller and doesn't require any external circuitry. This also makes it less subject to external failures.

In addition to a library, they also provide a sketch that demonstrates the use of the same technique used to generate a random seed for the microcontroller's PRNG without the library:
https://sites.google.com/site/astudyofentropy/project-definition/timer-jitter-entropy-sources/entropy-library/arduino-random-seed


How can I get additional Slave Select pins?

My solution would be to keep it simple. Use real pins for every SPI SS. Buy an other Arduino board with more pins if you need more pins.

What else is connected to your Arduino board ? Perhaps it is easier to reduce those pins. Almost all analog pins can be digital pins as well. You could use external ADC modules. Perhaps replacing 1-Wire or DHT11 or DTH22 with I2C sensors. Using a I2C display. There are many options to use buttons and leds with a few pins. And so on.


When I connect the Vcc and GND of my circuit to my Arduino, it is powered off?

Note: if you are changing something have the power off.

The first thing to try is unplug the IC. If it powers up after the IC is removed it is Possibly the IC is bad; However measure the Voltages on the proto board where the IC is inserted, be sure Pin 16 is +5V when referenced to pin 8.  Check the data sheet for the correct pinout, I do not know what IC you are using. If the voltage is correct it is pointing more to a bad IC.

The final check for the IC is to insert the IC and remove the ground lead to the LEDs.  If the system comes up then the problem is not enough power to drive the LEDs as is. If it does not come up replace the IC.  Even a momentary reverse voltage or a ESD (Electro Static Discharge) incident will damage the IC, we know is is going to fail, we do not know when.

Be sure your resistors are at least 300 Ohm or higher, with that resistance the LEDs when all on will draw a total of 80mA. If you want to do the calculations try this link: "http://www.onlineconversion.com/ohms_law.htm".

If you want to check the LEDs, remove the IC and connect +5V one at a time to the wire that goes to the resistor from the IC.
Good Luck,
Gil


In SPI protocol you'll need to read the SPI buffer twice because the data you wrote will be read by the IC and the IC will respond to it in the next communication and that's when you know.

Also, by looking at the message, I see that your IC is working fine, but is your CAN bus initialised properly? I'm a FSAE team member and I've faced this issue with the CAN Bus termination resistances and the ODB-II configuration on the Sparkfun CAN Bus shield.

Also, have you tried any other libraries for the CAN Shield? For me the seeedstudio library of their CAN shield worked very well.


What happens if you supply too much voltage to an LED?

In the most simple terms: it will kill the LED.  However things are really not that simple.

First off, an LED is a current driven device, not a voltage driven device. That is, it doesn't really care what the voltage is, but it does care what the current is.  Of course, too much voltage will kill it - but too much current, regardless of the voltage, will kill it.

It's important to understand that an LED is what is known as a non-linear component.  Things like resistors are called linear because they have a linear relationship between voltage and current. Increase the voltage, and the current increases by the same proportion. Increase the resistance and the current decreases by the same proportion.

However an LED is not like that. A typical Voltage-vs-Current graph for an LED looks like this:

Once the voltage reaches the "forward voltage" of the LED the current flowing through it rapidly increases. As you can see it very quickly gets towards infinity. Above a certain point and an increase in voltage has no real difference in the current. In that example the difference between 3V and 5V would be both infinite and zero. In other words, it's pretty meaningless.

But we're still over-simplifying, and that's because we've assumed an ideal power supply. That is, one that can supply a fixed voltage, but infinite current. In other words, a power supply with zero impedance.

No such thing exists, though.

Every fixed-voltage power supply can be seen as an ideal voltage source with an in-line (series) resistor. That resistor limits the amount of current that the supply can provide before the voltage drops too low.  In schematic terms, it looks like this:

simulate this circuit – Schematic created using CircuitLab

If the voltage of the source is above the forward voltage of the LED it will try and draw an infinite amount of current from the source.  That current will lead to a voltage drop across the resistance RZ, which results in the output voltage of the source being reduced.

It will reduce to be the same as the forward voltage of the LED.

We can, of course, calculate the current that would come out of the supply if we know the impedance of the source, but that's not something that is often known.  So you assume it's low and take precautions.

For example, if we happen to know the impedance of the source is 1Ω (maybe it's stated in the datasheet for the power source...) and the voltage is 5V, and we have an LED that has a forward voltage of 2V (I like nice round numbers), we can work out that:

The voltage drop caused by the impedance is 3V (5-2)
The current that causes that drop is 3A (I=V/R, 3/1=3A)

3A is way off the scale for an LED, and it will basically melt internally.

So we add an extra resistance to drop more of the voltage at a lower current.

Now if we take the example of powering an LED directly from an Arduino's GPIO pin without a resistor, we can do the same kind of calculations.

We know that we mustn't draw more than 40mA from a pin (absolute maximum), so if we take that as the current that can come out of a pin before it drops below an acceptable level we can work out an estimate of the impedance. Since the datasheet tells us the output level it shouldn't drop below is 4.2V when powered by 5V, we know that the maximum voltage drop at the maximum current would be 0.8V (5-4.2).  So:

R=V/I = 0.8/0.04 = 20Ω.

There. That's an approximation of the output impedance of a GPIO pin on an Arduino.  So we can plug that into our formulae and connect an LED, and we get:

The voltage drop caused by the impedance is 3V (5-2)
The current that causes that drop is 150mA (I=V/R, 3/20=0.15)

150mA is not massive. It's more than an LED typically wants (20-30mA tops), so the LED won't be happy, but it won't instantly blow at that level. It will be brighter than normal, get hotter than normal, and its lifetime will be much much shorter than normal.

That's not the worrying thing though.  The worst thing is the power dissipation from the impedance:

P=I²R = 0.15²×20 = 0.45W.

That's almost half a watt of heat being generated by the GPIO pin's drivers. If you consider that a half-watt resistor is pretty chunky, if you can picture that power being crammed into the tiny space of a single MOSFET within a silicon chip, you can see how that may become a problem.

It's really not capable of dealing with that level of heat, and the GPIO pin's driver MOSFET goes belly up.  Bye bye MOSFET, bye bye GPIO pin.

As an aside, you would probably also see other strange things happening as the chip tries in vain to deliver large currents to a single GPIO pin. Other areas of the chip get starved of power, power rails drop in voltage, code crashes, etc. All from just one little LED being connected without a resistor.


What's the 2nd ICSP header for in Arduino Uno R3?

It's for the other MCU on the board.

The main MCU on the Uno is labelled "ZIC1". This is the one that is programmed when you press "Upload" in the IDE. But unlike other Arduinos that use a FTDI chip to connect to the serial port on the main MCU, the Uno uses another MCU instead, labelled "U3" on the left. This MCU runs a small bit of code that acts as a serial port via USB and passes through the bytes to its USART1. This then connects to the USART on the main MCU, where the bootloader on that chip accepts the bytes coming through and writes to flash and EEPROM on the main MCU.

You can use this additional MCU as you would any other, but the only I/O it has available are the USB connection, the SPI connection via its ICSP header, the UART1 connection to both the main MCU and pins 0 and 1, and two LEDs on PD4 and PD5.


You’ve probably switched some wires.
Relay Connection with Arduino, usually takes 3 Pins:

VCC / In (5v)
Signal (Data) - [D2] Pin On your sketch.
Ground

It is that simple.
Some recommendations apart from your question:

Make sure to know how your relay starts.
That is: Starts Always On or Always Off.

On your sketch (relay initialisation); set the initial relay state before defining its function as OUTPUT.

...
digitalWrite(relayPin; LOW);
PinMode(relayPin, OUTPUT);

...

Ensure the wires are properly connected to avoid wasting time understanding why the relay doesn’t work.
Special attention to Ground Wiring.

Note: Depending on your schematic; You may require to bridge your Grounds.


The ESP communicates using the UART, not SPI. It uses modem-like AT commands. Unless you write your own ESP firmware, in which case how it communicates is up to you - and so is the accompanying Arduino library.


Send Keyboard Media Keys with Keyboard Library

You have to do some tweaks to the usbkeyboard libraries that comes with the IDE.

For a video tutorial, take a look at this:

Arduino Leonardo as a multimedia keyboard

Which uses the information from this site, if you prefer text only:

Arduino Leonardo multimedia keys

The Leonardo and ProMicro both use the ATMega32u4 and should both work with theses tweaks. If you need more functionality than the ones that this tweak gives you, you have to dig down into usb descriptors on usb.org for the commands you need.


if (moisture <= 350) //if moisture is less than reading 350 {

That is wrong, because you have the brace { after the comment. You need it before the comment, eg.

 if (moisture <= 350) { //if moisture is less than reading 350

Or preferably in my opinion:

if (moisture <= 350) //if moisture is less than reading 350
  {

  I'm just asking if it's possible to change the if (moisture <= 350)

Yes, of course. That's what variables are for. You could read a potentiometer, and the value from that could replace 350 in the code. You could use a simple LCD or LED display to show what the current reading is.

  delay(600000) //water for ten minutes

Your problem here is that the sketch will be totally unresponsive (it would not react to your changing the moisture level) during the time you are watering. You might want to read How to do multiple things at once which shows how you can keep doing other things, while waiting for time to elapse.


There are four variants of LwIP bundled with the ESP8266 core:

V1.4 (Compile from source)
V1.4 (Precompiled)
V2 Lower Memory
V2 Higher Bandwidth

By default (for most boards) one of the V2 variants is selected. You need to change that to the V1.4 (Compile from source) for it to use the version that you have modified.


Since all of these cheap fingerprint readers are similar you can find a compatible datasheet and just find the commands and descriptions there. However, I couldn't find a datasheet that would include a good description of the protocol. So the other option is to look at the protocot through the software SFGDemo which is apparently capable of getting an image of a fingerprint. Or to use this python package which apparently also can download the image.


How to control a DC motor via Arduino Uno as a slave and Mega 2560 as master?

Serial is quite easy to implement and use the SoftSerial.

Example code for serial can be found in the Arduino IDE under the menu:

File | Examples | 04. Communication


Is it possible to run a binary from EEPROM?

Short answer: No; From the atmega328's data sheet (though it applies to all AVR's):

  AVR uses a Harvard architecture – with
  separate memories and buses for program and data. Instructions in the program memory are
  executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the program memory

  ...

  Program Flash memory space is divided in two sections, the Boot Program section and the
  Application Program section. Both sections have dedicated Lock bits for write and read/write
  protection. The SPM instruction that writes into the Application Flash memory section must
  reside in the Boot Program section

It's architecture prevents using external program memory, but you can load anything into program memory at boot. At that point I would venture to say you are just programming AVR and not arduino, since you would need to replace the arduino bootloader and break the arduino IDE's ability to upload programs.

Alternately you could also use an emulator or interpreter of some intermediate language; basically code that steps through and runs other code. As a general rule an emulator runs around 8x slower.

There are micro-controllers from other brands that do support this functionality, I know a couple different PIC's do.


The bootloader runs in the 328, and just as your application programs do, it sets a UART baud-rate for uploading programs to the Uno.

Current bootloaders use 115200 baud for upload; the most recent previous ones used 57600 baud. Setting that is part of the bootloader code. Whatever your application program last set for a baud-rate doesn't matter; if you reset the Uno, the bootloader sets the UART to the known upload baud-rate, and waits briefly for the PC to begin an upload, and jumps to the currently loaded application program if no upload is begun.

Your PC's Arduino IDE configuration is written to use the known bootloader baudrate (you can see that in the avrdude command). In fact, since I have some boards with soldered-in chips with the older, 57600 baud bootloader burned in them, I have two Uno-board configurations in my IDE; one for those older chips, and one for the current ones.


It sounds like the 4N25 opto-coupler on its own can't do what you need because it's not designed to directly make/break a connection between a power source and its load (i.e. it isn't functionally equivalent to a relay).

Internally, the switching functionality is provided by an NPN photo-transistor. A typical open collector usage would be something like this:

(Image copyright Lewis Loflin: http://www.bristolwatch.com/ele/opto_isolated.htm)

The switch (S1) and the power source (Vi) on the left would be your Arduino. All the connections on the right would be part of your device (the actuator).

As you can see, you need 3 connections on the right: voltage source (Vcc), ground, and the output (Vo, which goes to your device). The circuit basically works by pulling the output (Vo) either up to Vcc to turn it on, or down to ground to turn it off.

It looks like all you have is Vcc and Vo, so this kind of configuration won't work. (Don't try to use the ground from your Arduino instead. That could cause various other problems.)

It should be possible to setup additional circuitry to act more like a Solid State Relay, but without a ground reference point it can be harder than it sounds. A mechanical relay might be the easiest option.


I cleaned up your code a bit. Removed duplicate and unused code. I used a for-loop to make it run for 100 repetitions.

Feel free to let me know if you have any more questions, or if there are things that aren't clear.

// You aren't using these libraries, so I commented them out
//#include <AccelStepper.h>
//#include <MultiStepper.h>

int smDirectionPin = 2; //Direction pin
int smStepPin = 3; //Stepper pin
int smFirePin = 13;  //Trigger pin

byte maxRepeats = 100;

void setup()
{
  /*Sets all pin to output; the microcontroller will send them(the pins) bits, it will not expect to receive any bits from thiese pins.*/
  pinMode(smDirectionPin, OUTPUT);  //Direction Pin
  pinMode(smStepPin, OUTPUT);  //Step Pin
  pinMode(smFirePin, OUTPUT);  //Fire pin
  digitalWrite(smDirectionPin, LOW);
  digitalWrite(smStepPin, LOW);
  digitalWrite(smFirePin,LOW);

  Serial.begin(9600); //Open Serial connection for debugging
}

void loop()
{
  digitalWrite(smDirectionPin, LOW); // set stepper motor to run forwards

  for( byte i=0; i<maxRepeats; i++ ) // run the following section 100 times
  {
    //move 10 steps forward
    for( byte j=0; j<10; j++ )
    {
      move1Step();
    }

    // wait and take a photo
    delay(3000);// there is already a delay in the `trigger` function, so this like could be removed
    trigger();
  }

  // return the stepper motor to the starting position
  digitalWrite(smDirectionPin, HIGH); // set stepper motor to run in reverse
  for( byte i=0; i<maxRepeats; i++ ) // run the following section 100 times
  {
    //move 10 steps backwards
    for( byte j=0; j<10; j++ )
    {
      move1Step();
    }
  }

  // Do nothing
  while(1){ }
}

void move1Step()
{
  digitalWrite(smStepPin, HIGH);
  delayMicroseconds(750);
  digitalWrite(smStepPin, LOW);
  delayMicroseconds(750);
}

// Power on the IR trigger circuit to fire the camera
void trigger()
{
    delay(1000); // wait for vibration to settle
    digitalWrite(smFirePin, HIGH); // take the picture
    delay(2000); // wait for that to happen
    digitalWrite(smFirePin, LOW); // disable the IR circuit again
}


How to assign ESP8266 access point a hostname that can be resolved by the stations?

I'm unclear on the distinction being drawn here:

the hostname and not mDNS

mDNS, like DNS, and hostname lists are all things a "resolver" would use to map a "hostname" to an IP address.
If you mean "how do I use DNS instead of mDNS?", you'd need to have your ESP8266 running a DNS server.  And for clients to be aware of it you'd probably have to be running a DHCP server as well.
By the way, the examples list for the ESP8266 Arduino package contains a DNSServer/DNSServer example that appears to do exactly this.  I have just tested it.
This is the exact code I ran out of the ESP8266 Arduino github repo at the tag for the version of the ESP8266 Arduino core I tested it on, 2.7.4.


arduino webserver serves single web page to WAN/Internet very very slowly

I haven't used the ethernet library for a while, but I remember that it served up tiny packets - basically each write call went in its own TCP packet. It sounds like you may have latency issues across the WAN.

You could try using your Apache instance to proxy the Arduino pages. Details are at http://httpd.apache.org/docs/current/mod/mod_proxy.html I have this running but all my pages are small so I'm not sure how it would behave on larger pages.


Selecting different arrays using a list of pointers

You have it right, only fix initialization of test variables:

you do not call map_arrays() in setup()
you assign uninitialized arr_list item to b

const int* arr_list[3];
const int arr_sizes[3] = { 3, 4, 5 };  // array of the array sizes
const int ar1[3] = { 12, 2, 8 };       // arrays of  different sizes
const int ar2[4] = { 41, 3, 6, 47 };
const int ar3[5] = { 9, 32, 1, 5, 7 };

void map_arrays() {          // list of pointers with the addresses of the
// arrays
  arr_list[0] = ar1;
  arr_list[1] = ar2;
  arr_list[2] = ar3;
}

int arr_number = 1;          // select array
int a = arr_sizes[arr_number];    // the size of the selected array
const int *b;
int test = 0;

void setup() {

  Serial.begin(57600);  //serial monitor

  map_arrays();

  b = arr_list[arr_number];

  for (int i = 0; i < a; i++) {     // for the selected arr_number iterate and
    test = b[i];                 // return the index elements
    Serial.println(test);
  }

  Serial.println("size =");
  Serial.println(a);
  Serial.println();
  delay(1000);
  Serial.println("index =");
  Serial.println(test);
  Serial.println();
  delay(500);

}

void loop() {
}


Automatic subtle colour changing on ws2812b with arduino

For the color, you can use the time (millis()) as a hue parameter.

void SwitchLED(int MyArray[], int n) {
    CRGB color = CHSV(millis()/1024, 255, 255);
    for (i = MyArray[0]; i < MyArray[0]+n; i++) {
        leds[i] = color;
    }
}

I used 1024 here to scale the time, so it takes 4 min 22 sec, to go through the hue cycle. And a power of two, should solve a visual glitch on millis() overflow.


AnalogRead(0) always returns 0 on RFduino

Without RFDuino specs handy, I'm guessing - but I think it's likely - that the A/D converter gets shut down in an ultra low power sleep and requires some amount of time to wake up. The mis-reading pin, pin 0, is the one your sketch reads immediately on waking. That read call probably takes long enough that the A/D wakes up by the time your read pin 2 so it gives a better reading.

Try switching the order in which you read the pins and see if pin 2 mis-reads if you try to read it immediately after waking. If it does, the cure may be as simple as a 10-100 uSec delay between waking and trying to read any analog data. I just pulled that number out of the air; you might start with a couple of milliseconds and see how low you can make it before you start to see errors, then double that amount.


I played a lot with HC-05 and HC-06 until I understand the way they work. Now i've big Android App communicating with HC at 115200 bauds and sending and receving heavy data.

I hope these tips will help you and other guys and save you time:

1) the way the HC-05 and HC-06 detect end of AT command is different:

HC-05 (can be slave and master): each AT command must end by CRLF. So or you add CRLF in your Android code or you select the option "CRLF line ending" in your console.

HC-06 (only slave): need a "time" between AT Command. According to the data sheet if there is more than 1 sec, the HC consider this is the end. Even if your question is about the HC-05 I think it can be VERY interesting to understand the big problem which can happened with the "delay" between AT.
If you use a communication at 9600 bauds and type AT commands on serial monitor and echo both what HC reply and what you send, you will have such things: type AT+VERSION and see on serial monitor AT+OVKERSION  Why ? Because as the delay between each char is long, as soon as the HC had receive "AT" he thinks that's the command and start to reply "OK".
So with a HC-06 you must send the AT command in one "shoot" and then add a delay of 2 sec to be sure.

2) Problem of settings.
The HC save the speed you set as the name and the pin code. So trying to set the pin, name and speed in the setup funcion is not usefull as at each time the Arduino will reset, each time you'll try to set the data.
Also, factory setting of HC seems to be 9600 bauds.
So you have to create a small sketch, which you'll use only ONE time to set the HC. Like this:

Serial.begin(9600);
delay(2000);

// AT+NAMEXXX where XXX is the new name
Serial.print("AT+NAMEJOHNDOO");
delay(2000);

// AT+PINXXXX where XXXX new code (4 number)
Serial.print("AT+PIN1999");
delay(2000);

// AT+BAUDX where X from 1 to 8
// 1 -> 1200 Bauds
// 2 -> 2400 Bauds
// 3 -> 4800 Bauds
// 4 -> 9600 Bauds
// 5 -> 19200 Bauds
// 6 -> 38400 Bauds
// 7 -> 57600 Bauds
// 8 -> 115200 Bauds
Serial.print("AT+BAUD8");

This for HC-06. For HC-05 you must add CRLF and you don't need the delay.

Important: as, at the end of this sketch, the HC is now at 115200 bauds, you must havea serial.begin(115200) for comunicating with it. If you run this sketch two time, the second run will do nothing as the Arduino will try to comunicate at 9600 bauds with a HC listening at 115200.

3) Problem of speed.
On the Arduino, you can use the software serial lib only if you plan to send and receive at up to 19200 bauds. Some say it work at 38400 but I've had problems at this speed.
The best way it to avoid Software serial and use directly the basic RX and TX of the Arduino. Using that you can run at 115200 without any problem.

Even if this answer is a bit "outside the question" I hope this will help you working with the HC.


How to set address for using more than MPU9250

This is the type of information which a Data Sheet is intended to communicate.  In I2C mode the AD0 pin selects between two possible addresses,

1101000 for AD0=0 and
1101001 for AD0=1.

In SPI mode you can presumably have as many as you like by giving each its own chip select.

That said, using multiple sensors may not be very useful unless your apparatus is flexible - only the 3 accelerometer axis would be expect to yield different values based on position relative to the center of rotations.


DHT11 not giving correct value if I attaching a servo motor

Your code looks like there is no bug in there.  You might want to look at using a library that lets you assign a pin in the constructor, so you don't need to read from a specific pin.  There might be something internal going on that you don't know (or want to know) about.  As for the movement of the servos do you realise you a rotating 181 degrees int p = 0; p <= 180 is 181 degrees, drop the = if you wanted 180.  Also pos++ is the same as pos += 1 but requires less of those tiring key presses :)

You say that the DHT11s work on their own.  The servo works on its own.  So it not a hardware fault.  I assume its not a wiring fault, but please double check.  That means it has to be something to do with the power.  If you are powering the servo from a digital pin then this is unlikely to work, try powering it from the 5V output pin on the other side of the board.

However if you are powering it from the 5V output pin and it doesn't work then you need to power it from a external source, a mobile phone charger will do (if you have one you can chop the plug off).  The problem with using external PSU is you must tie the grounds together.  Doing this means the Arduino and the external device agree what zero volts is and things work.  This is easily done by taking the gnd of the PSU and putting it in the GND connector of the Arduino and the taking the GND for the servo from the other GND on the Arduino.

I hope that all makes sense, if not tell me what you need clarifying.


AVR timer overflow interrupt not working

You are misunderstanding what an overflow interrupt is. That is called when the timer overflows (ie. it reaches TOP which in the case of an 8-bit timer is 255). Since you are counting to 124 that will never happen, and thus the interrupt will not fire.

You want the "compare A vector" which is called when the "A" register compares to the limit. Example code:

void timer0_init( void )
{
    TCCR0B = bit (CS01) | bit (CS00);    //clock select is divided by 64.
    TCCR0A = bit (WGM01);     //sets mode to CTC
    OCR0A = 0x7C;             //what to count to
    TIMSK = bit (OCIE0A);     //Enable compare match A interrupt
}

ISR(TIMER0_COMPA_vect)
{
    PINB = bit (PINB0);   // toggle pin 5
}

int main(){

    DDRB |= bit (DDB0);    //set this pin as an output for an LED
    timer0_init();         //set up timer0 for 1 ms overflow
    sei ();                // allow interrupts
    while(true) { }        // forever
    return 0;
}

I changed it to toggle pin 5 (which happens extremely quickly) so it will seem to be on but a bit dim. You can see on an oscilloscope or logic analyzer that it is toggling rapidly.

You don't need to turn interrupts off or on inside an ISR. You are better off using the bit names rather than "magic numbers" in your code, as my example shows.


First, you need to figure out the bandwidth requirements and if this is possible at all. You need to do some basic calculations and answer the question if the Arduino and the different components have the bandwidth (byte/second) that is required.

The Arduino MCU (AVR) is too "weak" to do this on it's own. A special shield is required. Such as https://www.adafruit.com/products/1788

The Arduino Due has more processing power but still not stereo quality; https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer

More info to be googled.

Cheers!


NRF24L01 Direct Communication Library Logics

Both of the Libraries you mentioned are well written. I've used both, but decided to write my own based those libraries. For me, the network libraries were written for their project and didn't really fit my needs. So I decided to write my own. I combed the internet for a bare bones NRF24 Library and found this one. This was my starting point. It didn't need the Arduino Core Library and handled all the SPI functions. Then I read the NRF24L01 datasheet several times, then read it again.

With that said, you can broadcast up to 6 radios at a time. Per the datasheet, the receiver knows which radio sent the packet. The STATUS register (0x07), should tell you who sent the packet:

I was unable to get this working (I am still working on it), so for now, I send my packet as a struct:

typedef struct  {

uint8_t id;
uint32_t data;

}
Packet;

Packet pck;
pck.id = 2; // id of my second radio

Keep in mind when you program your Arduino as the receiver, you have to tell it who it will be receiving from. The transmitter and receiver have to be on the same RF channel, speed and same pipe. To choose who receives the packet may not work the way you think, but as I mentioned you can program the receiver to know who the transmitter was and code around it.

I would suggest you dig into the datasheet.


How to interface USB to custom Arduino Uno Schematic and programming atmega?

Since I want it all on one board like the arduino uno my question is how is the USB-B connected to the microcontroller and how would i Incorporate in my schematic?

The USB interface forms a bridge between the USB connector and the UART of the "master" MCU.  You don't have to use a microcontroller, but almost any UART to USB bridge chip will do the job.  Common ones are the CH340G (cheap and unstable), CP2102, FT232, etc.  The DTR signal from the USB chip is used to reset the main MCU.

You should look at the existing Uno schematics to see how the two chips are wired together.

  Another question (out of curiosity) if I was to mass produce said PCB with one program on the atmega chip and leave out a USB module so people wouldnt be able to reprogram it (without taking the board apart obviously) How would that be done?

You would program the board through the ICSP pins - in the same way that you put the bootloader on.  Normally you'd invest in a proper programmer to connect up to the chip, but you can do it with an Arduino acting as the programmer.


expected primary-expression before ',' token ...problem

Assuming that your motor is connected to pin 8, and you want to set that signal high, you have to define it:

#define motor 8

void setup() {
   pinMode(8, OUTPUT);
}

void loop()
{
  digitalWrite(motor, HIGH);
  // put your main code here, to run repeatedly:
}

Since you use it also in setup, also replace it there:

#define motor 8

void setup() {
   pinMode(motor, OUTPUT);
}

void loop()
{
  digitalWrite(motor, HIGH);
  // put your main code here, to run repeatedly:
}

Beyond that, MOTOR_PIN is a better name, since it is a pin you refer to, not the motor itself. Also it is a convention that defines are written with capitals, so you get:

#define MOTOR_PIN 8

void setup() {
   pinMode(MOTOR_PIN, OUTPUT);
}

void loop()
{
  digitalWrite(MOTOR_PIN, HIGH);
  // put your main code here, to run repeatedly:
}


How can I call the constructor of a Class after it called once?

You can't. Once constructed, an object remains constructed until you delete it.

You could either use dynamic allocation and new and delete to create and destroy objects at will, or you could create multiple objects with different settings and use different objects at different times.

Another option would be to modify the library to create a new function that accepts and assigns new server settings. All the constructor does is store the settings in variables - there's no reason why you couldn't just change those variables.


Does sharing code on Arduino Create automatically grant any license rights?

Arduino Create doesn't assume any licensing of any form. Sharing isn't a public thing. You have to specifically provide someone with a link to your sketch. If you choose to post that link publicly then that is your concern.

Any licensing should be included with your sketch.


How to Measure many voltages (Uno) - Analog extenders a good option?

Actually it is two separate questions and I answer your first question of reading multiple analog values using one ADC and the answer is Yes you can use this approach but  you should give enough time for each channel to charge internal ADC capacitor when you change channel .so if you use more independent ADC you get more time for each channel and result is better


Connect 9 V battery to Arduino Mega 2560 directly?

Yes. On this page, you can see that you can safely connect 7-12V to the VIN pin.

Furthermore, you can simultaneously connect the USB; your Arduino will automatically draw power from the appropriate source.

Note that the power supply jack pin is connected to the Vin pin through a diode. Do not connect a battery and an external power supply, since a sufficiently high power supply voltage will try to charge your battery, which may be bad news for the battery.


How can I make this code read a page every 10 seconds?

As discussed in the comments, you need to connect to the client each time, not just once.

Here's my modified version of your code, which I hope will work -- I'm not set up to test it.

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 104 };
char server[] = "billigefittings.dk";

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println(Ethernet.localIP());
  Serial.println();
}

void loop()
{
  // Connect to the server
  Serial.println("connecting ...");

  EthernetClient client;
  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /lan.php");
    client.println();
  } else {
    Serial.println("connection failed");
  }

  // Wait a moment for data to arrive
  // Note: This is NOT a reliable way of doing it!
  delay(1000);

  if(client.available() > 0) {
    char c = client.read();

    Serial.print("page value:");
    Serial.println(c);

    if(c == '1') {
        digitalWrite(8, HIGH);
        Serial.println("8 HIGH ...");
        delay(5000);
        digitalWrite(8, LOW);
        Serial.println("8 LOW ...");
    }else{
        Serial.println("page value does not match '1' !");
    }
  }

  // Disconnect the client
  if(client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }

  // Wait another 9s, which will give us a delay of roughly 10s
  delay(9000);
}


It looks like you need to know how to create a string that contains:
steetalert.co.zw/write_data.php?Longitude=12.124311,Latitude=27,766785

Its quite easy (I think) try this:

const int cDecimalPlaces(6);
String szLon = String(fLongitude, cDecimalPlaces);
String szLat = String(fLatitude, cDecimalPlaces);
String szUrl = "steetalert.co.zw/write_data.php?Longitude=" + szLon ",Latitude=" + szLat;

Normally I would use sprint or a Format function, but I can't find those in the reference.


Either use jumper wire, or pull the connectors from the Housing and connect them with male connectors.


How can i stop DC motor when button on remote is released?

For an infra-red remote control you generally can't. Those don't normally have the concept of button release.

Normally there are two kinds of buttons on a remote:

Burst code
Repeat code

The first sends a short burst of the same code. This allows for a function to be run once per button press.  The second sends the same code over and over again constantly until you release it.

For the repeat code buttons you can use that to your advantage.  You program your Arduino to run the motor for a short period. That period needs to be slightly longer than the time between each code reception. Then it can appear that it's responding to the release of the button.

For example, if your remote sends codes 5 times per second then whenever you receive a code you start the motor. If you haven't received a code for more than say 300ms then stop the motor.


ATtiny85 (Sparfun Clone/Trinket), detect/read operation voltage

There are a few solutions.

If you want to save te state of your toggle button you can save it in the eeprom of your attiny85
You can use an ADC pin to check your VCC against the internal 1.1V reference
alternatively you can read the 1.1ref aganist Avcc. https://digistump.com/board/index.php?topic=1104.0


Arduino Comms disrupted, prevents program loading (catch 22)

I would suggest:

Turn on verbose compilation in the IDE.
Set up as you have been with the right port selected and go to upload - it will fail as normal
Find the avrdude command in the verbose output and copy the full command and its parameters
Open a command prompt or terminal window and paste in the command you copied (but don't run it yet).
Press reset twice to trigger the serial port creation
Run the command you pasted. It should immediately start uploading and "fix" your problem.


What is the use of ISP and ICSP in Arduino?

ISP/ICSP has no role when utilizing a typical, properly functioning Arduino, as the program code compiled from sketches is instead downloaded via a bootloader (either serial, often behind an on-board USB-serial converter, or else directly USB).

The role of ISP in the Arduino ecosystem is mostly limited to:

Loading a bootloader into new chips which do not have one, or have somehow lost theirs (note however that you can buy pre-loaded ATmega328's from many sources at a small premium)
As an alternative program loading scheme when the tiny amount of program memory used by the bootloader must be re-claimed for a particularly large sketch
Programing alternate targets to which the Arduino libraries have been partially ported, especially resource-constrained ones where the bootloader takes up a larger fraction of the total memory, such as the the ATtiny25/45/85
Replacing or modifying the firmware of an on-board USB-serial micro such as the 16u2 on an Uno to perform a different function, such as emulate a keyboard or mouse.  However, this chip can also be programmed over its USB interface in DFU mode.
Programming other non-Arduino devices used in a project (though these often have a different ISP scheme than the ATmega series).

But a typical project using purchased board(s) will involve none of these.

SPI vs. ISP

As jfpoilpret points out, a very popular way of interfacing chips to a microcontroller is the Serial Peripheral Inteface, or SPI.  Like ISP, this is a synchronous (has a distinct clock line) serial interface with a master and a slave, a mode or enable pin, and a distinct data line in each direction.  Some Arduinos use MCUs like the ATmega328p which re-use their SPI pins for ISP (with the reset functioning as the mode pin).

In effect, ISP is a sort of special "SPI-like" interface mode for programming an ATmega - often using the master-mode SPI engine of the programer to do the actual transfers.  But "ISP" applies only when programming an ATmega - the more generic case of communicating with a peripheral would be "SPI".

It's my impression that most GSM modules use asynchronous serial interfaces (ie, utilizing a UART engine), but there may be some which use SPI or other synchronous schemes, at least as an option.


This depends on what you are doing.
The IO hardware of the Uno (more specific the Atmega328p, which is the used chip) has internal pullup resistors, that can be used, when the pin is configured as input. This can be done in one line:
pinMode(pin_number, INPUT_PULLUP);

This is true for all AVR based chips.
Other, more complex and capable chips also have an internal pulldown resistor (as I remember this is true for the ESP32 for example). In this case you can do
pinMode(pin_number, INPUT_PULLDOWN);

If you are using special hardware of the Arduino, it depends on the hardware itself, since in most cases the normal IO hardware is internally not connected to the pin, when using this hardware. For example: The internal pullup resistor will not be active, when doing an analog measurement with the ADC (like via analogRead()).


RGB LED color control with a single value

What you are controlling there is one out of three values from the HSV (aka HSB) colour space.

Colour can be represented in a number of different ways, called "spaces".  You computer monitor displays colour in the RGB colour space - red, green and blue. An RGB LED of course also displays in the RGB colour space.  Your colour printer works in the CMYK colour space.

Different colour spaces represent the colour using different values and combinations of values, and which colour space you use may be imposed by technical limitations (such as in the printer it is dictated by the combination of the colours of the inks).

HSV is a convenient way of visually manipulating colour since it gives you easy to understand "Hue" (the colour), "Saturation" (how much colour) and "Value" (or "Brightness" - how light the colour is) values that are easy for a human to understand.

However physical devices don't generally work with that colour space, so you need to be able to translate between them.

You can think of HSV as the "Human" colour space, and RGB as the "Digital" colour space.

Fortunately it's relatively simple to convert from one to another and there are a number of code snippets online that give examples of how to do it.

I'm going to include one here that I use in my chipKIT TFT display library "Cariad".  Given three 8 bit values (0-255) of "hue" "sat" and "val" it will calculate the red, green and blue values. "hue" would be the one you change with your pot - the others can be static values (or you could add more pots to control those too).

    unsigned int H_accent = hue/43;
    unsigned int bottom = ((255 - sat) * val)>>8;
    unsigned int top = val;
    unsigned char rising  = ((top-bottom)  *(hue%43   )  )  /  43  +  bottom;
    unsigned char falling = ((top-bottom)  *(43-hue%43)  )  /  43  +  bottom;

    int r = 0;
    int g = 0;
    int b = 0;

    switch(H_accent) {
        case 0:
                r = top;
                g = rising;
                b = bottom;
        break;

        case 1:
                r = falling;
                g = top;
                b = bottom;
        break;

        case 2:
                r = bottom;
                g = top;
                b = rising;
        break;

        case 3:
                r = bottom;
                g = falling;
                b = top;
        break;

        case 4:
                r = rising;
                g = bottom;
                b = top;
        break;

        case 5:
                r = top;
                g = bottom;
                b = falling;
        break;
    }
    if (r > 255) r = 255;
    if (g > 255) g = 255;
    if (b > 255) b = 255;
    if (r < 0) r = 0;
    if (g < 0) g = 0;
    if (b < 0) b = 0;


How to install several IDE version on my PC

Arduino.cc have a guide :

https://www.arduino.cc/en/Guide/PortableIDE

The gist is:

Download the desired version in ZIP format
Unpack the content in the zip file to a folder
Start the arduino.exe in that folder.

Remember that you have to place all libraries, board definitions in that folder.

The folder can be copied to another computer or a USB stick....


The library has a built in loop function:

audio.loop(1);             0 or 1. Can be changed during playback
                           for full control of looping.

See WIKI page of the library.

Btw, it is unclear if you mean by 'a loop' a while(true) loop or the void loop() function. Although it should not make a difference.


Best Data model/Concept to Store Multi-Day Alarm for clock?

I would suggest a bit field for storing the days of the week when the
alarm is supposed to fire:

bit 0: fire on Sundays
bit 1: fire on Mondays
...

This numbering is meant to match the one of DateTime::dayOfTheWeek().
Pack this, together with the hour and minute of the alarm, in a struct
(or a class if you prefer). Maybe add a boolean to tell whether the
alarm is active. For example:
struct Alarm {
    bool is_on;
    uint8_t days;  // bitfield: 0 = Sunday
    uint8_t hour;
    uint8_t minute;
    bool matches(DateTime) const;
};

bool Alarm::matches(DateTime t) const {
    bool day_matches = days & (1 << t.dayOfTheWeek());
    return day_matches && t.hour() == hour && t.minute() == minute;
}

Then if (alarm.is_on && alarm.matches(rtc.now())), the alarm fires.


You declare incomingchar as a char. In your if you compare that char to a string (double quotes) incomingchar=="g". I think you want to compare it to a char (single quotes) like this:

if ( incomingchar == 'g' ) {
  // do something
}