texts: Design considerations for creating an Arduino 'shield' shield to limit EMI

texts:
I am building a shield that contains an AC power supply and relay for an Arduino-like board. The problem I am having is that the relay is quite noisy with respect to EMI, and I can see a few jitters or jumps in my system during normal operation even with a zero cross detector.

I have added in another shield between the 'relay' shield and the main board, which has helped the problem by creating a larger gap, but I would like a more permanent and robust solution.

I was thinking of building a simple shield that has nothing much on it and is simply a large ground plane that sits in between the relay shield and the main board. This would be a simple solution that does not involve making any shielding cages.

This ground plane would be connect to the chassis of my device, which is then earthed.

Since the device has both a DC ground voltage (0V DC) and a AC earth (0V AC) I was thinking maybe I should use both as part of my shielding. Since the board has layers on both sides perhaps I could design it to have the side facing the relays to be earthed, while on the other side, facing the CPU, would be DC ground. I could even couple the two planes with a capacitor, if it helps.

On the one hand I think the earthed option should be fine, but on the other hand I would like to know more about using the DC ground as an EMI shield. Would the simple earth only option work? Would even a DC ground only option work? Does it help to use the DC ground as an EMI shield for the DC components or am I over complicating it?


texts:
i am using one adapter (12vDC 2A) i want to be able to power led strip with it plus the control circuit the problem is that the atmega328 reboots but when i only powers up the led strip with that adapter and power the control circuit with a independent 5v adapter every thing seems to be alright but i cannot do that in real world i need to get advantage of the same adapter i attached a picture of what i am doing right now help me to fix this
i am using 7805 regulator to reduce the 12v to 5v


texts: How to write & read from SPIFFS file as object data on ESP8266

texts:
I am trying write four digit number to SPIFFS file, and read that four digit from SPIFFS file and display on seven segment.
The code, I am writing as below, I got "0" on each segment, but if manually make number = 4567; then seven segment show proper number on every segment.
Please help me to learn more about how to read & write and convert to object data.
Here is my code;
#include <FS.h>

const char* filename = "/InputInt.txt";
int digit_1 = 0;
int digit_2 = 0;
int digit_3 = 0;
int digit_4 = 0;

int Anode_1 = 16;
int Anode_2 = 14;
int Anode_3 = 5;
int Anode_4 = 4;
int count = 0;
int digits[4] ;
int AnodePins[4] = {4, 5, 14, 16};

int clockPin = 12;
int latchPin = 13;
int dataPin = 15;

int number = 0; //declear the variables

byte numbers[10] {B00000011, B10011111, B00100101, B00001101, B10011001, B01001001, B01000001, B00011111, B00000001, B00001001};

void setup() {
  Serial.begin(115200);
  Serial.println();

  bool success = SPIFFS.begin();

  if (!success) {
    Serial.println("Error mounting the file system");
    return;
  }
  SPIFFS.format();
  File fw = SPIFFS.open(filename, "w");

  if (!fw) {
    Serial.println("Error opening file for writing");
    return;
  }
  char Written = fw.print("1234");

  if (Written == 0) {
    Serial.println("File write failed");
    return;
  }
  fw.close();

  pinMode(Anode_1, OUTPUT);
  pinMode(Anode_2, OUTPUT);
  pinMode(Anode_3, OUTPUT);
  pinMode(Anode_4, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

} //End of setup

void loop() {
  int i;
  File fr = SPIFFS.open(filename, "r");

  if (!fr) {
    Serial.println("Failed to open file for reading");
    return;
  }

  for (i = 0; i < 4; i++) {
    byte number = (Serial.write(fr.read()));
  }
  fr.close();
  break_number(number);
  display_number();
  delay(3000);
} // End of loop

// seperate the input number into 4 single digits
void break_number(int num) {
  Serial.println("");
  digit_1 = num / 1000;
  digits[0] = digit_1;
  Serial.print(" Digit_1: ");
  Serial.println(digit_1);
  int dig_1_remove = num - (digit_1 * 1000);

  digit_2 = dig_1_remove / 100;
  digits[1] = digit_2;
  Serial.print(" Digit_2: ");
  Serial.println(digit_2);
  int dig_2_remove = dig_1_remove - (digit_2 * 100);

  digit_3 = dig_2_remove / 10;
  digits[2] = digit_3;
  Serial.print(" Digit_3: ");
  Serial.println(digit_3);
  digit_4 = dig_2_remove - (digit_3 * 10);

  digits[3] = digit_4;
  Serial.print(" Digit_4: ");
  Serial.println(digit_4);
}

void display_number() {                                             //scanning
  digitalWrite(AnodePins[count], HIGH);                            //turn on the relevent digit
  digitalWrite(latchPin, LOW);                                      //put the shift register to read
  shiftOut(dataPin, clockPin, LSBFIRST, numbers[digits[count]]);    //send the data
  digitalWrite(latchPin, HIGH);                                     //put the shift register to write mode
  delay(0);
  digitalWrite(AnodePins[count], LOW);                            //turn on the relevent digit
  count++;                                                          //count up the digit
  if (count == 4) {                                                 // keep the count between 0-3
    count = 0;
  }
}

Here is the result;
1234
 Digit_1: 0
 Digit_2: 0
 Digit_3: 0
 Digit_4: 0
1234
 Digit_1: 0
 Digit_2: 0
 Digit_3: 0
 Digit_4: 0
1234
 Digit_1: 0
 Digit_2: 0
 Digit_3: 0
 Digit_4: 0

Thanks,


texts: I am using different codes which set different values of baud rate through the Serial.begin() function. Do I need to change the baud rate of the serial monitor to match the initialized value on the code I am running every time, or can I just leave the serial monitor baud rate set at the highest frequency of all my sketches (115200)?


texts: memcpy is corrupting serial output even before call

texts:
I just want to memcpy some data into a buffer, but it completely destroys my serial output.

Arduino Nano
Arduino IDE || VS Code with Platform.io

Here the relevant declarations:

uint8_t picture[4170] = {255, 216, 255, 225, 0, 24, 69, ... }
uint8_t myBuff[244] = { }; // 243 + 1 crc

At one point I just want to transfer bytes from picture into myBuff with:

memcpy(myBuff, picture + (currentPackage * (sizeof(myBuff) - 1)), amount);
//memcpy(myBuff, &picture[currentPackage * (sizeof(myBuff) - 1)], amount);

The serial monitor just prints out the null-character over and over.
I even tried to just once do this in the setup:

memcpy(myBuff, picture, 100);

And even this seems to break something as I don't get any serial prints at all anymore.


texts: Can I power Arduino with 12V 1.2A adapter

texts:
I am new to arduino and i am making a smart energy meter for my home. I want to run the arduino months so, how to power arduino with a adapter, I have a 12V 1.2A adapter is it ok to power arduino with it or not?.
Thanks in advance.
As i said i want to run it long time.


texts:
I have a BLUno bluetooth arduino based on uno.

the logic kind of works, I am connecting ok to the phone, getting and sending messages via blue tooth

but with the serial data, Im having problems using it, and with the logic.

I want to have the option to turn ON/OFF some RGB LEDs, the problem is that the state is sometimes erratic.

here the code

int redLED = 2;
int greenLED = 4;
int blueLED = 3;

static bool redRunning;
static bool greenRunning;
static bool blueRunning;
static bool freq = 34;

void setup() {
  Serial.begin(115200);               //initial the Serial
  Serial.write("started");

  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(blueLED, OUTPUT);

  digitalWrite(redLED, HIGH);
  digitalWrite(greenLED, HIGH);
  digitalWrite(blueLED, HIGH);

  redRunning = false;
  greenRunning = false;
  blueRunning = false;
  freq = false;
}

void loop()
{

  if (Serial.available() > 0)
  f{
String s = Serial.readStringUntil('\n');

//    String s = Serial.readStringUntil("#");   // Until CR (Carriage Return)
//    s.replace("#", "");
    Serial.println("s:" + s);

if (s == "red_ON")
{
  redRunning = true;
}

if (s == "red_OFF")
{
  redRunning = false;

}  if (s == "green_ON")
{
  greenRunning = true;

}  if (s == "green_OFF")
{
  greenRunning = false;

}  if (s == "blue_ON")
{
  blueRunning = true;

}  if (s == "blue_OFF")
{
  blueRunning = false;

}

 }

 //

  if (redRunning) {
//    Serial.println("redRunning");

digitalWrite(redLED, LOW);
delay(125);
digitalWrite(redLED, HIGH);
delay(125);
  }

  if (greenRunning) {
//    Serial.println("greenRunning");

digitalWrite(greenLED, LOW);
delay(125);
digitalWrite(greenLED, HIGH);
delay(125);
  }

  if (blueRunning) {
    //    Serial.println("blueRunning");

    digitalWrite(blueLED, LOW);
    delay(125);
      digitalWrite(blueLED, HIGH);
    delay(125);
  }

  if (!redRunning && !greenRunning && !blueRunning) {
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, HIGH);
    digitalWrite(blueLED, HIGH);
  }

   }

So what is the proper way to handle state? so the LED stay blinking? but also can turn off all LEDs
also if I can turn LEDs combined, at the moment, I'm turning on one, then the other,

All these problems come from not understanding how to handle state internally, and manage changes that come via serial.


texts: I have this relay module. I don't understand what is a role of the jumper on it (for now it's shorting the jd-vcc (what??) and vcc pins).


texts: Arduino Serial data communication with NodeJS

texts:
I am using an Arduino Uno and a DTH11 temperature sensor to read temperature and then send that value to a computer via the serial port.

A NodeJS application is running on the computer and captures that value and writes to a log file.

When I try to get values from my NodeJS application, sometimes the value is broken into two values. Eg: 25 -> 2 and 5

This is my Arduino code:

dht DHT;

#define DHT11_PIN 7
float tem [4];

void setup() {
  Serial.begin(9600);
  pinMode(12, OUTPUT);
}

void loop() {
  int chk = DHT.read11(DHT11_PIN);
  int val = (int)(DHT.temperature);
  Serial.println(val);
  delay(600000);
}

This is my NodeJS program.

var fs = require('fs')
var logger = fs.createWriteStream('/data/Temperature/temperature.csv', {
  flags: 'a' // 'a' means appending (old data will be preserved)
})

var SerialPort = require("serialport")
var serialPort = new SerialPort("/dev/ttyACM0", {
  baudRate: 9600,
});

serialPort.on("open", function () {
  serialPort.on('data', function(data) {
    var moment = require('moment');
    var dayTime = moment().format('YYYY-MM-DD,hh:mm');
    var val1 = data.toString();
    var val = val1.trim();
    if (val == '') {
      console.log('no data');
    else {
      console.log(val);
      logger.write(dayTime + ',' + val + '\n');
    }
  });
});

Is it a problem with my code?

Thanks in advance.


texts: Arduino IDE COM Port error on Windows 10

texts:
I have an Arduino micro, uno, and mega and none of them will connect to the com port on the Arduino IDE. I went to the device manager aand it is recognized but when I try to update the driver I get this:

Any help of how to fix this problem?


texts: Can't write to serial immediately from PC to Arduino nano via pl2303 usb to ttl converter

texts:
Goal:

I am trying to send some characters to Arduino through serial from PC via a Prolific PL2303 USB to TTL converter(Chinese clone).

I have wrote a simple sketch(attached bellow) which should light up the LED if 'n' is found or should switch the LED off if 'f' is found from serial.

What's Happening:

I opened up the serial monitor. Send a character(say 'n' which should light up the LED). But nothing happened though the RX/TX LEDs flashed. Then I re opened the serial monitor. And just after re opening the serial monitor LED light up! Every time when I issue a character from serial monitor nothing happens. But just after re opening the monitor character is sent.

H/W Connection:

Arduino Vin -> LiPo positive rail(+11V)
Arduino GND -> LiPo negative rail(GND)
Prolific GND -> Arduino GND
Prolific RX -> Arduino TX
Prolific TX -> Arduino RX

Arduino Sketch:

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available() > 0){
    char bytesReceived = Serial.read();
    Serial.println(bytesReceived);

    if(bytesReceived == 'n'){
      digitalWrite(led, HIGH);
    }
    else if(bytesReceived == 'f'){
      digitalWrite(led, LOW);
    }
  }
}

Additional Notes:

Platform Windows 10
Installed Prolific PL2303 driver from here
This code is working using USB cable provided with Arduino.(I need longer cable)

Can't understand why this strange thing is happening. Any kind of help will be appreciated.

Thanks!


texts: what to write instead of delay() in interrupt function?

texts:
I was trying to develop a traffic light signal controller . when the button is pressed, the pedestrian green light will turn on faster than before . I used delay() in Interrupt function, But it is not working as expected . I am totally new in Arduino coding.
My whole code is below:
int carred = 11;
int caryellow = 10;
int cargreen = 9;

int padred = 13;
int padgreen = 12;

int padpushbutton = 3;
int buspushbutton = 2;

void setup(){
  pinMode(carred , OUTPUT);
  pinMode(cargreen , OUTPUT);
  pinMode(caryellow , OUTPUT);

  pinMode(padgreen , OUTPUT);
  pinMode(padred , OUTPUT);

  pinMode(padpushbutton, INPUT_PULLUP);
  pinMode(buspushbutton,INPUT);
  attachInterrupt(digitalPinToInterrupt(padpushbutton), padcontrol,CHANGE);
 attachInterrupt(digitalPinToInterrupt(buspushbutton), buscontrol,CHANGE);
}
void loop()
    {
     carchangeLights();
 }
void carchangeLights(){

   //turn  carred,padgreen off padred high and cargreen on for 10 seconds
  digitalWrite(carred, LOW);
  digitalWrite(caryellow,LOW);
  digitalWrite(padred, HIGH);
  digitalWrite(cargreen, HIGH);
  delay(10000);

   //cargreen off,  turn on caryellow for 4 seconds

  digitalWrite(cargreen, LOW);
  digitalWrite(caryellow, HIGH);
  delay(4000);

   // turn caryellow and padred off,turn on padgreen, turn on carred for 7 seconds
  digitalWrite(caryellow, LOW);
  digitalWrite(padred,LOW);
  digitalWrite(padgreen,HIGH);
  digitalWrite(carred, HIGH);
  delay(7000);
  //turn padgreen off and padred high , caryellow high for 3 second
  digitalWrite(padgreen, LOW);
  digitalWrite(padred, HIGH);
  digitalWrite(caryellow, HIGH);
  delay(3000);

}

void padcontrol(){

  int red = digitalRead(carred);
  int yellow = digitalRead(caryellow);
  int green = digitalRead(cargreen);

  if (red == HIGH && yellow == LOW ) {
    digitalWrite(carred, HIGH);
    delay(2000);
    digitalWrite(padred, LOW);
    digitalWrite(padgreen, HIGH);
    delay(15000);
     }

  else if(yellow == HIGH && red == LOW){
     digitalWrite(caryellow, HIGH);
    delay(2000);
    digitalWrite(caryellow,LOW);
    digitalWrite(carred,HIGH);
    digitalWrite(padred,LOW);
    digitalWrite(padgreen,HIGH);
      delay(15000);
    }
  else if(yellow == HIGH && red == HIGH) {
   digitalWrite(caryellow, HIGH);
    delay(1000);
    digitalWrite(caryellow,LOW);
    digitalWrite(padred,LOW);
    digitalWrite(padgreen,HIGH);
      delay(15000);
    }
   else{
    digitalWrite(cargreen,LOW);
    digitalWrite(caryellow,HIGH);
    delay(3000);

    digitalWrite(caryellow,LOW);
    digitalWrite(carred,HIGH);
    digitalWrite(padred,LOW);
    digitalWrite(padgreen,HIGH);
    delay(15000);
   }

}

void buscontrol(){

  int red = digitalRead(carred);
  int yellow = digitalRead(caryellow);
  int green = digitalRead(cargreen);

  if (red == HIGH && yellow == LOW ) {
    digitalWrite(carred, HIGH);
    delay(3000);
    digitalWrite(carred,LOW);
    digitalWrite(padgreen, LOW);
    digitalWrite(padred, HIGH);
    digitalWrite(caryellow, HIGH);
    delay(2000);
    digitalWrite(caryellow,LOW);
    digitalWrite(cargreen, HIGH);
    delay(10000);

     }

  else if(yellow == HIGH && red == LOW) {
    digitalWrite(padgreen,LOW);
    digitalWrite(padred,HIGH);
   digitalWrite(caryellow, HIGH);
    delay(2000);
    digitalWrite(caryellow,LOW);
    digitalWrite(cargreen,HIGH);
      delay(10000);
    }
  else if(yellow == HIGH && red == HIGH) {
   digitalWrite(caryellow, HIGH);
    delay(1000);
    digitalWrite(carred,LOW);
    digitalWrite(caryellow,LOW);

    digitalWrite(padgreen,LOW);
       digitalWrite(padred,LOW);
     digitalWrite(cargreen, HIGH);
      delay(10000);
    }
   else{
    digitalWrite(padred,HIGH);
    digitalWrite(cargreen,LOW);
    delay(10000);

   }
}


texts: Can a stepper motor be controlled directly from an Arduino?

texts:
I'm planning to build a simple XY plotter, and have been looking at the possibility of using a pair of small 5V 4-phase steppers to provide the movement. In my research, I've often seen stepper driver boards advertised, ranging from very big and expensive, through to quite small and cheap. Some of them actually look like little more than a darlington array on a PCB.

Do I really need one of those external driver boards, or can I control the steppers directly from my Arduino?


texts:
I'm working with an esp8266 and want to have it default to an access point when it cannot connect to a wifi network.  I'm using chriscook8's example from github here.

chriscook8 uses "+=" in several places and I can't find an explanation of what that means.

Here is an example from setup():

void setup() {
  Serial.begin(115200);
  EEPROM.begin(512);
  delay(10);
  Serial.println();
  Serial.println();
  Serial.println("Startup");
  // read eeprom for ssid and pass
  Serial.println("Reading EEPROM ssid");
  String esid;
  for (int i = 0; i < 32; ++i)
  {
    esid += char(EEPROM.read(i));  //<- here
  }

What does += do?


texts:
Could someone give me a hint regarding what would be the best practice to save memory: should I #define strings or use local static const char arrays?

Code example, option #1:

#define         LCD_LIMIT   "Number of hours"
...
setup(){
    DisplayData(LCD_LIMIT, actual_Data);
}
...
void DisplayData(const char *theme, String data){
}

Code example, option #2:

setup(){
    DisplayData(actual_Data);
}
...
void DisplayData(String data){
    static const char theme[] = "Number of hours";
}

Cheers


texts: Problem with 2 decimal places/2 significant figures

texts:
Lora/GPS Shield + Arduino Uno + PLX-DAQ (latest custom version)

I have a problem on how to generate more than 1/2 decimal output.
Currently, I'm trying to generate GPS Lat and Long(code from TinyGPS++) on PLX-DAQ

Just like in the image. Latitude generated in 1/2 decimal places.
I'm trying to get more than 2 decimal places.

For example : from 3.2 to 3.123953

Coding link:
https://www.dropbox.com/s/rqjpnsc9pg33f9n/Coding.txt?dl=0

Thanks.


texts: ESP8266 webserver does not return latest HTTP response

texts:
I tried getting a HTTP response from an ESP8266 which is in HTTP server mode, I am getting a response but not the latest one, response is always one command previous to that of my request to the ESP.
Also first time I don't get any response, from the nd request response start coming but previous.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <EEPROM.h>
#include <ESP8266WebServer.h>   //ESP Web Server Library to host a web page

const char* ssid = "SpruceRND";
const char* password = "sprucernd1234";

ESP8266WebServer server(80);   // server at port 80 (http port)

//Variable to store the HTTP request
String inputString ="";
boolean stringComplete = false;
String Clientquery ="";  //for store all query params
char query_array[30];    //for store all query character
int LEDPin = 4;

void ESPserialEvent()
{
  boolean x=0;
  Serial.println("Working ESPserialevent....");
  while (Serial.available())
  {
    char inChar = (char)Serial.read();    // get the new byte:
    if (inChar == 2)   //check if 1st byte is 2
    {
      x=1;
    }
    if (x == 1);
    {
    inputString += inChar;   // add it to the inputString:
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    }
    if (inChar == 3) //check if 1ast byte is 3
    {
      stringComplete = true;
      x=0;
    }
  }
}

void  handleNew()
{
  server.send(200, "text/plain", "Hello! SPRUCE"); //200=http status code,text/plain=content type,message
}

void handleMstring()
{
  Clientquery = server.arg("tx");    //Gets the value of the query parameter
//  Clientquery.toCharArray(query_array, sizeof(Clientquery)); // convert to chararry (buffer,length)
//  if (query_array[0] == 2 )
//  {
    Serial.println(Clientquery);
//  }
//  else
//  {
//     Serial.println("Incorrect string....");
//  }
  Clientquery="";
  ESPserialEvent();
  if (stringComplete == true)
  {
    server.send(200, "text/plain",inputString);
    //Serial.println("Response from Mcu=" +inputString);
    //Serial.println("");
    inputString ="";
    stringComplete = false;
    //Serial.println("Buffer clear...");
  }
}

void setup(void)
{
  pinMode(LEDPin, OUTPUT);
  digitalWrite(LEDPin, LOW);
  delay(1000);
  Serial.begin(9600);
  WiFi.begin(ssid, password); //begin WiFi connection
  Serial.println("Connecting to....");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/test", handleNew);
  server.on("/senddata", handleMstring);
  server.begin();
  Serial.println("Web server started!");
}

void loop(void){
  server.handleClient();
}


texts: Is it possible to extend the reach of a PN532 NFC/RFID shield?

texts:
I am working off an Arduino Uno with an AdaFruit PN532 NFC/RFID shield. The goal is to have a shoe box, with a false bottom. Under that false bottom would be my prototype, which I hope will be able to detect any MIFARE tag that is in the box, above the false bottom.

The range obviously for these devices is practically touching, but I was was wondering if there is anyway to extend the reach of the NFC/RFID shield, so that the entire false bottom of the box could act as that antenna.


texts: Alternative to delay() when using Ticker in ESP8622

texts:
When using the Ticker library on the ESP8266 you can't use the delay() function because Ticker functions are using the underlying timer. The original Arduino library says that you can use a Ticker as delay, but in the ESP8266 implementation things work differently. You "attach()" a callback function and specify the period.

How can I generate a delay that doesn't require the underlying timer?

(BTW, where is the documentation for the ESP8266 Ticker library? The repository has no documentation nor comments on the functions.)


texts: Trying to install amforth on Leonardo board

texts:
Just got a Arduino Leonardo (with headers) dropped in my lap this week. I've tried experimenting with the Arduino C++ IDE and find it awkward. I have some previous experience with Forth and would like to try loading amforth directly onto the ATmega32u4 microcontroller.

I found some "how to" information on the web but find it confusing and contradictory. Can anyone point to some easy to follow instructions? I'd greatly appreciate it!

In case it matters, my development box is a Fedora 29 workstation.


texts: Using Arduino for simultaneous lighting effects

texts:
I am building a computer for my son (me).  I'm trying to spark his interest in computer technology, so my idea is to drive multiple case lighting effects with a microprocessor or controller.  I went with the arduino over the pi because of simplicity of the system.

There are several lighting effects I want to drive, simultaneously, and that's where I'm wondering if the arduino is well suited, because the effects need to make use of delay(), and with it being single threaded I'm struggling to figure out how to make each output operate independently.

To give you an idea of what the microcontroller needs to drive simultaneously:

Flicker pattern using random delay values for outer case lighting
Heartbeat pattern for CPU cooling block
Blacklight / UV LED lighting for coolant lines.
Strobing LEDs aimed at the fans to make them look stationary.

Trying to run all these effects in a linear loop with delay() operators just doesn't seem to be feasible.

Do I need to get an UNO for each effect?  Or is there a way of making these outputs operate independently?


texts:
This is a snip it of code from a program I am writing. I have the program turn an LED on and if a button is pressed when the LED is on I want it to add to a counter and print the counter value. The problem seems that my if statement is skipped. Right now the while loop is setup for 5 seconds using millis() and stays off using a short delay. This part (button_press_9())) is a function call to a Boolean I have setup for debouncing. If I put the function call in an if statement by its self for example to test it. It works and will turn an LED on and off. It seems the combination of the two is incompatible.

Thank you in advance.

unsigned long previousMillis = millis();
unsigned long currentMillis = millis();

while ((currentMillis - previousMillis) < onTime)
{
    digitalWrite(ledPin4, HIGH);
    if (ledPin4 == HIGH && (button_press_9()))
    {
        counter++;
        Serial.println(counter);
        currentMillis = onTime * 100;
    }
    currentMillis = millis();
}
digitalWrite(ledPin4, LOW);
delay(1000);


texts: How arduino boards eliminate the need to press buttons to flash?

texts:
I've come across many Arduino shields for various boards like the Uno, ESP8266, and ESP32 which sometimes have a button for flashing and other times they do not because the flashing is automatic.

When I upload a binary sketch to ESP32 directly through a separate Serial to USB converter, I have to make the button connections and press the buttons manually for the uploading process to work.

The manual button pressing flashing process for the ESP32 goes like this:

Hold the Reset button (IO0 to ground)
Hold the Flash button (EN to ground)
Release the Reset button (IO0 to float)
Release the Flash button (EN to 3.3v)
The board is now in flashing mode
Press "Upload" in Arduino IDE
Wait until the IDE log shows "Connecting..."
Wait until the sketch is fully uploaded
Press the Reset button (IO0 to ground then float)

Arduino boards like the WeMos Lolin32 board eliminate the button pressing process completely during the flashing process.

QUESTION: Which part of the hardware on the Lolin32 board makes the flashing process autonomous?

Here's the manual uploading schematic:

And here's the WeMos Lolin32 board, that eliminates the button pressing process completely when I upload a sketch:

I believe the answer will also apply to any other auto-flashing board out there.


texts:
I want to play video from SD card   by using arduino mega 2560 and TFT 3.2" touch screen is it possible ?

if yes please tell me.

thanks in adavance


texts: How do I specify a particular pin to use as output for the Print class?

texts:
all.

I'm attempting to write a class that inherits from the Print class.  I only need serial output.

However, I'm having difficulty locating any reference on how to specify which pin on the ATMega my class will use as output of the write(...) functions.

How does the Print class know where to send output to ??

Thanks in advance.


texts: How much power can the Teensy 3.2 deliver to external components?

texts: Can a teensy 3.2 deliver enough power to properly activate multiple servos by chance?


texts:
I'm building a weather data collector and I want to be able to dump that weather data somewhere. I've considered the options, and since I'm going to be storing a fairly small amount of data (in the megabyte range) I don't want to use SD cards (also SD cards are expensive). I've heard of use of NAND flash memory chips (like the W25Q32), and I was hoping that I could possibly interact with them in a simple way (since most ways require writing to each individual address). Is there possibly a way to build a file system within one of these small flash memory chips and interact with them as simply as interacting with an SD card?

TLDR: I want to interact with a flash memory chip easily to store basic ASCII data


texts:
I am using a SEEED SD Card Shield. Everytime I attempt to write the card, I get

When Using File> Examples> SD > CardInfo:

initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

Or when using File>Examples> SD> Files:

Initializing SD card...initialization failed!

I even tried SdFat (IDE couldn't find anything), the "SD Library" by Adafruit (No change), and other things.

I'm using a Funduino MEGA 2560. Could that be the problem?!


texts: A more elegant way to deal with timers without using delay()?

texts:
I am looking for a more elegant way to write a function that performs timer-based tasks as in the case of the code below, which essentially collects 5 sample values from a microphone module over a given period of time and then computes their average. It is important that it does not use the delay() function because other tasks are supposed to run in the background which should not be affected by the delay.

  int sensorPin = A0;
  int ledPin = 13; //  pin for the LED
  int sensorValue = 0; // variable to store the value coming from the sensor
  unsigned long timer;
  int interv = 50;
  unsigned long sampleArray[] = {0, 0, 0, 0 , 0};
  unsigned long millisaver;

  void setup ()
  {
    pinMode (ledPin, OUTPUT);
    Serial.begin (9600);

  }

  void loop ()
  {

    if (millis() > 2000) {
      if (millis() < 2050) {
        millisaver = millis();
        timer = (int) millisaver;
        Serial.println(timer);
      }
      if ( millis() > timer && millis() < timer + interv ) {
        sampleArray[0] = sensorValue = analogRead (sensorPin);
      }
      else if ( millis() > timer+interv && millis() < timer + interv*2 ) {
        sampleArray[1] = sensorValue = analogRead (sensorPin);
      }
      else if ( millis() > timer+interv*2 && millis() < timer + interv*3 ) {
        sampleArray[2] = sensorValue = analogRead (sensorPin);

      }
      else if ( millis() > timer+interv*3 && millis() < timer + interv*4 ) {
        sampleArray[3] = sensorValue = analogRead (sensorPin);

      }
      else if ( millis() > timer+interv*4 && millis() < timer + interv*5 ) {
        sampleArray[4] = sensorValue = analogRead (sensorPin);
      }
      else if ( millis() > timer+interv*5) {
        unsigned long averageVal = (sampleArray[0] + sampleArray[1] + sampleArray[2] +sampleArray[3] + sampleArray[4])/5 ;
        Serial.println(averageVal);
        millisaver = millis();
        timer = (int) millisaver;
      }
    }
  }


texts:
I am using Arduino uno. My data is storing into EEPROM whenever i run my program, it will store multiple data depend on the loop. For my program it calculate 10 sample in 0.1 sec, so 100 sample in 1 sec. How can i know how much memory i can run?

I have added this code to my program it display 895.

#include <Arduino.h>
int freeRam () {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
void setup(){
Serial.begin(9600);
Serial.println(freeRam());}
void loop(){}


texts:
I'm first time working with a Teensy 3.1. I have to connect this (MS5803-01BA: http://www.amsys.de/products/ms5803.htm) pressure sensor via SPI to my Teensy.

My problem is, that I don't have any reliable knowledge on SPI. I read the Wikipedia for it and also the Teensy-Manual.

For the pressure sensor I already got a C-Code but it is only working with the ATMEL ATmega644p microcontroller. I tried to get the code to work with my Teensy, but it seems like I don't get either any input nor any output.

I hope that one of you can help me with the following code and tell me what I'm missing out on. Thank you.

Code:

http://pastebin.com/xaWXfRUR

Datasheet of the pressure sensor:

http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf

C-Code for the pressure sensor for the ATMEL ATmega644p microcontroller:
http://www.amsys.de/sheets/amsys.de.an520_e.pdf

PS: Please excuse my not perfect English for it's not my native language.


texts: Can't send SoftwareSerial to Class Object

texts:
I have a problem when I try to use SoftwareSerial in a class..

Here my detail My class

class MyEsp8266
{
 protected:
     SoftwareSerial *esp8266;
 public:
     MyEsp8266(SoftwareSerial *_esp8266){
           esp8266 = _esp8266;
     }
     void begin(int baud){
        esp8266->begin(baud);
     }
     String testAT(){
          esp8266->println("AT");
          return esp8266->readString();
     }
}

My Arduino code

#include <SoftwareSerial.h>
#include "MyEsp8266.h"
// the setup function runs once when you press reset or power the board

SoftwareSerial _esp(10, 11);
MyEsp8266 wifi(&_esp);

void setup() {
    Serial.begin(9600);
    wifi.begin(115200);
    Serial.println(wifi.testAT());
}

It doesn't log anything But when I have used all code in Arduino code it worked.

#include <SoftwareSerial.h>
// the setup function runs once when you press reset or power the board

SoftwareSerial _esp(10, 11);

void setup() {
    Serial.begin(9600);
    _esp.begin(115200);
    _esp.println("AT");
    Serial.println(_esp.readString());
}

Thank any tips.
Regards.


texts: Getting negative results from calculations

texts:
I'm trying to proportion potentiometer value to analog pin value. Like 1024 to 255.

int readVolumePot() {
    int val = analogRead(potVolumePIN);

    Serial.print("VOL");
      Serial.println((val * 255/1024));

      return (val * 255/1024);
  }

As potentiometer turns I got irrelevant values.

VOL3
VOL3
VOL3
VOL17
VOL-16
VOL-16
VOL-21
VOL-1
VOL-10
VOL-3
VOL-4
VOL11
VOL8
VOL13
VOL17
VOL15

In Arduino's website they say

  some constant calculations may overflow (e.g. 60 * 1000 will yield a
  negative result).

Notwithstanding, I cannot find an appropriate way to convert the potentiometer value to analog pin value.


texts:
I'm trying to use the timer registers to do some timing on my Arduino Mega 2560.

The output of the following code confuses me:

void setup ()
{
    // Set up serial connection
    Serial.begin(9600);
    while (!Serial) {}

    // Print control registers of timer 1
    Serial.println(TCCR1A); // Outputs 1
    Serial.println(TCCR1B); // Outputs 3
}

void loop () {}

Why is TCCR1A equal to 1 and TCCR1B equal to 3? The documentation of the chip says the initial values of the registers are zero. I could of course set them to zero, but I want to understand why it works like this. The values are the same for the other 16-bit timers (3, 4 and 5).


texts:
I have created a retro keyobard using a ZX spectrum and a PRO MICRO based on the info here: http://blog.tynemouthsoftware.co.uk/2013/04/arduino-leonardo-based-zx81-usb-keyboard.html

When plugged into my laptop or a raspberry PI it works fine. However, when running any of the emulators like FUSE it doesn't work at all.

Can anyone explain why this is and what I have to do to make it work? Searching around on the web I see it has something to do with the key mapping which I can understand for when I do shifted keys but why it doesn't work when I just press p is eluding me.

EDIT:
When using a USB sniffing program I can see that my "real" keyboard sends 0x8 bytes for an 'a' 00 00 04 00 00 00 00 00

BUT my arduino sends 0x9 for an 'a' 02 00 00 04 00 00 00 00 00

Snippets of the the code I am using is

// keyMap and keyMapShifted are both 2D arrays of type byte
byte keyMap[8][5] = { {'5', '4', '3', '2', '1' ....etc
byte key = shifted ? keyMapShifted[[r][c] : keyMap[r][c]
Keyboard.write(key)

Ideas? A Bug? Do I have to rewrite Keyboard.write?


texts: How to read a 25 kHZ PWM signal from PC fan header?

texts:
I would like to control a DC motor's speed using the PWM output from my motherboard header.

Here's the standard pinout for a 4-wire PC fan header:

╔═══╦════════╦═════════════════╦════════╗
║ # ║  Name  ║   Description   ║  Wire  ║
╠═══╬════════╬═════════════════╬════════╣
║ 1 ║ GND    ║ Ground          ║ black  ║
║ 2 ║ +12V   ║ Fan Power       ║ yellow ║
║ 3 ║ SIGNAL ║ Fan RPM         ║ green  ║
║ 4 ║ PWM    ║ Digital Control ║ blue   ║
╚═══╩════════╩═════════════════╩════════╝

Since my DC motor doesn't have a PWM input, I thought of using an ATmega328P in my custom board to read the PWM output of the fan header -- pin 4 -- so that I can use a motor driver to control my motor's speed.

However, I'm not sure how I should read the PWM signal from the motherboard.

What is the HIGH voltage level of PWM output?
Do I need a voltage divider resistor for it?

A source for the fan control specifies this to be 5.25V at maximum, but since I haven't tested it out myself, I don't want to risk feeding a 12V signal to my microcontroller's input lines.
Should I use pulseIn() function for the 25kHZ (21~28kHZ range) PWM output?
Can the ATmega328p handle this frequency range?

I prefer to use Arduino's bootloader with the wiring library, but if you have AVR-specific examples that I could follow, I'd appreciate it.


texts: Password.h and keypad.h change pass sketch for Arduino

texts:
I have a fixed password. If letter "D" is pressed on the keyboard and the correct password is entered, the fixed password will be then changed. This newly entered password is now the correct password, until the user decides again to change password. It is not working. How to fix it?

#include <Keypad.h>
#include <Password.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

const char keys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'*','0','#','D'}
  };
const byte rowPins[ROWS] = {9,8,7,6};
const byte colPins[COLS] = {5,4,3,2};

Keypad    keypad { makeKeymap(keys), rowPins, colPins, ROWS, COLS };
Password passwd = Password("123A4");
char passwd2;

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

void loop() {

  char key = keypad.getKey();
   if (key != NO_KEY){
      delay(60);
      switch (key){
      case 'D': changepasswd(); break;
      case '*': checkpasswd(); break;
      case '#': passwd.reset(); break;
     default: passwd.append(key);
      }
   }
}

void checkpasswd() {

  Serial.print(passwd2);

   if (passwd.evaluate()){
      Serial.println(" OK.");
   } else {
      Serial.println(" Wrong password!");
   }
   passwd.reset();
}

void changepasswd() {
  char key = keypad.getKey();
      delay(60);
      Serial.print(key);
      passwd2 += key;
      passwd.set(passwd2);

   Serial.print("Password changed to ");
   Serial.println(passwd2);

}


texts:
I'm following this tutorial to control a DC motor with an Arduino.

I have the same problem as this stackexchange post arduino.stackexchange.com/questions/10049/problems-with-l293d where the motor is not rotating.

The chip is heading to the right. (5v pins are on the right)
Connecting directly the motor to the battery works.
Current (5V on the bottom & 2*1.5V) is flowing everywhere expected EXCEPT on the yellow & green wires of the motor (the red wire of the battery pack is connected to the second line of the breadboard).
Connecting directly the motor to the battery works.
I copied the code of the above tutorial which is basically : "digitalWrite(4,HIGH);", there is current on the cable.

Am I wrong into thinking that a L293D chip can output sufficient current ? Is the chip malfunctioning ?


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

texts:
As a hobbyist I code in a variety of arduino's and in Digispark's (Attiny 85 and 167).
But I'm doing a project with space contraints, so I'd need to use just the MCU directly over my pcb.
Apart from a voltage regulator (to get the VIn to 5V or 3.3V) do I need extra components to mount the MCU to my PCB?
DO I need crystals, capacitors, etc? Or the MCUs (mostly AtMega 32u4 and Attiny85 and Attiny167) have it all what's needed inside them?
I'll program the MCU before soldering on to the PCB, so there's no need for USB or programming stuff or leds.
Thanks!


texts: How to build an µC controlled power regulator?

texts:
The idea: Use an Arduino-like µC to control a set of CPU fans by control the voltage the CPU fans receive. My question: How can I do this in an easy way?

Yes, I know, there is PWM but this is not very suitable for this purpose: I did some tests with it but it turns out that the characteristics of PWM fans don't suite my purpose: PWM fans are designed to be controlled between not audible and full speed, not between nearly not rotating and full speed. Even very special fans with a wide range of PWM speed control don't work as well as powering a regular 12V fan with just 5 or 6V.

Which brings me to an alternative idea: It should be possible to send an I2C or SPI signal to some kind of IC that then provides a voltage as required.

Alternatively to that there seem to be PWM controlled voltage regulators available. But that doesn't seem to be a very elegant solution, isn't it?

Or is there an even better way of controlling the voltage output to the fans I'm not aware of?

I'm aiming for a solution that works well and can be build with little effort. Unfortunately I don't know how to do that: I can't find any breakouts I could use right away for that purpose. Probably there are some and I just have not been able to find them? Any help is appreciated!


texts: 4 IR sensors on Arduino pro micro. 2 are working other aren't

texts:
#include <Keyboard.h>
int IRpin = 5;
int IRpin2 = 6;
int IRpin3 = 8;
int IRpin4 = 9;
int led = 13;

void setup() {
  Serial.begin(9600);
  //start the serial port
  Keyboard.begin();
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
}

void loop() {
  float volts = analogRead(IRpin);
  Serial.println("volts1:");
  Serial.println(volts);
  delay(1000);
  if (volts>500.00){
    Keyboard.press(KEY_RIGHT_ARROW);
    Keyboard.releaseAll();
  }
  float voltss = analogRead(IRpin2);
  Serial.println("volts2:");
  Serial.println(voltss);
  delay(1000);
  if (voltss>600.00){
    Keyboard.press(KEY_LEFT_ARROW);
    Keyboard.releaseAll();
  }
  float voltsss = analogRead(IRpin3);
  Serial.println("volts3:");
  Serial.println(voltsss);
  delay(1000);
  if (voltsss > 500.00) {
    Keyboard.press(KEY_UP_ARROW);
    Keyboard.releaseAll();
  }
  float voltssss = analogRead(IRpin4);
  Serial.println("volts4:");
  Serial.println(voltssss);
  delay(500);
  if (voltssss > 600.00) {
    Keyboard.press(KEY_DOWN_ARROW);
    Keyboard.releaseAll();
  }
}

I connected 4 IR infrared sensors to Pro micro and only 2 of them are working. The other 2 are sending random values.
Connection for all 4 IR sensors.:
IR VCC->Arduino VCC
IR GND -> Arduino GND
Output-> 5,6,8,9


texts: AT+HTTPACTION: What is status 606 means?

texts:
I use Sim808 gprs/gsm/gps module and call these:

AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","internet"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+HTTPINIT
AT+HTTPSSL=1
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","https://www.mywebsite.com/getTime?token=jsdaljdaskl"
AT+HTTPPARA="REDIR",1
AT+HTTPACTION=0

I always get +HTTPACTION: 0,606,0 as the result.

What does 606 mean? I cannot find it everywhere in the documentation.


texts:
I bought an Arduino-on-breadboard kit. I have several PCs with serial ports, and now I'm being told I need a USB-to-serial converter. I thought I was ready to start uploading sketches, so how can I do this?

I'm able to understand serial communications and am capable of wiring a MAX232 chip into a breaduino if necessary, but I'm not sure it will work, so to save some time I'm asking, mostly because I was unable to figure it out with Google searches alone.

PS: I also have a stk500, but then I would be out of the easiness of using Arduino sketches and the programming language. I need the fastest route to prototyping/testing my sketches.


texts: Read RC receiver channels using Interrupt instead of PulseIn

texts:
I am designing my own quadcopter control algorithm, whereby I currently read 4 RC receiver channels using PulseIn on each loop in the following manner:

ch1_raw = pulseIn(rcPin1, HIGH, 25000);

In other words, ch1_raw contains the length of a HIGH pulse in microseconds.

I now want to avoid PulseIn in the interest of speed and instead achieve the same using interrupt.

I have looked at http://playground.arduino.cc/Main/PinChangeIntExample and I am aware that other similar questions have been asked (e.g. How to read RC receiver channels without using pulsein() command with arduino and Is PulseIn fast enough for Quadcopter?), but I don't understand how to implement interrupt to give me the correct ch1_raw value on each loop.

Can somebody help me? (I'm new to Arduino, so go easy on me please!) Thanks!

Edit:
So far I have tried to implement the following:

#include <PinChangeInt.h>

unsigned long pulsestart, pulsewidth;

int rcPin1 = A0;

void setup(){

  pinMode(rcPin1, INPUT);

  Serial.begin(9600);

  PCintPort::attachInterrupt(rcPin1, counttime,RISING);
  PCintPort::attachInterrupt(rcPin1, subtracttime,FALLING);

}

void loop(){

  Serial.print("  pulsewidth: ");
  Serial.println(pulsewidth);

}

void counttime()
{
  pulsestart = micros();
}

void subtracttime()
{
  pulsewidth = micros()- pulsestart;
}

Edit 2:
(Somewhat) successful implementation so far, using EnableInterrupt.h instead. It seems that FALLING is being detected, but not RISING.

#include <EnableInterrupt.h>

#define rcPin1 10

volatile uint16_t pulsestart=0;
volatile uint16_t pulsewidth=0;
//volatile unsigned long pulsestart=0;
//volatile unsigned long pulsewidth=0;
volatile uint16_t risingcount=0;
volatile uint16_t fallingcount=0;

void counttime()
{
  pulsestart = micros();
  risingcount++;
}
void subtracttime()
{
  pulsewidth = micros()- pulsestart;
  fallingcount++;
}

void setup() {
  Serial.begin(9600);
  pinMode(rcPin1, INPUT_PULLUP);
  enableInterrupt(rcPin1, counttime, RISING);
  enableInterrupt(rcPin1, subtracttime, FALLING);
}

void loop() {
  //delay(1000);
  Serial.print("risingcount: ");
  Serial.print(risingcount);
  Serial.print(" fallingcount: ");
  Serial.println(fallingcount);
  //Serial.print("pulsewidth: ");
  //Serial.println(pulsewidth);
}


texts: Arduino Uno + Adafruit Ultimate GPS Shield Serial issue

texts:
I've had an Arduino Uno for a couple of months-making basic sketches-and recently purchased an Adafruit ultimate GPS shield and attached with soldered headers. This shield has 2 options for reading data, direct and soft serial.

I can sit near a window in my house and receive data using the direct method. This is just due to uploading a blank sketch and reading the serial window. Next, I tried to use one of the examples included in the Adafruit_GPS library and the serial window shows a bunch of nonsense updating.

Has anyone else seen this problem? I'm wondering if its the digital pins on the Arduino that I may have damaged since the example code has a simple phrase to display at the start, and I don't even get this.

Code eg: Serial.println("Get version!").

Just to verify, both boards have power and the direct method was giving me good GPS readings, the serial method gave me junk (not even a simple printed phrase to start), and I verified the Soft Serial switch was flipped and the baud rates matched in code and serial window.

I've attached pictures of the direct method results from that in the serial window, and then the junk results using an unaltered sample serial code. Any help with this would be appreciated.


texts:
I need to send data from an Arduino mega to an Arduino Uno for XOR calculation
Input data is an integer in the range 0-10
Input data is sent every 500ms
On the mega:
void setup() {
    Serial.begin(9600);
}

void loop(){
    int inp = (rand()%9); //randomised input
    Serial.write(inp);
}

Outputs the right values on the Serial monitor
On the uno:
#define key 'F'

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

void loop(){
    int val = Serial.read();
    int cal = val ^ (int)key; //XOR operation
}

Is not working as it some values are missing from the input stream
For example: if the input data is 1,2,3,4,5,6 on the uno serial monitor I can only see 1,2,4,5,6
I am unable to troubleshoot this. Can anyone help me out in this? Just started learning how to implement communication on the Arduino


texts: what command should i use to read and write through spi.tranfer command

texts:
#include<spi.h>
byte val;     // variabe for storing temp data
#define PIN_SPI_SS    (9)
#define PIN_SPI_MOSI  (10)
#define PIN_SPI_MISO  (11)
#define PIN_SPI_SCK   (12)

void setup();
pinMode(SS,output);
pinMode(SCLK,output);
pinMode(MOSI,output);
spi.setBitorder(MSBFIRST);
SPI.setDataMode(SPI_MODE3);
serial.begin(9600);
spi.begin();

void loop();
  digitalWrite(SS,LOW);
  uint8_t b1 = SPI.transfer(0x00);
  uint8_t b2 = SPI.transfer(0x00);
  uint8_t b3 = SPI.transfer(0xFF);
  digitalWrite(SS,HIGH);
  int16_t val = b1 | b2 ;
  serial.print("val=");
  serial.println(val,DEC);

refer for DATA SHEET//https://www.ti.com/lit/ds/symlink/lm74.pdf?ts=1591436049550&ref_url=https://www.ti.com/product/LM74
my problem is i am not able to know what command should i use in SPI.transfer function for writing & reading  temperature data here i use 0x00 for reading 16 bit data of temperture register,but what about writing in configuration register  ,LM74 use 0xFF command for shutdown mode,but  how we came to know that 0xFF refer only to configuration register.


texts:
I am trying to make a timer that has a accuracy up to 1 tenth of a second. However when it is suppose to print "0", it will print an "A". For example, when printing "10", it will print "1A".
This program only lasts up to seconds. Any suggestion is highly appreciated, thank you!

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
unsigned long time2 = 0;
int x = 0;
int a = 0;
int b = 0;
void setup() {
  lcd.begin(16,2);
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("00:00:00:0      ");
  Serial.begin(9600);
}

void loop() {
  unsigned long time1;
  time1 = millis();
  if (time1 - time2 > 100){
    time2 = time1;
    lcd.setCursor (9,0);
    x=x+1;
    lcd.print(x," ");
  }
  if (x>=10){
    x=0;
    a=a+1;
    lcd.setCursor(7,0);
    lcd.print(a,":");
  }
  if (a>=10){
    a=0;
    b=b+1;
    lcd.setCursor(6,0);
    lcd.print(b+a);
  }
}


texts: Ubuntu class string has no member remove

texts:
I am running some code that works fine on my windows system using the .remove method.  On Ubuntu 16.04 I get the following errror:

error: ‘class String’ has no member named ‘remove’

To see if it was installation, I uninstalled arduino with

sudo apt-get purge arduino arduino-core

then

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install arduino arduino-core

and the issue remains.  I have seen some people say opening arduino through the terminal (from this), although that does not fix it.

Arduino version
2:1.0.5+dfsg2-4

Any help is appreciated.


texts:
I have connected two CD4021 with an Arduino, and pull up resistors. The code which runs is in this example until the point of serial printing.
https://www.arduino.cc/en/Tutorial/ShftIn22
Although, the PI-8 inputs give me the same value (111111111111111) and not different. Any idea?
Wiring

Code
void setup() {
  Serial.begin(9600);
  pinMode(dataPin, INPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);

}

void loop() {
  digitalWrite(latchPin, 1);
  delay(20);
  digitalWrite(latchPin, 0);
  CD4021_inputs = shiftLN(dataPin, clockPin);
  CD4021_inputs_second = shiftln(dataPin, clockPin);
  if (CD4021_inputs != 255 || CD4021_inputs_second!=255) {
    Serial.print(CD4021_inputs, BIN);
    Serial.println(CD4021_inputs_second, BIN);
  }
}


texts: LCD display and ultrasonic sensor not functioning

texts:
I am doing fish feeder project with level detection for the feeds but lcd display and ultrasonic sensor did not function.

#include <LiquidCrystal.h>
#define trigPin 12              // the trig pin to digital pin 12
#define echoPin 13              // the Echo pin to digital pin 13
#define L 8
#define M 9
#define H 10
// #define trigmotor 1 //closelid
int led = A1;           // LED indicator to digital pin A1
#include <Servo.h>
Servo MyServo;

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

const int thresholdH = 0;
const int thresholdM = 70;
const int thresholdL = 90;
// defines variables
long duration;
int distance;
float percentLV;

void setup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600); // Starts the serial communication
  pinMode(led,OUTPUT);
  digitalWrite(led,LOW);            //set the led off(initial condition)
  lcd.begin(16, 2);
}
void loop()
{

int degreesOfRotation = 8;
int servoPinNumber = 11;
float hoursBetweenMeals = 12;
float mealDelayTime = 0;

{
    MyServo.attach(11);
    MyServo.write(degreesOfRotation);
    mealDelayTime = hoursBetweenMeals * 1800000;
    delay(20);

    while(degreesOfRotation < 152) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation += 1;
    }
    while(degreesOfRotation > 8) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation -= 1;
    }
    delay(mealDelayTime);
}

{
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = (duration * 0.034 / 2);
  float percentLV = (40 - ( distance - 16 )) * 100 / 40;

  if (percentLV > thresholdL && percentLV < 100) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("PLEASE REFILL!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, HIGH);
    digitalWrite(M, LOW);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, HIGH);
    //delay(3000);
    //digitalWrite(trigmotor, LOW);
    //delay(1000);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV <= thresholdL && percentLV > thresholdM) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("U May Refill Now");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, HIGH);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV <= thresholdM && percentLV > thresholdH) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Take it easy");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, LOW);
    digitalWrite(L, HIGH);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);

  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("FULL!!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);

    Serial.print("PercentLV: ");
    Serial.print(percentLV);
    Serial.println("%");
  }
  delay(1000);

}

}


texts: How to show the distance in decimal use sensor TF-Luna Lidar or more specific value

texts:
I want to ask about TF-Lunar Lidar, I've written code to know the distance in cm by reading the array data, right now I need some help about how to read the data so it can be showing the more specific value (float or in decimal)
Or do you guys know what is the speed of the waves transmitted and captured by the lidar sensor, so that I can calculate it in a more specific form, such as using the method of calculating the distance on the Hc-srf04 sensor
I also have used this format to read the distance in mm, but It never works (image about array data)


texts: Program giving one type of output in arduino ide stm32f1xx board version 2019.10.9 giving different output in board verison 2019.12.31

texts:
void setup() {

      Serial.begin(9600);
      Serial1.begin(9600);
      Serial1.println("HM 10 here");
      Serial.println("STM32 here");

    }

 void loop() {

      char inputdata;
      while (Serial1.available()){
      Serial.println("In loop");
      inputdata = (char)Serial1.read();
      Serial.println(inputdata);

    }

With this code , I was able to send signals to hm10 and was able to see the sent signals in serial monitor of arduino ide in the 2019.10.9 version but not in 2019.12.31.
I am dumping the code on stm32 using ftdi driver.
I am sending the string "hai" from BLE terminal app.
I updated my arduino library board manager and stm32f1xx board version upgraded to version 2019.12.31.

In stm32f1xx board version 2019.10.9 , when i send values from the app to hm10 , i get this output on serial monitor

STM32 here
In loop

In loop
h
In loop
a
In loop
i
In loop

In loop

But in the case of stm32f1xx board version 2019.12.31 , i get this output on serial monitor

HM 10 here
STM32 here

If I have to use any libraries do guide me..


texts:
I'm Driving a stepper using a L298N driver and an arduino mega. I want to release the stepper after the movement so it can swing freely, because it gets hot, and it doesn't need to hold position.

Anyone know how to do it? I'm using just the basic stepper library.

Thank you.


texts: Is there a way to make wiring a bare microprocessor to a shield easier?

texts: I currently do most of my AVR work on breadboards, but the large variety of Arduino shields and code out there makes me wonder if I'm not beating my head against the wall sometimes, and looking up port to pin mappings both wastes time and slows me down. Is there any convenient way to adapt AVRs (other than those pin-compatible with current Arduinos) to Arduino shields?


texts: Make a Jack-Bluetooth Module for the car

texts:
I'm making a Jack-Bluetooth module so that I can send music to the car (or other devices w/ Jack plug) without an internal Bluetooth module in the car.
https://habr.com/en/post/456182/ says that I need around 44 kHz of sampling frequency to get high quality sound. Is there a BT module on the market w/ these specs?
Audio Recording using Arduino BT module says that the HC-05 HC-06 HC-07 are not good enough.
If there are no such cases, I think I should consider buying an Arduino that has an built-in BT/WiFi module or I can buy such a BT transmitter but beats the fun.


texts:
I am trying to get humidity and temperature readings (eventually to trigger a misting system), but the values keep returning as 0C and 0%humidity (in general).  Originally, I was using an am2320 sensor and using the analog pins.  Here, I used the following code:

#include "dht.h"
#define dht_apin A2 // Analog Pin sensor is connected to
#define MIST 7
#define LIGHT 2

dht DHT;

void setup(){
 pinMode(MIST, OUTPUT);
 pinMode(LIGHT, OUTPUT);
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor

}//end "setup()"

void loop(){
  //Start of Program

    DHT.read11(dht_apin);

    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature);
    Serial.println("C  ");

    delay(5000);     //Wait 5 seconds before accessing sensor again.

  }

  //Fastest should be once every two seconds.

// end loop()
}

Thinking the sensor may have not been working, I tried using a different sensor (DHT11), and following the tutorials got the same result using this code:

#include <dht11.h>
#define DHT11PIN 4

dht11 DHT11;

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

}

void loop()
{
  Serial.println();

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (C): ");
  Serial.println((float)DHT11.temperature, 2);

  delay(2000);

}
// end loop()

The Arduino is being powered by a wall wart and is also connected to my computer via USB (I read that sometimes the USB doesn't supply enough power).  The weird part is that for about 1 minute I got reasonable results (humidity ~50%, temp 22C).  Then, I tried adding an if loop to turn on an LED if the humidity dropped below 60% (thinking I could use the same code to operate a relay to turn on a misting system).  The LED lit up, but the readout went back to the 0%humidity and 0C.  I have since deleted this loop but cannot seem to get reasonable measurements.  If I change the signal pin, I sometimes get a new readout 255% humidity and 255C, but I haven't been able to repeat this reliably.

For the wiring:  S to pin, + to 5V, - to GND

Note:  I have tried every analog pin and "regular" pin, so the code may designate something that is different in my picture.  When testing, I have triple checked that the signal pin in the code is correct for my wiring configuration.  I've also tried with a different Arduino with the same result.  I'm pretty new at this, but the code is pretty much copy-paste and there are only 3 wires.  I've read that there are many DHT libraries, so I'm thinking my issue has something to do with that, but I have no clue how to judge the appropriateness of a library for my application.

[[[[[[[[[[[[p


texts: I use Arduino Pro Mini. As I know, every MCU has a number. Different MCU has different number.  How to get it ?


texts: How to increase sensitivity of Capacitive Touch Switch?

texts:
I am working with Capacitive Touch Sense technology.In that I am using TTP224 Touch detector IC. I am getting good sensitivity when I am using Touch pad without putting any non electric material over it and able to switch ON/OFF connected led.But when I put any non electric material like Acrylic Sheet of 2mm thickness I am not able to get any signal through pad or not able to ON/OFF connected led.

So, How can I increase sensitivity of Touch pad?

I have bought TTP224 module from here.

And what can be the alternatives for TTP224???


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

texts:
Hi I want to control a DC motor using Arduino mega2560 and Arduino Uno as a slave. Mega have to process data from an ultrasonic sensor(measuring distance) and control the motor based on the input. I tried to google but couldn't find a better tutorial or code. I'm using Adafruit motor shield l293d. I have the idea about the wiring part just need a simple code.

Eg:

 if( distance < 20) {
   //send signal to slave to run the motor forward
 }else {
   //send signal to slave to stop the motor
 }


texts: Where are the chip configurations stored in IDE 1.6.x? How to modify them?

texts:
With the new 1.6.x version of the Arduino IDE, obscurity of adding new chips has gained new level. It now seems you have to add HTTP links to some JSON files in single-line edit field in settings.

I did so and to add AtTiny to Arduino IDE, I used this JSON file: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

I have AtTiny 13 however. It's same as the others, according to datasheet, but has different signature:

avrdude: Expected signature for ATtiny45 is 1E 92 06
         Double check chip, or use -F to override this check.
Wrong microcontroller found.  Did you select the right board from the Tools > Board menu?

I tried to search ATTiny45 and the signature over the files - no success.

What I need is to add the ATTiny13 to the list so that I can finally actually do some programming, instead of being completely helpless.


texts: Why the global variables info is not shown for Arduino Due in IDE?

texts:
If I compile a sketch for the Arduino Mega:

Sketch uses 1804 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 188 bytes (2%) of dynamic memory,
leaving 8004 bytes for local variables. Maximum is 8192 bytes.

If I compile the same sketch for the Arduino Due:

Sketch uses 26304 bytes (5%) of program storage space. Maximum is 524288 bytes.

Why is the global variables part not supported for the Due, it seems to me it's quite important (even more than the sketch size).

Or can I enable this option somehow? (and if yes, how)


texts: Can I hook up a compass directly to my GPS module?

texts:
I have a Parallax PMB-688 GPS module I'm using with an Arduino and was wondering if I could hook up a compass directly to my GPS. The GPS has an RX port which I hypothesized a compass could be attached to but I don't know if the GPS would be able to comprehend the compass data alone or if I would need to hook it up to the Arduino separately. Please let me know if you have done this or know whether or not it will work. Thanks,

Chris


texts: How to filter out "jumpy" readings sent using Bluetooth

texts:
I'm using App Inventor to continuously send orientation values (as strings) to my Arduino, which are read using Serial.parseInt(). Using simple IF statements (if value > threshold), I'm trying to turn on an LED and otherwise turn it off.

What I'm getting however, is an LED that goes on and off along with these values, which alternate between the actual and desired values and extreme unwanted values as shown in the picture:

Given that my orientation values, as they are, alternate between -180 to 180, I'm using a simple IF statement that seems to work reasonably well, except when the unwanted readings give inaccurate values that are within my range.

My Arduino code:

#include <SoftwareSerial.h>

const int TXD = 3;
const int RXD = 4;
SoftwareSerial mrBlue(TXD, RXD);

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  mrBlue.begin(9600);
  Serial.setTimeout(20);
  mrBlue.setTimeout(20);
}

void loop() {
  // put your main code here, to run repeatedly:

  if (mrBlue.available() > 0) {

    int data = mrBlue.parseInt();
    if (data > 180 || data < -180) {

    }
    else {
      Serial.println(data);
    }
  }
}


texts: Input voltage from circuit drops despite Arduino turned off

texts:
I'm using an Arduino Uno to emulate an old Atari disk drive as described here:
http://whizzosoftware.com/sio2arduino/

As both the Atari and the Arduino use 5V TTL serial communication, the hardware setup is pretty simple, RX and TX are crossed over, GND is connected an an additional line is used for status information.

All works fine when the Arduino is the only device connected to the Atari's serial port (called SIO). Since the SIO bus is a daisy-chain bus, I should be able to hook up serval devices after each other. However, once I connect an original floppy drive together with the Arduino, both the original floppy drive as well as the one emulated by the Arduino stop working.

What made me wonder is that the original drive couldn't be accessed even if the Arduino was turned off but the wiring left in place. Only after I removed the RX and TX pins from the connection, the original drive could be accessed.

I checked with a scope and realized that data transmission was still reaching both devices, however idle voltage was just around 2V instead of 5V. I then checked the resistance on the Arduino between the digital input pins as well as RX/TX in relation to GND and got (varying, depending on the scale I set my multimeter) values that probably have the effect of a voltage divider and thus reduced the voltage on the whole bus by about half.

I was thinking to add a resistor on the RX/TX lines coming from the SIO bus in order to maintain the voltage on the bus, but that would effectively mean that also less current reaches the Arduino RX/TX pins and might therefore render it useless if the voltage drops below the point where the Arduino can distinguish between logical high and low.

Or is there a way to circumvent these internal resitors between the digital inputs and GND? Does this have anything to do with the pull-up/pull-down resistors which I could probably only influence when the Arduino is on?

Thank you in advance for any pointers (other than adding another switch to physically remove RX/TX from the bus when the device is off ;) )!


texts:
My main goal is to use connect the HC-SR04 ultrasonic sensor with ESP8266.

Problem is, HC-SR04 works with 5V while the ESP8266 works with 3.3V
In order to solve this, idea would be to use a logical level converter.

I bought some of this 3.3V 5V TTL Bi-directional Logic Level Converter(s) a good while ago, and thought they would fit best for this project.

Here's my setup

5V from arduino
3.3V from digital power supply
GND connected together
Nothing connected to TX0 (HV side)
Voltmeter connected to TX1 (LV side), still getting a 3.3V

Here's a closer look at the breadboard connections

Am I doing something wrong ? Any suggestions would be appreciated !


texts: Arduino IDE display DEBUG PORT Serial1 output

texts:
How can I display / capture Arduino IDE's Serial1 output?
Can I display it using Arduino IDE or using a script in Python?

This python script (courtesy of Chad G) works for the Serial:

#!/usr/bin/env python3

import serial
import sys

if len(sys.argv)<2:
    print("Please give serial port number")
    exit()
port=sys.argv[1]
ser= serial.Serial('/dev/ttyUSB'+port,9600,timeout=5)

while True:
    try:
    stringMe = str(ser.readline().strip())
    if len(stringMe)>3:
        print(stringMe)

    except:
    print(sys.exc_info())
    ser.close()
    exit()

called as (for USB0):

python3 Arduino/tools/multiMonitor/monitorUsb1.py 0

or, if I want to save to a log file:

python3 Arduino/tools/multiMonitor/monitorUsb1.py 0 >> Arduino/tools/multiMonitor/log/usb00.txt


texts: How do I correctly choose components for my current project?

texts:
Previously I asked a question that was a bit to broad so I'm narrowing the focus to a single component board of my design.

I have a set of 3 luckylight R/G bar graphs
(datasheet here: https://cdn-shop.adafruit.com/datasheets/KWL-R1230XDUGB.pdf)
A 5.1 V 2A power source
(recycled ac/dc converter voltage tested datasheet here: http://pdf1.alldatasheet.com/datasheet-pdf/view/322359/BOTHHAND/M1-10S05.html)
a series of 5 SN74HC595 (for controlling the LED multiplexing)
and an Arduino Nano.

The purpose of the bar graphs is to show the player how much of his available system energy he/she is using.

The first three bars of the graph are set to Red, the next 5 are yellow, and the final 4 are green.

As various components are switched on, or other activities drain the power of the engine core, a program level command will switch the multiplexing array to have them shut off.

The problem I'm having is getting enough power to each of the LEDs of the bar graph without overloading the IC pins on the Arduino or shift registers and making the colors appear correctly.

I know I could use Darlington arrays, or a bunch of transistors to keep the power going to the LEDs on a line independent of the ICs, but i'm not sure the right way to go about this. I have a few ULN2803 Darlingtons and a lot of 2n2222a transistors.

(Also my current Arduino code only has, at max, 8 LEDs from each register on at the same time, with a forward voltage of 2.4 volts and 20mA per LED. There are three cycles to my code because the bar graphs have three shared cathode pins that run three 2x4 matrices.)

Additionally I don't know precisely how to calculate the resistor values I would need for this arrangement to maintain the same voltage being applied to the 24 simultaneously running LEDs and get their brightness to be equivalent. Currently i'm noticing LEDs that are farther down the 595 logic chain are receiving less power and appearing weaker. (yes i have been running them off the power coming from the Arduino thus far)

Hopefully this is a narrow enough question.


texts:
I am new to Arduino and electronics so please correct me if I made a mistake.

Many sensors and actuators require 5V. The Lolin NodeMCU V3 has outputs of 3.3V. I want to have them working together.

I have read that the VIN pin outputs the voltage of the USB power source, which is around 5V. I bet that many sensors and actuators can be connected to VIN.

I guess that the main difference with the VCC pin of other boards is the accuracy and stability of the potential.

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

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

I have seen that many sensors have a not so narrow range of working voltages. That makes me think that small oscillations in the USB voltage may not be significant.

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

Thank you in advance.


texts:
I have a simple following analog reading code:

void setup()
{
  // initialize serial comms
  Serial.begin(9600);
}

void loop()
{
  // read A0
  int val0 = analogRead(0);
  int val1 = analogRead(1);
  int val2 = analogRead(2);
  // print to serial
  Serial.print(val0);
  Serial.print(" ");
  Serial.print(val1);
  Serial.print(" ");
  Serial.print(val2);
  Serial.print("\n");
  // wait
  delay(50);
}

How do I determine the sampling rate? I understand for the serial print, it's 3*4 bytes (for val0,1,2) + 2 bytes for space and 1 bytes for \n, which is 15/9600.

How much time is spent on analogRead?


texts:
I am using Arduino Micro. Is there any way to use PWM on pin 4 instead of Pin3 ?

I tried to change pins_Arduino.h but didnt worked.

//#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11 || (p) == 13)

#define digitalPinHasPWM(p)         ((p) == 4 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11 || (p) == 13)

and

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    ////////////////////////modified///////////////
    //TIMER0B,      /* 3 */
    //NOT_ON_TIMER,
    NOT_ON_TIMER,
    TIMER0B,        /* 4 */
    ////////////////////////////////////////////////////
    TIMER3A,        /* 5 */
    TIMER4D,        /* 6 */
    NOT_ON_TIMER,

    NOT_ON_TIMER,
    TIMER1A,        /* 9 */
    TIMER1B,        /* 10 */
    TIMER0A,        /* 11 */

    NOT_ON_TIMER,
    TIMER4A,        /* 13 */

    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,

    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
    NOT_ON_TIMER,
};


texts:
Can an Arduino Uno calculate the time that an assembly instruction will take in nanoseconds, not microseconds? I don't want to use a PC, because the calculation will be more accurate using an Arduino, as the processor won't be running other tasks.

If the Arduino can't, is there any way to improve it, or any other open source hardware that can do?


texts: When the TX and RX pins for Bluetooth are connected the LCD screen will not update. Why is that?

texts:
I have connected a Bluetooth shield and LCD screen to an Arduino Uno. I have two active low push buttons to increase or decrease the variable desiredTemp. This value is meant to be displayed on the LCD screen, and on my smartphone over the Bluetooth serial connection.

This works as intended for my smartphone, however, when my transmission and receive pins are connected to the board the LCD screen is frozen until the pins are removed. Additionally, I'm not able to update the desiredTemp variable through the Bluetooth serial connection.

Attached is my code:

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

LiquidCrystal LCD(10,9,3,2,1,0);
double inIRPin = A0;
double inThermPin = A1;

int LED = 4;
char recvChar;

int increaseTemp = 7;
int decreaseTemp = 6;
int increaseTempState = 0;
int decreaseTempState = 0;

#define RxD         13
#define TxD         12
SoftwareSerial BTSerial(RxD,TxD);

double valIR = 0;
double valTherm = 0;
double val = 0;
double temp = 0;
double const tempRatio = 0.125;
double desiredTemp = 40; //Degrees Celcius

void setup() {
 // put your setup code here, to run once:

 pinMode(increaseTemp,INPUT);
 pinMode(decreaseTemp,INPUT);

pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
pinMode(LED, OUTPUT);
setupBlueToothConnection();

pinMode(inIRPin, INPUT);
pinMode(inThermPin, INPUT);
LCD.begin(16,2);
LCD.setCursor(0,0);

}

void loop() {
  // put your main code here, to run repeatedly:
   valIR = analogRead(inIRPin); //IR Sensor Output
  valTherm = analogRead(inThermPin);

   increaseTempState = digitalRead(increaseTemp);
   decreaseTempState = digitalRead(decreaseTemp);

   if(increaseTempState == LOW){
    desiredTemp++;
  }
   if(decreaseTempState == LOW){
     desiredTemp--;
   }
   if(BTSerial.available()){
      recvChar = BTSerial.read();
      Serial.print(recvChar);
      BTSerial.println(desiredTemp);
      if(increaseTempState == LOW){
         desiredTemp++;
         updateLCD();
       }
       if(decreaseTempState == LOW){
         desiredTemp--;
         updateLCD();
       }
       if(recvChar == '1'){
         BTSerial.println("Increasing Temp");
         desiredTemp++;
       }
       if(recvChar == '0'){
         BTSerial.println("Decreasing Temp");
         desiredTemp--;
       }
   }
    updateLCD();
  }

 void setupBlueToothConnection()
 {
    BTSerial.begin(9600);

    BTSerial.print("AT");
    delay(400);

    BTSerial.print("AT+DEFAULT");             // Restore all setup value to
    factory setup
    delay(2000);

    BTSerial.print("AT+NAMESmartCoaster");    // set the bluetooth name
    delay(400);

    BTSerial.print("AT+PIN0000");             // set the pair code to connect
    delay(400);

    BTSerial.print("AT+AUTH1");             //
    delay(400);

    BTSerial.flush();

  }

 void updateLCD(){
      LCD.setCursor(0,0);
      LCD.print("Current Temp:");
      LCD.println(temp);
      LCD.setCursor(0,1);
      LCD.print("Desired Temp:");
      LCD.println(desiredTemp);
      delay(100);
  }


texts:
I have a 4 channel relay for my Arduino. Here's an image:

From what I can tell, it's rated for 5V direct current because of the big 05VDC at the bottom, but please tell me if I'm wrong? If I'm wrong, then that's the problem here.

I've tested out an LED on 5V DC to work and connected it to output side of the relay.

I've connected my Arduino to the input, programmed with the following code:

const int RELAY_PIN = 3;

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(96000);

}

void loop() {
  Serial.println("Relay ON");
  digitalWrite(RELAY_PIN, LOW);
  delay(1000);

  Serial.println("Relay OFF");
  digitalWrite(RELAY_PIN, HIGH);
  delay(1000);
}

I can confirm that the corresponding LED on the relay for channel 4 does blink for 1 second and stay off for 1 second, which I'm expecting it's meant to do. I've never worked with an Arduino or a relay before.

However, the 5V DC LED on the other end never lights up. Why is my relay not switching on?

Edit: About the LED circuit. It is on and fully powered. If I bypass the relay and join the two wires, the LED lights up. If I plug the two wires into the relay, the LED never lights up.

Edit2: About the jumper: I have a secondary 5V power supply connected to the VCC for what I'm told is isolation. I've read a little on the matter, but am not fully aware of how it works.

Edit 3:

Connections

I have the following connections:

Output 3 (Arduino) to Input 4 (Relay)
5V (Arduino) to Input VCC (Relay) [The one next to the input pins]
Power supply positive/ground to GND (Relay)
Power supply negative/live to VCC (the one next to the JD-VCC)

This did not work. What did work was the following configuration:

Output 3 (Arduino) to Input 4 (Relay)
5V (Arduino) to Input VCC (Relay) [The one next to the input pins]
Jumper across VCC and JD-VCC on the Relay


texts: Writing First Library - Serial Stream Object

texts:
I have done quite a few projects with Arduino, but have never done more than a "Hello World" in C. I am writing my first library, and a lot of the object oriented stuff is going over my head. Anyway, my library is working as it is supposed to, I pass a float to my function and it formats it properly and sends it out over serial. However, I implemented it in a clunky way. The Arduino API Style Guide mentions a way that seems much better:

  When using serial communication, allow the user to specify any Stream object, rather than hard-coding "Serial". This will make your library compatible all serial ports on Mega and the Due, and can also use alternate interfaces like SoftwareSerial. The Stream object can be passed to your library's constructor or to a begin() function (as a reference, not a pointer). See Firmata 2.3 or XBee 0.4 for examples of each approach.

Can anybody elaborate on how to do this, or show me some code?


texts: I'm having trouble figuring out how to start my project. The objective is to control a robot with four servo motors and six DC motors through bluetooth. I have a bluetooth shield from Adafruit and I'm using the Arduino UNO. Ideally, I want to control this robot by sending it packets through Processing. The problem is I don't know how to create a packet with a header, payload, and checksum. I can't find any examples; can anyone help me find something to help me get started?


texts: How can I charge 12V Li-ion or lead acid batteries using a solar panel? I also wish to interface the three, i.e. the Arduino, the solar panel and the battery, together so that the Arduino is basically driven by the battery but as the battery discharges, the solar panel would charge it. What circuitry do I need? Also tell the specifications of the solar panel.


texts:
I saw the following code from https://circuits4you.com/2018/03/10/esp8266-jquery-and-ajax-web-server/ but I could not understand it thoroughly...
I looked at the documentation of PROGMEM from this https://www.arduino.cc/reference/en/language/variables/utilities/progmem/ but could not understand the importance in the code on why you should put your variables in flash memory instead of SRAM (the usual memory?)?
const char MAIN_page[] PROGMEM = R"=====(
  <!DOCTYPE html>

If you click on me, I will disappear.

Click me away!

Click me too!

  circuits4you.com

)=====";

Also, I could not understand the definition of R"====()====", what is meant by this in arduino?


texts: Unable to issue any AT commands to BT BLE Breakout Board

texts:
I'm a programmer, more from the software side but I do have hardware working knowledge too. I've completed the Arduino Starter Kit's 15 projects, Now trying to build some things with ESP8266 and HM-10 BLE.

I was able to connect ESP8266 to my network and start a TCP server too via AT commands(using  Arduino's Serial Monitor and FTDI 232RL USB to TTL converter)

I also have a HM-10 Bluetooth Breakout+connector board (Its based on CC2541 by TI (visible on the SMD chip)) brought from here.

Using the same setup I was able to issue AT commands successfully for ESP8266. However I tried many things, different baud rates and \r\n combinations; I just couldnt get the HM-10 to acknowledge my AT commands.

Setup: link

Connections:

Arduino +5V --> +ve input of LDO regulator --> 3.3v OUPUT to Vcc of HM-10
Common GND for LDO regulator input and output pins, FTDI 232RL and HM10

FTDI TX --> voltage divider (1k ohms --> connection output to HM 10 RX --> 1k ohms --> 1k ohms --> GND)

There is no code/sketch as of now. I'm just trying to hook up the HM-10 BLE chip. I can pair my Android phone to it but that's not the concern here.

The concern here is I cannot configure the HM-10 using AT commands.

The HM-10 does not reply an "OK" acknowledge for my "AT" command. Nothing happens in the serial monitor after hitting enter. Just a blank screen.

Is there a way by which I can determine what baud rate to use and what combination of \r and \n?

What am I missing here?


texts:
can someone tell me why my L led on arduino uno glowing continuously I tried restarting my pc, changing USB port
I also tried uploading an empty file and resetting the  Arduino board but nothing seems to work. Does it mean I have to buy a new one?


texts: High frequency audio sampling and storage

texts:
I want to use an arduino duemilanove atmega168 for audio signal processing. I can sample the signal at around 38.5kHz using this code. I want to send the sampled data over the serial to a computer for processing.

Data acquisition rate: 38.5 kbps (using 8-bit precision)
Maximum serial communication rate: 115200 bps (I don't know exactly how this relates to the transfer rate of the actual data (without any overheads), but anyhow the limit is 13.94 kbps)
Arduino flash memory: 16 kB

I would like to transmit around 4-5 seconds of the audio signal to the computer. Is there a way to achieve this?


texts: How can I run a webserver in a Arduino Uno? I want to use my Arduino to monitor things in my home such as temperature. I want to be able to access this data through the internet.


texts: C++ Adding Two 16 bit binary numbers together

texts:
I am trying to add two 16 digit binary numbers together. Each binary number will have been entered by the user and saved as: int binaryOne[16] and int binaryTwo[16]. Originally,

int binaryOne[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int binaryTwo[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

are the values declared. Then, the user has the option to change these values using buttons that I implement before the Solution() function. So, once the used gets to the Solution() function, the numbers may be stored as:

int binaryOne[16] = {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1};
int binaryTwo[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};

This is what I have so far:

void Solution() {
  /*
    Rule of binary addition:
    0 + 0 = 0
    1 + 0 = 1
    0 + 1 = 1
    1 + 1 = 1 and carry = 1
   */
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Solution");
   lcd.setCursor(0,2);

    int a[16] = binaryOne[16];
    int b[16] = binaryTwo[16];
    int i = 0;
    int remainder = 0;
    int sum[32];

    while(a[16] != 0 || b[16] != 0){
      sum[i++] = (a[16] % 10 + b[16] % 10 + remainder) % 2;
      remainder = (a[16] % 10 + b[16] % 10 + remainder) / 2;
      a[16] = a[16] /10;
      b[16] = b[16] / 10;
    }
    if(remainder != 0){
      sum[i++] = remainder;
    }
    i--;
    while(i>=0){
      lcd.print("%d", sum[i--]);
   }
   return 0;
}

I believe I am doing something wrong with calling the arrays since I am renaming them to a[16] and b[16] within this function. I'm also curious, since I only have 16 bits of space on the screen, what if the user enters a binary number such as 1111111111111111 + 1000000000000000 and therefor there is going to be a carry on that first digit? Would it be best just to have an error message?


texts: toInt error when converting character of string to interger

texts:
with the following code:

int foo = bar[1].toInt;

or

int foo = bar[1].toInt();

I get this error

request for member 'toInt' in '*(bar + 1u)', which is of non-class type 'uint8_t {aka unsigned char}'

the context for this is bar is the response from a HTTP client over web sockets


texts: Cannot upload sketch to Arduino Micro with Arduino IDE on OSX

texts:
I have been programming a Arduino Micro for weeks now, but suddenly it is not able to upload a sketch.

I am using OSX Mavericks on a Macbook Pro which has USB 3.0 ports. It has never been a problem to upload sketches, but this is the error i get:

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "Startin"; type = a
    Software Version = N.o; Hardware Version = t.
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


texts:
I'm trying to communicate via I2C on the Raspi, programming it with the Arduino Create Web Editor.  I have enabled I2C on the pi, made sure /dev/i2c-1 exists.  The pi can see the device (just a simple LCD for now) via the command line on the pi itself.
I'm getting the error "no I2C device available for Wire10".  I'm wired to SDA1/SCL1 (pins 3 and 5).  I have previously tested the display and the code on an UNO and it works fine.
Please help!  I saw someone had this issue before and simply said "I fixed it" but didn't provide an explanation.
Thanks!  (Code below for reference)
/* I2C LCD with Arduino example code. More info: https://www.makerguides.com */

// Include the libraries:
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD

// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4); // Change to (0x27,16,2) for 16x2 LCD.

void setup() {
  // Initiate the LCD:
  lcd.init();
  lcd.backlight();
}

void loop() {
  // Print 'Hello World!' on the first line of the LCD:
  lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
  lcd.print("Hello Worlds!"); // Print the string "Hello World!"
  lcd.setCursor(2, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
  lcd.print("LCD tutorial");
}


texts: Checking a jumper between two pins on Arduino

texts:
I'm in the process of making a tag scanner (which transfers the tag ID to the computer), and I figured I'd use an Arduino Micro for that and just use the keyboard function on it to save myself a whole lot of hassle. From what I've read, however, having the keyboard open all the time can make it tricky to program it.

I figured my solution would be to use two of the pins as a jumper check, and have some code in the setup to read the input pin; if the circuit is closed between them, the keyboard function never activates, and if it's open, the Arduino will act as a keyboard. That way I should be able to put the jumper on if I need to program it, and leave it off if I just want it to run.

Unfortunately, I've never really done anything like this before, and I don't really want to just start plugging things around and run the risk of damaging my board. I've read around a bit, but I figured I wanted to bounce my ideas off of someone before I try it.

First, would you recommend a different approach? I did see a question that used the internal pullup resistor to check if a jumper connected it to ground, but since I only want to make this check once, is that a good route to go?

Secondly, if I connect it between two pins, am I correct in thinking I'd need a resistor between them (the Arduino website suggested 470ohm to 1kohm when connecting to other devices, so I'm guessing this would be a good number)? How would I set the pins up to make this work; should I put one pin as output and the other as input, and just read the input pin (after which I'd simply turn the output pin off), or would I need to add additional connections?

Thirdly, since this will use the USB port on the Arduino that is used to program it, is there a way to wipe the code from the Arduino in case of Serious Bugs, or is it possible to "brick" the board by tying up the USB permanently? I mean, I'll definitely make use of the Serial connection to test the output (and also to test the above jumper), so I think the odds are small enough to try it anyway, but... better safe than sorry?


texts: Arduino recieve sensor data from other arduino SPI

texts:
I have Arduino Uno (sender) and Arduino Uno Wifi rev 2 (receiver). I want to send the ping value to the other one via serial - jumper wires.
Arduino Uno is using the newping example, and I want the Uno Wifi to receive the sensor value and print it to serial.
I am using SoftwareSerial.h
jumper wires go TX<->RX , RX <->TX, GRD-GRD according to the pins in the sketch below.
The problem is the sketch code for the Uno WiFi (receiver), it keeps printing garbage and seems like no carriage return sometimes.
13
⸮10
⸮52
⸮5LC⸮1⸮H⸮10
5⸮H⸮51
13C⸮10
⸮5⸮H⸮5LC⸮13
10
⸮52
51C⸮13
10
⸮52
5LC⸮13
⸮10C⸮52
⸮51
13
10
⸮52
50

Code on Uno (sender):
// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------
#include <SoftwareSerial.h>
#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
SoftwareSerial mySerial(9, 10); // RX, TX

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

 Serial.println("Hello World Serial");
 mySerial.begin(4800);
 mySerial.println("Hello World, mySerial");
}
void loop() {
  delay(500);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");
  mySerial.print(sonar.ping_cm());
  mySerial.println();
  }

code on uno wifi (reciever):
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);

}

void loop() { // run over and over

    Serial.println(mySerial.read());
    delay(1000);

}

I can see the Uno (sender) with NewPing is printing the correct data to it's serial but I can't get the Uno wifi (listener) to get the same value. Its just garbage. I am new to this, what am I doing wrong?


texts: Where to get the potentiometer that comes with Arduino kit

texts:
Does anyone know where I can get the potentiometer that comes with the Arduino kit? You can see them here.

They are sold out on their website.


texts: atmega328p on breadboard using ftdi to upload sketches @8mhz 3.3v

texts:
I'm having trouble getting the atmega328p chip to upload sketches using my ftdi. It always comes up with an error saying not in sync.

I have an 8Mhz crystal with 22pf capacitors. The weird thing is I could flash the bootloader using my avrispmkII @ 3.3v. AFAIK this tells me the chip is running. I have an led connected to pin7. It doesn't flash when turn the power on.  However it does flash when powered from 5v and everything is working fine. I could upload sketches using the ftdi.

I have the ftdi on a breakout to pin headers. I have the reset pin wired up to the DTR via a 100nf capacitor. The reset has a 10k pull up. CTS pin is grounded. The usart is as follows tx (atmega) ---> rx(ftdi)  and rx(atmega) to tx(ftdi). I have also switch between 3.3v and 5v logic using the vccio pin on the ftdi. I.e. vccio = 5v if atmega is 5v.

I know the programmer need to know what voltage am using, how critical is it, since I don't have a 3.3v regulator to hand. I used a lm338 and it's coming out as around 3.2

I selected arduino pro/mini @ 8mhz 3.3v atmega328p when I flashed the bootloader

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

pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

pro328.upload.protocol=arduino
pro328.upload.maximum_size=30720
pro328.upload.speed=57600

pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDA
pro328.bootloader.extended_fuses=0x05
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F

pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino
pro328.build.variant=standard

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

output from avrdude

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.