I does sound like RS-485.

You can get cheap RS-485 transceivers from the usual sources.  These take the 0..5v TX line and convert it to RS-485 voltages, or RS-485 voltages and convert to the 0..5v RX expected by your Arduino.  You would normally enable only one direction at a time - sending RS-485 from the Arduino TX or receiving RS-485 to the Arduino.

In your case, you just want to receive, so keep the transmit side (TX to RS-485) disabled, while enabling the receive side (RS-485 to RX).

RS-485 is just an electrical standard, and they could be sending any pattern of on and off signals they want, but often they will be sending asynchronous data with one start bit, 7-8 data bits, and one stop bit per character - which the Arduino's Serial port can handle.  So it's worth testing to see if that works.

The next thing you need to know is the clock rate, or "baud rate", which is how many bits per second (including start and stop bits) it is sending.  Often you can figure this out by trying some standard rates like 1200,2400,4800,9600,19200,38400,57600,115200 (there are others) and printing the results to your screen - when you are at the wrong rate you will get nothing, or some odd garbage.  When you get the right rate, it will look more reasonable.

If no speed works, you may need to reverse A and B.

You might temporarily hook up an LED and a resistor (say 2.2K or higher) between the RX from the RS-485 and your 5v power.  This will give you an idea of when there are transmissions from or to the thermostat.  If it only transmits once a minute, say, you might have to wait a while for each speed test.  Or changing the set temperature may trigger a send.

You may be able to test the lower speeds at least using Software Serial, and then echo the received data to the hardware serial port which goes to the Serial Terminal in the Arduino IDE.

From there, you may need to figure out the protocol - the structure of the data.  Protocols vary widely.  It may be text or it may be binary; if it's binary you may want to have the arduino convert each character (values 0..255) into hexadecimal (00..FF) for printing.

Most protocols for this kind of control send data in a burst, or packet.  You will likely be able to detect the start and end by the timing (ie: a long pause between the end and the start of the next).  Of course, some protocols might send several packets continuously, but still the first character (or binary value) after a long pause will often be the packet header.

Remember that there may be packets from the themostat, and packets to the thermostat, and you will see both without knowing which is which (so long as you are just passively tapping the line).

I hope this is enough of a pointer to get you started.  Decoding protocols is a more extended subject.


UPDATE!
The issue has been fixed, just after finding this stackoverflow answer by bat macumba. I'll leave the question here, in case someone stumbles into the same problem.


Yes, you can edit the library yourself, or copy its functions to your sketch and modify them.

You can also use another library, like u8g2.


Smaller and cheaper alternative to Arduino Uno for permanent projects

I think the first best choice is to remove the ATMega328p-pu chip from your Arduino UNO and incorporate it into your final circuit.
The chips are only about $1.50.

That way, you can just use your UNO as a programmer instead of the final device that you deploy.

I'm not sure why there isn't more documentation about the proper way to remove the ATMega328p-pu chip and using it on your breadboard, after completing your programming.

I explain exactly how to do this on my blog: http://raddev.us/arduino/post/2018/07/03/arduino-uno-using-your-atmega328p-u-as-stand-alone

But, here are the basics.
First you remove the chip.  It will look like the following after you do so.  (Note: I'm using the Elegoo clone of an UNO).

Next, you apply power to pin 7 and connect pin 8 to GND.

Need A 16MHz Crystal

But, the chip won't seem to run your sketch at this point.
That's because you actually need a crystal to run at 16MHz.

The UNO board has that chip installed and that is why it works.
You can see it here:

Finally you add the 16MHz crystal and a couple of 22pF caps and your chip will run standalone (no UNO).

You add the crystal to pins 9 & 10.  You can see all the details by reading my blog entry or reading the atmega328 datasheet.

Finally, Just Wire Everything Else Up

After that, just wire the rest of your circuit up to the proper pins and you can run your ATMega328p-pu standalone.

It's actually a nice learning experience too.
Just buy replacement atmega328p-pu chips for your UNO and you can create all the projects you want to for very cheap.


Digital LED clock - matrix circuit question

Since you're using a matrix of anodes and cathodes you need to connect/disconnect both ends of each LED.

You will probably multiplex these LEDs and only light one at a time. Are the LEDs high enough current that you can't either source or sink enough current for a single LED directly from Arduino pins? Most LEDs run on ≤ 20 mA, which an atmega328 can handle.

If you are trying to drive LEDs that need > 20mA then your plan to switch both the +5 and the ground with transistors should work. As StarCat said, you should consider the "on resistance" of your transistors as part of your calculation for the value needed for the current limiting resistors of your LEDs.


What's the problem? My motor works properly only when we press the left key and not others

The reason your code only works for left, is because when v is LOW your else block gets executed and sets all pins to low! You need to use else if.

if(condition1)
{
  ...
}
else if (condition2)
{
  ...
}
else
{
  ...
}


Trying to use an LCD 1602 to display, but I don't have a 10 KOhm potentiometer

Yes. All a potentiometer is, is two resistors end to end.  The "wiper" is the join between the two resistors.

It doesn't matter too much what value potentiometer (and hence what value resistors) you use, as long as it's "around" the 10kΩ mark (100kΩ should be fine, 50kΩ, 1kΩ etc - anything below 1kΩ may not work) - what matters is the ratio of the values of the resistor.


As I said in a comment, if you really need to compute that moving sum,
you absolutely need to store the last 60 one-second counts in memory.
That being said, there are a few small issues with this code for which I
would have some suggestions:

There is no point in storing totalCount. You do not really use it,
and it will eventually overflow.

You do not need to explicitly initialize all globals to zero, as that
is implicitly done by the runtime: it is a requirement of the
language.

Your are calling digitalRead(countSensor) three times in a row. The
logic for counting edges is sound as long as the three calls yield the
same result, but that is not guaranteed. It is safer to only read the
pin once per loop iteration.

Similarly, the two calls to millis() can yield different results,
and that will make your timings slightly off.

The condition millis() - preMills > 1000 will only fire when
1001 milliseconds have elapsed. Because of the way millis() works,
sometimes you will miss the 1001th millisecond, and process on the
1002nd millisecond. In order to avoid accumulating these small timing
errors, it is best to update preMills by always adding exactly 1000.

As pointed out by jsotola, you do not need to shift the array: you can
instead reuse the array cell that holds the data you do not need
anymore.

You do not need to perform the whole sum every time. You can instead
update the previously computed sum by removing the count of the second
that falls off the current one-minute window, and adding the count of
the current second.

Here is my attempt at applying all the above suggestions. Warning: it
has not been tested.
const uint8_t countSensor = 8;

uint8_t record[60];       // last 60 one-second counts
uint8_t currentIndex;     // current index in record[]
uint8_t oldSensorState;   // previous state of countSensor input
uint32_t previousSecond;  // last time we printed minuteCount
uint8_t thisSecondCount;  // count of items in the current second
uint16_t minuteCount;     // count of items in the last minute

void setup() {
    Serial.begin(9600);
    pinMode(countSensor, INPUT_PULLUP);
}

void loop() {
    // Count falling edges.
    uint8_t sensorState = digitalRead(countSensor);
    if (oldSensorState == HIGH && sensorState == LOW) {
        thisSecondCount++;
    }
    oldSensorState = sensorState;

    // Update stats every full second.
    if (millis() - previousSecond >= 1000) {
        previousSecond += 1000;

        // Update minuteCount by removing the second that falls off
        // the window and adding the one that enters the window.
        minuteCount += thisSecondCount - record[currentIndex];

        // Replace the count that is not needed anymore by
        // the current one.
        record[currentIndex] = thisSecondCount;

        // Start counting a new second.
        thisSecondCount = 0;

        // Update current index, wrapping at 60.
        if (++currentIndex >= 60) {
            currentIndex = 0;
        }

        Serial.println(minuteCount);
    }
}


Can I use Arduino Nano V3 to program another arduino (Pro Mini)?

Yes!

Yes, you can substitute the Arduino Nano V3 for the Arduino Uno and follow the instructions here, providing that the Arduino Pro Mini is a 5V version. (Otherwise, you will have to do some voltage conversion.)

Both boards have the same SPI pins as the Arduino Uno. The connections would be as follows:

Arduino Nano --> Arduino Pro Mini
5V  ------------------->  Vcc
GND  ---------------->  GND
D10  ----------------->  RESET (10uF between RESET & GND)
D11  ----------------->  D11
D12  ----------------->  D12
D13  ----------------->  D13

The process detailed in the link can be summarized as follows:

Load the ArduinoISP sketch into the Arduino that you will use as programmer. You find it under Examples > 11. ArduinoISP > ArduinoISP.
Select the serial port of the Arduino Nano (target): Tools > Port > corresponding port number.
Wire up the two Arduinos as described.
In the Tools menu, set the programmer to the Arduino as ISP.
Select the target board: Tools > Board > Arduino Pro Mini.
Open the program to be loaded to the Arduino Pro Mini and program it by selecting Sketch > Upload using programmer


Trying to control DC motor speed with PID

PID- or any similar control needs

set point
actual value
controlling variable (your PWM value)

The difference between set point and actual variable and its change over time are combined to calculate the controlling variable in order to minimize that difference.

Control theory in general is too complex to answer the "how to" here in general.

Besides measuring the actual value you also need knowledge about the behavior of your system: e.g. If you change the PWM value from 50 to 100, how much and how quick will the motor speed change? Even the response form over time will affect the optimal parameters for your control loop. It's called (feedback) loop because any change of the PWM value will change that difference and lead to a different new value of the controlling PWM value again (Allowing for instable behavior in case of bad controlling parameters).

Getting the actual value is your first task. How your distancefonction affects the desired value (set point) might also need more clarification...


Controlling an LED with the 74HC4067E multiplexer

Pin 15 on that MUX is the enable pin, you need to tie it to ground. Otherwise, it's just floating, and it only would have worked by accident.

Also, you state:

  I am also providing 5V to the Vcc pin on the MUX. I don't really know why I am doing this, but it seems to work.

The chip needs power to work. The Vcc pin is where you give it the +5V power. Without that, it might still work, but only by accident and depending on the inputs on the other pins.


Why do sketches take up so much space and memory?

Arduino compiles in a lot of standard libraries, interrupts, ... etc. For example the pinMode and digitalWrite functions use a lookup table to figure out at run time which GPIO registers to write data to. Another example is that Arduino keeps track of time, it defines some interrupts by default and all this functionality requires some space. You'll notice that if you extend the program, the foot print will only change slightly.

I personally like to program controllers with bare minimum, without "bloat", but you'll quickly enter the world of EE.SE and SO because several easy to use functions will no longer work out of the box. There are some alternative libraries for pinMode and digitalWrite that compile into a smaller footprint, but come with other disadvantages like for example static compiled pins (where led cannot be a variable, but is a constant).


Pin 13, which is the on-board LED, is not a pwm pin. So you cannot Control the brightness of that LED on-board. You will have to use another LED and a PWM pin.


why does it use A0 to define analog pin 0 in some case and why use 0 directly?

The answer is in the source code. Keep in mind that for this answer, I'm assuming you have a standard Arduino Uno. For other Arduino platforms the values are different but the situation is the same.

If you look at the analog pin definitions in hardware/arduino/avr/variants/standard/pins_arduino.h, you'll find these lines:

static const uint8_t A0 = 14;
static const uint8_t A1 = 15;
static const uint8_t A2 = 16;
...

Which tells you that if you call analogRead(A0), it is equivalent to calling analogRead(14). So, really, the question is "How can calling analogRead(0) work?"

The answer to that is in hardware/arduino/avr/cores/arduino/wiring_analog.c. If you wade through the defines, you'll see that at the top of analogRead, there is the following code:

if (pin >= 14) pin -= 14; // allow for channel or pin numbers

The result is that passing either 0 or A0 results in 0 being used in the analogRead code.


nodemcu doesnt response in at command mode

Some points to note:

VIN should connect to 5V (it goes through the on-board 5V -> 3.3V regulator). If you connect VIN to 3.3V you will be starving the device of power.
The NodeMCU doesn't come with AT firmware installed. You will have to install it first before it will respond.
If you have a NodeMCU why are you bothering with an Arduino? The NodeMCU can do everything (and more) that the Arduino can do (except it lacks IO).


Sorry, no Arduino required, but you probably already have a web cam on your desktop. If you don't mind being observed like Schrodinger's Cat, you can use a small utility like YawCam in Windows or Motion on Linux to trigger the screen lock when you are no longer visible at your console.


Integrating Freescale Multi Sensor board with Arduino

So... 20 months later I stumbled upon this question, only to find out I wrote it. Awkward! Anyway, for anyone who stumbles across this question in the future, here is the answer.

The Rx pin is connected to the Bluetooth module, and as such the module will keep the pin in an idle state (either idle-high or idle-low). The Rx pin of the Arduino UNO (or the Rx0 pin on the Mega/Due) requires to be free of anything that may interfere with the upload. The Arduinos rely on the Rx pin for the sketch upload. If anything is connected to it, the IDE will freeze and nothing will be uploaded. Simply disconnect the FRDM board, upload the code, and put the board back in place. Then it should work.


Most basic way would be to use only DIR, PWM and Break.

Use Break as enable (put high at begining of the program, put low when you want to start rotation).

Use Dir to change rotation of the motor (usually high is CV, low is CCV, but you need to check the datasheet)

And hook up PWM to PWM pin on arduino. This will control the speed.


Getting wrong values from serial.read() connected to a Raspberry Pi

ser.write(str(x_value));

Writes the string representation of the integer x_value, which is a sequence of ASCII characters.

ByteReceived = (Serial.read());
Serial.print(ByteReceived);

Reads a character (byte) and prints to the value (again as a sequence of characters).

45 51 48 45 53 52 45 49 52 45 52 55 55....

45 is ASCII character value for the character '-', 51 is the character '3', 48 is '0' and so on.

Cheers!


It adds the value or variable on the right to the variable on the left and assigns the result to the variable on the left.

A += B

is the same as:

A = A + B

It's short-hand.

In the case of a String it concatenates the right hand item on to the end of the left hand item.


Can I use an internal clock on Wemos D1 Mini?

I think the answer to your question can best be summed up by one word: "Kinda".
The best reasoning is the NodeMCU Lua documentation which states:

Time keeping on the ESP8266 is technically quite challenging. Despite being named RTC, the RTC is not really a Real Time Clock in the normal sense of the word. While it does keep a counter ticking while the module is sleeping, the accuracy with which it does so is highly dependent on the temperature of the chip. Said temperature changes significantly between when the chip is running and when it is sleeping, meaning that any calibration performed while the chip is active becomes useless mere moments after the chip has gone to sleep. As such, calibration values need to be deduced across sleep cycles in order to enable accurate time keeping. [...]

So while it's called RTC it's not an RTC in the traditional sense - it's merely a timer that runs even when sleeping, but not with any degree of accuracy.
You can access the current RTC count with the Non OS SDK function
uint32_t system_get_rtc_time()

You can combine that with
uint32_t system_rtc_clock_cali_proc()

which gives you the number of uS per tick of the RTC timer.
There's no way to change the RTC timer count, so you will have to work out some "delta magic" to update your own internal time value (an epoch value is simplest) from the difference between successive calls to get the RTC count.
All somewhat tricky and the accuracy won't be great anyway, so you'll be wanting to use NTP to update that epoch value regularly.
But it could give you a "rough idea" of how long you've been asleep for, etc.
You would have to run some experiments to know how much the time drifts compared to the NTP value in real usage.


The only way to check the relative position is, first to define, what is the absolute position of a person, is it his other hand, his heart, his head, his foot?

When you defined the absolute position of the person, then you need to use a sensor at that absolute position that can measure the current position, e.g. GPS (if outside), but this is not accurate.

You also can use a gyroscope or device similar to what you use for the glove. When you initially keep them together you now the relative position (around 0.0). Than you can track movement differences of both the glove and the absolute position, send it to the glove (or vice versa) and calculate the difference. There might be calibration issues.

Another way is to use a camera and continueously check for a line of sight signal (IR, led), but this also can have issues (like distance measurement, what if there is no line of sight etc).


how to make led fade on and blink while wav file plays

As this can not be your entire sketch we can only guess that you are using some sort of SDCard music playing Arduino shield and library.

An application can not call the delay() function if the application is trying to accomplish more than one task.  Calls to delay() block the processor from doing anything other than waiting for the delay to time out.

In order to (appear to) do multiple tasks, run a loop with no calls to the delay() function.  Instead call the millis() function checking if enough time has elapsed to call the LED function or the sound function.  In neither function should you call the delay() function!  If you did not write the function (for example you are using a library) you may need to edit the code in the library to ensure it is following the no-calls-to-delay()-function rule!

In general terms, this is referred to as a state machine.  In this case, the state machine is driven by the amount of elapsed time as reported by the call to the millis() function.


number generator show wrong segments on 7 segment display

Note, this is not an answer to your question, but I like to show some programming improvements, making your sketch  much shorter and easier to maintain.

Instead of having all functions one, two, etcetera, use a parameter to pass the number. So you get this: (I couldn't test it as I don't have an Arduino IDE at hand). Also you can use a for loop in the loop function to set the output pins.

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 }
};  //OFF

int buttonState = 0;
const int button = 12;
int randVal;
bool pressVal;

void num_Write(int);
void digit(int value);

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

  for (int pin = 2; pin <= 8; pin++)
  {
    pinMode(pin, OUTPUT);
  }

  pinMode(button, INPUT);
}

void loop() {
  buttonState = digitalRead(button);
  if (buttonState == LOW) {
    turnOff();
    pressVal = false;

  }
  else
  {
    if (pressVal == false)
    {
      int pin = 2;
      for (int i = 0; i < 7 ; i++)
      {
        digitalWrite(pin++, num_array[11][i]);
      }
      randVal = rand() % 10;
      pressVal = true;
    }
    Serial.println(randVal);
    if ((randVal >= 0) && (randVal <= 9))
    {
      digit(randVal);
    }
  }
}

void digit(int value)
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[value][j]);
  }
  delay(250);
}

void turnOff()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[10][j]);
  }
  delay(250);
}

You can also remove turnOff if you treat it like digit 10 but that is not so clear (or put the implementation of digit to another function and call it from digit and turnoff.

To solve your problem, print the values of each pin to the serial monitor. If they are correct, there is a problem in your circuit. If they are incorrect, there is a problem in your sketch. In the latter case, add more print statements until you found the exact problem.

Update

Fixed void forward declaration to function call (see comment of chrisl)

If the digit function is never called, it means:

((randVal >= 0) && (randVal <= 9)) is false, however, that is not possible since it is initialized to 0 and with the rand function it gets always values between 0 to 9.
pressVal is always TRUE.

So check the value of pressVal, also add (lots of) print statements, especiallya after each if and else so you know exactly the flow of your sketch. You will see it's very easy to find the error. If you pinpoint the problem to a digitalRead that is not the expected value, THAN there is high likely a problem with your circuit (a button that is never going to be LOW or HIGH). In that case, you probably forgot a pullup/pulldown resistor.


The biggest mistake people always make with serial communications of any form is to just send raw data over the connection. While you might just about get away with that on a 100% reliable direct serial connection over a short distance, as soon as you introduce anything with any form of uncertainty to it you are, as you have seen, doomed to failure.

So you have to come up with a reliable method of transferring data in such a way that the receiver knows that it has received valid data, and how to find valid data.

So you need to create a packet. That's not something where you just wave a magic wand and a packet is created. A packet starts it's life in your own head.

In order to reliably transfer data there are a few things you need to consider from the point of view of the receiver:

Where is the start of my data?
How much data is there?
Is this data correct?

The receiver has to have some way of knowing where the start of a packet is amid the torrent of bytes it is being sent. It needs to look out for something unique, something it cannot mistake for anything else. This is called synchronisation. It is often done with a specific sequence of bytes (known as a preamble) that can, through various means, never appear anywhere else.

And at that point things start to get a little more complex, for now you need some way of wrestling that kind of thing into a system that can only send bytes of 0 to 255 with no way of distinguishing raw data from control information like this synchronisation sequence. And that is where the concept of escaping comes in. This is where you nominate certain byte values as control bytes and decide that these bytes will never appear in your data without some kind of marker to say they are data bytes. A common escape marker is 255 (used in the telnet protocol) or 27 (the ANSI ESC character) although any character can be chosen.

For instance if you choose to have a synchronisation sequence of 0xAA, 0x55, you can then decide that neither of those bytes will ever appear in your data without first being preceeded by character 0xFF. So if you happened to have that sequence in your data you would expand it out to 0xFF, 0xAA, 0xFF, 0x55.  But what if you want to send the value 0xFF, in your data? How do you handle that? Well, you also escape 0xFF as well. 0xFF, being the escape character, has no actual value in the data. It only says that the next character must be interpreted as data. So to send 0xFF you would actually send 0xFF, 0xFF. Your receiver sees the first 0xFF and thinks "ah, the next byte that arrives, whatever it is, just be data." It then gets a second 0xFF and knows it is data. (Actually this is the opposite of escaping which says the next character is a control character, but the underlying concept is the same).

If it ever sees 0xAA, 0x55 then it knows, without a shadow of a doubt, that this is the start of a packet, or random noise. And that is where the next two points above come in: Validating your packet.

If your packets are always the same size then all you need to know is how many bytes to expect, which can be hard coded into your software. If you have different sizes of data to send then you also need to tell the receiver how big the data is. This forms part of the packet header. A small block of meta data that preceeds the actual data that holds information about the packet. Depending on your topology that could be things like the size of the data, where the packet came from, where it is going, etc, and maybe a checksum, though some people like to put the checksum after the data since it simplifies sending.

And then there is the checksum. Possibly the most important thing next to the synchronisation. And so easy to get wrong.

Having a checksum that is too simple is not so good. It can be fooled. That is, if values get corrupted in the data with a simple checksum it is far more likely that the checksum still says it's correct than with a more complex checksum. You should read up on existing checksum algoritms, such as Cyclic Redundancy Check (CRC) and things like the checksums used in IP packets. All are good lessons on how to deal with checksums properly.

So far we have just tackled the serial equivalent of UDP - throw a packet at a receiver and hope it gets there. Doing anything more reliable becomes much more complex. If you want to know if your packet actually got there you will need your receiver to acknowledge reception, possibly including some information about the packet it received, such as a sequence number. If the transmitter never receives that acknowledgement it needs to send the packet again, which means it needs to remember what the packet is that it sent. So you need a packet buffer, or even better, a packet queue. And timeouts. And sequence numbers.

That latter is most important. A sequence number is a unique (or unique over a reasonable period of time) identifier for a packet. When a transmitter doesn't receive an acknowledgement is it because the receiver never got the packet, or that the receiver did get the packet but the acknowledgement never made it back to the transmitter? If the latter then the receiver is liable to get the same packet multiple times through retransmission. By including a sequence number the receiver can go "hang on a moment, I have seen this packet already" and it can throw it away sending a new acknowledgement in the process.

So as you can see, reliable communication isn't as simple as just sending data, or even sending data in the form of a struct. There is a whole lot more to learn and understand.

I suggest you read some of the IP networking RFCs to learn more about reliable packet transmission and reception.

Oh, and I haven't even touched on sliding window reception and such like for how to best program your receiver software...


Why does the following code not cause the led's to flash but rather stay on continuously

The objective of the code is not clear. It seems the idea is to repeatedly blink 3 LEDs, connected on pins 5,6 and 7. To do so, the code needs slight modification-
int timer = 1000;
int thispin = 5;

void setup() {

  for (int thispin = 5; thispin < 8; thispin++)
    pinMode(thispin, OUTPUT);
}

void loop() {

  for (int thispin = 5; thispin < 8; thispin++)
    digitalWrite(thispin, HIGH);

    delay(timer);

  for (int thispin = 5; thispin < 8; thispin++)
    digitalWrite(thispin, LOW);

    delay(timer);

}

Also, since you wanted to know why the LEDs stay ON continuously with your code-
This is because there is no delay statement after any of the digitalWrite-LOW statements. If there's no delay, the LEDs may turn off for a fraction of a millisecond, which won't be noticeable.


digitalWrite (ledPin1 = HIGH); should be digitalWrite (ledPin1, HIGH);

PS if ( (x = LOW) && (y = LOW) && (z = LOW)) should be if ( (x == LOW) && (y == LOW) && (z == LOW)). = is for assignment, == is for comparison.


I tested your sketch after adding pinMode(13, OUTPUT) in the setup, and it works as you intended.

But, as you don't post your schematic, I was only able to chech on-board LED blinking.

void setup()
{
  pinMode(13, OUTPUT);

  for (int i=0; i < 3; i++) {
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);
  }

    // put your setup code here, to run once:
    for(i=startDigitalPin; i<=maxDigitalPin; i++) {
        pinMode(i, OUTPUT);
       digitalWrite(i, LOW);
    }
}

I also reduce your code using a for loop.


Servos are digital by definition.  All you have there is two sellers that are selling the same product, but they are describing them slightly differently.  They are both SG90 servos. They are both digital (they require a digital PWM signal to control them, hence they are digital).

However, here's a little hint: Add the postage costs on to the cost of the servo - you'll see there's not that much difference in price - only 3 rupees between them.  That's about ¢5 or 3p.


Not able to upload any code to Arduino Uno

I have a post Have I bricked my Arduino Uno? Problems with uploading to board - that describes various tests you can carry out to isolate where the problem is.


Arduino and AVR Serial Communication over USB

Turns out the problem was with my Makefile. avr-gcc was missing the -mmcu=atmega328p flag. Once I added that and changed F_CPU to 16000000UL everything works.


What is causing this warning in Arduino IDE?

The warning was caused by this line:

char *monthShort[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

In C++, the content of a character string such as "Jan" cannot be
modified. Thus, if you assign the string to a pointer, the pointer
should be declared as const char *:

const char *monthShort[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
                            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

The same applies to the other arrays of strings: daysLong, daysShort
and monthLong. As a consequence, the prototypes of the methods
getDOWStr() and getMonthStr() should be changed in order to return a
const char *.

BTW, are you sure this library is still maintained? This should have
been fixed a long time ago, and it seems the source was last modified in
2015. You may be better off using a more modern alternative. For
instance, in the Arduino library manager, you can find DS3231 and
Adafruit's RTClib.


Timer (or other) interrupt happens while servicing an interrupt - how to accurately handle the second one?

Q1:

  ... exit the input ISR and interrupts are (automatically?) re-enabled

Yes, the RETI (return from interrupt) instruction enables interrupts.  See third paragraph of section 7.7 in Atmel's document #8271 (a 650-page spec sheet for the Atmega 48, 88, 168, 328 series), which says:

  When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a Return from Interrupt instruction – RETI – is executed.

Q2:

  Assuming the timer is uncomplicated (it wouldn't overflow twice during my input ISR) how do I accurately handle the fact that it overflowed during my input ISR and I "missed" it?

If the timer is running a clock, set the timer control bits to automatically reload the count register upon each overflow (or underflow).  That will leave a full count period for processing each timer interrupt.

That is, you can pre-load a next-timer-count (I think it can be different from the current count if necessary), so the timer can start its next interval automatically.  If the timer is used for some purpose more complicated than that, you may need a nested interrupt.

Q3:

  Would this differ if instead of the timer I simply had a second input2 that similarly might fire during my input1 processing (but would present a useful input long enough to process after input1, presuming I knew it triggered)?

If indeed input2 sticks around long enough to process after input1 processing is done, no problem.  Its interrupt will occur after the first interrupted code sequence executes one more instruction after the RETI occurs.  (See paragraph 6 of section 7.7 in doc8271.)

If input2 is brief, several different things can happen.   (a) If it is shorter than a clock cycle, in general it won't trigger an interrupt.  (b) If it is a level-interrupt-triggering event on INT0 or INT1 that ends while another interrupt is being processed, it won't trigger an interrupt.  (See discussion on page 72, section 13.2.3, of doc8271 of INTF0 and INTF1 being clear for level interrupts.) (c) If it is an interrupt-flag-setting event that sets a flag and ends while another interrupt is being processed, it will trigger an interrupt after the global interrupt flag is set, unless current processing clears its flag.

I think the above accurately states what happens on Atmega devices, but I suggest you also see doc8271 – and run tests – to see for yourself.  Here is part of what paragraphs 4 and 5 of section 7.7 in doc8271 say regarding (b) and (c):

  There are basically two types of interrupts. The first type is triggered by an event that sets the Interrupt Flag.  ... Interrupt Flags can also be cleared by
  writing a logic one to the flag bit position(s) to be cleared. If an interrupt condition occurs while the
  corresponding interrupt enable bit is cleared, the Interrupt Flag will be set and remembered until the interrupt is enabled, or the flag is cleared by software. Similarly, if one or more interrupt conditions occur while the Global Interrupt Enable bit is cleared, the corresponding Interrupt Flag(s) will be set and remembered until the Global Interrupt Enable bit is set, and will then be executed by order of priority.

  The second type of interrupts will trigger as long as the interrupt condition is present. These interrupts do not necessarily have Interrupt Flags. If the interrupt condition disappears before the interrupt is enabled, the
  interrupt will not be triggered.


How do I upload an Arduino STM32 binary from the Mac command line?

There are several different tools for uploading binaries to a Cortex M3.  Depending on the board (not chip) configuration, they include (ht: Majenko):

dfu-util through an FT232 adapter
stm32flash through serial
micronucleus through the Micronucleus bootloader
stlink through an STLink programmer

Many Arduino flavors use a board with some kind of USB or FT232 adapter.  In this case:

the STM32 line of processors include a DFU (device firmware update) bootloader in ROM.

The dfu-util project supports a Mac version of dfu-util, their command line DFU tool.

Note that this answer is identical for any binaries which run on the processor, be they Arduino sketches or programs developed with other frameworks.


How can I transmit data to/from arduino from up to ~750 ft away?

There are a number of considerations that need to be made when considering any wireless communication solution over long distances and over water.

WiFi is capable of working over long distances especially with higher power cards (1W ones are now readily available) and directional antenna (anything from 3dBi to 30dBi of gain). There are advantages and disadvantages to using WiFi like this for your purposes:

WiFi uses 2.4GHz which is attenuated by the presence of water and water vapour. If you are close to the surface of the water surface, this can cause variable range with weather conditions increasing humidity and spray - even slight choppiness can massively increase the humidity close to the surface.
WiFi is a fairly heavyweight protocol that has several layers that need setting up each time a connection is made. This takes time and means marginal connections will have zero throughput as they will never get setup.
WiFi is intended to have high throughput (>1MBps) and doesn't degrade gracefully below this point. There isn't often a need to shift data this fast on an Arduino project. Speed and range are a trade-off.
Directional antenna on boats can be hard work. The more gain an antenna has, the more directional it is, which in turn means you need to aim it better. Even mild rocking can make this difficult to impossible. It depends if you are on a smooth pond or the sea really.

If you do want to go with WiFi, Ubiquiti make some neat products like the Nanostation that allow long range connections to be set-up over long ranges.

Personally I would stay away from 2.4GHz near water, and go with one of the other ISM bands. Depending on your location, this could mean 315MHz 433MHz, 868MHz, or 915MHz. It depends which region of the world you are in which ones you are allowed to use.

These lower frequencies are suited to longer ranges and penetrating object and water. There are a lot of different solutions in this space, all of which have ups and downs.

The Hope RFM12B is a very popular small RF board that has several easy to use libraries available - I use Jeelib personally. These are just capable of the 750ft range you require. They are available in all most ISM bands, and personally I have found the 868MHz best outdoors, whilst the 434MHz is better indoors.

The newer Hope RFM69W is a similar board but with more functionality and more power. It has 13dBm (20mW) of power vs 0dBm (1mW) of power on the RFM12B. I have been seeing an increase in range of ~50-100% with these boards.

The RFM69HW is a high power version has 20dBm (100mW) of power. I haven't range tested this, but would expect up to 3-4 times the range of an RFM12B.

Ciseco, a UK company, also make a series of boards that use CC1110 chips as transceivers. These are in an XBee like form. One of their boards, the ARF, has a power amplifier. These have 26dBm output power (400mW) and in a brief test in a built up area, I have seen a range of about 2km.

It's important to note that these are transceivers so that they can send and receive, which means you can acknowledge if packets have been received.

There are boards like the nRF2401L which use 2.4GHz, but use a much lighter weight protocol than WiFi so work better on marginal ranges. They are dirt cheap (~£2). They have the same disadvantage of water impacting range.

I don't like Xbee at all. The boards are overpriced and I find the range isn't great even with the higher powered modules.

You could also "roll your own" and use simple 434/868/915MHz on-off-keyed (OOK) transmitter/receivers. Protocol design isn't easy though, and you lose a lot of hidden functionality that the more advanced boards have.


How can I burn the bootloader onto atmega328 (not atmega328p)?

How can I burn the bootloader onto ATmega328 (not ATmega328P)?

As Juarj commented, For a variety of standalone AVR microcontrollers you can add new "cores" to the Arduino IDE using it's board manager.
This provides the Arduino IDE with information about your specific chip and this means the IDE can instruct the avrdude program appropriately and select a bootloader image that was written to support your specific chip
The Minicore documentation says it supports all variants of ATmega328
Other well-known examples of cores for bare AVR microcontroller chips  include ATtinycore which supports a wide range of ATtiny microcontroller chips like the popular ATtiny85.


An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this:

8 relay module

Just connect all 8 valves to the relays, you power the relay with a separate source for the valves, and connect the pins to the Arduino.

These ones have opto couplers, which give an extra security between the valves and the Arduino.

8 relay module with opto couplers
(note I just put the first entry I found, you might find better/cheaper similar items, e.g. at AliExpress for $4).

As Andre said in a comment below, you can use an Arduino Mega if you need more outputs. Or if you want a challenge you can use use a multiplexer IC like 74HC595 (plenty of examples to be found with Arduino).

For controlling one relay with an Arduino enough examples can be found, for 8 it's similar (just use 8 GPIOs), or a multiplexer IC.


NRF24l01 with Atmega 32u4 and internal clock

You ask a yes/no question, to which the answer is yes, nRF24L01 as a serial peripheral device will work as well as if you had used an Arduino UNO or any other microcontroller, provided the SPI bus is correctly initialized.

Generally you want the following in the setup() part of your sketch/program:

  pinMode(CE_pin, OUTPUT);//chip enable set as output
  pinMode(CSN_pin, OUTPUT);//chip select pin as output
  pinMode(MOSI_pin, OUTPUT);//SPI data out
  pinMode(MISO_pin, INPUT); //SPI data in
  pinMode(SCK_pin, OUTPUT);//SPI clock out

  digitalWrite(CSN_pin, HIGH);//SPI idle
  digitalWrite(CE_pin, LOW);

  SPI.setBitOrder(MSBFIRST);//SPI Most Significant Bit First
  SPI.setDataMode(SPI_MODE0);// Mode 0 Rising edge of data, keep clock low
  SPI.setClockDivider(SPI_CLOCK_DIV2);//Run the data in at 16MHz/2 - 8MHz
  SPI.begin();//start up SPI library


This is what I came up with. Note that the ReadLimits function is called after ReadAnalog and before runSpeed. In that order the stepper will not move in the direction of the limit switch, if it is pressed.
PS since you used setAcceleration, don't you need to call run instead of runSpeed?
void loop()
{
  ReadAnalog();
  ReadLimits();
  stepper.runSpeed(); //step the motor (this will step the motor by 1 step at each loop indefinitely)
}

void ReadLimits()
{
  if( digitalRead(2)==LOW && stepper.speed()>0 )//read input, assuming they have pull-up resistors.
  {
    stepper.setSpeed(0);
  }

  if( digitalRead(3)==LOW && stepper.speed()<0 )//read input, assuming they have pull-up resistors.
  {
    stepper.setSpeed(0);
  }
}

edit to avoid some confusion; here is the entire code with my suggestion embedded:
#include <AccelStepper.h> // accelstepper library
AccelStepper stepper(1, 8, 9); // direction Digital 9 (CCW), pulses Digital 8 (CLK)

//Pins
const byte Analog_X_pin = A0; // x-axis readings
const byte enablePin = 7;

//Variables
int Analog_X = 0;             //x-axis value
int Analog_X_AVG = 0;         //x-axis value average
  //----------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  //----------------------------------------------------------------------------
  //PINS
  pinMode(Analog_X_pin, INPUT);
  pinMode(enablePin, OUTPUT);
  //----------------------------------------------------------------------------
  InitialValues(); // averaging the values of the 3 analog pins (values from potmeters)
  //----------------------------------------------------------------------------
  // Stepper parameters
  // setting up some default values for maximum speed and maximum acceleration
  stepper.setMaxSpeed(2000);     //SPEED = Steps / second
  stepper.setAcceleration(1000); //ACCELERATION = Steps /(second)^2
  stepper.setSpeed(1000);
  delay(1000);
}

void loop()
{
  ReadAnalog();
  ReadLimits();
  stepper.runSpeed(); //step the motor (this will step the motor by 1 step at each loop indefinitely)
}

void ReadLimits()
{
  if( digitalRead(2)==LOW && stepper.speed()>0 )//read input, assuming they have pull-up resistors.
  {
    stepper.setSpeed(0);
  }

  if( digitalRead(3)==LOW && stepper.speed()<0 )//read input, assuming they have pull-up resistors.
  {
    stepper.setSpeed(0);
  }
}

void ReadAnalog() {
  if (abs(Analog_X-Analog_X_AVG) > 50) {
    digitalWrite(enablePin, HIGH);  // enable the driver
    stepper.setSpeed(5*(Analog_X-Analog_X_AVG));
  } else {
    digitalWrite(enablePin, LOW);   // disable the driver
    stepper.setSpeed(0);
  }
  // Reading the potentiometer in the joystick:
  Analog_X = analogRead(Analog_X_pin);
  // if the value is 25 "value away" from the average (midpoint), we allow the update of the speed
  // This is a sort of a filter for the inaccuracy of the reading
  if (abs(Analog_X-Analog_X_AVG) > 50) {
    stepper.setSpeed(5 * (Analog_X-Analog_X_AVG));
  } else {
    stepper.setSpeed(0);
  }
}

void InitialValues() {
  //Set the values to zero before averaging
  float tempX = 0;
  //----------------------------------------------------------------------------
  // read the analog 50x, then calculate an average.
  // they will be the reference values
  for (int i = 0; i<50; i++) {
    tempX += analogRead(Analog_X_pin);
    delay(10); //allowing a little time between two readings
  }
  //----------------------------------------------------------------------------
  Analog_X_AVG = tempX/50;
  //----------------------------------------------------------------------------
  Serial.print("AVG_X: ");
  Serial.println(Analog_X_AVG);
  Serial.println("Calibration finished");
}


How to move a servo quickly and without delay function

The quickest way possible from LightON to LightOFF is simply servo1.write(lightOFF); without loops or delays, in one go; no need to do it degree by degree. For example:
int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 <= lightON; pos1++) {
  servo1.write(pos1);
  delay(15);
}

servo1.write(lightOFF);

If you want it to move a few degrees every loop and do other things in the loop while it moves, you can time it with millis() instead of delay(). The code below should move the servo 5 degrees every 0.5s:
int moveTime = 500; // Move every 0.5s
unsigned long int startMillis = 0;
int position = lightOFF;
int step = 5; // Move 5 degrees

void loop() {
  if (millis() - startMillis >= moveTime) {
    servo1.write(position);
    if (position <= lightON) {
      position = position + step;
    }
    startMillis = millis();
  }
  // Do other things
}

Untested and incomplete, but you get the idea.


I would make it myself.

One way to do it:

Create an enum with all states, like Normal, ChangeMonth, ChangeDay, ChangeHour, ChangeMinute };
Use one button to increase the item you are changing with 1
Use the other button go to go the next enum

You can make it fancier by using longer/shorter presses (e.g. to increase faster)

Don't forget to debounce button inputs.


Your IF statement, you're using: (val = 0), and I believe you meant (val == 0).

Also, you're using else(val > 0) and else doesn't need any argument. So the fixed code should look like:

int sidepin = 2;
int LED = 5;
int val;
void setup() {
  pinMode(sidepin, INPUT);
  pinMode(LED, OUTPUT);
}

void loop() {
  val = digitalRead(sidepin);
  if(val == LOW)
  {
    pinMode(LED, HIGH);
  }
  else
  {
    pinMode(LED, LOW);
  }
}


Using Arduino Uno as ISP to program Mega 2560

Find the file called "boards.txt" located in your Arduino installation directory. In my case, the path is "arduino-1.6.5/hardware/arduino/avr/boards.txt". Open it with your favourite text editor and locate the ATMEGA2560 section. (not in notepad, it breaks the file format, notepad++ my choice)

in boards.txt

back-up the file incase you break it,
find the line :
mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8
and change it with :
mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9

Source : http://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega/#rating-74


Connecting button as PC usb input via arduino

This is a great tutorial on exactly what you want to achieve:

http://mitchtech.net/arduino-usb-hid-keyboard/


Accessing a C++ static variable from gcc inline asm

Try this:

asm volatile("lds r24, %0" : : "i" (&Driver.ISR_param));

The "i" constraint means you provide an integer constant. It can be
any integer, unlike the uppercase "I" constraint which is limited to
6-bit positive integers.

Addendum:
The constraints supported by gcc are listed in the gcc documentation,
section Constraints for asm Operands:

The "i" constraint is listed in the subsection “Simple Constraints”
and is described as:

  An immediate integer operand (one with constant value) is allowed.
  This includes symbolic constants whose values will be known only at
  assembly time or later.

The "I" constraint is in the subsection “Machine Constraints” and,
for the AVR architecture, is defined as

  Constant greater than -1, less than 64.


Arduino drawing a bitmap on nokia 5110 lcd

The 21 and 18 are the dimensions of the image. It's not just pixels though.

The first number (21) is the number of bytes in a row of the image - that is one eighth of the width in pixels.  The width must be a multiple of 8.

The second number is the number of rows in the image - basically the height in pixels.

The two numbers, when multiplied together, must equal the number of bytes in your array.

From the documentation:

  Description

  Draw a bitmap at the specified x/y position (upper left corner of the bitmap). Parts of the bitmap may be outside the display boundaries. The bitmap is specified by the array bitmap. A cleared bit means: Do not draw a pixel. A set bit inside the array means: Write pixel with the current color index. For a monochrome display, the color index 0 will usually clear a pixel and the color index 1 will set a pixel.

  Arguments:

  u8g : Pointer to the u8g structure (C interface only).
  x: X-position (left position of the bitmap).
  y: Y-position (upper position of the bitmap).
  cnt: Number of bytes of the bitmap in horizontal direction. The width of the bitmap is cnt*8.
  h: Height of the bitmap.

It would appear your image data is complete gibberish.  This is what I decode it to be:

 ######  #     #  #
 ###   # # ####  #    #
  # ## #  #  #     #
   ## ##   #  #    #
   #      ##     #
 #   #  #  ## #####

        #        ####
#   #   #    #   #   #
  # #   ## ###    # # ##
# #  #  #  # #     # ##
   # # #   # # #  # ###
  ##    ##


As a fundamental principle of design you should not be expecting to receive multiple characters in the ISR.

The interrupt fires when a character has been received, so that is all your program should count on finding.  You can if you really want to poll the UART when you are done reading the first character and see if another has arrived, but there would generally not be time for that to have happened and you definitely should not be waiting for it in the ISR.  Rather, if the ultimate consuming code needs multiple characters, then that should hold off executing dependent code until multiple invocations of the ISR have resulted in the collection of the needed number of characters.

Things can get a little more complicated on parts with multi-stage UART FIFOs, but that is not the case here.


Arduino Mega and other modules power consumption

You can't fix it with more voltage. The board you are using (schematic here) uses a linear voltage regulator. All increasing the voltage does is make the regulator run hotter.

You could try running from around 7V, this will minimize the heat dissipation in the regulator and may allow you to pull more current through it but I suspect you've simply hit the design limits of the power supply circuits.

Instead of using the Arduino's built in power supply to convert from 12V to 5V you could try using an external 5V supply with a greater current capability connected directly to the Arduino 5V rail.


DS1307RTC Outputting cryptic 165/165/2165 date. What are some possible fixes?

Put in the following line in void setup():

Wire.begin();

(Assuming Wire library has been included.)
This will set up the I2C connection between the Master (Arduino) and the Slave (RTC).

For more generic use, the syntax is: Wire.begin(address);

The complete code is:

void setup () {
  Wire.begin();
  Serial.begin(9600);
  //rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // UNCOMMENT TO SET TIME & DATE TO THAT AT COMPILATION.
  //rtc.adjust(DateTime(2017, 8, 31, 14, 45, 14 )); // UNCOMMENT TO SET TIME & DATE MANUALLY. (YEAR, MONTH, DAY, 24-HOUR, MINUTE, SECOND)

}


Direct port manipulation to write 40 bits

I have few SPI ADC which have forced SPI bus down to 1 Mhz. I understand that the shiftout works at 14Khz which is too slow.

You can change the SPI speed at any time. Once the device is selected (Slave Select asserted) then reconfigure the SPI bus for high speed operation.

eg.

SPI.setClockDivider(SPI_CLOCK_DIV2);

SPI is definitely the fastest way you can communicate with a shift register.


Can't compile my library because "String does not name a type"

Your syntax is wrong in myESP.cpp. Change this:

myESP::String macToStr(const uint8_t* mac) {
}

myESP::String doGet(String data, String sensor, int duration) {

}

to this:

String myESP::macToStr(const uint8_t* mac) {
}

String myESP::doGet(String data, String sensor, int duration) {

}

The return type is String and the function implementation should be prefixed with the class name myESP::. Obviously, you also need to fill in the body of the implementation or you'll get more errors because you don't actually return anything.


You can do something like

void loop(void) {
    u8g2_uint_t x;

    u8g2.firstPage();
    do {

        // draw the scrolling text at current offset
        x = offset;
        u8g2.setFont(u8g2_font_inb30_mr);       // set the target font
        do {                                // repeated drawing of the scrolling text...
            u8g2.drawUTF8(x, 30, text);         // draw the scolling text
            x += width;                     // add the pixel width of the scrolling text
        } while( x < u8g2.getDisplayWidth() );      // draw again until the complete display is filled

        u8g2.setFont(u8g2_font_inb16_mr);       // draw the current pixel width
        u8g2.setCursor(0, 58);
        u8g2.print(width);                  // this value must be lesser than 128 unless U8G2_16BIT is set

    } while ( u8g2.nextPage() );

    offset-=1;                          // scroll by one pixel
    if ( (u8g2_uint_t)offset < (u8g2_uint_t)-width )
        offset = 0;                         // start over again

    delay(10);                          // do some small delay
}

this is taken from here.

It is an excellent lib, but it is can require big amount of memory, fit very well on ESP8266 (tried on nodeMCU) / ESP32.

Of course on ESP32 it is faster.

Used for small OLED 0.98" screen


Arduino IDE, Underlying Code and Libraries

Just check the source code. Specifically look at Arduino.h, main.cpp and wiring*.

These files should also be present in the Arduino application folder somewhere, but you'll have to go through quite a few subfolders to find them.

The different boards have different .h file that will specify the pin-numbers and other chip specific data.

The "auto detect" functionality is done by keywords.txt files. At least for libraries. That way if you install a new library with keywords.txt file, the library functions-names are recognized.

The processes of taking all these files, and the users code, and compile it all whole story on it's own.


What about the amperage? (I guess that the max amperage of the USB power supply is divided between the board and sensors/actuators connected). How does it compare with the VCC output of, let say, an Arduino UNO?

The 5V pin is connected directly to the 5V of the USB. Whatever your USB port can provide the 5V can provide, minus the current used by the ESP8266.

  How important is in most practical cases not having exactly 5V? (clearly, I am not considering using the sensors for extremely accurate measurements). I am interested in things like movements/distance/light/accelerometers/humidity etc. sensors and LCD displays, relays, small motors, etc..

That all depends on the device. Read the datasheet. Look at the Electrical Characteristics. It will tell you the recommended (and the absolute maximum) voltage range.

  Is there a better yet simple way to connect 5V devices to this board?

Again, it all depends on the devices. Many many devices that are marketed as 5V are in fact "anything from 2.8V to 5.5V" or something like that. Read the datasheets!

The NodeMCU is a tricky board to use with 5V because there is no isolation between the USB power and the 5V pin's power. You can't power the board through the 5V pin and still be able to use the USB port or you risk destroying the USB port or computer that the NodeMCU is plugged into.  If possible you really want to be running as many 3.3V devices as you can, or to keep any external 5V supplies completely separate (except ground, of course) from the 5V of the NodeMCU.


Compiling Assembly Script in External EEPROM to Arduino Code

I would suggest you investigate a different micro with external addressing or one that loads its code from an external memory such as flash like the ESP32s do.


Problem with reading multiple potentiometer values on Arduino Uno

One problem is that if the value for pot1 has not changed, the value for pot2 will never be sent, even if it has changed, due to the early return when checking the value of pot1. You could fix this by changing to:

void readAndSendPotentiometerDataIfChanged(void) {

  //Potentiometer One
  int newPotentiometerOneValue = analogRead(A0) / 10.2;
  if (newPotentiometerOneValue != lastPotentiometerOneValue) {
      Serial.print("!pos1");
      Serial.print(newPotentiometerOneValue);
      Serial.print(";");
      lastPotentiometerOneValue = newPotentiometerOneValue;
  }

  //Potentiometer Two
  int newPotentiometerTwoValue = analogRead(A1) / 10.2;
  if (newPotentiometerTwoValue != lastPotentiometerTwoValue) {
      Serial.print("!pos2");
      Serial.print(newPotentiometerTwoValue);
      Serial.print(";");
      lastPotentiometerTwoValue = newPotentiometerTwoValue;
  }
}


Write your own program to control Arduino Uno

Most of the time I wrote code for arduino on codeblocks.

The other times on sublime text.

So the answer is yes.


An interrupt can not always stop the code, although that is almost always the case. Certainly having an interrupt based kill switch would be better than a "regular code" polled one, which would still be better than nothing. If possible I would feel safest with a cut-power-to-the-whole-thing style safety switch.

Many functions that have sensitive timing constrains disable interrupts while they are active. It is rare for any of these to take a noticable amount of time, but it is possible that a bug in an interrupt dissabled function or another interrupt function could cause it to block and in that case your stop switch wouldn't work. rare, but possible.

I suppose you could turn on the chip watchdog timer, have a regular timer based interrupt reset the watchdog timer at a certain interval, and have your interrupt safety switch enabled. Then if interrupts ever stopped firing for too long the chip would reset itself. Checkout AVR132: Using the Enhanced Watchdog Timer. I've never used the watchdog myself, but it exists for a reason.

I don't have enough experience with a scheduler system to know if they would be helpful.


All my code does is stop the motors when the front sensor detects a wall. My next step is to implement the encoders to give the robot a 90 degree turn.

would this work?

  if (wall_sensed()) turn_90right(); //if wall is sensed, turn 90 degrees to the right

You may also consider change

  digitalWrite(5,LOW);
  digitalWrite(6,LOW);

to:

  digitalWrite(MOTOR_LF,STOP);   //stop left front motor
  digitalWrite(MOTOR_LR,STOP);   //stop left right motor

so that

it is a lot more readable; and
if you were to change pin assignment, it is done consistently throughout your code.


Is there any limitation with Arduino Nano serial communication distance?

For that sort of difference you are better using RS-485 instead of UART.  UART is really only designed for short-distance communication.

Converting UART to RS-232 will give an improvement, but switching to RS-485 instead will give you the ability to create a multi-drop bus for connecting more than two Arduinos together over a long distance.

UART uses 5V logic level signalling (on the normal Arduinos - 3.3V on most 32-bit boards). It has a "weak drive" and is highly susceptible to induced noise over longer distances.
RS-232 uses ±10V "Non Return to Zero" signalling. This gives far greater immunity to noise and a stronger drive for greater distances.
RS-485 (and the associated peer-to-peer RS-422) use differential signalling. This gives the greatest immunity to noise over the longest distances.

In summary:

RS-232 can be used if you only want to connect two devices together in a low noise environment.
RS-422 can be used to connect two devices together in a high noise (industrial) environment.
RS-485 can be used to connect lots of devices together in a high noise environment.

For more information on how they work there are some good Wikipedia pages:

RS-232
RS-422
RS-485

For interfacing any of these to an Arduino you will need extra hardware ("Driver Chips"). For example:

RS-232: MAX232
RS-422: MAX1184
RS-485: MAX485

There is also "CAN", which is a more modern replacement for RS-485 and is used in many industrial and automotive environments. As this is a newer technology than RS-485 there are fewer resources available and "initial cost to entry" can be higher.


My personal experience as professor (programming, mechatronics) is that if you have previous programming experience and you are aware of concepts as OOP, it is better to go for C/C++. The arduino language is really great for beginners, but have some limitations (e.g. you must have all your files in the same folder). And it is basically a simplification of C/C++ (you can practically copy&paste arduino code to a C/C++ file, and it will work). Also it makes sense that you can go and use a full well known IDE as eclipse:

http://playground.arduino.cc/Code/Eclipse

Initially it is required a bit more of setup and configuration of your dev environment, but IMHO it is worth it for programmers with experience in any other language.

In any case, it won't harm you to start using the arduino language and the arduino IDE for a few days to get familiar with the arduino hardware and then move to C/C++ with Eclipse for really developing your project.


Send data using Arduino GSM shield GET/POST/PUT?

Your GET request is ill-formed. Based on your server's API docs, it should look like this instead:

Serial.println("connecting...");
client.print("GET /api/data?api_key=c3ce75cc23386ca4ca663c******&attributes={");
client.print("\"ldr1\":" + String(ldr1));
client.print("}");
client.println(" HTTP/1.1");
client.println("Host: api.geeknesia.com");
client.println();

While it is technically not illegal to have a body in a GET request, according to the HTTP 1.1 specs, the body should have no effect on the server's response i.e. it should be basically meaningless. Your server's API docs indicate that a body isn't needed/supported when you send data with GET, as is the case with most other servers.

You should consider replacing Arduino Strings with C char arrays; they're a lot safer and reliable.


Why is setup() executed twice at runtime?

It isn't, it's displaying the previous message from when you didn't have the Serial Monitor open yet, plus the new message caused by the Arduino resetting from the Serial Monitor being opened.

If you put a longer message in there you'll probably see the first line get cut off and then the full line.


Transistor as switch for signal and high current buzzer

I'll try to answer your post with "just words" and we will see how it goes. If it is not clear to you, i will post small schematic.

I do not recommend the first schematic that you posted.
You will likely reverse bias the BE (base emitter) junction with 12v. Most bipolar transistors have a maximum reverse BE bias of 5 v.

I do recommend using bipolar so that you dont have to study, understand the range of turn on voltages for a MOS transistor.

The bipolar is always 0.6v
and a Darlington bipolar is twice that.

Also, i dont know why you have the 100nF caps in there. They will guarantee a surge, everytime you turn the circuit on and hence put noise on your supply bus.

When I design a driver for a similar application i frequently use a TIP100 (https://www.digikey.com/product-detail/en/on-semiconductor/TIP100G/TIP100GOS-ND/1485300)

So use the basic design of your second circuit but use the TIP100.

ALWAYS have a resistor (10k ohms or so) to keep the leakage current (Icbo) from turning on the transistor when you dont want it on !

I would put all the loads into the Collector circuit in your second schematic, rather than make the uP drive your LED.

If your load is at all inductive (a coil) then ALWAYS put a reverse-biased diode across the load to catch any inductive kick back.

If this is all Greek to you, then just say so and I will draw a simple universal circuit that will work for 3.3v drive or 12v drive.

All the Best to you.
RP


Can I read from a memory card with three pins?

Not with an ATTiny85, and not with so few pins, no.

However, all is not lost.

The ATTint85 has 512 bytes of EEPROM inside it where you can store your login details. All you need is some way of telling setting that data in your sketch from the PC - and the simplest way is probably through a USB serial connection.

If you don't have a serial connection available (I think Digispark has a custom interface they use) then you can use whatever interface you have available to do the job.


How do I use digital pin on sensor to analog on arduino uno

PWM stands for Puls Width Modulation and is only available when the Digital Pin is in OUTPUT mode.

And YES, you can connect the flame sensor's D0 to any digital pin on the Arduino.

And yes it is possible to connect the flame sensor's D0 to a analog pin, but why not use the A0 from the flame sensor and connect it toi a analog pin on the Arduino?


report.keys = keys; // This is my main trouble

You can't assign the contents of one array to the contents of another array.  You can only copy the contents manually from one to the other.

The simplest way is with a loop:

for (int i = 0; i < 6; i++) {
    report.keys[i] = keys[i];
}

There is a helper function - memcpy() - which can do it for you if you prefer:

memcpy(report.keys, keys, 6);

It effectively does exactly the same thing - copy 6 bytes starting from the address of keys into the addresses starting at report.keys.

As for the "hard coded" reports I suggest you create some const arrays in the global context - and even use PROGMEM to ensure they consume no RAM. That, of course, requires an entirely different way of passing and accessing the data.  It may be simpler to split the report into 6 individual variables and pass each byte separately:

void sendKey(byte k0, byte k1, byte k2, byte k3,
             byte k4, byte k5, byte modifiers)
{
  KeyReport report = {0};

  report.keys[0] = k0;
  report.keys[1] = k1;
  report.keys[2] = k2;
  report.keys[3] = k3;
  report.keys[4] = k4;
  report.keys[5] = k5;
  report.modifiers = modifiers;
  report.reserved = 1;
  Keyboard.sendReport(&report);
}

sendKey(0x17, 0, 0, 0, 0, 0, 0x05);

Yes, it's a little more long winded in the function, but calling the function is somewhat more simplified over the other options.


How to use while loop in arduino for infinte loop

The find method reads the characters until the searched string is found or a timeout interval is passed.

In your case if the connection is not successful, the first find will not find "WIFI" and will read all the input including the "+CWJAP:3", then on timeout it returns false. The second find will wait until timeout and then return false.


First, you need to know how the LEDs are arranged. There are 8 layers, each with 8 rows, each with 8 LEDs.

Each LED is represented as a single bit inside unsigned char cube[8][8]; - the first [8] is the array of layers, the second [8] is the array of rows, and the unsigned char holds 8 bits to represent the state of the 8 LEDs in that row.

Each LED layer has one MAX7219 8x8 LED Matrix Controller. To tell it what to do you need to give it a Command byte and a Data byte. So to tell it to light up LEDs 1, 2, and 7 on the fourth row, you need to tell it 0x04 0x86. You send this command by setting CS LOW, sending the 16 bits of the Command+Data, then setting CS HIGH.

Each MAX7219 is connected one after the other in an SPI string. To command all of them at once you need to set CS LOW, send 16 bits for each MAX7219 (128 bits in all), then set CS HIGH. If you only want to command one MAX7219, you need to send a NOP Command+Data (0x00 0x00) to all the others.

The way the program works is:

setup()

a. Initialise the Serial port, and print a message.
b. Set the CS pin as an OUTPUT, then initialise SPI.
c. Initialise all the MAX7219 chips by sending a series of commands -
the same Command+Data to each of them (maxTransferAll()).
d. Initialise the Timer interrupt (setUpInterrupts()).
loop()
This isn't shown in the code. Presumably it alters the cube[8][8] array to make the special effects.
TIMER1_COMPA_vect (the interrupt handler)
Every time the timer ticks, the handler will command all of the MAX7219s to show the next row of LEDs.  This will last until the next timer tick, when the next row will be displayed. If this is done fast enough, the human eye's "persistence of vision" will not see the rows flickering.

For each row (`y`) in the `cube` array
   Set `b` to 0
   For each bit ('x') in the `cube` data
      If the bit is set (`getvoxel(...)`) set a bit in `b`.
   Store `b` in the `value[y]` array

value now holds the bytes needed as Data for the next row for each of the MAX7219 chips.

    Send value over SPI using `maxTransferLEDCube(...)`

Since the cube displays the same row for each layer simultaneously, the Command doesn't have to change, only the Data does. That's what the value array holds: the Data to be sent to each MAX7219 chip.


Using same pins number in different arduino?

The notion that “both Arduinos are in the same sketch” is slightly off.  Each of the Arduinos will contain a program; their programs might be identical if you do some fancy programming, but it is simpler to write one sketch per Arduino.

Thus, your first Arduino will run a sketch designed to control the devices it is connected to, and your second Arduino will run a sketch designed to control the devices that it's connected to.  Conceivably, you might have some devices that both Arduinos connect to.

Calling the two sketches S1 and S2, the device on pin number n as referred to in S1 will typically be a different device than the one on pin number n as referred to in S2.  Most but not all of the pin usage assignments for each pin number will be different in one sketch versus the other.

It's likely the two Arduinos will need to communicate with each other.  For a range of methods, see for example  How to have an Arduino communicate with 3 other Arduinos.  For additional detail see Arduino-to-Arduino serial communication and How to network many Arduinos with sensors using I2C.

If you decide to use I2C, then also see MasterWriter Tutorial and Wire Library webpages at arduino.cc.


Uploading .hex to ATTiny13 using Arduino

Your computer cannot talk directly to the ATtiny. You need some piece of
interfacing hardware between them. This is called an ICSP (or ISP)
programmer. You also need software to drive the programmer, typically
avrdude.

If you do not have a programmer, you can buy one (I had success with
some very cheap USBASPs), or you can program an Arduino Uno to behave
like an ISP programmer. You do this by uploading into the Arduino a
program called ArduinoISP, like explained in the tutorial Using an
Arduino as an AVR ISP (In-System
Programmer). You will
typically use the Arduino IDE and the Arduino core for the Uno to
compile and load ArduinoISP into your Uno. Once this is done, you can
use the Arduino as a programmer and burn your .hex into your ATtiny.

If you want to compile your own programs for the ATtiny, you will need
the avr-gcc compiler and the avr-libc. These are bundled with the
Arduino IDE, so you already have them. You will need an Arduino core for
the ATtiny only if you want to use the Arduino APIs and libraries.
Otherwise you can write plain C programs with noting else than the
avr-libc and avr-gcc.

Edit: To compile a plain C program, you can type something like
this:

avr-gcc -mmcu=attiny13a -DF_CPU=1200000 -Os -Wall -Wextra flickled.c -o flickled.elf
avr-objcopy -O ihex flickled.elf flickled.hex

This assumes your source file is called flickled.c and your ATtiny
runs at 1.2 MHz.


You could use a rotary encoder for that purpose!

Basically the rotary encoder is a knob that, for every "tick" you give it, it returns a different value to your Arduino. With a bit of programming you can sense the direction of the turn, if it is positive then you lighten up the LED, and vice versa.

I used that to control a RGB led, it works very well! here some more information on the rotary encoder and the code needed to use it.


Start I2C communication at an external event

You could set a 'volatile' flag in the interrupt routine. In the loop() you can check if the flag is set. That is how the i2dev uses the interrupt for the MPU-6050. See the MPU6050_DMP6.ino example.

First thing to do is set the I2C clock to 400 kHz. Keep the wires short and pullup resistors low.

Wire.begin();
Wire.setClock(400000L);   // 400 kHz I2C clock speed

You can let the MultiSpeed I2C Scanner run for a while to see if it is stable.

The ADS1115 has also I2C High-Speed Mode up to 3.4MHz. The Arduino can not do that. The Arduino has a fast SPI mode, but the ADS1115 has no SPI bus.

Using an interrupt adds extra overhead. A fixed software timer with millis might be just as fast.

Do you want the maximum of 860 Samples per second? The Arduino Uno or Mega or Leonardo are too slow for that. Do you want to continuously read data or just a burst and store it in ram ?


How to send MFRC522 data to a C# app using a NodeMCU TCP server?

MFRC522::uid is a struct (see source code). There's no defined way to print it.

If you want to write the raw bytes over the TCP connection, you can just use

client.write((uint8_t*)mfrc522.uid.uidByte, mfrc522.uid.size);

If you want to write it as ASCII text, you can use the following:

void byte_to_str(char* buff, uint8_t val) {  // convert an 8-bit byte to a string of 2 hexadecimal characters
  buff[0] = nibble_to_hex(val >> 4);
  buff[1] = nibble_to_hex(val);
}

char nibble_to_hex(uint8_t nibble) {  // convert a 4-bit nibble to a hexadecimal character
  nibble &= 0xF;
  return nibble > 9 ? nibble - 10 + 'A' : nibble + '0';
}

void printHEX(Stream &s, uint8_t *data, size_t length) {
  char *buffer = new char[length*2];
  for (size_t i = 0; i < length; i++) {
    byte_to_str(&buffer[i*2], data[i]);
  }
  s.write(buffer, length*2);
  delete[] buffer;
}

Then use it like this:

  printHEX(client, mfrc522.uid.uidByte, mfrc522.uid.size);

It loops over all bytes in the UID, converts them to ASCII (hexadecimal representation, so 2 characters per byte), and then writes the text over the TCP connection.

(Note that there are many other problems with your code as well, e.g. the includes are missing the opening '<'.)


Transistor amplifier to drive speaker using Arduino PWM

Your amplifier arrangement is fundamentally flawed. At the moment you are "tickling" the top end of the electromagnet in the speaker - that is, you are energising it when the Arduino outputs a HIGH, and leaving it energised to de-energise by itself when the Arduino outputs a LOW.  Coupled with that the fact that a PCM file outputs PWM with a carrier frequency much higher than a tone() function (and ideally above human hearing frequencies) you end up with almost nothing happening on the speaker.

The classic Class A amplifier has a different arrangement:

simulate this circuit – Schematic created using CircuitLab

With that arrangement the transistor and R1 form a simple RTL inverter. Size R1 to give the output current you need for your speaker (lower resistor = more power = more heat = bigger transistor as well). R3 and C2 remove the high frequency switching from the PWM (you could also replace R3 with a suitable inductor if you want less losses from the resistor). C1 removes the DC offset from the signal to give the full swing to the speaker and prevent excess clipping and heating.

It's not an efficient design by any means. A better "first stage" (replacing R1 and Q1) would be a high drive output logic gate (one of the CD4000 series, since it can run from 12V). I have seen AND gates used before - this also gives the benefit that you can use the second input to the AND gate as a MUTE signal. The rest (R3, C1, C2) remains the same.

The advantage of using a logic chip instead of the RTL arrangement is that it gives a more efficient "Push-Pull" output which can deliver much more current with far less heat losses.

Instead of the speaker you could connect an audio power amplifier to the output of C1 to then drive a more powerful speaker. In this case you can most likely remove the first stage (Q1/R1/R2) and drive the RC filter directly from the Arduino.


The 6-12V range applies only to the onboard voltage regulator(if you provide power via Vin or the barrel jack). The Arduino itself runs on 5V and the regulator needs a bit headroom above that to do the regulation.
You can run the Arduino via USB, since it has 5V, just as needed by the Arduino
And you can provide power directly to the 5V pin (with a voltage of 5V or course).
If some of your components draw a lot of power, you should never draw that current through the Arduino. You need to connect the power supply in parallel to your components and the Arduino, so that the high currents can flow past the Arduino, not through it.


You have the receive port on your arduino connected to the receive port on your bluetooth module. Connect pin 5 to the Tx on your module and connect pin 6 to the Rx on your module.


the arduino software is looking for spi.h in a example code

"SPI.h: No such file or directory." Now I added an SPI folder in the libraries but after verifying it shows another error. I did the same thing to others but the compiler is looking for more and more files. What can I do? By the way, I'm using a Gizduino+ w/ ATmega644.

Did you check the product web-page for the IDE patch. You must install the core for this Arduino clone. There might be some issues with which version of the IDE to use and what version of the library. Check the product web-page for more details.

Your question is too product specific and this is not that type of support page.

Cheers!


Solved!

It was a (big) silly mistake of my own. I overloocked the init() function right after entering the main() function. I'm shure it initializes the hardware and the entire system, so my board stucks when I skipped it.

So my code now looks like this:

#include <Arduino.h>

const int LED_PIN = 13;

int main(void)
{
    init();

#if defined (USBCON)
    USBDevice.attach();
#endif

    pinMode(LED_PIN, OUTPUT);

    while (1)
    {

        digitalWrite(LED_PIN, HIGH);
        delay(100);
        digitalWrite(LED_PIN, LOW);
        delay(900);

        if (serialEventRun) serialEventRun();
    }

    return 0;
}

BTW, the mix: Arduino + Vim + ino, rocks! Now I can do whatever I want from the console :)


Which board has the highest max current via 3.3v pin?

Your USB will output only 500mA or max to max 1A in some cases. Even if your board is rated for higher output you will be restricted by your source. First step is to increase your source. Secondly check which 3.3V regulator is present on which board and check the datasheet of the regulator to get information about it.
Either ways you can externally add a high current 3.3V regulator and connect it to your 3.3V pin on the arduino. As voltages are equal no current will flow between them.
But remember your source needs to output the higher current first


Trying to turn off fading RGB LED after 30 secs

Here is a little snippet of logic that you can implement in your code :

if(millis() - getOutOfSleepTime >= 30000) {
    activateSleepMode();
    while(!buttonPress);
    getOutOfSleepMode();
    getOutOfSleepTime = millis();
}

if(buttonPress)
    activateSleepMode();


As I mentioned in the comments, reinstalling/updating all your 3rd party libraries to the latest versions is probably the first thing to try. Updating the IDE itself may also help.

If that hasn't worked then a forum topic here seems to describe the same kind of issue: http://forum.arduino.cc/index.php?topic=168854.0

One of the users seems to have tracked the problem down to a couple of Adafruit libraries. He suggests the following:

  1) Delete the folder "Robot_Control" from Program
  Files\Arduino\libraries\

  2) Make sure, that the two Adafruit folders in the same folder are
  named Adafruit_GFX and Adafruit_ST7735. I had them named "AdafruitGFX"
  and "AdafruitST7735", but that was wrong.

Deleting the Robot_Control folder doesn't sound like an ideal solution to me, but perhaps there's an incompatibility which can't be easily fixed. Unfortunately, the Arduino IDE handles libraries in a slightly strange way, so weird problems can happen from time to time.


Arduino Yun USB host - reading usb MIDI data and passing forward to another device

You need the USB Audio kernel driver and the aconnect utility:

$ opkg update
$ opkg install kmod-usb-audio
$ opkg install alsa-utils-aconnect

Then just connect the ports:

$ aconnect -lio
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 40: 'SC-8820' [type=kernel]
    0 'SC-8820 Part A  '
    1 'SC-8820 Part B  '
    2 'SC-8820 MIDI    '
client 44: 'My Little Keyboard' [type=kernel]
    0 'My Little Keyboard MIDI 1'
$ aconnect "My Little Keyboard" SC-8820
$

(This is plain Linux and does not need to run anything on the ATmega.)


RF receiver becomes weakened after motor turns on

That behaviour is to be expected. Motors are very noisy and cause massive amounts of interference in radio signals.

The best thing you can do is to try and suppress that interference. For this you will need three 0.1µF (100nF) ceramic capacitors.

One capacitor is connected between the terminals of the motor to reduce noise transferred down the wires (wires make good antennae). The other two connect between each of the terminals and the metal body of the motor.

The metal body of the motor then becomes a shield to trap the noise.


The RGB LED strip has a common anode (V+). When you put 12 V on R, G or B, the LEDs have 12 V on both sides, so there is no voltage across it and no current.

And if you put 0 V, they have 12 V across it and light up.

To fix it, just invert the PWM value in your code:

analogWrite(255-pinR, R);
analogWrite(255-pinG, G);
analogWrite(255-pinB, B);


My understanding is that ARM is the chip architecture (a conceptual design, really),

ARM is the CPU core architecture used in the Atmel SAM3X MCU family. The MCU is the CPU plus all of the facilities (PWM, ADC, DAC, DMA, etc.) that are implemented in order to allow the CPU to interact with external circuitry.

  and that Arduino simply implements this design,

Most appropriately, "Arduino" is the IDE and the software libraries that come along with it, plus the specifications and connector layout of the various pieces of Arduino hardware.

  and is also a "system on a chip" because it has other things (USB ports, GPIO pins, etc.) that make it more of a computer than just a MCU.

"SoC" is exactly what it says on the tin: it's an entire system on a single chip. The Due is not a SoC, since it's a full board. The BCM2835 found on the RPi is a SoC. The SAM3X is a MCU, since it still requires more than just connectors to become a full "system".

  My understanding is that if embox runs on ARM, which they claim it does, then at some point in the future I can take my application and run it on another ARM-based system without any real headache/pain.

Provided that embox runs on the new system and that your application can be compiled for it.


Arduino Pro Micro not recognised by computer or showing up in ports

The arduino pro micro is notoriously difficult to program. I am sure you have figured this out when first installing the drivers but on power up, the micro runs a bootloader for <750ms  so for me at least, it was extremely difficult to install drivers.
However, if you look at this guide by sparkfun, you will see that resetting the board in quick succession will load a longer 8 sec bootloader, which gives your more time to program it. Obviously, this is not normally something you need to worry about as the Arduino IDE automatically resets the board sending it into the bootloader when you upload a sketch to it.
Back to your problem, if it is not popping up as a device when you plug it in to your computer, go into control panel > system > hardware > device manager and look to see if you can find it there. If it still doesn't show up, do what I said above and reset it twice and hopefully you will see the bootloader appear where you can reinstall the drivers for it. You can find the appropriate drivers in the same location where you installed the IDE originally.
Hope this helps!


How to scale a bitmap (uint8_t array) in Arduino?

You didn't tell use the size of your QRCode, nor the type of Arduino you
are using. So I am just going to guess that your problem is that you may
have enough RAM to store the raw QRCode, but not enough to store a
scaled bitmap version.

The Adafruit tutorial for their thermal printer library suggests
printing bitmaps with the method:

printBitmap(width, height, tablename)

where tablename is an array holding the bitmap data. This will
obviously not work if you don't have enough RAM to store the array.
Fortunately, there is an overloaded method:

void Adafruit_Thermal::printBitmap(int w, int h, Stream *fromStream)

that allows you to stream the image data instead of preparing it in RAM.
You can create a stream that delivers arbitrary data by writing a class
that derives from Stream. Here is a tentative, untested
implementation, that delivers a scaled-up QRCode one pixel at a time:

// Stream a scaled QRCode one pixel at a time.
class QRCodeStream : public Stream
{
public:
    QRCodeStream(const QRCode &code, uint8_t scale = 1)
    : qrcode(code), scale(scale) {}

    // Output: writing to this stream is a no-op.
    size_t write(uint8_t) {}
    void flush() {}

    // Input delivers the QRCode pixels.
    int available();
    int peek();
    int read();
private:
    QRCode &qrcode;
    uint8_t scale;
    bool done = false;
    uint8_t code_x = 0;  // coordinates of the QRCode module
    uint8_t code_y = 0;
    uint8_t pix_x = 0;  // pixel coordinates within the module
    uint8_t pix_y = 0;
};

int QRCodeStream::available()
{
    // For simplicity, pretend the bytes come one at a time.
    if (done) return 0;
    else return 1;
}

int QRCodeStream::peek()
{
    if (done) return -1;
    if (qrcode_getModule(&qrcode, code_x, code_y)) {
        return 0;  // black
    } else {
        return 255;  // white
    }
}

int QRCodeStream::read()
{
    if (done) return -1;
    int data = peek();

    // Move to the next pixel.
    if (++pix_x >= scale) {
        pix_x = 0;
        if (++code_x >= qrcode.size) {
            code_x = 0;
            if (++pix_y >= scale) {
                pix_y = 0;
                if (++code_y >= qrcode.size) {
                    done = true;
                }
            }
        }
    }

    return data;
}

This would be used as

printer.printBitmap(width, height, QRCodeStream(qrcode, scale));

Note that QRCodeStream delivers the image data as 8-bit gray scale,
where each pixel is returned as one byte, either 0 (for black) or 255
(for white). This is likely not the format expected by the thermal
printer library, which seems to expect 1-bit black and white data, with
8 pixels packed in each byte. You will have to adapt the code for
the right format, which will likely be tedious, but not overly complex.
I leave that “as an exercise to the reader”.


From the documentation:

  TERMINAL 7 Disable
  This terminal will force the winding currents to zero when tied to the step and direction controller +5V.

  The DISABLE input on the G213V is optically isolated and requires logic “1” to DISABLE and logic “0” to ENABLE the drive. Once it is disabled, the motor windings are unergenized[sic] and the motor freewheels. (emphasis mine)

So, feed the disable input a high.


How do I run a bipolar motor with an arduino uno?

Just for your knowledge and future reference - Arduino digital pins can deliver maximum of 40mA each. If you power Arduino by USB, Arduino UNO can draw maximum of 1A, and Nano maximum of 500mA. That is, the 5V pin can deliver that current, not a digital pin. Therefore pin 13(digital pin) can deliver 40mA at 5V, which is 200mW power.

Now, looking at your motor, TS-32GZ370-950,from datasheet at maximum efficiency the current needed is 140mA. Stall current is 480mA, therefore you should be able to deliver close to 480mA @ 12V for the motor to work under all possible loads. Now, that is 5.6W or so. Your 5V pin making the motor work simply meant that the load is low to medium. But you are unable to use the motor's full potential anyway.

Your driver choice is ok, because L298 can deliver up to 2 A, which is fine.
The 9V battery(Alkaline I suppose?) will work, but the lifespan will be very very short. You can look at discharge graphs here : https://www.powerstream.com/9V-Alkaline-tests.htm

It will last about 1 hour at moderate load. Consider using other types of batteries. Your motor accepts voltage up until 24V, so feel free to experiment.

Best of luck!


Read the datasheet!

  V_ANT_IN

  This pin is reserved an external DC power supply for active antenna.
  If using 2.85V active antenna, pin 19 has to be connected to pin 20.
  If the bias voltage of active isn’t 2.85V,you can input bias voltage of you need to this pin.

So just wire the antenna to the RF_IN pin and GND, and connect pin 19 to +3.3V (since your antenna is 3.3V not 2.85V).


Will M2.5 screws fit the holes in the Arduino Uno?

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


http://en.cppreference.com/w/cpp/preprocessor/include

#include <filename>

  The intent of this syntax is to search for the files under control of the implementation. Typical implementations search only standard include directories. The standard C++ library and the standard C library are implicitly included in these standard include directories. The standard include directories usually can be controlled by the user through compiler options.

#include "filename"

  The intent of this syntax is to search for the files that are not controlled by the implementation. Typical implementations first search the directory where the current file resides and, only if the file is not found, search the standard include directories as with (1).

So basically it's intent is to give some idea of where the file should be.
I, myself use "" for files that are inside the directory of my program. And <> for files or libraries that are in my path or other external locations.

This question is also more related to programming in general as Arduino specific.

Also see:
https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename


If your 12V power supply has enough current to drive your LED strip at its maximum power, plus the Arduino's power supply, plus about 10-20% of "wiggle room" you should be fine. As the LED strip draws spikes of current the voltage from your power supply might bounce around a little, but the Arduino's voltage regulator would be fine with as little as 7.5V input.

Note that your Arduino's voltage regulator will get hot if you use much current from the Ardunio's 5V rails, since it has to regulate 12V down to 5V and the linear regulator on the Arduino converts the extra voltage to heat.


Managing 80 ~ 90 accelerometers with Arduino

1) Use the I2C address select inputs as an "enable".  If you run out of I/Os before running out of bus time, drive the enables from an I/O expandander. If your accelerometers are SPI, drive or use the expander to drive the chip selects.

2) Use a tree of slave MCUs (Arduino or otherwise) reading a number of accelerometers, extracting and batching the useful data, and reporting only that upstream to a master.  Probably use whichever of I2C or SPI your accelerometers are not using (SPI can be much faster, so hopefully that).

Some accelerometer / gyro parts have an on-board processor which you may be able to program to do some of the data extraction for you.

You could also consider using an FPGA to collect the data.  A commonly available one with enough I/O pins to have a dedicated connection to each accelerometer (and so read them all in parallel) would probably also have the internal resources to implement an Arduino-class soft core processor, if not better.


having problems with my arduino bluetooth car project(with L298n Motor Driver)

The code seems to have a few missing lines for logic. Here's a corrected version from my understanding.
#include <NewPing.h>

#include<Servo.h>

#define TRIGGER_PIN A1
#define ECHO_PIN A0
#define MAX_DISTANCE 300
#define IR A2

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

Servo myservo;

String voice;

void setup() {
  Serial.begin(9600);
  myservo.attach(8);
  myservo.write(90);
  pinMode(IR, INPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);

}

void loop() {
  int distance = sonar.ping_cm();

  if (Serial.available() > 0) {
    voice = "";
    delay(2);
    voice = Serial.readString();
    delay(2);
    Serial.println(voice);

    if (voice == "turn left") {
      left();
    } else if (voice == "left") {
      left();
    } else if (voice == "turn right") {
      right();
    } else if (voice == "right") {
      right();
    } else if(voice == "move forward"){
      forward();
    } else if(voice == "move backward"){
      backward();
    }

  }

}

void forward() {
  int distance = sonar.ping_cm();

  if (distance < 10) {
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    voice = "";
  } else {
    digitalWrite(12, HIGH);
    digitalWrite(10, HIGH);
  }
}
void backward() {
  int IR_Sensor = digitalRead(IR);
  if (IR_Sensor == 0) {
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    voice = "";
  } else {
    digitalWrite(11, HIGH);
    digitalWrite(9, HIGH);
  }
}
void left() {
  myservo.write(180);
  delay(500);
  myservo.write(90);
  delay(500);
  int distance = sonar.ping_cm();

  if (distance < 10) {
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    voice = "";
  } else {
    digitalWrite(12, HIGH);
    delay(700);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);

  }
}

void right() {
  myservo.write(0);
  delay(500);
  myservo.write(90);
  delay(500); {
    int distance = sonar.ping_cm();

    if (distance < 10) {
      digitalWrite(12, LOW);
      digitalWrite(11, LOW);
      digitalWrite(10, LOW);
      digitalWrite(9, LOW);
      voice = "";
    } else {
      digitalWrite(10, HIGH);
    }
    delay(700);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }
}

void Stop() {
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
}