text:
Question About The Error In This Code
Could someone point out what exactly I'm screwing up here and provide a specific solution. Here's the error message:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

sketch_jul24g:38:11: error: expected ')' before '(' token
 (  pinMode(led, OUTPUT);     )
           ^

sketch_jul24g:38:30: error: expected unqualified-id before ')' token
 (  pinMode(led, OUTPUT);     )
                              ^

sketch_jul24g:39:1: error: expected declaration before '}' token
 }
 ^

exit status 1

expected ')' before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And here's the code:
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        6 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16 // Popular NeoPixel ring size

// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 0 // Time (in milliseconds) to pause between pixels

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

  // initialize the digital pin as an output.
(  pinMode(led, OUTPUT);     )
}

// the loop routine runs over and over again forever:
void loop() {
   pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(255, 255, 255));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(DELAYVAL); // Pause before next pass through loop
  }
  pixels.setPixelColor(i, pixels.Color(255, 255, 255)); // turn the LED on (HIGH is the voltage level)
  delay(3);               // wait for a second
  pixels.setPixelColor(i, pixels.Color(0, 0, 0));    // turn the LED off by making the voltage LOW
  delay(8000);               // wait for a second
}

Like I said-what's going on? Thanks!

examine example code that is included with the Arduino IDE ... pay attention when you are looking at the code

Please pay attention when structuring your code and try to understand what opening and closing braces { } and parentheses ( ) are used for in C++.

use { pinMode(led, OUTPUT); } to create a new scope and if you don't need new scope just remove (, )


text:
avrdude: stk500_recv(): programmer is not responding, arduino pro
I'm trying to upload a sketch to upload the blink sketch to an arduino pro using a SparkFun Serial Basic Breakout (on Ubuntu 18.04).
setup
Within the arduino IDE I have the following set-up:

Tools -> Board: Arduino Pro or Pro mini
Tools -> Port: /dev/ttyUSB0
Tools -> Programmer: USBasp

I have connected:

DTR sparkfun to DTR on arduino
RX1 sparkfun to RX1 on arduino
TX0 sparkfun to TX0 on arduino
VCC sparkfun to VCC on arduino
GND sparkfun to GND on arduino

the error
The error that I get is as follows
Arduino: 1.8.13 (Linux), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
/home/cmhughes/Desktop/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/cmhughes/Desktop/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/arduino_build_457079/cmh-Blink.ino.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/cmhughes/Desktop/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/cmhughes/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
...

The error message continues, and tries 10 attempts.
the question
I've tried many different things, including: changing the RX1 to TX0 connections, using a different FTDI serial adapter, trying a different USB cable, trying on Windows operating system.
What else can I try to see if I can progress this?
arduino pro

SparkFun Serial Basic Breakout - CH340C and USB-C

wire RX to TX. transmit to receive

@juraj many thanks; if I've understood you, then that's on the list of things that I've tried ....

it is not a troubleshooting suggestion. it is how it must be

reset the Arduino while avrdude attempts the upload

@Juraj many thanks, that was very helpful. Using both of the things that you detailed, I have now been able to upload onto my arduino pro. If you'd like to post an answer, I'll gladly accept it. Thanks again.

Hello friend ! How Arduino detect you switched to programming mode ? Need an Reset signal before upload sketch(Another important things: All reset signal got timeout conditions). So use push button before upload !

Many thanks, @dsgdfg, that's very helpful :)

the DTR connection should make the reset, but it looks like it doesn't work here

DTR isn't compatible both boot or program things ! DTR will be reset device on standart communication(so every time need disable DTR for talking with Arduino)

@dsgdf The original design for the Arduino Pro Mini  includes a capacitor between the board's "DTR" header position and the ATmega328;s RESET pin - this is intended to facilitate programming through an "FTDI Friend" or similar USB-serial adapter which then uses the DTR line to reset the ATmega328 and cause it to run the bootloader that waits for serial program upload or which times out and runs the previously uploaded "sketch". See https://store.arduino.cc/arduino-pro-mini. So you don't normally have to disable or re-enable DTR anywhere.

@RedGrittyBrick That might be true. However, capacitors used for delay in circuits without guarantee of feeding voltage do not work healthy! (see : SYNC error). Another point Not all communication converters contain DTR!

The upload procedure needs to reset the ATmega328 by use of DTR. This invokes the bootloader code in the ATmega328. If there is a problem with your DTR connection, you have to instead manually press the RESET button at the appropriate time.
So probably your connection to DTR was faulty or. less likely, there could be a fault in the onboard capacitor between the Pro-Mini's "DTR" header and the ATmega328 RESET pin
https://store.arduino.cc/arduino-pro-mini -> Documentation

Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the Arduino Pro Mini is designed in a way that allows it to be reset by software running on a connected computer. One of the pins on the six-pin header is connected to the reset line of the ATmega328P via a 100 nF capacitor. This pin connects to one of the hardware flow control lines of the USB-to-serial convertor connected to the header: RTS when using an FTDI cable, DTR when using the Sparkfun breakout board. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of the reset line can be well-coordinated with the start of the upload.

Might have to do with the usb chip on that being not as widely supported as the official chip Arduinos use on their Uno’s, Mega’s, etc. the ch340C one sometimes needs drivers so look online for those drivers and download them.

source: Stack Exchange

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

sort: votes


text:
I'm able to send messages from SIM800a module and receive "+CMGS: 177 Ok" but I'm not able to receive it in the number entered in the code
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
char msg;
char call;

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  Serial.println("GSM SIM900A BEGIN");
  Serial.println("Enter character for control option:");
  Serial.println("h : to disconnect a call");
  Serial.println("i : to receive a call");
  Serial.println("s : to send message");
  Serial.println("r : to receive message");
  Serial.println("c : to make a call");
  Serial.println("e : to redial");
  Serial.println();
  delay(100);
}

void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'c':
      MakeCall();
      break;
    case 'h':
      HangupCall();
      break;
    case 'e':
      RedialCall();
      break;
    case 'i':
      ReceiveCall();
      break;
    case 'r':
      ReceiveMessage();
      break;

  }
 if (mySerial.available()>0)
 Serial.write(mySerial.read());
}

void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+917018483787\"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("sim900a sms");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}

void ReceiveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
  delay(1000);
  if (mySerial.available()>0)
  {
    msg=mySerial.read();
    Serial.print(msg);
  }
}

void MakeCall()
{
  mySerial.println("ATD+917018483787;"); // ATDxxxxxxxxxx; -- watch out here for semicolon at the end!!
  Serial.println("Calling  "); // print response over serial port
  delay(1000);
}

void HangupCall()
{
  mySerial.println("ATH");
  Serial.println("Hangup Call");
  delay(1000);
}

void ReceiveCall()
{
  mySerial.println("ATA");
  delay(1000);
  {
    call=mySerial.read();
    Serial.print(call);
  }
}

void RedialCall()
{
  mySerial.println("ATDL");
  Serial.println("Redialing");
  delay(1000);
}

please format your code ... it is not readable the way you presented it

what is the exact problem that you are seeing ... you did not ask a question, so it is unclear what you want to know

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


text:
How to use "+" character as a String
Well I am trying to save phone number as a string. For ease of use I want to add "+" character programmatically. Like this:
String cepNo ="+" + "901234567";

But program gives this error.
exit status 1
invalid operands of types 'const char [2]' and 'const char [13]' to binary 'operator+'

How to add "+" beginning of the string.

A string literal isn't a String. You can't concatenate them like that. This is C, not BASIC.

The arduino error is on the +, not the "+".

You cannot add C strings (i.e. NUL-terminated arrays of char) with the
+ operator. It only works with String objects. You can, though, add
a String object and a C-string, because in this case the compiler
implicitly converts the C string into a String object:
String phone_number = "901234567";
phone_number = "+" + phone_number;

The last line is interpreted by the compiler as
phone_number = String("+") + phone_number;

That being said, I encourage you to try to avoid String objects if
possible. These use dynamic memory allocation which carries the risk of
heap fragmentation. The same thing can be achieved with plain C strings:
char phone_number[] = "901234567";
char full_phone_number[strlen(phone_number) + 2];
strcpy(full_phone_number, "+");
strcat(full_phone_number, phone_number);

Note the size of the second string: strlen(phone_number) + 2. You need
one extra char for the + sign, and another one for the NUL string
terminator.
Now, with C strings you can do better, and avoid copying: reserve enough
room in an array for the full number (“+” included), and then fill the
digits starting from the second slot in the char array. You can then
add the + sign later:
char phone_number[16];
strcpy(phone_number + 1, "901234567");
phone_number[0] = '+';

Although I personally would write the “+” sign and a NUL while
initializing the array:
char phone_number[16] = "+";
strcat(phone_number, "901234567");

use String cepNo = String("+") + "901234567";
or
String a = "+"; String cepNo = a + "901234567";

Or, simply don't use the + operator.


text:
dot matrix arduino turn off the intermittent led
I made a dot matrix that contain 10 row and 12 column , total 120 led.
I want to turn on the leds like this picture but when I open ground 1 , 2 and pin 0 , 1 , 2
6 leds light together.what kind of structure should I build?
Sheme :

I tried row by row like this:
 clear_cube();
 regWrite(cube[0][0], HIGH);
 set_array(4);
 //delay(10);

clear_cube();
regWrite(cube[1][0], HIGH);
set_array(3);
//delay(10);

clear_cube();
regWrite(cube[0][0], HIGH);
set_array(2);
//delay(10);                                                                                When I decrease the delay 5 leds blinking.

100  50  10  0 delay   Youtube

You can't just turn them on like that.
Instead you have to turn one row on. Then the next row. Then the next. Very fast.
So you first display:
O@OO
OOOO
OOOO

Then you display
OOOO
OO@O
OOOO

Then you display
OOOO
OOOO
O@OO

And you cycle through that very fast.  Usually using a timer to run it all.  The fact that you're using '595s will slow you down and make it harder to update fast enough to look non-flickery.

I will try that

I tried but it does not work .I update the code like above @Majenko♦

That code is completely meaningless.

No. regWrite turn on the positive and set array turning on the ground.I'm uploading a video 100 50 10 and 0 delay

That looks like it's working. But like i said, your use of '595s will make it hard to make it non-flickery. You need to refresh very fast. Ideally hundreds of times per second, though tens of times per second will be tolerable.

You want to multiplex them by rows or columns. If you do it by columns, then do the following: Set all columns to open circuit. (everything off.)
Set the row value pins for the first column, then
activate the column pin for the first column. The LEDs for the first column light up.
Now delay for a brief period (say 20 ms) and go on to the next column. (Obviously you'd use a loop for this.) Repeat.
You should write your code as a state machine using millis() rather than using delay, or you will paint yourself into a corner and you'll write code that totally blocks the machine just to display the LED grid. If you use millis() and a sate machine you'll be able to do other things at the same time you loop through the LEDs


text:
ST7735s 1.8" SPI 128x160 TFT Module - White Screen
I am having an issue in my 1.8" TFT LCD module with SPI interface in Arduino Nano. I keep seeing the white screen on my tft.
I have made the following connections using Jumper cables:

RST  --- connected to D8 (on Nano)

CE/CS --- Connected to D10

DC ----  Connected to D9

DIN (MOSI) -- connected to D11

CLK --- connected to D13

VCC --- connected to 5V

BL ---- Connected to 3.3 V

GND -- connected to GND

Sorry i am new to this world, so dont know how i can provide you the wiring connections i have made and so jotted it down in this post.
I am using the Adafruit ST7735 GraphicsTest with the code modified according to the above pin:
/**************************************************************************
  This is a library for several Adafruit displays based on ST77* drivers.

  Works with the Adafruit 1.8" TFT Breakout w/SD card
    ----> http://www.adafruit.com/products/358
  The 1.8" TFT shield
    ----> https://www.adafruit.com/product/802
  The 1.44" TFT breakout
    ----> https://www.adafruit.com/product/2088
  The 1.14" TFT breakout
  ----> https://www.adafruit.com/product/4383
  The 1.3" TFT breakout
  ----> https://www.adafruit.com/product/4313
  The 1.54" TFT breakout
    ----> https://www.adafruit.com/product/3787
  The 2.0" TFT breakout
    ----> https://www.adafruit.com/product/4311
  as well as Adafruit raw 1.8" TFT display
    ----> http://www.adafruit.com/products/618

  Check out the links above for our tutorials and wiring diagrams.
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional).

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 **************************************************************************/

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>

#if defined(ARDUINO_FEATHER_ESP32) // Feather Huzzah32
  #define TFT_CS         14
  #define TFT_RST        15
  #define TFT_DC         32

#elif defined(ESP8266)
  #define TFT_CS         4
  #define TFT_RST        16
  #define TFT_DC         5

#else
  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
  #define TFT_CS        10
  #define TFT_RST        8 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_DC         9
#endif

// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board's microSD card.

// For 1.44" and 1.8" TFT with ST7735 use:
// Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// For 1.14", 1.3", 1.54", and 2.0" TFT with ST7789:
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
#define TFT_MOSI 11  // Data out
#define TFT_SCLK 13  // Clock out

// For ST7735-based displays, we will use this call
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// OR for the ST7789-based displays, we will use this call
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

float p = 3.1415926;

void setup(void) {
  Serial.begin(9600);
  Serial.print(F("Hello! ST77xx TFT Test"));

  // Use this initializer if using a 1.8" TFT screen:
  tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

  // OR use this initializer if using a 1.8" TFT screen with offset such as WaveShare:
  // tft.initR(INITR_GREENTAB);      // Init ST7735S chip, green tab

  // OR use this initializer (uncomment) if using a 1.44" TFT:
  //tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

  // OR use this initializer (uncomment) if using a 0.96" 160x80 TFT:
  //tft.initR(INITR_MINI160x80);  // Init ST7735S mini display

  // OR use this initializer (uncomment) if using a 1.3" or 1.54" 240x240 TFT:
  //tft.init(240, 240);           // Init ST7789 240x240

  // OR use this initializer (uncomment) if using a 2.0" 320x240 TFT:
  //tft.init(240, 320);           // Init ST7789 320x240

  // OR use this initializer (uncomment) if using a 1.14" 240x135 TFT:
  //tft.init(135, 240);           // Init ST7789 240x135

  // SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here
  // Note that speed allowable depends on chip and quality of wiring, if you go too fast, you
  // may end up with a black screen some times, or all the time.
  //tft.setSPISpeed(40000000);

  Serial.println(F("Initialized"));

  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST77XX_BLACK);
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST77XX_WHITE);
  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

  // a single pixel
  tft.drawPixel(tft.width()/2, tft.height()/2, ST77XX_GREEN);
  delay(500);

  // line draw test
  testlines(ST77XX_YELLOW);
  delay(500);

  // optimized lines
  testfastlines(ST77XX_RED, ST77XX_BLUE);
  delay(500);

  testdrawrects(ST77XX_GREEN);
  delay(500);

  testfillrects(ST77XX_YELLOW, ST77XX_MAGENTA);
  delay(500);

  tft.fillScreen(ST77XX_BLACK);
  testfillcircles(10, ST77XX_BLUE);
  testdrawcircles(10, ST77XX_WHITE);
  delay(500);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
}

void testlines(uint16_t color) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, 0, x, tft.height()-1, color);
    delay(0);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, 0, tft.width()-1, y, color);
    delay(0);
  }

  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
    delay(0);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, 0, 0, y, color);
    delay(0);
  }

  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, tft.height()-1, x, 0, color);
    delay(0);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
    delay(0);
  }

  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
    delay(0);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
    delay(0);
  }
}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t y=0; y < tft.height(); y+=5) {
    tft.drawFastHLine(0, y, tft.width(), color1);
  }
  for (int16_t x=0; x < tft.width(); x+=5) {
    tft.drawFastVLine(x, 0, tft.height(), color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=tft.width()-1; x > 6; x-=6) {
    tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=radius; x < tft.width(); x+=radius*2) {
    for (int16_t y=radius; y < tft.height(); y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=0; x < tft.width()+radius; x+=radius*2) {
    for (int16_t y=0; y < tft.height()+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}

void testtriangles() {
  tft.fillScreen(ST77XX_BLACK);
  uint16_t color = 0xF800;
  int t;
  int w = tft.width()/2;
  int x = tft.height()-1;
  int y = 0;
  int z = tft.width();
  for(t = 0 ; t <= 15; t++) {
    tft.drawTriangle(w, y, y, x, z, x, color);
    x-=4;
    y+=4;
    z-=4;
    color+=100;
  }
}

void testroundrects() {
  tft.fillScreen(ST77XX_BLACK);
  uint16_t color = 100;
  int i;
  int t;
  for(t = 0 ; t <= 4; t+=1) {
    int x = 0;
    int y = 0;
    int w = tft.width()-2;
    int h = tft.height()-2;
    for(i = 0 ; i <= 16; i+=1) {
      tft.drawRoundRect(x, y, w, h, 5, color);
      x+=2;
      y+=3;
      w-=4;
      h-=6;
      color+=1100;
    }
    color+=100;
  }
}

void tftPrintTest() {
  tft.setTextWrap(false);
  tft.fillScreen(ST77XX_BLACK);
  tft.setCursor(0, 30);
  tft.setTextColor(ST77XX_RED);
  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_YELLOW);
  tft.setTextSize(2);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_GREEN);
  tft.setTextSize(3);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_BLUE);
  tft.setTextSize(4);
  tft.print(1234.567);
  delay(1500);
  tft.setCursor(0, 0);
  tft.fillScreen(ST77XX_BLACK);
  tft.setTextColor(ST77XX_WHITE);
  tft.setTextSize(0);
  tft.println("Hello World!");
  tft.setTextSize(1);
  tft.setTextColor(ST77XX_GREEN);
  tft.print(p, 6);
  tft.println(" Want pi?");
  tft.println(" ");
  tft.print(8675309, HEX); // print 8,675,309 out in HEX!
  tft.println(" Print HEX!");
  tft.println(" ");
  tft.setTextColor(ST77XX_WHITE);
  tft.println("Sketch has been");
  tft.println("running for: ");
  tft.setTextColor(ST77XX_MAGENTA);
  tft.print(millis() / 1000);
  tft.setTextColor(ST77XX_WHITE);
  tft.print(" seconds.");
}

void mediabuttons() {
  // play
  tft.fillScreen(ST77XX_BLACK);
  tft.fillRoundRect(25, 10, 78, 60, 8, ST77XX_WHITE);
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_RED);
  delay(500);
  // pause
  tft.fillRoundRect(25, 90, 78, 60, 8, ST77XX_WHITE);
  tft.fillRoundRect(39, 98, 20, 45, 5, ST77XX_GREEN);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST77XX_GREEN);
  delay(500);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_BLUE);
  delay(50);
  // pause color
  tft.fillRoundRect(39, 98, 20, 45, 5, ST77XX_RED);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST77XX_RED);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_GREEN);
}

The Output of this code on serial output:
01:16:16.840 -> Hello! ST77xx TFT TestInitialized
01:16:19.829 -> 1876
01:17:44.911 -> done

I have tried many things from past two days but no luck on this issue.
I have seen the following posts and implemented but effort gone in just accumulating knowledge but unable to resolve the issues:
What am I missing? ST7735 TFT white screen
Why am I only seeing white screen in TFT 1.44 ST7735?
Kindly please let me know in case anyone resolves this issue.

Try it without the RST connected. Might work worth a try.

I have a 1.44' SPI 128x128 V2.0 [Blueish (teal) PCB, Green Tab Screen].
I was having the same problem. I had connected the VCC pin to 3.3V.
Solution: connect VCC to the 5V pin
The white screen is gone. I hope it helps.

Hmm, okay.  But, the O.P. is ("was" really) not apparently in that situation: VCC --- connected to 5V


text:
Fastest sim module available?
I have used sim900 in my project but it isn't fast, I don't know if it is because it is on 2G or what, I wanna know if I can get something good that can send SMS messages immediately and doesn't take time to send multiple messages, if I switch to something that supports 3g can that solve my problem?

what is the actual problem that you are trying to solve?

@jsotola I have been trying to make a device that is being used to alert a seleted few people by SMS of a danger in that area, like when someone call on that number, it will automatically reject my call and then send my number through sms to other people that this guy is saying that there is some danger and for more information call this guy, but for that I need to send SMS messages as soon as possible, I have tried it with sim900 and it has reached it limit like it takes a few seconds before it can send the next message.

And there are a lot of things in GSM like class, speed etc, and I don't know if using 3G or 4G can make any difference to SMS sending speed too, so that is what I am asking here, if using them can make any difference or not.

I have been trying to make a device that is being used to alert a seleted few people by SMS of a danger in that area ... that part of your comment is clear and easy to understand and for some reason the rest of the comment is gibberish .... anyway,  maybe there is a way to send an SMS to multiple numbers with one command

SMS is a 2G technology, it does not utilised packet switch system in 3G/4G, so if you want to reduce latency, try to uses data network like socket connection.


text:
How are locations in FLASH memory addressed?
There is an external FLASH memory (W25Q80DV) that I want to use with the Arduino.
This memory has 4096 pages of 256 bytes each.
I want to make multiple writes per page to use memory evenly and erase less.
Test code:
#include <SPI.h>

#define readStatusReg_1 0x05
#define readArrayReg 0x0B
#define writeEnableReg 0x06
#define pageProgramStatusReg 0x02

#define FLASH_SELECT_CHIP 33

// # Select / Unselect chip
void selectChip(bool state) {
  switch (state) {
    case true:
     digitalWrite(FLASH_SELECT_CHIP, HIGH);
     digitalWrite(FLASH_SELECT_CHIP, LOW);
      break;
    case false:
     digitalWrite(FLASH_SELECT_CHIP, HIGH);
      break;
  }
}

// # Wait flash ready state
void notBusy() {
  uint16_t whileCounter;
  selectChip(true);
  SPI.transfer(readStatusReg_1);
  while((SPI.transfer(0) & 1) && whileCounter < 45000) { whileCounter++; }
  selectChip(false);
}

// # Send command and address
void sendCommandAndAddress(const byte command, const unsigned long address) {
  SPI.transfer(command);
  SPI.transfer((address >> 16) & 0xFF);
  SPI.transfer((address >> 8) & 0xFF);
  SPI.transfer(address & 0xFF);
}

// # Write enable
void writeEnable() {
  notBusy();
  selectChip(true);
  SPI.transfer(writeEnableReg);
  selectChip(false);
}

// # Write FLASH page
bool writeFlashData(const unsigned long address, byte * data) {
  writeEnable();
  selectChip(true);
  sendCommandAndAddress(pageProgramStatusReg, address);
  uint16_t len = sizeof(data);
  for(uint16_t i = 0; i < len; i++) {
    SPI.transfer(*data++);
  }
  selectChip(false);
  notBusy();
  return true;
}

void setup() {
  // SPI
  pinMode(FLASH_SELECT_CHIP, OUTPUT);
  digitalWrite(FLASH_SELECT_CHIP, HIGH);
  SPI.begin();
  SPI.setDataMode(0);
  SPI.setBitOrder(MSBFIRST);

  // Write FLASH
  #define TESTADDRESS 0x1000
  byte msgData[] = "Hi all!";
  writeFlashData(TESTADDRESS, msgData);
}

void loop() {}

Here, the address #define TESTADDRESS 0x1000 (4096) is specified for writing data.
I'm not clear if this is the page address or the byte address from which I will start recording?
I would like to actually split one page into multiple blocks and write data for them separately.

I'm not clear if this is the page address or the byte address from which I will start recording?

That is the byte address.  As the data sheet in section 8.5.13 says:

If an entire 256 byte page is to be programmed, the last address byte (the 8 least significant address bits) should be set to 0. If the last address byte is not zero, and the number of clocks exceed the remaining page length, the addressing will wrap to the beginning of the page.

In other words: if you want to write an entire page then start at the beginning of the page. If you don't and you write more than there is room left in the page you will wrap round back to the beginning of the page again.
So if you write two bytes starting with address 0x10FF you will actually write one at 0x10FF and the second at 0x1000, not 0x1100, since you wrap at the page boundary.

thank you for the answer!

Good answer, except I don't think your example is correct. On an 8-bit device like an AVR-based arduino, a page boundary is a 256 byte page. The range 0x100F to 0x1010 is not a page boundary. The example should 0x10FF to 0x1100. On 16, 32 and 64 bit processors, there are often also word alignment considerations around even 2 byte, 4 byte, or 8 byte addresses, but those don't apply to Arduinos (at least not to AVR-based Arduinos.)

@DuncanC This has nothing to do with AVR. This is an SPI-connected Flash chip - the W25Q80DV.

@DuncanC But you're right about the boundary - that was just me getting my bytes and nibbles muddled up.

Yeah, I realized that after the post. The flash chip almost certainly has an 8 bit bus though, which would be why it uses 256 byte pages.


text:
Arduino Micro: Followed the BlinkWithoutDelay instructions, but somehow it's not working in my code
Any help would be greatly appreciated!
/*
   Jebediah's Launch Control System for Kerbal Space Program
   Alpha Build 2.00
   An Open-Source Project by John Seong
*/

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

const byte ROWS = 4;
const byte COLS = 3;

const int buzzer = A3;

const int ledAbort = 5;
const int ledStage = A5;

const int buttonAbort = 4;
const int buttonStage = A4;

int ledAbortState = LOW;
int ledStageState = LOW;

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {12, 11, 10, 9};
byte colPins[COLS] = {8, 7, 6};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

unsigned long previousMillis = 0;

const long interval = 1000;

// Show a two-line message on the LCD.
void lcdShow(const char *line0, const char *line1) {
  lcd.clear();
  lcd.print(line0);
  lcd.setCursor(0, 1);
  lcd.print(line1);
}

void lcdShowResult(float result) {
  lcd.print(result);
}

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

  pinMode(ledAbort, OUTPUT);
  pinMode(ledStage, OUTPUT);

  pinMode(buttonAbort, INPUT_PULLUP);
  pinMode(buttonStage, INPUT_PULLUP);

  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcdShow("  JEB'S LAUNCH", " CONTROL SYSTEM");
  delay(3000);
  lcdShow("ALPHA BUILD 2.00", " STUDIO HORIZON");
  delay(3000);
  lcdShow("WELCOME, KERMAN.", "PRESS ANY KEY...");
  while (!keypad.getKey()) ;  // wait for key press
}

void loop() {
  static enum {START, MENU, SET_COUNT, COUNT_DOWN, LAUNCH, SET_THRUST, SET_WEIGHT, TWR_COMPUTE} state = START;
  static uint32_t last_second;  // millis() value on last full second
  static int count;
  static float thrust, weight, ratio;

  char key = keypad.getKey();

  switch (state) {
    case START:  // transitional state
      lcdShow("1. LAUNCH SEQ", "2. TWR CALC");
      state = MENU;
    /* fallthrough */

    case MENU:
      if (key == '1') {  // Countdown
        lcdShow("COUNTDOWN TIMER", "SECONDS: ");
        count = 0;
        state = SET_COUNT;
      } else if (key == '2') {  // TWR
        lcdShow("TWR CALCULATOR", "THRUST: ");
        thrust = 0, weight = 0, ratio = 0;
        state = SET_THRUST;
      }
      break;

    case SET_COUNT:
      if (key >= '0' && key <= '9' && count <= 99) {
        lcd.print(key);
        count = 10 * count + (key - '0');
      } else if (key == '#') {
        lcdShow("    T-MINUS", "     SECONDS");
        // Force a refresh on entering COUNT_DOWN:
        last_second = millis() - 1000;
        count++;
        state = COUNT_DOWN;
      } else if (key == '*') {
        state = START;
      }
      break;

    case COUNT_DOWN:
      if (millis() - last_second >= 1000) {
        last_second += 1000;
        count--;
        if (count <= 10) {
          tone(buzzer, 500);
          delay(500);
          noTone(buzzer);
        }
        if (count == 0) {
          Serial.println("Lift off!");
        } else if (count < 0) {
          state = LAUNCH;
          break;
        }
        lcd.setCursor(1, 1);
        lcd.print(count < 10 ? "  " : count < 100 ? " " : ""); // pad
        lcd.print(count);
      } else if (key == '*') {
        state = START;
      }
      break;

    case LAUNCH:
      tone(buzzer, 3000);

      int stageConfirm = digitalRead(buttonStage);
      int abortConfirm = digitalRead(buttonAbort);

      unsigned long currentMillis = millis;

      if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;

        if (ledAbortState == LOW) {
          ledAbortState = HIGH;
          lcdShow(" T-ZERO WARNING", "CONFIRM IGNITION");
        } else if (ledAbortState == HIGH) {
          ledAbortState = LOW;
          lcd.clear();
        }

        if (ledStageState == LOW) {
          ledAbortState = HIGH;
        } else if (ledAbortState == HIGH) {
          ledAbortState = LOW;
        }
        digitalWrite(ledAbort, ledAbortState);
        digitalWrite(ledStage, ledStageState);
      }
      break;

    case SET_THRUST:
      if (key >= '0' && key <= '9' && thrust <= 9999) {
        lcd.print(key);
        thrust = 10 * thrust + (key - '0');
      } else if (key == '#') {
        lcdShow("TWR CALCULATOR", "WEIGHT: ");
        state = SET_WEIGHT;
      } else if (key == '*') {
        state = START;
      }
      break;

    case SET_WEIGHT:
      if (key >= '0' && key <= '9' && weight <= 9999) {
        lcd.print(key);
        weight = 10 * weight + (key - '0');
      } else if (key == '#') {
        lcdShow("THRUST-TO-WEIGHT", "RATIO: ");
        if (thrust != 0 || weight != 0) {
          ratio = thrust / weight;
          lcdShowResult(ratio);
        }
      } else if (key == '*') {
        state = START;
      }
      break;
  }
}

And what exactly is not working? What did you expect and what actually happened? What did you do to debug the problem?

You have to be more specific about the problem. I took a cursory look at the code and saw a delay() within a state machine. This is something you usually want to avoid. In fact, the whole point of a state machine is to avoid calling delay() in order to keep the system responsive.


text:
Can it time between blips, store the time between blips, subtract one time from the other and divide one time by another and display it?
I am counting rotations of a shaft and timing events that occur during that rotation.  I wish to display
the event timing as a percentage of ~1/4 of the rotation timing.  This would involve recording the rotation time, dividing that number by 3.6 and dividing that number by the value of the event timer, then displaying that percentage on an LCD array.

I don't really understand, what you are trying to do. I also don't understand, what exactly your problem is with writing the code. For normal timing the millis() and micros() function can be used, which give you the time since startup in milliseconds or microseconds respectively

your last sentence is a rough outline of the program function ... This would involve recording the rotation time, dividing that number by 3.6 and dividing that number by the value of the event timer, then displaying that percentage on an LCD array. .... add much, much more detail ... basically, turn it into a flow chart that you can convert into code

Welcome to SE/Arduino! Please take the [tour] and read "[ask]". Please also note, that these sites are neither services to get a program written nor teaching in depth. Show us some code, describe the specific problem and post a detailled question. As your question is now, the answer is simply "yes."

What you are looking for is the millis() function.
It returns the time that passed in milliseconds since the board power up.
With this function you can find the time delta, and achieve all the described calculations.
For more information


text:
Convert string to array
I have a project and i need to convert string (contain numbers and letters) to array
String name = "s111, s222, bbbb,cccc ";

and i want
array[0] = s111;
array[1] = s222;
array[2] = bbbb;
array[3] = cccc;

here is the code :
 String name = "s111, s222, bbbb,cccc ";
 int array[50];
 int r=0,t=0;

 for(int i=0;i<name.length();i++){
      if(name.charAt(i) == ','){
          array[t] = name.substring(r,i);
          r = (i+1);
          t++;
         }
 for(int k=0 ;k<=t ;k++){
   Serial.println(array[k]);
  }

When I compile I get just zeros like :
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;

What exactly does not work? What did you expect and what actually happened? Please provide a full compilable code (this one does not have the declaration of the other variables in it, including the array). Also my answer to this question might also be helpful.

why are you asking us to guess what your code actually does? ... we can't even test your code because you provided code that does not compile ... your description of the problem, it wont work, it useless

I think the description is clear

Re “i want array[0] = s111;”: this doesn't make sense. array is an array of ints, and “s111” is not an int.

thanks but do you have another way to split the character of that variable

Do you need an array of strings or an array of int? If int, how should the last 2 parts be interpreted? ASCII hex?

array of strings

"I think the description is clear." You are wrong. Your question is a muddy mess. You haven't provided enough code for us to test your program. You haven't told us what goes wrong with your current code. You haven't told us what format your output is supposed to be in (you finally said "array of strings" in the comments, but you need to edit your question to provide a full description of the problem in the question itself. Don't expect somebody trying to help you to read through an endless question-and-answer session to figure out what you are really asking.

When you declare int array[50]; you declare an array of numbers so only numbers can be stored inside it. If you really want an array of strings then declare an array of strings like String array[50]; There was also a a problem that sometime you split the name by comma, sometime by space, and sometime by comma+space. Also your code was missing closing bracket.
The algorithm has to split both by comma and my space and then take only values that have length more than one to avoid inserting empty strings.
String name = "s111, s222, bbbb,cccc ";
String array[50];
int r=0,t=0;

for(int i=0;i<name.length();i++)
{
  if(name[i] == ' ' || name[i] == ',')
  {
    if (i-r > 1)
    {
      array[t] = name.substring(r,i);
      t++;
    }
    r = (i+1);
  }
}

for(int k=0 ;k<=t ;k++)
{
  Serial.println(array[k]);
}

thanks you it works


text:
What is the name of this chip on Arduino Mega ? I am not finding its datasheet 56 TI MSP?

What is the using purpose of this chip?

I think that says M5P not MSP - in which case it's IC5 - the LM358D op-amp used to control the USB power FET.

There is only one 8-pin SMD IC on the top side of the Arduino Mega 2560.

From the schematic
it appears to be the "LMV358IDGKR" a TI dual op-amp used for two separate functions on the Mega.

Selecting power source - VIN vs USB.
Illuminating the built-in "L" LED (on D13) without loading PB7

I solved my problem with your help


text:
What are the correct techniques for implementing functional client access to an asynchronous serial interface?
This is not a question for beginners.
I am implementing a functional interface to an asynchronous serial device connected to the Serial1 port on a mega.
To ensure clarity, I want to implement a series of functions thus:
    {param} CallInterface({param1},{param2},...) {
        sendRequestPacket();
        ....{await Response or timeout}....
        return Response;
     }

Obviously, when "awaiting Response" we are blocking the operational thread and have to allow an additional thread processor access in order to retrieve and parse the response.
On a multithreaded platform, this would be trivial to implement using semaphores and other multi-threading techniques, but on Arduino,AVR the solution is possibly less obvious, or not.
So, the question is, what is the best and most effective way to implement a pattern such as this on the Arduino platform?

Obviously, when "awaiting Response" we are blocking the operational thread ... actually, that is not obvious ... you could use non-blocking code

It's hard to tell what's the “best and most effective” without knowing the exact requirements of your project. I once faced a similar situation when I needed my code to be non-blocking. I then added a “callback” parameter to CallInterface, to which the response is to be delivered, and an update() method to the object implementing the interface, in order for it to catch the response and deliver it to the callback.

@jsotola can you please follow this up with an example of a non-blocking code pattern That would work on the Arduino platform?

@EdgarBonet Thanks Edgar, yes this is a similar model to Async Javascript / Node. Initial impressions are that I would need to implement a callback array in the receiver code to capture any and all potential requests for this data that need to be fulfilled when and if the response arrives. The only issue I foresee with this is that there is no "linkage" between the request and response other than the fact that the response happens soon after the request.

There is no way of linking a specific request with a specific response other than to block requests until all pending requests are fulfilled, or a timeout occurs.

one of the parameters of the call can be forwarded to the callback. or with lambdas you can capture parameters

The typical way I handle this kind of thing is to have one "master" function that controls everything using a finite state machine in a non-blocking way.
That function could contain all the logic to do things, or it could be simpler and just handle the basic communication and then pass details on to a callback function that is specified in the action function call.
So the flow could be:

You call a function that just sets up things:

It stores details of the request to be made
It records the address of a "callback" function

You execute your "run" function repeatedly from loop()

It sends the command to the target
It receives and parses the response storing it internally somewhere
When the response is complete it executes the callback function passing it the response

Not all of 2 would happen each iteration of loop(), so write it in a non-blocking way (using .available() etc) and only call the callback when everything is complete.
So in that way you can set up a chain of things to happen:

You submit request 1 with callback A.
Callback A submits request 2 with callback B.
Callback B submits request 3 with callback C.

... etc ...
As an example this is how a modem control could look:
Modem.command("AT+CREG?", testRegistration);
>>> send         AT+CREG?
<<< store        +CREG: 0,2
<<< store
<<< identify     OK
--- Execute testRegistration(true, "+CREG: 0,2\n\n");

Or maybe if it goes wrong:
Modem.command("AT+CROG?", testRegistration); // Oops, made a typo...
>>> send         AT+CROG?
<<< identify     ERR
--- Execute testRegistration(false, "");


text:
Is this circuit properly made?
I can't get to work a circuit that doesn't look that hard to copy.
This circuit was done for an Arduino extension of my DSC HS2032 system. I was trying the example "Status" on the Arduino's library DSC Keybus Interface v1.2.0.
On the example, we can see this circuit:
 *      DSC Aux(+) --- Arduino Vin pin
 *
 *      DSC Aux(-) --- Arduino Ground
 *
 *                                         +--- dscClockPin (Arduino Uno: 2,3)
 *      DSC Yellow --- 15k ohm resistor ---|
 *                                         +--- 10k ohm resistor --- Ground
 *
 *                                         +--- dscReadPin (Arduino Uno: 2-12)
 *      DSC Green ---- 15k ohm resistor ---|
 *                                         +--- 10k ohm resistor --- Ground

Here on the photos, I'm showing what I have done.

This is the HS2032 panel where (on the YEL and GRN) I connect the Arduino. I changed the Arduino's power source to be from my laptop so I could easily test it on the Serial Monitor. YEL->White/Green wire and GRN->Green wire
Now goes the Arduino's wiring.

Remember from the panel, the yellow is the white/green and the green is the green (they are coming from the right). First, each of both wires goes directly to 15kOhm resistor. Secondly, it splits between a 10kOhm resistor which then ends up into Arduino's ground, or it goes directly to the Arduino's pin 3 or 5, depending on the cable.
Results
The Serial Monitor shows "DSC Keybus Interface is online" and over.
If I connect green and white directly to 3 and 5, it will say sometimes "Keybus disconnected" and "Keybus connected" without any additional messages ever.
So my question is, am I missing something here? Why is the Serial Monitor not responding or what can I do to check where is the problem?
EDIT
This are the serial monitor readings, nothing from the Panel. I had to connect without resistances to get this output, otherwise, the only output would be "DSC Keybus Interface is online."
08:26:32.359 ->
08:26:32.359 -> DSC Keybus Interface is online.
08:26:35.345 -> Keybus disconnected
08:26:42.722 -> Keybus connected
08:26:47.838 -> Keybus disconnected
08:26:51.131 -> Keybus connected
08:26:54.937 -> Keybus disconnected
08:27:12.661 -> Keybus connected
08:27:17.122 -> Keybus disconnected
08:27:34.218 -> Keybus connected
08:27:41.697 -> Keybus disconnected
08:28:19.509 -> Keybus connected
08:28:22.487 -> Keybus disconnected
08:28:25.068 -> Keybus connected
08:28:28.053 -> Keybus disconnected
08:29:23.692 -> Keybus disconnected
08:29:31.175 -> Keybus disconnected
08:29:33.990 -> Keybus connected
08:29:37.005 -> Keybus disconnected

There's quite a lot of bare copper visible. Is that mains power?

I don't see the connection between AUX- and Arduino ground. You need common ground between them

@marcellothearcane if you are talking about the first photo, the RED, BLK, YEL and GRN are used for direct connections to the original keypad. More on the left, you can see the siren wiring. There is also one copper coming out of BLK, it is the blue wire bended to fit properly.

@chrisl excelent. I will take a wire from DSC Aux (-) (we can't see it on the images) to the breadboard's GND ground, finally going to the Arduino's GND ground through the black wire. Will tell you how it goes!

@chrisl I think it didn't work, but it is still something. I attached the Serial monitor result.

The blue wire on your breadboard doesn't seem to match anything in your circuit diagram -- is that right?

@RedGrittyBrick the blue wires come from YEL and GRN with 10kOhm. They join together with the black wire on the (-). The black wire ends in the Arduino's ground. Maybe I should make a neat diagram?

I added the circuit diagram that copies exactly what I made.

The schematic you drew does not match the ASCII circuit you copied. You need to swap the GND and Arduino wires on the resistors.

Is this circuit properly made?

No.
A lot of the problem is that you don't have a well-drawn schematic. I think that what you have is a couple of voltage dividers to interface a 5V arduino with a higher voltage device. I suspect a voltage divider isn't the best solution but presumably it works for someone else. So what you need is ...

simulate this circuit – Schematic created using CircuitLab
If I were you I'd pull your existing wiring apart completely and start again, arranging the components and wires so that they match this schematic as closely as possible in terms of position and orientation. Then trace the connections through carefully to make sure everything matches.


text:
How can I burn the bootloader onto atmega328 (not atmega328p)?
Hi I bought some atmega328 chips (not to be confused with atmega328p). They are very similar but the atmega328p chips are just more power efficient, so I've read. Anyways, my goal is to burn the arduino bootloader onto these chips so that I can make some breadboard arduinos. I used the arduino ISP sketch and hooked up everything like so ->

I was following instructions from the following link ->
https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
However, when I press the Burn Bootloader button under Tools, it keeps telling me that it can't verify that my chip is an atmega328p. Well it is not atmega328p but everywhere online says it does not matter since they are the same architecture. The error also tells me that I can override by typing -F, but it doesn't tell me where to input this. I'm pretty sure that may fix the issue, but I am not sure where I'm supposed to put the -F.
Also I saw another post that was similar to this one but the answer said that the problem is the atmega328 chip itself. Is it even possible to add the bootloader to these chips??? Other sources said it is, but I can't seem to do it.

use MiniCore https://github.com/MCUdude/MiniCore

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

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

Oh wow thanks! I will definitely try this!


text:
Use callbacks in Arduino with pointers to functions (will functions persist in memory?)
As I been learning Arduino (micro controllers, c++, etc) I have learned that memory is very limited. I already understand how memory works when it comes to variables. But I do not understand how memory works when it comes to functions. Since I am a backed developer I try to stay away from interrupts and instead use callback functions. Another reason why I prefer to use callback functions is because I love the visual studio IDE. I create my core functionality of whatever project I am building on a c++ project targeted for Windows. Once my algorithms/logic works the way I want it I reference those libraries on Arduino.
Anyways I am using lambdas to pass functions to my helper libraries. That way I do not use the delay function to wait for a response and I am always listening for events. Basically my question is if it is correct to have code like this (function SendEvent):
/* MyRadioLibrary.h */
// I am not including all the code of `MyRadioLibrary` because that makes it hard to
// understand what I am asking. Instead I will try to use a lot of pseudo-code. Let me
// know if you want me to post the code as an edit.

class MyRadioLibrary
{

public:

    static void SendEvent(int typeOfEvent, void(*onEventCompleted)(bool x))
    {
        // I have an array of pointers to functions
        void(*onEventCompletedBuffer[10])(bool x);

        // I enqueue that event with a queue helper class

        // Send event ....

        // DO NOW WAIT FOR RESPONSE SINCE CALL BACK IS ALREADY SAVED
    }

    static void loop() {

         // listen for radio messages
         if(radio.available()){
                // get response
                // dequeue pointer to call back
                // execute call back
          }

    }
};

And my arduino sketch contains this code:
#include <MyRadioLibrary.h>

void setup()  {
    // setup pins etc..
}

void loop()
{

    if (isButton1Pressed())
    {
        MyRadioLibrary::SendEvent(1, [](bool didEventCompletedSuccessfully) {

            if (didEventCompletedSuccessfully)
            {
                // turn on green LED
            }
            else {

                // turn on red led
            }

        });
    }
    else if (isButton2Pressed())
    {
        MyRadioLibrary::SendEvent(2, [](bool didEventCompletedSuccessfully) {

             // call back function

        });
    }

    MyRadioLibrary::loop(); // listen for response events. When we get one fire call back.
}

Now the question
When I call the SendEvent function I am passing 2 things (1) an integer and (2) a pointer to a function that is the call back. The integer (1) is passed as value and that will be part of the stack of the SendEvent function. The pointer (2) will be stored on an array of pointers. But what about the lambda function? where will that be stored? Instead of using a lambda function should I declare those functions in global scope and pass the global function instead of a lambda? Will I run the risk of the pointer (2) pointing to a function that no longer exists if I use this way of coding?

Re “pass the global function instead of a lambda”: Once it's translated into machine code, it makes no difference whether it's a lambda or a regular function.

Your functions won't cease to exist. All of the code in your compiled and linked code image gets loaded into code-memory (Flash) and it stays there throughout the run, through resets, and through power-cycles, until another image is loaded over it.
Are you confusing pointers to functions with pointers to a function's local variables which occupy RAM memory, specifically within the function's stack-frame which is transient, being created and "destroyed" as the function gets called and returns - and successive stack-frames won't necessarily be created in the same place.


text:
can i convert a pin into ground
i recently started using Arduino uno , but to my despair , the ground pin , without which i cant do any project (or can i ) , so i thought of a possible solution , what if i could program the board to make a pin act as a ground , so what to do
straight 2 questions , what to do to convert any pin into ground
or can i ignore using the provided ground pin .
i have already tried fixing the pin but it cant be fixed because a detached pin has got stuck into it

There is more than one ground pin on the arduino.  Just use another one.  You can make a pin into ground, that’s what happens when you write a pin LOW, but only for a very limited amount of current.  So it depends on what you want to do there.  But really, just use one of the other ground pins.

thanks for help , but can u help me furhter , i am a total starter , where is this second grnd , and actually i just connect my laptop for v+

there are 5 ground pins on Uno. two between Vin and 5 V. one next to pin 13 and two on the ICSP headers. so what happen to the ground pin?

Look at the board.  The pins are labeled.  You should be able to find them.

yeah ur comment was useful , i found all of then , but still as an alternative , if i ever mess up with my board , can i convert any pin into ground

You can sink a very limited amount of current to a GPIO pin by setting it to a digital output and setting the value to LOW. However, you should only sink about 20 mA into it (40 mA absolute max). That's a very small amount of current for powering devices. It would be easy to exceed that limit and burn out the pin. Also, when you first power up the Arduino the pin will probably be open, and if you ever set it to HIGH it will be a 5V source instead of a ground.

In short, don't try to use a GPIO pin as a power ground. The board has a number of ground connections. You can attach a wire to one of those and then connect multiple wires to that single wire. There is no harm in doing that.

Can I convert any pin into ground

Any of the digital outputs can be set LOW but there is a limit on how much current they can sink,
This makes this approach unsuitable for most use cases other than charlieplexing LEDs and similar low-current applications.
It would be better to

use any of the other ground connections.

two between Vin and 5V
one between Aref and 13
one on the 2x3-pin ICSP header for the 328
one on the unlabelled 2x3-pin ICSP header for the 16U2
one in the power jack

replace the damaged header using solder-wick and a soldering-iron.
solder a wire from a suitable ground pad on the PCB

e.g. from the ground pad for the 2.1mm power connector.

The ATmega328P data sheet says

Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady
state conditions (non-transient), the following must be observed:
ATmega328P:
1] The sum of all IOL, for ports C0 - C5, should not exceed 100mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100mA.
3] The sum of all IOL, for ports D0 - D4, should not exceed 100mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition

So no more than 20mA from or into any single pin over a long time. And no more than a total of 100 mA from or into a group of pins.


text:
How do I serial print a constant single string and a changing variable within it?
I want to print a single line including the variable "val" only once rather than looping or repeating of the same line and within it the val will change according to the reading. Is it possible? If so, how?

#define trigPin 5
#define echoPin 6

float distance(uint8_t T, uint8_t H);

void setup()
{
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    Serial.begin(9600);
    Serial.print("The object is: ");
}

void loop()
{
    float val = distance(32, 68);
    Serial.print(val);
    Serial.println(" cm away");
    delay(500);
}

Welcome to SE/Arduino! Please take the [tour] and read "[ask]". Then come back and [edit] your question. Please show us some code that you have. It can be the code that you want to run and that does not work. Tell us what you expect and what you get instead.

What? Sorry, I don't understand, what you mean

You want to print something like “result: 123”, and the replace “123” with other values within the same line, without printing other lines. Did I correctly guess what your question is about? PS: People shouldn't have to guess, you should put your best effort into making the question clear enough.

@EdgarBonet, what's the fun in that? Don't you want to play 20 questions? :)

within it [the already printed line] the val will change according to
the reading

This “within it” makes little sense. “Printing” is just sending bytes
through the serial port, and you don't choose where these bytes are
going: you just send them one at a time. The program you use as a
“serial port monitor” then displays those bytes in whatever manner it
sees fit. You cannot control from the Arduino where things get
displayed.
Or maybe you can...
If your monitor program can emulate an old school terminal, then
it can understand special control sequences, including escape codes,
that instruct it to perform specific actions, such as moving the cursor
or erasing part of the screen. Suitable terminal emulators include
screen on Linux and MacOS, and Putty on Windows. You may find
something appropriate for your mobile platform. Notably, the Arduino
serial monitor is not a terminal emulator, and doesn't interpret those
control sequences.
Assuming you are using a suitable terminal emulator, the simplest
solution to your problem is to just repeat the whole sentence “The
object is: xx.xx cm away” for every measurement, but do so by
overwriting the current line instead of moving to the next one. You thus
replace Serial.println() by Serial.print(), and precede each
sentence by a carriage return character (ASCII CR = 0x0d = '\r'),
which is interpreted as the command “move the cursor to the start of the
line”:
void loop() {
    float val = distance(32, 68);
    Serial.print("\rThe object is: ");  // note the '\r'
    Serial.print(val);
    Serial.print(" cm away");  // no println()
    delay(500);
}

There is a caveat here. If you overwrite a sentence (say “The object is:
10.07 cm away”) by a shorter one (“The object is: 9.92 cm away”, one
character less), the previous sentence will not be completely
overwritten, so you may end up with “awayy” showing on the display. This
can be overcome by ensuring a fixed-length formatting of the numbers
displayed, by padding with spaces, or by sending an “erase current line”
command to the terminal.
As a side note, what Serial.println() does is print what you
requested, followed by a CR character, and then a line feed character
(ASCII LF = 0x0a = '\n'). The line feed is interpreted by the
terminal as the command “move the cursor to the next line, without
changing its horizontal position”.
If you find it annoying to repeatedly print “The object is:”, you can
instead use more advanced control sequences. For instance:

“<ESC>[16G” means “move the cursor to column 16”
“<ESC>[K” means “clear from the cursor to the end of the line”

where <ESC> is the escape character:
void loop() {
    float val = distance(32, 68);
    Serial.print("\x1b[16G\x1b[K");  // "\x1b" is the escape character
    Serial.print(val);
    Serial.print(" cm away");
    delay(500);
}


text:
String(int) function stopping the Arduino
Well I am trying make an application with arduino leonardo and GSM Shield. There are conditions if, else if, else .. etc
  if (smsMetni.indexOf("DURUM") != -1) {
    Serial.println("SMS income");
    String temp= String(analogRead(LM35_pin) * 0.48828125);
    String temp2 = "Hava " + temp + " derece.";
    char tempSMS2[] = "";
    temp2.toCharArray(tempSMS2, 30);
    Serial.println(tempSMS2);
    Kapadokya.smsGonder(gonderilecekTelNumarasi, tempSMS2);
  }

After the last line "Kapadokya.smsGonder(gonderilecekTelNumarasi, tempSMS2);" program stopping I watching serial monitor there is no notification or error. just stopping.
If I change those lines and remove String(analogRead(LM35_pin) * 0.48828125) :
    String temp= String(analogRead(LM35_pin) * 0.48828125);
    String temp2 = "Hava " + temp + " derece.";

and just write like this, it works very well.
String temp2 = "Hava  derece.";

maybe you think there is a problem with LM35, even if I change it String(analogRead(LM35_pin) * 0.48828125); with String(30);, it doesn't work again. after the last line it is not continue.
only one sollution I've found if add delay(500) after each line it works but my codes looks ugly with this. are there any solution.

Without seeing the whole program code I suspect you are running out of memory because you are using the String class extensively. Try NOT to combine strings into a new string object as you need twice the space and then only copy its content into a TOO SMALL tempSMS2 array that has the size of 1 (the terminating null character).
Just serial print the string literals as you have them at hand. Also use the L-Macro to keep the string literals in program memory and not in RAM. Serial.print is also perfectly capable to print numbers. No need to convert them into String first.

You should avoid String on the Arduino. It will cause random crashes. However that's not your issue. Your issue is trying to copy the data into an array that is too small.
char tempSMS2[] = "";

That creates a one byte array which contains just a \0. You then try and squeeze your String data into it and it of course overflows all over the rest of your variables and data.
A better solution is to work directly in char arrays. It is a little trickier though:
First convert your float to a string:
char tempFloat[8];
dtostrf(analogRead(LM35_pin) * 0.48828125, -7, 3, tempFloat);

Then build up your string:
char tempSMS2[30];
strcpy_P(tempSMS2, PSTR("Hava "));
strcat(tempSMS2, tempFloat);
strcat_P(tempSMS2, PSTR(" derece."));

Wow. it looks amazing. but if add Serial.println(tempSMS2); at the last line only printing " derece". can you fix it.

Oops, that last strcpy_P should have been a strcat_P.

(PGM_P)F("foo") can be written more simply PSTR("foo"). Actually, the F() macro uses PSTR().

@EdgarBonet Yeah, I can never remember which is which of these macros. TBH I never use them, but then I never use AVR unless the client specifically requires it.


text:
Is it bad to power a arduino mega with 6V via USB?
I'm working on a project where there is no external 5V voltage regulator available but only 6V. I can not power it through the power jack because via this way I do not have enough current and get thermal shutdown.
Can I power it via 6V over USB? at the moment I'm trying this out and it works but what are the long term risks I'm prone to?

yes, it is bad.

The Absolute Maximum Operating Voltage of the ATMega2560 is 6.0V. The same applies to the ATMega8u2 that does the USB to Serial on the Arduino Mega board.
Recommended maximum voltage is 5.5V
So yes, you can run it at 6 Volts, but you are right on the edge, so I wouldn't recommend it.
Possible risks are a decreased lifespan of the Arduino, and there might be some stability issues.
If the application isn't safety critical, and you don't mind having to replace the board after it failed in, say, two year of operation, it could be an acceptable risk (if there are no easily available alternatives)
PS you might want to measure you power supply. It may say it's 6V but could give out 6.2V. The output voltage of some supplies also vary with the load that's across it.

The incomming voltage is actually indeed 6.2 voltage

put a diode (or two) on the incoming rail to drop it 0.6 (or 1.2)v.

We actually have a din rail inside the project. So we were planning on doing just that.

Voltage drop across a diode depends on the current, so it won't give a very stable voltage (like a regulator does). But it will probably be fine.

Is it bad to power a arduino mega with 6V via USB?

Yes, the Arduino Mega is not designed to be powered that way and you are probably abusing the USB specifications. USB can supply higher voltages than 5V but only if it is properly negotiated with the device.
The schematics (see Documentation tab) show a 5V regulator powered from the 2.1 mm Power-connector or from the "Vin" header pin. If the regulator specs say it can work from 6V, you should probably use that instead. However although the 1870_LD1117S50CTR seems to be a low-dropout (LDO) regulator, it has a dropout voltage of 1V. So I wouldn't power it from a 6V source - that seems equally marginal.
In short, I think you really need to find a more suitable power source.


text:
Weird RTC DS3231 Output only when saving the dates to variables
I am sorry to ask this question as I think it has more to do with my mediocre C++ programming skill than with the arduino.
I do have a project where I want to use an RTC DS2131. I started out by using all the separate examples of the modules I need and put them together. But the RTC give me a headache :-(
The example ran fine where it just output the date to the serial port. Somthing along this:
Serial.print(RTC.getDay());
Serial.print("-");
Serial.print(RTC.getMonth());

Now I want these values in different variables because I want to save them on an SD card as well.
Thus I came up with this simple test program:
#include <Wire.h>
#include <RTC.h>

static DS3231 RTC;

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

void loop()
{
int yearNow;
int monthNow, dateNow, hourNow, minuteNow, secondNow, weekNow;

if (RTC.isRunning())
  {
    yearNow=RTC.getYear();
    monthNow =RTC.getMonth();
    dateNow=RTC.getDay();
    weekNow=RTC.getWeek();
    hourNow=RTC.getHours();
    minuteNow=RTC.getMinutes();
    secondNow=RTC.getSeconds();

    Serial.print("Weekday: ");
    Serial.print(weekNow);
    Serial.print('  Time:');
    // Finally the hour, minute, and second
    Serial.print(hourNow);
    Serial.print('-');
    Serial.print(minuteNow);
    Serial.print('-');
    Serial.print(secondNow);
    Serial.print(" ##  ");
    Serial.print("Date: ");
    Serial.print(yearNow);
    Serial.print('/');
    Serial.print(monthNow);
    Serial.print('/');
    Serial.println(dateNow);

  }
}

Now I would expect this output:
Weekday: 4  Time:16-10-36 ##  Date: 2020/7/28
But this is what I get:
Weekday: 42591416-10-36 ##  Date: 2020/7/28
As a sidenote the variables in this sketch are declared as "int". After having looked into the header files of the library I tried uint8_t resp. uint16_t for the year.
But nothing changed.
I am sorry but I have no clue as what beginner mistake I am achieving this time?? :-(
Thanks for your help.

You used single quotes instead of double quotes. Single quotes are for single characters. Double quotes are for strings (or character arrays).
Serial.print('  Time:');

should be
Serial.print("  Time:");

Thanks. I thought " and ' are interchangable.

They are in javascript or PHP, not in C/C++.


text:
ESP01 won't boot when connected to the LED strip
I have a weird bug behavior.
I have an ATX power supply, which powers a long WS2812B 5v strip, controlled by the Esp 01 and the board...
Now the bug happens only when I connect the data pin to the strip. The ESP won't start after I restart the ATX PSU. And if it does it just crashes after some time...
Here is the SPOOKY part: when I start the esp WITHOUT the pin connected and plug it in after it starts it will keeep working for days... but sometimes it just decides it will go bananas... W T F! Any ideas why?????
I suspected voltage drops, but nope. I tried a battery, a second adapter and a USB power... none helped. Same behavior as soon as you connect the strip and hit restart/update, it goes bananas...

On ESPs there are some pins, that need to have a specific value during boot. As the ESP01 already has so few pins, you might have used one of them, so the connected strip might prevent the ESP from booting. I currently don't have the time, but you can google that yourself.

That is the tx pin. this is a standard led module which uses the standard GPIO2 pin. so it should not be possible that i got that pin. Any other ideas? i ordered an other esp so cross fingers it works.

it's probably pulling down gpio2, preventing a normal boot. watch the voltage on that pin during startup; if not vcc, bingo.

ye im suspecting that im missing the 500ohm resistor you should put on the data line. will update when i have it.

I used a 470Ohm to connect GPIO2 and VCC. (to ensure HIGH during boot phase).
As suggested on : https://www.esp8266.com/viewtopic.php?p=77993
esp01 5v to 3.3shifter 470Ohm

Regards,
Dom


text:
Problem with using SD and Adafruit_SSD1306 libraries at the same time
I am searched over the internet and found out a few similar questions, but non of them were helpfull, so I decided to open a new quetion.
I tried both SD and Adafruit_SSD1306 libraries and they both worked fine when they were separated - in different codes. The error came when I used them in one code.
In my programme I try to init SD card, write to it and then init dispaly (everything works fine). After that I do another write cycle into the SD, but I get an error in opening a file:
error opening test.txt

In other words I cant write anything into the SD card after oled display is initialized (display works then without any problems).
Here is my code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#include <SPI.h>
#include <SD.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32

TwoWire Wire1(PB9, PB8);// Use STM32 I2C2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);

const int chipSelect = PA15;

void setup() {

    Serial1.begin(9600);
   if (!SD.begin(chipSelect)) {
    Serial1.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  }
  Serial1.println("card initialized.");

 for (int i = 0; i < 10; i++)
  {
  File dataFile = SD.open("test.txt", FILE_WRITE);

  if (dataFile) {
    dataFile.println("Test");
    dataFile.close();

    Serial1.println("Test");
  }
  else {
    Serial1.println("error opening test.txt");
  }
delay(30);
  }

  delay(2000);

 // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial1.println(F("SSD1306 allocation failed"));
  }

  delay(500);

  for (int i = 0; i < 10; i++)
  {
  File dataFile = SD.open("dat_test.txt", FILE_WRITE);

  if (dataFile) {
    dataFile.println("Test");
    dataFile.close();

    Serial1.println("Test");
  }
  else {
    Serial1.println("error opening test.txt");  //here is the error I get
  }
delay(30);
  }
}

void loop() {
}

Here is the output:
card initialized.
Test
Test
Test
Test
Test
Test
Test
Test
Test
Test
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt

I am using STM32F103CB.

and how do you connect the SD card? what dev board do you use? a Blue Pill?

Have you tried commenting out the display call between the two file-write sequences, and will the second write-sequence run then?

@JRobert, yes I tried that and both SD writings worked fine. Its very wierd, because it only happend after the OLED init.

@Juraj SD card is connected via SPI (PB3 - SCK, PB4 - MISO, PB5 - MOSI, PA15 - CS), OLED display uses I2C (PB8 - SCL, PB9 - SDA) and I am using my own custom board.

the experts are here https://www.stm32duino.com


text:
Flash ESP8266 from SPIFFS filesystem
I'm searching for a way to flash an ESP8266 programmatically, i.e, without user interaction (and especially without the Arduino IDE).
Assuming I can put the program to be flashed on the SPIFFS filesystem, is there a way to flash the ESP with that file?

yes, but why store it in SPIFFS? see the ESP8266HTTPUpdateServer and ESP8266httpUpdate libraries examples

I said I wanted no user interaction.  Besides, I don't want a server in my ESP.

how do you get the file to SPIFFS? the ESP8266httpUpdate library downloads an update bin from a server and updates using the Updater object without storing the bin to SPIFFS.

Yes, it is (or at least WAS possible a few years ago) to have an ESP8266 self-program if you can get the file onto the file system, by using the Update core that is used by OTA and httpUpdate. This was a example program to do it, but I don't know if it still works. I would also suggest that you look at using LittleFS instead of SPIFFS as the latter has been depreciated.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <FS.h>

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

  SPIFFS.begin();
  Dir dir = SPIFFS.openDir("/");

  pinMode(BUILTIN_LED, OUTPUT);
  digitalWrite(BUILTIN_LED, LOW);

  File file = SPIFFS.open("/firmware-update.bin", "r");

  uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
  if (!Update.begin(maxSketchSpace, U_FLASH)) { //start with max available size
    Update.printError(Serial);
    Serial.println("ERROR");
  }

  while (file.available()) {
    uint8_t ibuffer[128];
    file.read((uint8_t *)ibuffer, 128);
    Serial.println((char *)ibuffer);
    Update.write(ibuffer, sizeof(ibuffer));
  }

  Serial.print(Update.end(true));
  digitalWrite(BUILTIN_LED, HIGH);
  file.close();
}

void loop() {
}

Perfect!  This is exactly what I was looking for.  Also thanks for the suggestion of LittleFS, I will consider it.

Yes, it still works, but now you need to pass data as a pointer:
Update.write(&ibuffer, sizeof(ibuffer));

it is an array so it is a pointer already


text:
WS2812B are only white on custom board
I recently designed a board for an LED project. I am using WS2812B as the LED, and an ATMEGA328P-AU as the microcontroller. I also am using an arduino nano as my ISP and using "flash with programmer". When I flashed the FastLED blink example (Code below) the LED lit up as white and stayed white when it was supposed to flash red. I tried various examples and they all had the same outcome, just white. Am I missing a crucial component in my circuit (aside from some decoupling capacitors)? Is it a software problem?
#include <FastLED.h>

#define NUM_LEDS 1
#define DATA_PIN 5

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
     FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);  // GRB ordering is typical
}

void loop() {
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(500);
}

Sounds like a timing problem. Have you set your fuses to use the external 16MHz or is it still on the internal 1MHz (or 8MHz whatever the default is)?

@Majenko It was a timing thing! thank you for the suggestion! I burnt the bootloader onto the chip, then flashed the sketch and it fixed the problem!

Then yes, it was the fuses set wrong.

The WS2812B chips are very sensitive to timing. They rely on pulses being just the right length for things to work.
It is common if the timing is off that you just end up with white.
Since you have a blank chip that you have never put a bootloader on the fuses will be set wrongly for your configuration. By default a chip comes configured for the internal 8MHz oscillator. That means that everything will be running at half the speed.
You need to set the fuses to use the 16MHz crystal so that it matches the F_CPU setting of 16000000 in the board configuration. Either that or use a board configuration that expects to run at 8MHz.


text:
Arduino Uno + NodeMCU serial to MQTT
I made a pool monitor with ORP + pH + temp sensor. I had everything working (apart from ORP sensor causing interference with pH sensor, but that is a different topic...) for the past couple days in a temporary enclosure. Today I moved the device into a new enclosure. After rewiring it stopped sending out the probe data via MQTT and I'm struggling figuring out why..
If I open the serial monitor for the NodeMCU I can see the data from the Arduino coming through -
{"ph":"11.44","orp":"-23411","temp":"-196.60"}
...

So, it would appear the serial link is working since I'm getting the data. When listening on my MQTT topic, I get a "hello world", so my MQTT and wifi connections appear to be okay. If I type something in the serial console, it DOES get picked up by the MQTT topic. It seems like there is something wrong with the loop sending out the data, but this is the same loop I had and same loop as other sketches? I've even tried a different sketch on the NodeMCU with no luck. I'm really having trouble understanding what went wrong here. Is there something incredibly obvious that I am just spacing out on here?
Arduino Host w/ probes
int id=99;
#include <SoftwareSerial.h>
#include "orp_grav.h"
#include <OneWire.h>
#include <DallasTemperature.h>

//ph configs
#define SensorPin 0            //pH meter Analog output to Arduino Analog Input 0
#define Offset -2.0            //deviation compensate
unsigned long int avgValue;     //Store the average value of the sensor feedback

//orp configs
Gravity_ORP ORP = Gravity_ORP(A1);
unsigned long int ORPavgValue;     //Store the average value of the sensor feedback

//TEMP CONFIGS, using 2.2k pull-up resistor
#define ONE_WIRE_BUS 5 // Data wire is plugged into digital pin 5 on the Arduino
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire device
DallasTemperature sensors(&oneWire); // Pass oneWire reference to DallasTemperature library

//NodeMCU serial comm
SoftwareSerial sw(2, 3); // RX, TX

void setup() {
 Serial.begin(9600);
 Serial.println("Interfacfing arduino with nodemcu");
 sw.begin(9600);
 if(ORP.begin()){
    Serial.println("Loaded EEPROM");
  }
 sensors.begin();
}

void loop() {
  /////////////  PH LOOP /////////////
  int buf[10];                //buffer for read analog
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=1024-analogRead(SensorPin);
    delay(10);
  }

  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        int temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    avgValue+=buf[i];

  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue+Offset;                      //convert the millivolt into pH value
////////////////////////////////////////////

  /////////// ORP LOOP ///////////
  int orpValue;
  int orp_buf[10];                //orp_buffer for read analog

  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    orp_buf[i]=(int)ORP.read_orp();
    delay(10);
  }

  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(orp_buf[i]>orp_buf[j])
      {
        int temp=orp_buf[i];
        orp_buf[i]=orp_buf[j];
        orp_buf[j]=temp;
      }
    }
  }
  ORPavgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    ORPavgValue+=orp_buf[i];
  orpValue = ORPavgValue/6;
 //////////////////////

 ///////////TEMP///////////
 sensors.requestTemperatures();
 float tempValue = (sensors.getTempCByIndex(0) * 9.0) / 5.0 + 32.0;
 //////////////////////

 //Console debug
 Serial.print(phValue);//offset
 Serial.print("\t");//
 Serial.print((orpValue));
 Serial.print("\t");//
 Serial.println((tempValue));

 sw.print("{");
 //
 sw.print("\"ph\":\"");
 sw.print(phValue);//offset
 sw.print("\",");

 sw.print("\"orp\":\"");
 sw.print(orpValue);//offset
 sw.print("\",");

 sw.print("\"temp\":\"");
 sw.print(tempValue);//offset
 //
 sw.print("\"}");
 delay(5000);
}

NodeMCU MQTT code
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "Password";
const char* mqtt_server = "192.168.1.208";
#define mqtt_port 1883
#define MQTT_USER "user"
#define MQTT_PASSWORD "password"
#define MQTT_SERIAL_PUBLISH_CH "hass/sensor/pool"

WiFiClient wifiClient;

PubSubClient client(wifiClient);

void setup_wifi() {
    delay(10);
    // We start by connecting to a WiFi network
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
    }
    randomSeed(micros());
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    client.publish("outTopic", "hello world");
    // Create a random client ID
    String clientId = "NodeMCUClient-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str(),MQTT_USER,MQTT_PASSWORD)) {
      Serial.println("connected");
      //Once connected, publish an announcement...
      client.publish("hass/sensor/pool", "hello world");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}
void setup() {
  Serial.begin(9600);
  Serial.setTimeout(500);// Set time out for
  setup_wifi();
  client.setServer(mqtt_server, mqtt_port);
  reconnect();
}

void publishSerialData(char *serialData){
  if (!client.connected()) {
    reconnect();
  }
  client.publish(MQTT_SERIAL_PUBLISH_CH, serialData);
}
void loop() {
   client.loop();
   if (Serial.available() > 0) {
     char bfr[101];
     memset(bfr,0, 101);
     Serial.readBytesUntil( '\n',bfr,100);
     publishSerialData(bfr);
   }
 }


text:
Function declared in another file not recognized (undefined reference to)
I am making a multi-file arduino project, but the compiler can't recognize a function.
I am using the arduino-cli version 0.10.0
This is the error I received
undefined reference to pin_init() collect2.exe: error: ld returned 1 exit status Error during build: exit status 1
This is the command:
arduino-cli compile -b arduino:avr:uno C:\Users\Cioccarelli\Desktop\transmitterCopy\main

main.ino:
#include "C:\Users\Cioccarelli\Desktop\transmitter\automation\automation.h"

void setup() {
    pin_init();
}

void loop() {}

automation.h:
#pragma once

// This is where the components input pins are stored, they are put here by the add_pin function
byte pinSetup[0];
byte pinSetupSize = 0;

// This function is called in the setup() and it initializes every pin listed in pinSetup[] as input
void pin_init();

automation.cpp:
#include "C:\Users\Cioccarelli\Desktop\transmitter\automation\automation.h"

extern pinSetup;
extern pinSetupSize;

void pin_init() {
    for (int i = 0; i < pinSetupSize; i++)
        pinMode(i, INPUT);
}

I think this issue might have to do with the fact that I don't completely understand file inclusion, but I haven't found anything useful in my research

Update: today I rebuilt the project with different names and I cut everything which wasn't related to the problem, in hope to identify it.
new main:
#include "C:\Arduino\transmitter\nightmare\nightmare.h"

void setup() {
    pin_init();
}

void loop() {}

new automation.h (nightmare.h):
#pragma once

// This function is called in the setup() and it initializes every pin listed
//in pinSetup[] as input
void pin_init();

new automation.cpp (nightmare.cpp):
#include "C:\Arduino\transmitter\nightmare\nightmare.h"

void pin_init() {}

new file structure:

I also made a copy and made some changes so it could become a C++ file
(substituting the setup() with main() and replace every "byte" type with "int")
I then put it in Visual studio, it compiled perfectly.
The arduino IDE gives the same error

To be simple, put all files into one directory, and do #include "automation.h". Since you have a small project, this can work out.

@Linny I know this would work, but I want to do things this way because I want to learn how to manage multiple directories and because this is a very early stage of the project, in the future that kind of solution would work very poorly

The compiler didn't have a problem; the linker did. That is, once your main function was compiled (correctly) to call pin_init(), the loader tried to put together all of the compiled modules and link up calls that were not satisfied locally - within the same file - to functions defined in another module. That is when this message got generated. No such function definition was found, despite the declaration of it in main.ino.
If you can compile this with the Arduino IDE, watch what it does: It will compile each of your source-code modules, one at a time. Then link all of your modules' compiled versions together to produce the .hex file (that will eventually get uploaded to the Arduino). You need to mimic that when you're compiling & loading from the command line.
Update:

today I rebuilt the project with different names

Is your .cpp file in the same folder as your .ino file? Or in another folder, such as the folder containing your .h file? I suspect it's the latter. When I built your project it in the Arduino IDE, it succeeded when the .ino and the .h were in the same folder, failed exactly as you described when I moved the .cpp file to where the .h file is.
The solution goes back to what I suggested earlier; that no definition of pin_input() was found, as the .cpp file containing it wasn't seen by the IDE (or your command-line compiler) and therefore not compiled and linked. Each of your files needs to be compiled and all of them together need to be linked, for the external calls to be satisfied.
With the IDE, put your project's .ino and .cpp files in the same folder so the IDE will see and compile each of them and know what to files to link. The IDE won't give you much flexibility for locating your .cpp files.
With the command line compiler, you can put your files wherever you will, make a separate[1] compile only run for each of them, then make another run of the linker component[2] naming all of the compiled units (the IDE names them as .d) and provide the path to your library folder(s).
[1] I'm not familiar with the command-line compiler's command-line syntax; maybe you're able to specify a number of compiles with one command.
[2] Again, IDK whether you need invoke the linker with the same command but with a link-only option switch, or you'll need to invoke the linker yourself, on the command line.

the arduino IDE gives the same error, I made some additions to the question

The Arduino IDE (and I guess arduino-cli behaves the same) will try to
link into your project every source file that lives in the same
forlder as the main .ino file.
Try this: get rid of the “automation” and “main” subfolders, put
everything at the root of the project, and try to build again. If you
end up with too much stuff in the root, you may consider the possibility
of creating your own libraries, but that's for another day...


text:
Connecting a time on/off circuit and my adafruit neopixel light strip
I'm new to programming and hardware so be gentle.
I've used this tutorial Arduino Ultra Mega Timers to create a time on/off circuit.
I'm attempting to connect some adafruit neopixel led strips to a 5v relay. I've been trying to read up on how exactly relays work and what wires would go from GND, 5V, and Dout to NO and NC but I've hit a brick wall because all of the schematics I've found show light bulbs connecting to the relays. A detailed explanation of exactly how to connect the LED strip to the relay and why it works would be great as I am trying to learn!

You cannot find a tutorial for controlling neopixel strips with a relay, because that just does not make any sense. You don't need a relay to control the strip.
The Neopixels consist not only of the LEDs themselves, but also of one LED driver chip per LED (WS2811 and it's siblings). These driver chips control the LEDs based on the data, that you send through the data pin. Actually one Neopixel LED consists of 3 LEDs inside a single package, one LED each for the colors red, green and blue (so that you can create all the other colors with a combination of them). The driver chip controlls the brightness of all three colors.
Thus you only need to connect your 5V power source to the strip (5V and ground) - Be sure to connect the power lines directly to your power supply, so that the LED current does not flow through the Arduino (because that can fry your Arduino) - and the data In pin of the strip to a fitting digital pin of the Arduino. You can use the Adafruit Neopixel library or the FastLED library for controlling them.
To turn the strip on, you set the needed pixels to the wanted color and then call the show method of the library (which sends out the color data through the data pin). To turn the strip off, you simply clear all the pixels (the libraries have extra functions for that), which basically means setting all pixel to black (red, green and blue components all zero).
So forget about the relay and just use the strip directly. Also Adafruit has a very good guide on how to use the Neopixels.

Hey,
I really appreciate your reply Chris. I understand what you are saying. But I've already programmed the strip to blink for a certain time, at the intensity I want, and the color that I want. The problem is I want the Neopixels to turn on at a specific time during the day which is the reason why I'm using the RTC and the relay. Are you saying the RTC and the relay aren't necessary at all to do what I want? I want the LEDs turn on at 12 and off 2 on their own. If the relay isn't necessary to do what I asked, would you mind pointing me in in the right direction?
Thanks!

You need the RTC for time keeping. But you don't need the relay. The tutorial, that you linked, uses both, but that doesn't mean, that you always need to use them together. Divide the functionalities of your project up: 1. You want to keep and know the time; for that you need the RTC. 2. You want to control the LED strip (here you only need the strip). And the code should just put both things together.

You can still follow the tutorial, but instead of the code for turning the relay on and off, you should insert the code for turning your LEDs on and off. The relay is just not needed there; it has no function in your project.