How to get timestamp of when the data was collected

Getting a "timestamp" of when data is collected is entirely down to you.
Most Arduinos don't have any concept of the current time, only the time since the program started running. To know what the time "now" is you have to have some mechanism to tell the Arduino what the time is, along with a method of keeping track of that time.
There are devices called Real-Time Clock (RTC) modules which keep track of the time for you. They don't magically know the time - you still have to tell them at least once.
You could tell it the time through the serial port to set the clock - from then on (assuming the RTC has power) the RTC will know what the time is.
Another option to get the time into the RTC is to use an internet connection (ESP8266, WiFi shield, Ethernet shield, etc) to perform a Network Time Protocol (NTP) query to a time server on the internet (such as pool.ntp.org) to get the current time and update the RTC.  This should be done regularly to correct any drift in the RTC.
Once you have an RTC and a method of setting the time you can query the time whenever you sample some data and store that time along with the data in whatever way is most suitable for your situation.


Can't burn Bootloader on Atmega328P Using Arduino Uno

I have had this problem in the past and it has always been one of two solutions

The wires were misconfigured, and I only saw it after the Nth time
Wrong chip, I was trying to program a 328 when it expected a 328p

And the secret third option:

Some chip/wire/etc. was busted/burned/bad.

Unfortunately These were the only outcomes to ever come for me when I encountered that particular error.


Reading Analog values of bluetooth module HC 05

Try looking up the datasheet to see if there is a command for signal strength. It's impossible to directly read the the analog value since the signal strength is way too low in amplitude.


65 hall effect sensors as switches to be used as a keyboard with a teensy

[Completely rewritten answer]
That seems fun. But why 65 keys ? with 64 keys it is easier.

You have to test the sensitivity of the hall switches with the magnets to know how far apart the keys must be. Perhaps they only work with strong magnets or perhaps a number of them are activated when the glove is near.

With hall switches, there are 65 digital signals from the sensors.
The most common way to create more digital inputs is to use shift registers. For example with the 74HC165. Nick Gammon has the best tutorial of the 74HC165 with daisy-chain.
There is also an example is with the CD4021 and the ShiftIn function, but the 74HC165 is mostly used.
The shift registers can be daisy-chained, they are made for that.

Your AH1807 has a open-drain output. That means you need 65 pullup resistors.
It is not possible to connect all the outputs and turn them on one by one, since it requires 150ms to wake up.

Another option is using multiplexers. It can be used for analog and for digital signals. For example with four 16-to-1 multiplexers you can create 64 inputs going to 4 pins. The best multiplexer tutorial is once again written by Nick Gammon.

With four analog multiplexers of 16-to-1 you would require only 4 pullup resistors after the multiplexer. I think it is better to use a resistor per hall sensor (65 pullup resistors).

When using reed switches (those tiny glass tubes, used in house alarms), they can be set in a matrix/grid with rows and columns and the Keypad library. For example 10*7 requires 17 pins. The Keypad library allows that multiple keys are pressed at the same time.


bitRead() gives wrong answer Arduino UNO R3

PORTx is the latched value last written there. The external value is found in PINx.


How to remember variable values after rebooting an Arduino Uno R3 board?

The internal RAM of the Arduino will be reset when you repower the chip, so if you want to keep your data, you need to store it in EEPROM.

If you are worried about the limited write/erase cycles, you should estimate how often the data would be updated (i.e. written to EEPROM) and how long you plan the lifetime of the device you build. If 100,000 cycles then still is an issue, you have several options:

Keep the variables in RAM and only write them to EEPROM say every 5 minutes (100,000 cycles then makes about one year of continuous usage until the EEPROM might fail).
Use an external EEPROM (in a socket) that could be easily replaced if needed.
If replacing it is not an option, consider using an FRAM instead (advantage vs EEPROM: much more erase/write cycles but also very expensive, so not an option for large amounts of data but certainly for a few variables).

Note, however, that your description sounds like a typical use-case for user settings that you don't want to get lost on reboot. For those the internal EEPROM is the right place: only store them when they're changed and you're golden -- the user won't change them a 100,000 times easily...


Supply arduino through Vin pin with a battery

Voltages, being a potential difference are always measured relative to another voltage.  Normally that reference voltage is referred to as ground, though may not always be.

The + and - on the battery refers to the polarity of the battery not the polarity of the voltage.

For instance, relative to the - terminal the positive terminal is 12 volts higher, or +12V.  Relative to the + terminal the negative terminal is 12V lower, so -12V.

When one of your battery terminals is connected to a point in your circuit nominated as ground (the - terminal of your battery in this case) then your battery voltage at the + terminal is measured relative to ground, which we say is 0V.  So the + terminal is 12V higher than the - terminal, and the - terminal is 0V, so therefore the + terminal must be 12V with respect to ground.  The - terminal, since it is connected to ground is at the same voltage as ground, so it is 0V with respect to ground.

If you were to connect the + terminal of a battery to ground instead, then the - terminal would be 12V lower than ground, so would be -12V with respect to ground.  The + terminal would be 0V with respect to ground.


ATTiny85 won't boot if PIN2 is not pulled high

Well, I've made some headway.  I hope to update this with something more helpful though.
I don't have a digispark or even the correct Zener diodes to replicate the necessary parts of it.  However, I did install t85_default.hex on an ATTiny85 with some alterations to the hex file to place break instructions in a few strategic places.  And then I ran avarice/debugwire against it.
The basic problem is that it's trying to tune the internal oscillator against the USB frames by looking at the D- pin.  Basically, it's stuck in tuneOsccal.
988  00001d06 <tuneOsccal>:
   1     1d06:       b3 9b           sbis    0x16, 3 ; 22
   2     1d08:       fe cf           rjmp    .-4             ; 0x1d06 <tuneOsccal>
   3     1d0a:       07 d0           rcall   .+14            ; 0x1d1a <countFrame>
...

So if you want to avoid this, you need to compile with that feature off, and there is a feature to do that.
I have not yet run one with this feature disabled.  But I did compile t85_default once, using make CONFIG=t85_default and found it necessary to remove the START_WITHOUT_PULLUP from the first line of the t85_default/bootloaderconfig.h file.
The code mentions the existence of OSCCAL_SAVE_CALIB, which lets you specify your own OSCCAL value, assuming the factory one for the chip isn't good enough for whatever reason.  But there doesn't seem to be any guidance on how you're supposed store it or where.  Looking at the code though, if enabled, you can see it loads the OSCCAL value from just before where the bootloader starts.
A simple way to put it there without messing with command-lines and linker scripts would be to just edit the the t85_default.hex that results from building with OSCCAL_SAVE_CALIB enabled, and add an extra record for setting the osccal value at the correct address, which I guess would be 0x19FA, so:
:0119FA00XXSS
Where XX is whatever you've determined your OSCCAL value is and SS is the checksum value, or 0x100 - ((0x14 + XX) & 0xFF) in this case.  Or, if you want to be lazy, put whatever you want for SS and let AVRDude complain tell you what it's supposed to be when it tries to load the .hex file.  It will report the expected value in decimal, which you can convert to hex and patch into the file, and run AVRDude again.


Arduino trim: does it remove the \n as well?

The source for the trim() function is in WString.cpp.

void String::trim(void)
{
    if (!buffer || len == 0) return;
    char *begin = buffer;
    while (isspace(*begin)) begin++;
    char *end = buffer + len - 1;
    while (isspace(*end) && end >= begin) end--;
    len = end + 1 - begin;
    if (begin > buffer) memcpy(buffer, begin, len);
    buffer[len] = 0;
}

We can see it uses the isspace() function, but where's that function defined? WString.cpp only #includes WString.h, so we go there.

In WString.h, we can see it includes ctype.h. Time to go to the C++ Reference, which tells us that yes, \n is a "space" according to isspace(), so it is trimmed.

(note that isspace() is affected by localization settings. I'm not sure what the localization settings are when compiling for Arduino)


delayMicroseconds(1000);// maximum delay is 65535 uS

or

#include <util/delay.h>
_delay_ms(1);


Why call a USB connection a serial connection?

As @ratchetfreak answered, USB is a Serial bus. But there is more.

The microcontroller on Arduino boards has one or more built-in peripherals called UARTs, which stands for Universal Asynchronous Receiver-Transmitter.

This is what the Arduino core calls a Serial port. It uses the same kind of protocol as the old DB-9 serial ports on PCs and such, but at 5V or 3.3V logic levels. Contrast this 0V to 5V voltage swing to indicate Logic LOW and Logic HIGH with the RS-232 standard for the old PC serial ports, which use a +12V to -12V swing to indicate such.

But PCs today don't often have the old RS-232 serial port. They instead have the new USB - Universal Serial Bus - port. On the Arduino board is chip that communicates on one side via USB with the PC and tells the PC that it provides the equivalent of the old COMPORT or /dev/ttyS* serial device; and on the other side via UART with the microcontroller on the Arduino board.

It's like we are "emulating" the old PC serial ports in software over the new USB bus, which itself is a serial communication system, though much more complex than a plain UART.


I figured out why while(Serial.available()>0) and if(Serial.available() > 0) would or would NOT work in terms of my shift register code. It has to do with the serial monitor line feed and carriage return setting! If it isn't set to no line ending, it will either not register the input number or reset it back to zero right after the input is read. Learned to always check the line return option in the serial monitor! With this solved, the original question is nothing more than a general if vs while statement; which I already know the answer.
Thanks to everyone who contributed to this question! It did help me understand a lot more about Serial.available() in general. @jsotola gave a really good article. Combined with this YouTube video, it makes a lot more sense now.


Using ALL the analog pins on Mega for Servo

OK..Solved...tried a library I had previously discarded for another project but it works with this situation..SoftwareServo ....(had also tried versions of Servo and MegaServo with no luck) I have attached a proven sketch that shows the method using arrays (as i have 16 servos to control) hope this is of use to others.

    /*This sketch will enable you to use ALL of the Analog pins on a Mega2560 to control a Servo
 * it uses the Arrays and the Softwareservo.h as the other Servo libraries do not support
 * Mega Analog above A9
 * this is the only method i have found that works
 * hope this is of use to others.
 */
#include <SoftwareServo.h>

SoftwareServo servos[16];  // create servo object to control a servo

int pos=0;
int servoPins[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15};                    //servo pin numbers
int servoPosMin[] = {80,80,80,80,80,80,80,80,80,89,80,81,80,70,80,45};                        //servo lower setting to suit individual servo
int servoPosMax[] = {100,100,100,100,100,100,100,100,100,100,100,100,100,110,100,160};        //servo upper setting to suit individual servo
boolean refresh = false;  // toggle refresh on/off
int m = 0;
int p = 0;
void setup()
{
  Serial.begin(115200);
  for (m=0;m < 16;m++) {
      // attaches the servo on pin to the servo object
    servos[m].attach(servoPins[m]);
      // init angle of servo inbetween two limitations
    servos[m].write(((servoPosMax[m]+servoPosMin[m])/2));
    Serial.println(m);
    delay(10);
      SoftwareServo::refresh();
  }
}
void loop()
{
  for (p=0;p < 16;p++) {

    for (pos = servoPosMin[p]; pos <= servoPosMax[p]; pos += 1) { // goes from 0 degrees to 180 degrees
      servos[p].write(pos);                                       // tell servo to go to position in variable 'pos'
      delay(15);                                                  // waits 15ms for the servo to reach the position
      Refresh();
  }
    for (pos = servoPosMax[p]; pos >= servoPosMin[p]; pos -= 1) { // goes from 180 degrees to 0 degrees
      servos[p].write(pos);                                       // tell servo to go to position in variable 'pos'
      delay(15);                                                  // waits 15ms for the servo to reach the position
      Refresh();
    }
  }
}
void Refresh() {
  refresh = refresh ? false : true;                             // set refresh one time / 2
  if (refresh) SoftwareServo::refresh();
  Serial.print("Servo Number = ");
  Serial.println(p);
  Serial.print("  Angle =  ");
  Serial.println(pos);
}


The official ESP32-CAM has a AMS1117 voltage regulator that creates the 3.3V for the ESP.
The AMS1117 has an Absolute Maximum Input Voltage of 15V. It has a Dropout Voltage of 1.1-1.3V.
So you should stay above 4.6V to be on the safe side.
Since it's a linear voltage regulator, using a higher voltage battery has no advantage, as the "excess voltage" is converted to heat. It could even damage the regulator if too much heat is created.
You should pick the battery with the lowest voltage that still produces 4.6V when almost empty. So you could use the 7.3V battery you indicated. I'm assuming this is a 2-cell Li-ion battery, that has a voltage of 8.4V when full, and around 6V when empty. Which nicely fits your requirements.


To process incoming images, voice commands, produce sounds, and also do WiFi is almost certainly beyond the capabilities of any micro computer, like the Arduino (maybe some of the more recent models might). I strongly doubt that the Mega 2560 would. It doesn't have a heap of RAM for one thing (it has 8k of RAM). Look at the sizes of images produced by cameras these days, they are usually measured in megabytes, not kilobytes.
What might work for you would be a Raspberry Pi, which is basically a small Linux computer on a board, with a substantial amount of RAM.


Judging from your mentioning 62.5 kHz as the base frequency for
pins 5 and 6, I assume you are talking about an Arduino Uno or
something similar.

If you set the timer 0 to phase correct PWM mode (which is how the
Arduino core configures the other timers), then its base frequency is
about 31.373 kHz (F_CPU/510). With the prescaler set
to 8, you get a PWM frequency of about 3.922 kHz on pins
5 and 6.

Note that you can set all three timers in this mode and have 6 PWM
channels at this frequency. But note also that by reconfiguring
Timer 0 you loose all the standard Arduino timing functions.


How do I control 4 LEDs with 2 Digital Outputs?

Using two pins it is possible to drive 4 LEDs as long as you only want one of them on at a time.  One LED will always be on - it's not possible to have a setting where there is no output selected.

Basically you are "decoding" a binary value output:

00 = LED 1 on, other three off
01 = LED 2 on, other three off
10 = LED 3 on, other three off
11 = LED 4 on, other three off

To do that you need to use (or construct) a 2-to-4 decoder.

Using logic gates it can be constructed like this:

If you can translate that into transistors then you'll end up with quite a lot of transistors.  Most people would use a specific 2-to-4 decoder chip such as the 74HC139.

Shift registers usually require three pins, yes, though there are possible ways of working with two pins.  You require two pins to provide the data and clock signals, and a third pin to latch the shifted data out to the outputs. However it is possible to use the first leading edge of the clock signal or a specially formatted data signal with a capacitor to create a pulse just before sending new data which can latch the old data.  This requires careful consideration though regarding how fast you would be transmitting, etc, and is not really recommended.

A better solution if you are limited in pins and need to drive multiple LEDs is to use WS2812 "NeoPixel" LEDs which chain together and use a single wire protocol to send data to all the LEDs in the chain.  You can support many LEDs (even hundreds) on a single IO pin, and they are full 24-bit RGB to boot.


have read that the ATTINY 85 does not have a serial port.

It depends on your definition of serial port.

From a hardware perspective it has a usi. That can be configured as a uart. Whether it fits your need or not is up to your application. Read the datasheet to be sure.


Reading iBeacon Data using HC-05 bluetooth module

The HC-05 doesn't support BLE, which is used for iBeacons.


Pneumatic cylinders with sensors with Arduino Uno

void loop() {

...

  if(digitalRead(dvereVysunute) == HIGH && digitalRead(davkovaniZasunute) == HIGH
  )
  {
      digitalWrite(davkovani, LOW);      // extend the second pneumatic cylinder
      delay(4000);
      digitalWrite(davkovani, HIGH);    // retract the second pneumatic cylinder after 4 seconds,
      // this code works when it is alone there, the next if statements not
  }

...
}

If the condition is met, then davkovani is going to be LOW 99.999% of the time. It will only briefly go HIGH, as there is no delay there. The loop will iterate and set it LOW again. So it may seem to be "not working" whereas the problem is that it "works" very briefly.


The SD library works only with FAT and FAT32 format. SD.begin() reads the 'disc volumes' and opens the root folder. If the card is not formatted or formatted with other file system standard, begin() fails.

EDIT: and the pin headers must be soldered


How do I move more than 128 pixels when using Arduino Leonardo's Mouse.move?

The USB HID protocol for mouse is the limitation on sending more then a byte sized value for the mouse movement in one event.

You can't create a faster USB mouse. Repeat the call of the move() function. Of course you can use a function to call move() repeatedly to move to target destination.

void mouseMove(long x, long y) {
  long max = max(abs(x), abs(y));
  int count = (int) (max / 127);
  signed char stepX = x / (count + 1);
  signed char stepY = y / (count + 1);
  for (int i = 0; i < count; i++) {
    Mouse.move(stepX, stepY);
  }
  signed char resX = x - (stepX * count);
  signed char resY = y - (stepY * count);
  if (resX != 0 || resY != 0) {
    Mouse.move(resX, resY);
  }
}


Switch case does not work after booting system

Personally I don't like the way you handle the "state machine", and I'd implement it in what I perceive is a more robust way (I may be wrong, though).

Moreover if you have a button please add a debounce; I usually do this with the Bounce2 library (or alternatives I code which are modified versions of that library). So... Let's change the things in the way I prefer.

// Include the library
#include <Bounce2.h>

// declare a bounce object
Bounce buttonDebounce = Bounce();

//in the setup:
pinMode(IN_PIN, INPUT); // or INPUT_PULLUP?
buttonDebounce.attach(IN_PIN);
buttonDebounce.interval(5);

//in the loop:
buttonDebounce.update();

Then in the loop you can use the buttonDebounce.rose() function or buttonDebounce.fell() to detect the button presses.

Now, for the state machine. You have four meaningful states (let's call them DISPLAY_1 to 4). It's better to give them more meaningful names. And let's add an invalid state. I usually prefer to use const bytes to force the size rather than enums or defines, but.. whatever ;)

So outside loop or setup declare the values and the state variable:

const byte SM_ErrorState = 0;
const byte SM_Display_1 = 1;
const byte SM_Display_2 = 2;
const byte SM_Display_3 = 3;
const byte SM_Display_4 = 4;
const byte SM_Display_5 = 5;
byte SM_currentState;

Now, the function buttons can be implemented in the classical way I learned to implement state machines, which is first make a switch case to test whether you have to advance, then advance to the next state if necessary and perform the entry action.

void buttons()
{
    buttonDebounce.update();

    nextState = SM_currentState;

    // Check if a new state is requested
    switch (SM_currentState)
    {
    case SM_Display_1:
        if (buttonDebounce.rose())
            nextState = SM_Display_2;
        break;
    case SM_Display_2:
        if (buttonDebounce.rose())
            nextState = SM_Display_3;
        break;
    case SM_Display_3:
        if (buttonDebounce.rose())
            nextState = SM_Display_4;
        break;
    case SM_Display_4:
        if (buttonDebounce.rose())
            nextState = SM_Display_5;
        break;
    case SM_Display_5:
        if (buttonDebounce.rose())
            nextState = SM_Display_1;
        break;
    default:
        nextState = SM_Display_1;
        break;
    }

    // If an advancement is requested, advance and then perform the entry action
    if (nextState != SM_currentState)
    {
        SM_currentState = nextState;
        switch (SM_currentState)
        {
        case SM_Display_1:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Sensor 1 reads");
            lcd.setCursor(0,1);
            lcd.print(value1);
            delay(20);
            Serial. print("Case 0");
            break;
        case SM_Display_2:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Sensor 2 reads");
            lcd.setCursor(0,1);
            lcd.print(value2);
            delay(10);
            break;
        case SM_Display_3:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Pump 1 ran");
            lcd.setCursor(0,1);
            lcd.setCursor(5,1);
            lcd.print(runs1);
            lcd.print(" times");
            delay(10);
            break;
        case SM_Display_4:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Pump 2 ran");
            lcd.setCursor(0,1);
            lcd.print(runs2);
            lcd.setCursor(5,1);;
            lcd.print(" times");
            delay(10);
            break;
        case SM_Display_5:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Next cycle in");
            lcd.setCursor(0,1);
            lcd.print(currentTime);
            lcd.setCursor(5,1);
            lcd.print(" Minutes");
            delay(10);
            break;
        default:
            break;
        }
    }
}

Now, the initialization. Remember that I told you to add an error state? This way you can force a state change on initialization by setting the variable to the SM_ErrorState value.

Then, the millis management in the loop. I'd avoid the particular case of the variable equal to 0 to trigger an immediate execution, since this will lead to errors later. Then I also prefer to sum the interval, to avoid having a drift. So I changed your way to another one. I also changed some code for better readability (for instance, letting the "timer" reset every minute rather than every 30 minutes, and changing the defines accordingly).

Here is my complete code; I left out the measure function since it does not impact the other code.

Let me know if this solves your problem. Oh, BTW, UNTESTED CODE, so some bugs may appear...

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Bounce2.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2);

int value1; // I think it is better if these
int value2; // two variables are initialized
int runs1 = 0; // Unsure if this is needed
int runs2 = 0; // Unsure if this is needed
int val = 0; // Unsure if this is needed

int inPin = 6;
unsigned long previousMillis = 0;
const unsigned int millisInOneMinute = 60000U;

byte elapsedMinutes;
const byte intervalMinutes = 30;

Bounce buttonDebounce = Bounce();

void setup() {
    Serial.begin(9600);
    lcd.begin();
    pinMode(inPin, INPUT);
    buttonDebounce.attach(inPin);
    buttonDebounce.interval(5);
    previousMillis = millis();
    elapsedMinutes = intervalMinutes; // Force a new measure
}

void loop() {
    if (((unsigned int)(millis() - previousMillis)) >= millisInOneMinute)
    {
        previousMillis += millisInOneMinute; // Avoid drifting
        elapsedMinutes++;
    }

    if (elapsedMinutes >= intervalMinutes)
    {
        elapsedMinutes = 0;
        measure();
    }

    buttons();
}

void measure() {
    // do your stuff
}

void buttons()
{
    buttonDebounce.update();

    nextState = SM_currentState;

    switch (SM_currentState)
    {
    case SM_Display_1:
        if (buttonDebounce.rose())
            nextState = SM_Display_2;
        break;
    case SM_Display_2:
        if (buttonDebounce.rose())
            nextState = SM_Display_3;
        break;
    case SM_Display_3:
        if (buttonDebounce.rose())
            nextState = SM_Display_4;
        break;
    case SM_Display_4:
        if (buttonDebounce.rose())
            nextState = SM_Display_5;
        break;
    case SM_Display_5:
        if (buttonDebounce.rose())
            nextState = SM_Display_1;
        break;
    default:
        nextState = SM_Display_1;
        break;
    }

    if (nextState != SM_currentState)
    {
        SM_currentState = nextState;
        switch (SM_currentState)
        {
        case SM_Display_1:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Sensor 1 reads");
            lcd.setCursor(0,1);
            lcd.print(value1);
            delay(20);
            Serial. print("Case 0");
            break;
        case SM_Display_2:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Sensor 2 reads");
            lcd.setCursor(0,1);
            lcd.print(value2);
            delay(10);
            break;
        case SM_Display_3:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Pump 1 ran");
            lcd.setCursor(0,1);
            lcd.setCursor(5,1);
            lcd.print(runs1);
            lcd.print(" times");
            delay(10);
            break;
        case SM_Display_4:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Pump 2 ran");
            lcd.setCursor(0,1);
            lcd.print(runs2);
            lcd.setCursor(5,1);;
            lcd.print(" times");
            delay(10);
            break;
        case SM_Display_5:
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Next cycle in");
            lcd.setCursor(0,1);
            lcd.print(elapsedMinutes);
            lcd.setCursor(5,1);
            lcd.print(" Minutes");
            delay(10);
            break;
        default:
            break;
        }
    }
}

EDIT: Generic implementation of a state machine

Ok, here I post my generic scheme for a state machine. Usually I use the "state-based" state machine, which is actions are linked to states; sometimes I also saw "transition-based" state machines, where actions were linked to transitions, but... Ok, I'm not a real expert, so I don't want to write a lot of (wrong) things.

In this kind of machines, each state can have up to three kind of actions and a check:

actions you perform when you ENTER the state
actions you perform continuously when you are INSIDE the state
actions you perform when you EXIT the state
and of course, you have to CHECK whether you need to make a transition to another state

For instance, when you have in a microwave a state corresponding to the ON state, you have to:

when you ENTER the state, turn on the heater
when you are INSIDE the state, update the timer value
when you are done and you are EXITing the state, turn off the heater
when during the CHECK you see that the timer has expired or the stop button was pressed, you switch to another state

So there are four kind of actions: ENTER, INSIDE, EXIT and CHECK. For linearity I learned that it is much better to write each of them in a separate switch case. This is my usual implementation scheme:

void stateMachine()
{
    byte nextState = currState; // currState of course is defined outside

    switch (currState)
    {
    // Here you have to CHECK, for each state, the conditions
    // needed to switch to another state; if you switch, put
    // the new state in nextState
    }

    if (nextState != currState)
    {
        switch (currState)
        {
        // Perform the EXIT functions for each state
        }

        // Advance to the next state
        currState = nextState;

        switch (currState)
        {
        // Perform the ENTER functions for each state
        }
    }
    else // See note below
    {
        switch (currState)
        {
        // Perform the actions to be performed continuously
        // INSIDE each state
        }
    }
}

NOTE: the else can be omitted or not. If you leave it, in the cycle that you detect the change you do not perform the INSIDE action; if you omit it, the INSIDE action will be performed. This is useful in different cases.

Now, usually (and yours is one of these cases) you only need the CHECK and ENTER sections (if you look at the code, you will see that only these two sections were implemented). Once in a while you will need also the INSIDE section, and once in your life you will also need the EXIT ;) (at least in my experience)


How to make Arduino communicate with MySQL?

I'm not familiar with those libraries, but a quick look gives me the impression that Bridge and Process are used together to make system calls over serial connection on the host system. Based on that..

First, looking at Arduino Process Tutorial Process.begin() should call the process that you want to call. Maybe something like this:

p.begin("curl"); // Assuming you have curl installed on your host system
p.addParameter("http://143.248.181.36/db.php?temperature=SOMEVALUE");

Second, your PHP script is broken.

/ check connection

^ That comment is missing a second slash /

You should definitely get the PHP/MySQL part working standalone before attempting to integrate Arduino in the process. I'm a bit doubtful that $argv gets populated unless you're running the script from command line. If you're making a GET HTTP request (as you would with curl) you might wanna try instead

$temperature = $_GET['temperature'];

If the above works as a workaround, you should get an entry into your MySQL table if you visit the URL below with your browser.

"http://143.248.181.36/db.php?temperature=100"

In any case, get the PHP script working first in your browser. One step at a time.


Is extra hardware and components needed to connect the bare MCU directly to a PCB, without a shield?

DO I need crystals, capacitors, etc? Or the MCUs (mostly AtMega 32u4 and Attiny85 and Attiny167) have it all what's needed inside them?

You don't need a crystal if you use the internal clock of the MCU (which means setting the fuses right and compiling your code to expect the right clock frequency). However if you are using a direct USB interface (such as for the ATMega32U4) then you will need a crystal as the precise timing is required for USB to operate.
You will need capacitors. Decoupling capacitors on all the power pins are not optional and must be included.
You will need a pullup resistor on the RESET pin unless you have set the fuse to disable the RESET pin (not advisable since it will prevent ICSP programming in the future - but can be useful for low pin-count chips).


Why does the RCSwitch.available return false?

I think that the value of available just determine if there is a message to receive or not.


What is the proper way to turn an Arduino UNO into an ISP?

The wiring is actually identical. It just uses the ISP header (2x3 pins) on the target board, instead of the pins 5v, GND, RST, 11, 12, 13. Just like the table you added says.

The downside to using the ISP header, is you need a male to female wire for connecting. Upside is you can easily take of these 6 pins, and connect it to a different arduino to be programmed.

I always needed to add a capacitor between RESET and GND. The exact value isn't that critical.

The reset pin is the one to the left of 3v3.


How to switch a low-voltage (1.5V) toy motor with an arduino?

You would be better off using a MOSFET which, when on, has quite a low resistance. For example the RFP30N06LE datasheet shows a RDS(on) of 0.047 Ω at 30A and 5V.

Using Ohm's Law we therefore expect a voltage drop of:

V = IR
V = 0.5 x 0.047
V = 0.0235

Thus, only 23 mV drop if you are drawing half an amp. I measured using a toy that drew 200 mA and found a 5 mV drop at 1.5V (compared to the theoretical 9 mV).

I have a page about driving motors that illustrates how you might wire up such a device.

The 12V on that schematic could just as easily be 1.5V.

The diode on the schematic is a snubber diode which protects the transistor from flyback voltages from the motor.

Comparison to transistor

BJT transistors will have a higher voltage drop between collector and emitter. For example the 2N3904 has a 200 mV drop (0.2V) (called VCE(sat)) when conducting 50 mA. This is a somewhat larger drop than the 5 mV drop that I got with the MOSFET, and a somewhat larger percentage of the 1.5V that you are starting with.


Using chipKIT WiFi Shield with an Arduino

No, you can't. The only libraries available for the chipKIT WiFi Shield are written specifically for the chipKIT boards.

Also, how have you plugged the board into an Arduino? The chipKIT WiFi Shield has Digilent's own header layout with a double row of headers where the Arduino only has a single row. Half the pins won't be plugged into anything.


Can I connect esp32 to a phone USB charger?

In principle yes (see also comment in update).

The voltage is ok (5V), typically USB, and it doesn't differ from the output of a computer USB port.

The output current is max 2000 mA, so check if your project (ESP + related hardware powered by this USB), is not exceeding 2000 mA. The ESP needs much less than 2000 mA, so if you didn't have a lot of external components or motors than you will be safe.

Update

Important omment from Sim Sson: The bare esp32 is not 5V-tolerant, so using a usb-charger is only ok for esp modules that have a voltage regulator onboard.


Here's an extract from page 39 of MMA8452Q-rev8.1.pdf, the MMA8452 spec sheet:

Rather than saying writeRegister(CTRL_REG4, 0x0B); in MMA8452Q::setupISR(), try writeRegister(CTRL_REG4, 0xD);.

0xB is 1011 in binary, while 0xD is 1101, which turns on INT_EN_FF_MT to enable freefall/motion interrupts.

The above should answer your question as asked.  The following expands on my earlier comment which said

  Absent other info, it looks like MMA8452Q::readISR() is not an interrupt processing routine, but instead a routine that polls an interrupt-source register to find out what source would have triggered an interrupt if correctly wired and initialized.

"Interrupt" as used in your question (and code) refers to when the MMA8452 signals (via an I1 or I2 output line) that an interrupt-worthy condition has occurred.

"Interrupt" as in the question does not refer to an interrupt from the Uno's point of view, because (per diagram) neither of I1 or I2 connects to the Uno.

If speed of response becomes important, you may wish to hook I1 or I2 to one of the Uno's Digital Pins With Interrupts, ie pin 2 or 3, as noted in the AttachInterrupt page at arduino.cc.  Then you'd replace the polling loop that now periodically reads the MMA8452's ISR (interrupt status register) to check for set bits, with an interrupt service routine which would set a flag to cause loop() to use Wire.read to get ISR data.


Which pins are represented by these constants from ABR library?

The mapping can be found in the io.h file but also in Arduino core files.

Below is the pin mapping:

                        ATtinyX4
                      +----U----+
  (VCC)-------------1-|VCC   GND|-14------------(GND)
  (D10)-------------2-|PB0   PA0|-13----------(D0/A0)
  (D9)--------------3-|PB1   PA1|-12----------(D1/A1)
  (/RESET)----------4-|PB3   PA2|-11----------(D2/A2)
  (D8)--------------5-|PB2   PA3|-10-------(D3/A3/SS)
  (D7/A7)-----------6-|PA7   PA4|-9---(D4/A4/SCL/SCK)
  (MISO/SDA/D6/A6)--7-|PA6   PA5|-8------(D5/A5/MOSI)
                      +---------+

The serial library uses:

#define TX_PIN  PB0

Which is ATtinyX4 Pin #2, or Arduino attiny core digital pin D10 https://github.com/damellis/attiny/blob/master/variants/tiny14/pins_arduino.h.

Cheers


Newbie needing help with debounce errors in arduino

In the description of Debounce, you'll find the hint that this library is outdated and no longer maintained.

Its successors, Bounce1 and, more recently, Bounce2 are available from a github repository by Thomas Fredericks, Bounce-Arduino-Wiring.

Instead of simply downloading and unzipping the archive to ${HOME}/sketchbook/libraries, you might want to consider that this is the right moment to get familiar with git repositories as an easily updatable source for third-party libraries.

Supposed that you're on a GNU/Linux system with git installed, you would

cd /${HOME}/sketchbook/libraries
git clone https://github.com/thomasfredericks/Bounce-Arduino-Wiring.git

to obtain a clone of the necessary data.

If the name of the directory of the library contains dashes (-), you'll have to change this name: remove the dashes or replace them with underscores (_). Names with dashes aren't valid!

Once in a while, you would change to the directory of the respective library and simply run git pull to update your local copy to the latest version of the repository.


Trying to use Tap Detection solution using ADXL345 with Arduino

the arrays are indexed from 0 but you assign to TAP_ variables array values indexed 1,2,3.

Are you sure the sensor is wired ok? Did it work with a library example?


can we use Software serial and timer one at the same time or this software use also timer one?

According to Answer software serial only you pinchange interrupt and CPU  delay loop. which means it not effect any timer but it might freeze system while transmission.


Sure. Why wouldn't it be? Power is (pretty) static and noiseless.

Just be warned that having the clock and data in the same twisted pair (if your cable has twisted pairs) could cause issues over longer distances. I2C isn't designed for running over cables like that - it's designed for routing round short traces on a PCB.


exit status 1 'mcpButtonState' cannot be used as a function

Use [] not ():

 if((mcp.digitalRead(thisPin) == 0) && (mcpButtonState[thisPin] == 0))

Note the use of && instead of the word and.


Proxying streaming i2c data(int values) to serial

Your I2C bus is operating at 100 kHz. Your serial connection is set to 9600 baud. In case you are sending coordinates at a pace faster than the serial interface can keep up, the buffer will fill up. I assume you are using hardware serial (uno, mega, etc). Once the buffer is filled up Serial.write (which is called by Serial.println) will block until the buffer has free space. But the serial transmission depends on interrupts, and you are calling Serial.write inside an interrupt routine. By defult interrupt routines block other interrupts from happening. So your program gets stuck there and locks up both the serial transmission and the I2C interface.

It would be a good idea to put the serial write outside the interrupt routine, in the loop. Make a global variable bool newData = false; and set it true in the receiveData function. In your loop check the flag and transmit the data. Then set the flag to false.

You will still experience data loss if the serial interface can't keep up, but your application wont lock up. To solve the data loss simply use a higher baud rate, eg. 115200.


Which input pins can I use on the ESP8266 NodeMCU

GPIO2 is NodeMCU D4 which is U1TXD, transmit for the second UART, generally available. GPIO3 is NodeMCU U0RXD, receive for the first UART, generally available if you aren't using serial. GPIO1 is NodeMCU U0TXD, transmit for the first UART, generally available if you aren't using serial. GPIO9 is NodeMCU SPIHD and is NOT available, as it is required for the flash memory. All that is well documented in many places. You can easily use serial to move data between modules, or multiplex your input to the one module. Cannot provide much insight without more details.


I would suggest improving your code slightly as follows:

  uint8_t buf;
  uint8_t buflen = 1;
  if (driver.recv(&buf, &buflen)) // Non-blocking
     {
        int i;
        // Message with a good checksum received, dump it.
        Serial.print("Message: ");
        Serial.println(buf);//this prints out okay
        highPins[buf] = 1;
     }

The important point is that you do not need to declare buf as an array of just one element, but just declare the element itself (as uint8_t) and pass its address (&buf) to driver.recv(...).

As @Majenko suggested, you should alos check buf before using it as an index to highPins array, in order to avoid using an index bigger than teh array size.


Is it possible to run a monochrome LCD without driver circuit with an Arduino Uno?

Normally such LCDs are custom designed, mass produced displays especially for this calculator product. Thus it is very unlikely to find a datasheet or even a meaningful part number for it.

Most likely the pins on the LCD are directly connected to the corresponding fields on the LCD. In an LCD you have liquid crystals between two electrodes, which change their orientation, when a voltage is applied to the electrodes, which changes the light absorption of the layer. You need to apply the correct voltage to a pair of pins to activate their field. Most likely all of the fields or a few groups of them have a common electrode (which would be 1 pin). Without any documentation you are bound to experiment with the display, until you have found the correct voltages and pin arrangements. You might break the display in the process (for example through excess voltage).

I haven't done this myself, but googling gives an interesting result:

This project, where they hacked the LCD of a cheap calculator for a waveform generator (though the display seems to be way less complex than yours) They seem to use 1.5V as voltage, so this might be a good starting point.

Your display has many pins. Depending on the Arduino model, that you use, you will fast run out of pins to use. You can try arranging the pins into a matrix, which would mean multiplexing the fields (turning them on and off fast one after another). Or you can buy additional parts to extent your pin count, for example shift registers.

As jsotola wrote in the comments (and as several forum threads on web web state), you should not put a constant voltage onto the display, since this will damage it. (I guess the liquid crystals will degrade fast because of their polarity, which make the work in the first place). Instead you have to place an alternating voltage at the pins, which changes it's polarity. The  net voltage (The integrated voltage over time) must be zero. Thus you need to alternate the applied voltage. If you provide a span of 1.5V, you need to change between +0.75V and -0.75V.

As the display shouldn't need too much current and the voltage requirement is relative to the LCD ground, you might get way by setting the LCDs ground with a voltage divider to 2.5V and then operating around that. Though I'm not sure about that.

Otherwise you might need to actually change the polarity. This would also just need 1 extra digital output pin as the ground pin. One polarity would be the LCDs ground pin to Arduino's ground (outputting LOW at the digital pin) and the other pins to the needed positive voltage (HIGH divided down over a voltage divider or similar). The other polarity would be LCDs ground pin to the needed positive voltage (HIGH divided down over voltage divider) and the other pins to ground (outputting LOW).

As described above, hooking this bare LCD to the Arduino is not done fast and easy. You can try it, if you like to do it. But if you want to get your project (whatever it is) done fast, you should instead buy a LCD with integrated controller, which are mostly ready to use, and for which there are already libraries.


Serial monitor returns "48" when I enter "0"

Serial.println(incomingByte, DEC);

You told it to print the incoming byte in decimal, so that is what it did. 48 is the decimal equivalent of ASCII '0'.

Change that line to:

Serial.println((char) incomingByte);

That casts the thing you are printing to a character, and then the appropriate version of Serial.println prints it as a character, not a decimal number.

10 is the decimal equivalent of a new line (newline) so that is why you are also seeing 10 printed.

  I need to convert the incoming stuff into integers so that it can see if im guessing right or not

Assuming you mean an integer other than 0 to 9 (like, 42 for example) then you need a bit more work. I have a page about that sort of thing:

http://www.gammon.com.au/serial

Example code:

/*
Example of processing incoming serial data without blocking.

Author:   Nick Gammon
Date:     13 November 2011.
Modified: 31 August 2013.

Released for public use.
*/
// how much serial data we expect before a newline
const unsigned int MAX_INPUT = 50;

void setup ()
  {
  Serial.begin (115200);
  } // end of setup

// here to process incoming serial data after a terminator received
void process_data (const char * data)
  {
  // for now just display it
  // (but you could compare it to some value, convert to an integer, etc.)
  Serial.println (data);
  }  // end of process_data

void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
    {

    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte

      // terminator reached! process input_line here ...
      process_data (input_line);

      // reset buffer for next time
      input_pos = 0;
      break;

    case '\r':   // discard carriage return
      break;

    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

    }  // end of switch

  } // end of processIncomingByte

void loop()
  {
  // if serial data available, process it
  while (Serial.available () > 0)
    processIncomingByte (Serial.read ());

  // do other stuff here like testing digital input (button presses) ...

  }  // end of loop

In this example, the function process_data is called when there is a complete number to be handled.


How can I get analog-in reading from Digital-PWM-out on the same board?

You are fine by doing that, but you won't get what you expect.

A PWM signal isn't an analog value. It's a series of pulses, the duration of those pulses is set by the (not accurately called) analogWrite. So sometimes the value is 5V and sometimes it's 0V. You need to get the average value by adding e.g. an RC-filter.

Another option is to add a proper DAC (digital to analog converter) chip to your circuit.


Remove unwanted characters from char type

You can use strtok to split the string on the T character:
char *datepart = strtok(datetime, "T");
char *timepart = strtok(NULL, "T");

Serial.print("The current date is: ");
Serial.println(datepart);
Serial.print("The current time is: ");
Serial.println(timepart);

An alternative is to just find the T and turn it into the NULL terminating character:
char *T = strchr(datetime, 'T');
*T = 0;

If you need to copy the string data into a temporary string first you can do:
char temp[strlen(datetime)+1];
strcpy(temp, datetime);

Then operate on temp instead of datetime.


The Arduino IDE compiles and outputs standard Intel HEX format files that are compatible with (nearly?) all programmers. If you enable detailed logging in the preferences panel you can find out which directory the IDE is building your code in and if the IDE does not include specific support for your programmer you can then locate the .hex file and upload it using the tool you are familiar with. The projects are typically built in a build.* subdirectory under %TEMP% (or /tmp on unix).


According to the data sheet the minimum target distance is 20cm in the open air at a 343 m/s
The speed of sound in water is 1481 m/s so the minimum distance would be 20cm x 1481 / 343 = 86cm.

You cannot measure distances under 83cm in water.


upload.tool not used in custom boards.txt?

From https://github.com/bigjosh/Move38-Arduino-Platform#programmers:

  Since there is no bootloader in a tile, all code must be programmed rather than downloaded.

When you do an "Upload Using Programmer", the tool is specified in the {programmerID}.program.tool property in programmers.txt. The {boardID}.upload.tool value is only used for a standard upload.

Since programmers.txt is not in your hardware package, this makes it very inconvenient to customize. What's worse is that the platform.txt associated with the selected programmer is used, rather than the one in your hardware package, for "Upload Using Programmer". For this reason, some popular hardware packages include their own copies of all standard programmers. The downside of this is it really clutters up the Tools > Programmer menu if you have multiple of these packages installed.


First create a topic and include the ESP8266 ID. Do not make it part of the published value.

Second publish the raw data as-is, uint16_t raw_ir_code[RAW_IR_CODE_MAX]. The alternative is to convert to string (characters). But if the subscriber has the same architecture (interpretation of data), there is no need to convert it to string and back. Simply publish the raw data as it is.

You will need to cast the raw_ir_code vector to the appropriate type for the MQTT publish call.

Cheers!


Arduino project - will this fit together?

From what you've provided everything seems to be compatible.

Concerning the battery, a quick look at the Arduino website shows:

  Input Voltage 3.35 -12 V (3.3V model)

Meaning the regulator will work as long as the battery provides voltage above 3.35 but since your battery's voltage drops as it gets depleted you might not get the battery life you'd expect :/. In other words: it'll work initially  until the voltage drops below 3.35V and then you would have to recharge it.

  Is using Li-Ion in any way different from regular AA

Yes and No.
No : both provide a stable DC source and both can be used in similar applications.

Yes: Li-Ion batteries can be recharged and have a longer life-span, and most importantly, Li-Ion batteries don't have a sharp voltage drop as they get depleted, unlike regular AA batteries. Which is a bonus for this project ( i guess :p )

  I see 3 pins on the back of it

There are only 2 pins that actually provide the power from the battery while the third is usually used to monitor temperature or battery life remaining.So you can use this battery by only connecting the power providing pins (usually indicated by + and - ) and safely ignore the third.

Gd Luck!


Problem connecting 2 74HC595 8 bit shift registers in cascading connection

I am really very sorry to say that after a long inspection , i have found that
shift register clear (pin 10) pin of the second shift register remained inactivated due to loose connection of power, after fixing it, all shift registers are working very fine.
I do really apologize to all those friends who came to help me, for wasting their time, i am really very sorry for that...
all problems are solved now.


Jaromanda X is indeed correct - min() is defined on line 92 of Arduino.h, thusly:

#define min(a,b) ((a)<(b)?(a):(b))

Therefore when the ++mycount is substituted for the a, it is in fact substituted twice, in both the (a)<(b) and the (a):(b), leading to the increment by 2, each time min(++mycount,8) is executed.

As VE7JRO mentions, as it is defined in this way, the reference for min(x,y) states:

  Warning

  Because of the way the min() function is implemented, avoid using
  other functions inside the brackets, it may lead to incorrect results

min(a++, 100);   // avoid this - yields incorrect results

min(a, 100);
a++;            // use this instead - keep other math outside the function

As the second example states, keep any incrementing outside of the min() macro.

Alternatively, I think that you could use the inline function to workaround this issue:

#undef min
inline int min(int a,int b) {return ((a)<(b)?(a):(b)); }

Because inline provides a real function call (with parameters) it avoids the use of macros and substitution, which gives rise to the issue that you encountered.

inline is a much better (safer) way to implement the functionality provided by macros, in many cases. For more information, see Inline functions in C++ or read a C++ reference.


This is a generic debugging advice, but maybe it can still be of help:
have you tried driving the led from the loop, to check that it doesn't get stuck for some reason?

Other thing you could do is to get the datasheet of the motor driver, find out the inputs from the ATMega and see how they look like.
At least that would allow you to bisect the problem answering the question:
"Does the ATMega generate the expected signal?"


Im with @arvid-jense on this one, if you are working on a serious Digital Clock, then you should get the Real Time Clock.

Now if you are learning Arduino and want to play with your LCD Minidisplay and build a clock, you must know some important limitations of the millis() function on this project:

The mills function will overflow, after approximately 50 days.
Your clock will be inexact because the cycles of the Arduino
loop, you will be checking how much mills has passed on each loop.
(it will be lagging ~ 10 seconds each day, so on day 7 you will be one minute late)
the parameter for millis is an unsigned long, errors may be generated
if a programmer tries to do math with other datatypes such as ints.

That being said

#include <Wire.h>
#include <LiquidCrystal.h>

/**
 * Clock Variables
 */
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

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

void loop()
{
    setClock();
    /**
     * After set clock now you have 3 int variables with the current time
     */
     //seconds
     //minutes
     //hours
     lcd.setCursor ( 0, 1);
     lcd.print(millis());
}

void setClock()
{
    currentMillis = millis();
    elapsedMillis += currentMillis - previousMillis;

    /**
     * If we use equals 1000 its possible that because of the mentioned loop limitation
     * you check the difference when its value is (999) and on the next loop its value is (1001)
     */
    if (elapsedMillis > 999){
        seconds++;
        elapsedMillis = elapsedMillis - 1000;
    }

    if (seconds == 60){
        minutes++;
        seconds = 0;
    }
    if (minutes == 60){
        hours++;
        minutes = 0;
    }
    if (hours == 24){
        hours = 0;
    }

    previousMillis = currentMillis;
}

Nice tutorial on building an Alarm Clock


Why won't my iMac recognize my Mega32u4 Arduino Pro Micro board (I've tried several cables)?

From what you say here:

  I plug it into my iMac and open Arduino and go to the board tab, and it doesn't even have a Pro Micro choice, so i just choose Micro.

and from the dump you provide:

  Arduino: 1.6.9 (Mac OS X), Board: "Arduino/Genuino Micro"

It looks to me like you're selecting the wrong board. Instead of just picking a "similar" board from the Tools menu, what you should do is add the Sparkfun board manager package and then select the Pro Micro from it.

Here you can find the procedure step by step. Follow it and you should be all set.

EDIT:

If you tried to upload a sketch with a wrong board selection, then your your Pro Micro may have become "bricked". In order to unbrick it, follow this procedure (same link as above, different section).

Once you unbrick it, upload the specific blink example code for Pro Micro that you can find in another section of the same link.

If it keeps not working, READ THE ENTIRE ARTICLE linked and try out all troubleshooting instructions before anything else.


Using Waveshare Raspberry Pi TFT LCD with Arduino Uno

Possibly.

The XPT2046 chip is only for the touch screen, not the LCD.  That will be easy to get going on the Arduino since many many Arduino LCD screens use the same chip.

However, you will need to find out what driver chip the LCD display uses (maybe ILI9488 or HX8357 or something similar), and what pins on the Pi header relate to what function on the display (note: it is probably a 16 bit parallel interface, so uses a lot of pins).

Also note that this only applies to displays that connect only to the big 40 pin header. If it uses the FPC display connector you will have no luck trying to use it with an Arduino.


SIM900 GRPS Shield Power down over issue AT+CIICR cmd(Bring Wireless Coms)

The SIM9000 shield requires up to 2 Amperes to operate its wireless functions. Thus it must be powered from an external 9 Volt power supply, and the supply should be able to supply at least 2 Amperes, preferably more.

The shield will thus not work if powered through the Arduino, or using a low current external supply. The current draw for initial setup is low, hence registration of the SIM might be fine. Enabling wireless pushes the current draw beyond what your supply can cope with. This is shutting your setup down.

Replace (or use) a 2 Amperes or better 9 Volt DC power supply, feed this power to the shield, not the Arduino, and attempt your code again.

Note that there are some changes required in using an Arduino Mega instead of the Uno with the TinySine GPRS shield, which are described in the help files and on some example videos on YouTube.


Controlling water temperature accurately

You need to know the response time of your system and the repeatability of your measurements to characterize your data (establish confidence). I suggest taking samples and average them before turning the heater back on.

Imho, water will not happily stay within 0.5°C. Can you allow for coarse and fine modes? Use a higher PWM for great differences and then lower PWM for when close to target.

Once homed in on your target, there are a few means you can try to improve temperature stability. While pre-built things like PID work for many, I normally implement functionality like this manually.


Cycling LED's for specific time period with millis()

A way to make this work is to use only one previousTime variable, rather than three of them.

When the program as shown above starts out, millis() is in fact close to 0, so none of the three LEDs should light up in the first 2 seconds.  At the 2 second mark, LED 7 comes on.  previousTime2 gets set to current time, so the second if is not going to be satisfied for 2 more seconds.  At that point, LED 7 and 8 are in a race to see which one turns on second; whichever turns on first at the 4-second mark gets turned off within milliseconds, because when any LED turns on, the code turns off the other two LEDs.  Whenever the condition for LED 6 is met, so is the condition for at least one of 7 or 8; so 6 can't stay on more than 2 seconds at most, and even then is in a race with 7 and 8 to come in third.

With a single previousTime variable, code like the following might work.

current = (millis() - previousTime)/1000;
if (current < 6) {
  digitalWrite(6, HIGH); // turn on 6
} else {
  digitalWrite(6, LOW);  // turn off 6
}
if (current >= 6 && current < 8) {
  digitalWrite(7, HIGH); // turn on 7
} else {
  digitalWrite(7, LOW);  // turn off 7
}
if (current >= 8) {
  digitalWrite(8, HIGH); // turn on 8
} else {
  digitalWrite(8, LOW);  // turn off 8
}
if (current >= 12) {
  previousTime = millis();
}

Note, the following code has the same effect.

current = (millis() - previousTime)/1000;
digitalWrite(6, current < 6);                 // turn 6 on or off
digitalWrite(7, current >= 6 && current < 8); // turn 7 on or off
digitalWrite(8, current >= 8);                // turn 8 on or off
if (current >= 12) {
  previousTime = millis();
}


What pins should I use when blinking AtTiny13 with arduino IDE?

You'll need an Arduino library that supports that chip, to make it appear in the Tools > Board list.  The library docs will tell you which pins then correspond to which Arduino digital I/Os. From that you can decide which pin to attach an LED to (with resistor) and how to edit the blink sketch.

Example: http://www.instructables.com/id/Pimp-Your-Chocolates-with-Arduino-IDE-and-ATtiny13/step2/Program-the-ATtiny13/


Programmed 5 Volt output to power a relay

Your concern for the output capability of the pin should be its current sourcing or sinking capability, not its voltage. Arduino pins typically have a limit of 40ma per pin and a total maximum of 200ma. This is for the Atmega328p (you didn't say which Arduino you're using. You'll need to drive motors or relays or anything else with a substantial current requirement with a driver circuit powered independently of the Arduino itself. That can be with a shield made for the purpose or a circuit you design and build into your project. Motors and relays in particular need snubber diodes to protect the driving circuits from inductive "kickback" or spikes generated in their coils.


Inaccurate PWM Signal Frequency and Timing

it seems in the first picture that the two pulses have different duty cycles which is why it appears shifted. It looks like the 'on' part stays on for less time than the 'off' so your duty cycle is probably <50 but your frequency might still be 40kHz.

I think the most accurate way of getting 40kHz just with a teensy is to use timer interrupts as Majenko suggested. Check out the documentation for it here, its pretty straight forward,you set the timer to go off every 12.5us and in the ISR simply toggle a digital pin and keep count of how many times you've toggled it. If your teensy needs to run other interrupts you should change the priority using myTimer.priority(number); to possibly give the 40kHz interrupt a higher priority. One thing, don't use digitalWrite in the ISR as its slow af, either try digitalWriteFast or use assembly language to toggle it as pointed by Majenko.

Alternatively you could use a 555 timer which is easy to setup and I'm pretty sure it's been used to gerate 40kHz at 50% duty cycle, although it might be a bit tricky finding the correct capacitor/resistor values if they're too small/non-standard. Then you would hook up the output of the 555 timer to whatever you're hooking it up to and also to a digital input pin on the micro. Then you would have to set an external interrupt on that pin so whenever the 555 goes high the interrupt on the pin would fire and you would keep track of how many pulses have been generated.

Alternatively, you could use a digital signal synthesizer. I used the ad9837 for one of my projects. It can generate something like 0-3Mhz with a 5Mhz external clock at a resolution of 0.02 which is pretty good. I've got an altium design for it if you don't want to buy the module and an adapted version of the adafruit miniGen library which works with teensy3.5 link. Then you'd need to do the same feedback loop as the 555 to keep track of how many pulses have been produced (or your way of waiting X microseconds). The module is actually pretty low power so you could power it from a digital pin and turn that pin on/off every second.

I think you should try the interrupt method first, as it's the easiest. Also, I get that you want 8 pulses evey one second but maybe for debugging purposes have the 40kHz pulse go constantly and change your scope to measure frequency so you can see how far off you are from 40khz.Then once you know you're actually getting 40khz have it run every 1second.


how to send data to Adafruit Bluefruit Feather (32u4) over bluetooth?

The “UART” being referred to is the Nordic UART GATT Service. This is not a serial port or USB connection. It is a high level BLE protocol that simulates a serial port via the Bluetooth connection.

In order to connect to the device from your Mac you’ll need to write some C or Obj-C. I’ve done this for Windows, but not a Mac, so I’m afraid I can’t give you detailed instructions. However, the source code for the iOS Adafruit Bluefruit LE Connect app you’re using is open source and should be a good starting point.

Be warned of a few things though.

You’re going to have to learn a bit about the BLE protocols and standards. It’s not exactly for the faint of heart.
Apple throttles the speed/throughput of BLE for their iOS devices (as does Android) to protect battery life. I don’t know if they apply the same throttling to their laptops. You may not be able to achieve a satisfying data rate if you’re looking to create a high throughput “data pipe”.  With Win10 and the Bluefruit LE I was able to achieve 40 bytes every 30ms. You’ll likely be limited to 20 every ~30ms.

If you’re looking to just send some occasional text (maybe AT style) commands to the device via BLE though, you won’t come close to those limitations.


I forgot to take care of negative steps in remainder accumulation.
This solved it.
// x accum
float resX = mmX * (float)X_STEPS_PER_MM;
float lresX = (long)resX;
_x_acum += resX - lresX;

long extraStepsX = 0;
while(_x_acum > 1.0f){
     _x_acum -= 1.0f;
     ++extraStepsX;
}

while(_x_acum < -1.0f){
     _x_acum += 1.0f;
    --extraStepsX;
}
// move stepper for lresX + extraSteps


Looking for a wireless soil moisture sensor

The project is very much possible but it will be easier if you attach the moisture sensor directly to the arduino and add a wifi shield or a bluetooth shield to the arduino itself and make it communicate with computer or phone. You could also program the arduino to directly water the plants if it finds that they dont have much moisture. You will rarely find a sensor that transmits data wirelessly and still be economically feasible. The Sparkfun SEN-13322 moisture sensor is good for the purpose but again connect it to arduino direclty.


Sound or motion activated long term battery powered Arduino

What you want to do after the triggering is an important part of this design.

An Arduino platform is not necessarily the best choice for power sensitive applications.  You identified one problem in your post: Linear regulators.  What you are likely wanting is an efficient switching power supply to support a wide range of voltages as your batteries drain.

Many embedded processor have low power modes.  Some are specially designed to reduce current draw down into the nA range when idle or sleeping.  However, all such processors require special care when configuring for these deep sleep modes.  That is to say, the application plays an important roll in deciding how to put a processor into such modes.

Supporting hardware is perhaps the most important aspect of a low power designs.  Contributions from the most advanced low power processors can be wiped out if supporting hardware runs at mA ranges.  A simple 10K pull up resistor will draw 0.5mA in a 5 volt circuit. The impact is meaningless in a mains powered application.  But for long term battery operation is could means days of lost time.

All that said, there are resources for Arduino low power operation.  Here is a low power library.  You will have to decide if it is sufficient for you application. Or if you need to also investigate low power hardware solutions.


I had the same board and problem as you, what fixed is was changing the board setting to black even though it is phyiscally red.

Inside

Arduino\libraries\TFT_ILI9163C\_settings\TFT_ILI9163C_settings.h

Change

//  ---> SELECT HERE <----
#define __144_RED_PCB__//128x128
//#define __144_BLACK_PCB__//128x128
//#define __22_RED_PCB__//240x320

to

//  ---> SELECT HERE <----
//#define __144_RED_PCB__//128x128
#define __144_BLACK_PCB__//128x128
//#define __22_RED_PCB__//240x320


If you amplified with an op-amp powered by 5V then it couldn't produce more than 5V output, so that could be your solution. Failing that, I think a resistor and a couple of clamping diodes would help. The resistor is to current-limit the clamping diodes. I don't think you need to worry about dropping the voltage through the resistor because the analog input is high impedance.

I think the 1n4148 would be OK, I don't see why not.


What is importance of the reflow profile?

Reflow soldering is an assembly process for printed circuit boards (PCBs) in which surface-mount parts are placed on a PCB prepared with solder paste.  The solder is melted by heating in a temperature-controlled oven, which then electrically connects component leads to pads on the PCB.  ICs can be damaged by high temperatures/rapid changes in temperatures, so the thermal profile defines the acceptable limits on the temperature of the reflow to avoid damaging the component.


Can I make a 455Khz Sine Wave with the Arduino UNO?

The Arduino does not has a DAC (digital analog converter), so you cannot make an output varying in voltage (except for 0V / 5V) by default.

The PWM outputs use 0V/5V with duty cycle but this is not a sine wave.

So you need additional hardware anyway.

Also, regarding speed if you have a DAC. Assume 16 MHz for the Arduino, having a 455 Khz sinewave, you have about 35 clock cycli per complete sine wave. The sine values you can store in a table, but you need probably at least 3 or 4 clock cycli per sine wave value (to fetch the value from the table and to send it to the DAC), this results in about 8 values which will give a very rough sine wave.

So I would go for a separate sine wave generator.


The bootloader is the feature supplied with the Arduino board, but not a chip itself. If you want to clone Arduino (fully or partially), you will have to burn the bootloader yourself.


Arduino to Raspberry Pi wired communication

Hands down, I can rule out the I2C. This post sums it all up:

  SPI is faster.
  I2C is more complex and not as easy to use if your microcontroller doesn't have an I2C   controller.
  I2C only requires 2 lines.

Since speed is your first priority, either do USB or SPI. I'd personally go with USB, just for the reason that it's simple. Nearly any programming language can inference with COM ports, but that's not the case with SPI. Also, for SPI, you would have to either use a level shifter, or do a voltage divider for the Arduino to RPi wires (for RPi to Arduino wires, Arduino can still sense 3.3V as HIGH.)

Also, serial can be pretty fast. Technically, the Arduino can go up to 2 Mbps (not very fast compared to a lot of things, but fast enough for what the Arduino can even handle). One thing to note, the writer of the post stated that this is the highest you can practically achieve with the poorly optimized libraries:

Serial.begin(500000);


You are doing complex calculations inside an Interrupt Service Routine. This is not a good idea. Computing sines takes a large amount of time as this consists of multiple, complex floating point operations. Interrupt Service Routines should be short and as simple as possible.

This is probably the reason you can't have two PWM signals active at the same time at the same frequency. The ISRs simply take too long.

The solution would be to pre-calculate the desired waveforms or greatly simplify the waveform calculations (preferably without floating point). If you decide to pre-calculate, take care to stay within the limited amount of memory you have available on your Arduino. You can minimize the memory used by calculating and storing just 1/4 of a complete waveform and constructing the remaining 3/4 from these values.

This leaves the conversion of your PWM output to a real sine wave. How are you planning to do that?


Problem in defining a variable as multiplication

unsigned long onPeriod = 60ul * 1000;

ul makes 60 to unsigned long and then the calculation has place for result.

without ul the constants and the result are int and it overflows


Diorama Controller Part 2 - Need More Outputs

I think I understood what you want. If you want to control more LED's with less pins, consider using a shift register. For example, sn74hc595 could increase your digital outputs drastically. It has 8 bits, so you can have 2^8 combinations of outputs with it! For example, 0000 0001 is something, and 0000 0010 is something else, and so on. Check it out! I hope this helps :)

https://learn.sparkfun.com/tutorials/shift-registers - Basic knowledge about shift registers
http://www.bc-robotics.com/datasheets/sn74hc595.pdf
Other shift registers are great as well


A way to accomplish "Reset" is to set your starting value equal to millis() again. To do the equivalent of "Pause", you need a pause counter. When you begin a pause, save millis() to pauseTime. When you resume running again, add millis() - pauseTime to your pauseCounter. Then your interval should not expire until millis() - pauseCounter > Interval).


Global variables with C++ in multiple files

When using multiple source files you need to use header files to share things between them.

myproject.h:

#ifndef __myproject_h__
#define __myproject_h__
extern int aGlobalVariable;
#endif

myNewCode.c

#include "myproject.h"
int aGlobalVariable;

modifiedOldCode.cpp

#include "myproject.h"

This way the header file defines the variable as an extern in all of your c / cpp files so that it is visible to all of them but the variable is only actually declared and memory allocated for it in one place, in the .c file.
Similarly any functions that you want to be visible in both files should be declared in the headerfile (e.g. void myfunction(int x);) but the actual definitions should be somewhere in the .c or .cpp files.
The #ifndef and #define lines in the header as there so that if the header somehow gets included twice you don't get lots of redefinition errors.

There is nothing strange about c++ and globals, a global defined this way is global to everything, it doesn't matter what object you're in or how things are scoped. This can however have some strange effects since there is only ever one copy of a global while you can possibly have multiple instances of the c++ class that uses it. This can cause some consistency related issues if you aren't careful. Whether you need to worry about this or not depends very much on the nature of the code.


Are there any pressure sensor for 22 kg (~50lbs) and more?

Your problem may be that you are using sub-optimal search terms.
The kilogram is not a unit of pressure, but instead of mass.
Scales technically do not sense mass, but instead sense force.
This is assumed to be the force exerted by a resting body under earth gravity.
Pressure is force over an area, such as pounds-per-square-inch (PSI) or the Pascal which is a newton per square meter.

Anyway, the sensor you want is called a force cell.
The nice ones are rated in newtons or kilonewtons, with a kg being equivalent to
9.8 newtons.

Here is a load cell that take up to 50 kg.
http://www.phidgets.com/products.php?product_id=3135

Sources:
http://en.wikipedia.org/wiki/Force


Setup J-K Flip-flop for logging on Arduino RESET

Rather than having events that set 1Q or 2Q, consider having the external events take 1R\ or 2R\ low, to reset 1Q or 2Q.  When your sketch starts up, it would read 1Q and 2Q.  If one or the other is low, its event occurred and you can log it.  Then the sketch sets both Q's by dropping the CP lines with J's wired high and K's wired low.  You'd use three I/O pins: two for reading 1Q and 2Q, one for strobing the CP lines to set the Q's after reading them.

Arduino AVR pins default to inputs on Reset so the Arduino can reset without affecting the 74HC73's state.  A 10 to 20KΩ resistor to passively pull the CP lines high is reasonable.

Edit: Note, 1R\ and 2R\ operate asynchronously, and are independent of clock inputs.  This leads to simpler interface requirements for your external events.  However, it may also increase sensitivity to electrical noise; if your system is in a noisy environment a different approach might be needed.


The closest thing to what you describe is DMA (Direct Memory Access). The Arduino doesn't have DMA. More powerful microcontrollers often do, but not little 8 bit ones.

The closest you could do is to use a timer interrupt to run a small function periodically which reads the next value from an array and sets the pin to that state.

The TimerOne or TimerThree libraries can be of help to you here.


I'd like to make RC car and remote controller via bluetooth (HC06)

There are some fundamental problems in the code - bufferPosition never stops increasing (until it reaches 32768) and so buffer will overflow. However, neither of these two problems are causing the 'trash', as you are outputting the result of reading the serial, not anything from the buffer.

The problem lies in the casting of the result from BTSerial.read() to unsigned char.

Serial.print() does not like this. Actually it doesn't care, but it won't give you what you expect. It just prints out the value stored - so 'a', which is 97, will come out as '97' on the serial monitor. Serial.print() only outputs ASCII characters when you give it a char or char[].


What is the maximum SPI speed for a slave Uno/clone?

The maximum speed for Arduino as a slave is F_CPU/4, so it's 4Mbps.
When the Arduino is the master it can work at F_CPU/2, so it's 8Mbps


CHG340 supports common baud rates: 50, 75, 100, 110, 134.5, 150, 300, 600, 900, 1200, 1800, 2400, 3600, 4800, 9600, 14400, 19200, 28800, 33600, 38400, 56000, 57600, 76800, 115200, 128000, 153600, 230400, 460800, 921600, 1500000, 2000000 baud.

250 000 baud isn't supported by that IC.

The Baud steps is either 200% or 150% of the previous value (There is exceptions).

Tested and working Baud rates.

I used putty as serial monitor since the built in monitor didn't have all baud rates preprogrammed.

SpeedTest.ino

// Serial port Baudrates:
// const int Speed = 115200;
// const int Speed = 128000;
// const int Speed = 153600;
// const int Speed = 230400;
// const int Speed = 460800;
// const int Speed = 921600;
// const int Speed = 1500000;
const int Speed = 2000000;

void setup() {
  // Initialize serial:
  Serial.begin(Speed);

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
  Serial.print("Speed :  ");
  Serial.println(Speed);
}


Cannot set MOSI pin low even after ending SPI

Indeed, SPI is hardware implemented.  I was able to get the MOSI pin to operate as intended by clearing the SPI enable bit from the SPCR register as follows:

SPCR &= 0B10111111;  //disable SPI

To re-enable after sleep, I'm assuming I'll just do SPCR |= 0B01000000; ...pretty sure that will work but I'll update here if I have to modify my solution.

.

Perhaps also pertinant information:

I was using an object of SPIClass in SPI.h which is from the Arduino core libraries -- for some reason it wasn't disabling SPI in hardware when calling the spi.end() method, maybe because there was some other SPI object initialized by some other library.  Here is the source from SPI.cpp for the end method:

void SPIClass::end() {
  uint8_t sreg = SREG;
  noInterrupts(); // Protect from a scheduler and prevent transactionBegin
  // Decrease the reference counter
  if (initialized)
    initialized--;
  // If there are no more references disable SPI
  if (!initialized) {
    SPCR &= ~_BV(SPE);
    interruptMode = 0;
    #ifdef SPI_TRANSACTION_MISMATCH_LED
    inTransactionFlag = 0;
    #endif
  }
  SREG = sreg;
}

The line SPCR &= ~_BV(SPE); should have done the job for me but I'm guessing it never got there because initialized was probably still non-zero.


The proper syntax for referring to a struct member is [structName].[memberName]. Changing lastThing in lines 8 & 13 to savedValues.lastThing fixes the "undeclared" error.


Turning a DC motor a set number of Rotations using an encoder

You never tell the motor to stop.

void loop(){
   while(counter< 360*5){
     analogWrite(motor,255);
   }
   analogWrite(motor, 0); //add something like this or whatever could stop it
   //you may want to disable the counter now too
}

However, even with that change you are likely a long way from having a working, or at least reliable system - see other issues in my comment on the question.


Are function pointer assignments atomic in Arduino?

Have a look at the code for attachInterrupt() and detachInterrupt() in
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WInterrupts.c (well, that's where they are on a Mac, anyway. Arduino file structure on other OSes' probably looks similar in the lower levels of the path).

It appears that attachInterrupt() assumes that the interrupt in question is not yet enabled because it writes the function pointer without taking any precautions. Note that detachInterrupts() disables the target interrupt before writing a NULL-pointer to its vector. So I'd at least use a detachInterrupt() / attachInterrupt() pair

I'd want to run any such code in a critical section, myself. It appears your first way (detach, then attach) would work, though I can't be sure it couldn't miss an unfortunately timed interrupt. The datasheet for your MCU might have more to say on that. But neither am I sure at this point, that a global cli()/sei() wouldn't miss it either. The ATMega2560 datasheet, section 6.8, does say "When using the SEI instruction to enable interrupts, the instruction following SEI will be executed before any pending interrupts, as shown in this example", seeming to imply that it can buffer an interrupt while the interrupts are off.


Arduino boards are not working with powerbanks!

Most USB powerbanks will automatically turn off if there is not a minimum current draw to keep them turned on.  The Arduino is obviously drawing current below the limit for the devices you have.
A couple of options:

Add some additional load to keep the powerbank on indefinitely.  Of course this may waste power but that's part of the price to pay.
Find a power bank that is less sophisticated.  I have one with a manual on/off switch.  It powers the Arduino just fine until it runs out of power.
Find a different powerbank that has a lower threshold for staying on.  Some vendors give you this spec and others don't.
Modify the powerbank to stay on.  I'm not sure there is a general way to do this but you might experiment with it and see.


How to I measure the duration of touch with a soft potentiometer?

You have to go with timer interrupts. Here is the documentation: http://playground.arduino.cc/code/timer1

Roughly, when you detect a press, an interrupt is raised and the same thing goes for releasing. Using the timer values from both these events, you can accurately measure the time that the press lasted.


ESP8266 cannot connect to an existing network after using AT command

you have Firmata in Atmega, AT firmware in ESP and the 'blink led' js on computer.

you did not follow the tutorial properly. it requires jonny-five firmware in esp8266


This buildin LED is connected to an IO pin of the microcontroller on the Mega (most commonly pin 13, but might be different depending on the board). So the meaning depends on what the code on the Mega does with it.
When the board is reset (which happens on opening of serial connection), first the bootloader will run. It gives you a short blink on the buildin LED. After the bootloader finishes, your own code is in charge. Whatever you do in your code with pin 13 will be reflected on the LED. Here the meaning depends on you.


ATmega168a Breadboard - can't load via Arduino IDE

Have you burned a bootloader?
The standard Arduino IDE upload requires that you have a bootloader on the chip.
You can burn a bootloader with the Arduino IDE and your AVR dragon


Arduino analog input to iphone notification

It is totally doable, but we cannot give detailed tutorials here, since this is a simple Q&A site. So I will point you to a direction, that can lead you to the solution.
When building IOT devices with Arduino (and thats exactly, what you are doing) there are 2 internet services, that are commonly used for getting information from the device to other devices (like your phone):

Blynk
IFTTT (means If This Then That)

Both have apps and can be used to push notifications, when your IOT device does a webrequest to the service. There are also libraries for Arduino available (at least for Blynk). There are many tutorials out there, so I suggest, that you search for yourself and try some of them.
For the hardware of your IOT device, I would suggest an ESP board, because they already have Wifi build in, for example the ESP32 gives you great IO capabilities.


using more than 8 temperature probe of DS18B20 on Arduino

As far as I can see there is no limit on the number of sensors you can have on a bus.

So if you are having problems does your code work with less sensors? Try one and work up.

Is it a current issue are you pulling to much from the board?

Is the problem with the one wire library?

Have you got 4.7k pull ups on each sensor?


fatal error ESP8266WiFi.h: No such file or directory

The ESP8266 core for Arduino that you're trying to use is for programming ESP8266 directly. You are trying to program an Uno with an ESP8266 connected to it for use as a WiFi module. For that application the ESP8266 core is of no use. For your application it's most common to run the AT firmware on the ESP8266 and communicate via serial. If you're doing that I recommend the WiFiEsp library:

https://github.com/bportaluri/WiFiEsp

Since you're uploading to the Uno you should have Arduino/Genuino Uno selected in the Tools > Board menu.


It sounds like you figured most of your question out already.

(Someone correct me here if I'm wrong). The Atmega 328p uC, I believe, has an 8 byte hardware buffer for RX serial data. In software, the Arduino core code defines a maximum ring buffer of 64 bytes that acts as a FIFO queue.

So, what does his mean? Let's just focus on the hardware buffer since it's fairly easy. Say you send your data 1,2,...,10 at 10ms intervals, and you read your data at 100ms intervals (for illustration purposes). The problem is that you send 10 bytes of data but only have room for 8 bytes. So, your first two values (1,2) are pushed out of the buffer and lost. This idea also illustrates a FIFO queue, first in first out.

The same idea can be extended to a ring buffer.

Anyway, like you said, this could explain your problem. If you have 64 bytes, which will obviously be full since your inevitably losing data (20ms read with a 10ms write), you'll be seeing the effects for 64 * 20ms = 1.28s. There's probably some processing delay too which will extend this delay, but it's more than likely minimal if it's efficient code.


Why does a function inside void set up is repeating after some minutes

The setSyncProvider function of the TimeLib sets a function which will be called by the library every interval seconds. The interval is set with setSyncInterval. Default interval is 300 seconds.


Is there a way of turning a computer into a Arduino type board?

A regular Arduino uses an AVR, more "pimped" Arduino might go to ARM. Some special versions of Arduinos uses other chips, such as the ever iconic ESP8266.

For home automation, an ESP8266 is WAY enough. Using an ARM is quite and overkill for home automation. But I've never seen anybody using a full PC for it. Why? Because it is around 10-20 times more expensive. They require much more components and many other things.

Something close to a full PC that you can get is a Raspberry Pi (any version would do). They act like a small PC, some even use it as a laptop. See PiTop. The Raspberry Pi is stronger, more powerful, and much faster then any Arduinos. The Pi also has ethernet, a graphic interface, and an audio interface built in. That means that you can pretty much connect it to a monitor and it will work as a normal PC running either Windows or Linux. You can then watch a video, with graphics and sound, from the inthernet without external modules like you would need on an Arduino. Their only weakness is that it is harder to program them to read may sensors. That is why the Arduino is popular for covering that.

At the end of the day, it is your choice. I would personnally suggest an ESP8266. This module has many GPIOs, depending on the breakout that you have, and has WiFi built in. This is a great feature for home automation. Most home automation builders use this module.

If you have any questions about the informations I just gave you, comment it, I'll reply.


Answer: Code blocks does not currently have an Arduino debugger. The Arduino IDE does not have a debugger.

There is an Arduino debugger in Atmel Studio using the Visual Micro plugin.

That said, you have to use Ms Windows to use Atmel Studio which might not be available to you.

The Visual Micro debugger is simple and uses usb so does not require additional hardware but as your experience grows you might also like to progress to fully blown hardware debug using the native Atmel Studio Tools

Visual Micro debug in Atmel Studio

Atmel Studio Download


From your code, I assume that the bluetooth module is connected to pins 0 & 1 on the arduino. These pins are to be kept free/floating/not connected to anything if you need to upload code to your board.

Use software serial in such cases reduces the headache


freq * long, since they are both integers, are calculated as integers.

440*256=112640 - in binary that is 1 1011 1000 0000 0000 and trimmed to 16 bits becomes 1011 1000 0000 0000 which is -18432 and that is where the heart of your problem is.  Unless you explicitly say otherwise the Arduino's compiler does all calculations (except floating point) as 16-bit signed integers.

By casting the values to long it forces the compiler to 'overflow' the 16-bit limit and use a 32-bit limit instead:

long timer = 2000000 / ((long)freq * (long)len);

Another alternative is to define freq and len to be long from the outset instead of int.


The L298 is a very old, obsolete design based on bipolar transistors, which means it has a lot of internal losses.

The energy consumed in those losses shows up as heat.

It also has some degree of overload or overtemperature protection, so what you are observing is an automatic shutdown.  Or perhaps, your motor is causing the battery voltage to sag and resetting your Arduino at which point the sketch resumes after a bootloader delay.  6v is really too low an input voltage to the Arduino's regulator, but too high for direct input without the regulator.

You need to make sure that the current draw of your motors is reasonable, and you likely want to replace the terrible L298 with a more modern, low less FET driver.  You will need to select one rated for the actual current draw of your motor: you should consider not only free rotation of the motor, but the increased current draw if it is mechanically stalled.


As suggested in the comments, you have two options:

As suggested by Majenko, you can use the Arduino USB Host Shield:

Alternatively you could use a PS2 keyboard instead (as suggested by Gerben). Arduino already has a library to handle PS2 keyboards, so the implementation of it would be easy. For reference (and example program)
playground.arduino.cc/Main/PS2Keyboard

If you do not have access to a PS2 keyboard or just want to use a USB keyboard, Gerben further suggests that most USB keyboards can be converted to PS2 keyboards with an adapter:

The keyboard must be able to support both formats (USB & PS2).

The following webpage shows the connections needed to go from USB to PS2:  USB to PS/2 adapter pinout


Source power with 2 V and LED with forward voltage of 2 V

No, it would not damage your led. The forward voltage of a led is, the voltage at which the led 'conducts' the maximum current it can handle. Since diodes have a (exponential) curve, the current though a diode depends on the voltage across it.

So if you give the led 2V, it will use only 20mA. However if the voltage goes to e.g. 2.1V the current might be 25mA (since the curve is exponential), which is a bit too high, and will reduce the leds lifespan.

So for safely I'd add some resistors. E.g. a 10Ohm resistor will limit the current to 20mA max, as long as the voltage doesn't go over 2.2V

PS note that led Christmas lights use the same method to limit current, without a single resistor. I have here a 24v string of leds, grouped into 10 leds connected in series. So the voltage across each led is 2.4V. They are white leds, so they probably have a forward voltage of around 3.2v. But since they only get 2.4v, they will probably use only 5mA or less.


Why does enabling TIMSK1 mess up serial?

You've enabled interrupts for Timer 1 Compare A interrupt. Where is the interrupt handler?

For example:

ISR(TIMER1_COMPA_vect)
{
  // whatever
}  // end of TIMER1_COMPA_vect

Without that, the processor is just restarting. No wonder serial output is messed up.


Import into Arduino a vintage data bus from TMS1000

You're not going to find any pre-built libraries for this task which is somewhat unusual but not at all impossible.
Basically all you need to do is to connect the TMS1000 address/data and strobe lines to Arduino inputs and write yourself some relatively simple code to detect the various TMS1000 bus states and capture them when they happen.  In order to detect specific events as you have mentioned you will need to know more about the TMS1000 software that's running and what I/O devices that it's selecting.  But again, that's all pretty straightforward.
Keep in mind, however, that you are going to have to perform level shifting on ALL the inputs from the TMS1000.  This old TI chip was implemented using a PMOS (i.e. a predecessor to both NMOS and CMOS) and uses a NEGATIVE power supply instead of the more common today POSITIVE supply.
So rather than being powered by a +5V supply the way an Arduino is, the TMS1000 is powered by a -15V supply.  In this case ground is still at 0V but Vdd is -15V.  That means the I/O signals adhere to a different scheme as noted in the datasheet:

You can view the datasheet yourself at:
TMS1000 Datasheet
But what this means is that a LOW (i.e. Vil) is at -15V and a HIGH (i.e. Vih) is at 0V.  You will need to translate these voltages so that you don't damage either the TMS1000 or the Arduino and you get the correct levels on the pins that you are watching.
The TMS1000 datasheet has some suggested circuits for interfacing to 74LSxx series parts (i.e. 5V logic) which will probably get you started.  Note that the simplest method involves running the 5V logic with its VDD at 0V and it's "ground" at -5V.  While this might seem odd, the Arduino will not know the difference as voltage is always relative.


You can, but you shouldn't, because the the board will heat excessively, as you're out of the recommended range for the input voltage on vin (7-12V).

Unless you have a switching regulator (the one on the board is linear), then you shouldn't' have too much of a difference between the operating voltage and vin as an operating principle because of efficiency (and thus heat) issues.


The AVR library documentation for exit() is great help. It explains that the interrupts are turned off and an infinite loop is entered. As the interrupts get turned off the last characters in the Serial buffer are not transmitted.

You can use Serial.flush() to wait for the transmission to complete before calling exit().

Cheers!


How to tell what components are compatible with Arduino Due?

As far as I understood this energyShiled accepts any input between 5-24V and output 5 - 3.3V. This specs are compatible with arduino Due. And with the solar panel.

You can always power servos from seperate source or from the same battery but with seperate direct line.


Where to get the potentiometer that comes with Arduino kit

It's just any old trimmer pot. It's nothing special. Why do you feel you need that specific one? Any pot (of the right value) will do.  What value is it? (That datasheet is a generic one for all values).

Visit your favourite electronics retailer (IRL or on line) and pick a pot that is a suitable value and jiffles your tipples.


LEDs are not really efficient for heating up, you can better use a normal light bulb for that (they are less efficient, thus giving more heat).

The Arduino can only control some 100's of mA, that's not much for heating purposes.

Did you think about using a real heater (maybe small size), and use a relay to turn it on by your Arduino, and using a temperature sensor to switch it off above 28 and switch it on below 25 (or a lesser margin to keep up with the time it takes to change the environment temperature)?

If you do not want an external mains power, you could use probably a 12V heater and use a 12V->5V converter for your Arduino, or use a 5V heater pad, but according to what I have seen they are more for warming up cold hands, I doubt they can bring up the heat to 25-28 degrees Celcius. Besides, they are probably not very efficient.


Arduino Prototype on Breadboard: "avrdude: stk500_recv(): programmer is not responding"

Remove the pins connected to Tx and Rx while uploading the code , it worrked for me.
also include all the libraries currently used in your program.
Good luck!!


Arduino how can I search for missing library header files

Assuming the question is about missing libraries. When running (right arrow button) the Arduino IDE the compiler will spit out an error if a header can not be found.  Not all header files are downloaded when you install the Arduino IDE because they take up space and it is very unlikely anyone would need them all.  It is recommended to manage libraries from inside the Arduino IDE.

To do this click on "Sketch->Include Libraries->Manage Libraries...".  (To be clear, click on Sketch at the top of the Arduino IDE window, move to Include Libraries in the new menu then move to Manage Libraries... in the next new menu and click on Manage Libraries... .)  This will pull up a new window.  There are many libraries.  Use the "Filter your search" box.  For example type "Nokia LCD".  This cuts the number of possibilities to about 8.  A reasonable number to go through and find the correct library.