text:
Turning on and off two set of LEDs with two tactile buttons
I have two sets of 4 LEDs.
Set A (Led1 Led2, Led3, Led4)
Set B (Led5 Led6, Led7, Led8)
Both sets have its own tactile button:
Tactile A,
Tactile B,
Tactile A, turning on the LEDs set A and tactile B turning on the LEDs on set B.
So each time I press the tactile A, Led1 from Set A will turn on. The next press will turn on Led2 and LED1 off, then Led3 on, Led2 off, and Led4 on and led3 off.
Same for Tactile B and set B.
Tactile A will not change the set be and same tactile B.
So I came up with the below code. It works fine for Tactile A, for set A. But I am not able to turn on the set B with Tactile B. Tactile B is keep switching itself one after another the tactile B is no functioning. Each set should work with its own tactile button.

//Start -- Power supply on/off code

#include <Bounce2.h>

#define POWER_PIN 13
#define power 12

//End -- Power supply on/off code

//Start -- Switching Leds
// Leds set A
#define button 2
#define led1 8
#define led2 7
#define led3 6
#define led4 5
//Leds set B
#define tactile 3
#define led5 11
#define led6 4
#define led7 9
#define led8 10
int state = 0;      //integer to hold the current state Set A
int old = 0;        //integer to hold the last state Set A
int tactitleState = 0;      //integer to hold the current state Set B
int oldState = 0;        //integer to hold the last state Set B
int buttonPoll = 0; //integer to hold the button state for set A
int tactilePoll = 0; //integer to hold the button state for set B
//End -- Switching power

//Start -- Power supply on/off code

int powerState = LOW;
Bounce b = Bounce(); // Instantiate a Bounce object

//End -- Power supply on/off code

void setup() {
  //Start -- Power supply on/off code

  b.attach(POWER_PIN, INPUT_PULLUP); // Attach the debouncer to a pin with INPUT_PULLUP mode
  b.interval(25); // Use a debounce interval of 25 milliseconds
  pinMode(power, OUTPUT); // Setup the LED
  digitalWrite(power, powerState); // Turn off the LED

  //End -- Power supply on/off code

  //Start -- Switching power

  pinMode(button, INPUT); //button set as input
  pinMode(led1, OUTPUT); //Output set Led1
  pinMode(led2, OUTPUT); //Output set Led2
  pinMode(led3, OUTPUT); //Output set Led3
  pinMode(led4, OUTPUT); //Output set Led4

  digitalWrite (led1, HIGH); //set state Led1
  digitalWrite (led2, HIGH); //set state Led2
  digitalWrite (led3, HIGH); //set state Led3
  digitalWrite (led4, HIGH); //set state Led4

  digitalWrite (power, HIGH); //state of the input power

  //Second relay
  pinMode(tactile, INPUT); //button set as input
  pinMode(led5, OUTPUT); //Output set Led5
  pinMode(led6, OUTPUT); //Output set Led6
  pinMode(led7, OUTPUT); //Output set Led7
  pinMode(led8, OUTPUT); //Output set Led8

  digitalWrite (led5, HIGH); //set state Led5
  digitalWrite (led6, HIGH); //set state Led6
  digitalWrite (led7, HIGH); //set state Led7
  digitalWrite (led8, HIGH); //set state Led8

  //End -- Switching power

}

void loop() {
  //Start -- Power supply on/off code
  b.update(); // Update the Bounce instance
  if ( b.fell() ) {  // Call code if button transitions from HIGH to LOW
    powerState = !powerState; // Toggle LED state
    digitalWrite(power, powerState); // Apply new LED state
  }
  //End -- Power supply on/off code

  //Start -- Switching power Set A.

  buttonPoll = digitalRead(button); //Detect the state of the button
  if (buttonPoll == 1) {              //Check if the button pressed
    delay (50);                       //Delay 50ms
    buttonPoll = digitalRead (button); //Poll button again
    if (buttonPoll == 0) {           //if it is 0 considered one press
      state = old + 1;               //increas state by 1
    }
  }
  else {
    delay (100);                    //Delay 100ms
  }
  switch (state) {     //react tot button press & state
    case 1:
      digitalWrite (led1, LOW); //led1 is on
      digitalWrite (led2, HIGH); //led2 is off
      digitalWrite (led3, HIGH); //led3 is off
      digitalWrite (led4, HIGH); //led4 is off
      old = state;
      break;
    case 2:
      digitalWrite (led1, HIGH); //led1 is off
      digitalWrite (led2, LOW); //led2 is on
      digitalWrite (led3, HIGH); //led3 is off
      digitalWrite (led4, HIGH); //led4 is off
      old = state;
      break;
    case 3:
      digitalWrite (led1, HIGH); //led1 is off
      digitalWrite (led2, HIGH); //led2 is off
      digitalWrite (led3, LOW); //led3 is on
      digitalWrite (led4, HIGH); //led4 is off
      old = state;
      break;
    case 4:
      digitalWrite (led1, HIGH); //led1 is of
      digitalWrite (led2, HIGH); //led2 is off
      digitalWrite (led3, HIGH); //led3 is off
      digitalWrite (led4, LOW); //led4 is on
      old = state;
      break;
    default:                   //if the there is no state, then all leds are off
      digitalWrite (led1, HIGH); //led1 is of
      digitalWrite (led2, HIGH); //led2 is off
      digitalWrite (led3, HIGH); //led3 is off
      digitalWrite (led4, HIGH); //led4 is off
      old = 0;   // All states are reset to 0 off
      break;
  }
  //End -- Switching  led set A
  //Start -- Switching led set B

  tactilePoll = digitalRead(tactile); //Detect the state of the button
  if (tactilePoll == 1) {              //Check if the button pressed
    delay (50);                       //Delay 50ms
    tactilePoll = digitalRead (tactile); //Poll button again
    if (tactilePoll == 0) {           //if it is 0 considered one press
      tactitleState = oldState + 1;               //increas state by 1
    }
  }
  else {
    delay (100);                    //Delay 100ms
  }
  switch (tactitleState) {     //react tot button press & state
      case 1:
      digitalWrite (led5, LOW); //led5 is on
      digitalWrite (led6, HIGH); //led6 is off
      digitalWrite (led7, HIGH); //led7 is off
      digitalWrite (led8, HIGH); //led8 is off
      oldState = tactitleState;
      break;
    case 2:
      digitalWrite (led5, HIGH); //led5 is off
      digitalWrite (led6, LOW); //led6 is on
      digitalWrite (led7, HIGH); //led7 is off
      digitalWrite (led8, HIGH); //led8 is off
      oldState = tactitleState;
      break;
    case 3:
      digitalWrite (led5, HIGH); //led5 is off
      digitalWrite (led6, HIGH); //led6 is off
      digitalWrite (led7, LOW); //led7 is on
      digitalWrite (led8, HIGH); //led8 is off
      oldState = tactitleState;
      break;
    case 4:
      digitalWrite (led5, HIGH); //led5 is off
      digitalWrite (led6, HIGH); //led6 is off
      digitalWrite (led7, HIGH); //led7 is off
      digitalWrite (led8, LOW); //led8 is on
      oldState = tactitleState;
      break;
    default:                   //if the there is no state, then all leds are off
      digitalWrite (led5, HIGH); //led5 is off
      digitalWrite (led6, HIGH); //led6 is off
      digitalWrite (led7, HIGH); //led7 is off
      digitalWrite (led8, HIGH); //led8 is off
      oldState = 0;   // All states are reset to 0 off
      break;
  }
  //End -- Switching Leds set B
}

The link doesn't seem to work without an account. You code for checking if a button is pressed is very odd, and it surprises me that it even seems to work for the A set button. How are you buttons connected? Do they have a pull-up/pull-down resistor? Might I also suggest renaming you variables something less random. For example use stateA and stateB instead of state and tactileState. Idem for buttonPoll and tactilePoll. old and oldState.

Your code is rather hard to follow.
Your code to read a button press doesn't make much sense:
  buttonPoll = digitalRead(button); //Detect the state of the button
  if (buttonPoll == 1) {              //Check if the button pressed
    delay (50);                       //Delay 50ms
    buttonPoll = digitalRead (button); //Poll button again
    if (buttonPoll == 0) {           //if it is 0 considered one press
      state = old + 1;               //increas state by 1
    }
  }
  else {
    delay (100);                    //Delay 100ms
  }

That code will, I think, only detect a button press if you press the button for exactly 50 mS. Given that you already use the Bounce library, why don't you create Bounce instances for your LED controller buttons and use those to read those buttons as well?
Next issue: you are setting your button and tactile pins to INPUT rather than INPUT_PULLUP. Do you have pulldown resistors on those? (when your input is set to INPUT mode you need pulldown resistors, and need to connect the switches to +5V. If you use INPUT_PULLUP mode you don't need any resistors, but you connect your switches to ground. They then read HIGH until you press a switch, at which point the switch connects the pin to ground and pulls it LOW.)
Next issue: You are treating a value of 1 as pressed and 0 as not pressed. You should use the constants HIGH and LOW instead. (And note that if you use INPUT_PULLUP mode for your pins, you should wire your buttons to VCC, and treat HIGH as not pressed and LOW as button pressed.)
I would suggest renaming your variables and using arrays of LED pin numbers:
int set1Button 2;
int set1LEDs[] = {8, 7, 6, 5};
int set1State = 0; //No LEDs lit

int set2Button 3;
int set2LEDs[] = {11, 4, 9, 10};
int set2State = 0; //No LEDs lit

Pressing setButton1 should advance set1State, and pushing set2Button should advance set2State.
For value 0, set all LEDs to off. any other value, set the LED at index setXState - 1 on and all others off.
This code would work for the first set of LEDs:
for (int index = 1; index <= 4; index++) {
     int value = set1State == index ? HIGH : LOW;
     digitalWrite (set1LEDs[index-1], value);
}

Small correction: If using INPUT_PULLUP, one should wire the button to ground, not to Vcc. And of course the array definition should look like in Mats edit of your question. As far as I know, the above array definition does not work in C/C++.

Chrisl, the way my answer was worded it wasn't clear that for a pin set to INPUT you need a pulldown resistor and the switch connected to +5V, but for INPUT_PULLUP mode you need to connect the switch to ground. I edited the answer to make it clearer.

I work mostly in Swift these days, and couldn't remember the C/C++ static array syntax. Thanks @Mat for fixing it.

@DuncanC, Can you please provide a full code? I tried but it is not working.

This is not a code writing service, and my partial code might not fit with the rest of your sketch. Edit your question and provide the updated code at the end, along with detailed information on how it's behaving.

Your new wiring diagram shows you as having the buttons connected to +5V. Is that correct? Are you using INPUT mode or INPUT_PULLUP mode? Are you treating a HIGH value as button pressed, or a LOW value?

@DuncanC, The button is connected to 5V, and to pin 2 and other to pin 3,. So when the button press the pin 2 or same pin 3 goes hight.

And the rest of my questions?

@DuncanC, I use INPUT mode with a resistor as shown in the pic, if it is wrong so then I will use INPUT_PULLUP mode. When the button is pressed it will act is LOW.

INPUT mode, with pull-down resistors, should work. I don't see any pull-down resistors in the picture of your circuit however.

But your button debouncing code from your original post is a mess. Why not use the Bounce library for your switches? I assume that's what it's for.

@DuncanC, since I posted this question, I started an online course in Arduino coding and C++. I almost finished the Arduino course, and it was not that much helpful. I will start another advance course on Arduino. In future, I may be able to sort this out. But right now I am too beginner. I just do this for fun and experience and it is not a business.  I googled the Bounce library and checked YouTube, I will look at how it is possible. Thanks for the directions.

I found some examples in these links:
How to Detect Short, Long, and Double Clicks with Arduino
https://youtu.be/TwM1sp2IXYI
Button De-bouncing
https://youtu.be/4NcfEwm9WBI


text:
Uploading sketch to ATTiny84 with Nano as "Arduinio as ISP" stopped working
Update 12/11
Working through the answer posted.

Upload reset appearance - [Works blinks correctly.]
Convince yourself that reset appearance code reliable indicates DTR resets. [Opened the serial monitor 5-6 times, nothing changed or blinked]
10uF cap between Arduino Nano RESET and adjacent GND. [Done]
Plug the board back in and you should see the LED Blink rapidly for the power-on (not DTR) reset. [Blinks rapidly same as after upload of sketch in Step one]
Open (or Reopen) the serial monitor and see that the LED remains OFF. [No LED's]
Break the RESET leg of whatever circuit you chose for defeating DTR reset. Upload the ArduinoISP sketch [Uploaded and verified, no problem]
You should see a signature check error like this: [Yes this error occured same message as you posted]
Upload Empty sketch [ IT WORKS !!!!!]
Check using one of my previous sketchs [WOOT! It works]

Thanks, that resolved the issue!! (although I've aready bought a universal programmer because I didn't think I would ever get it working).
Update - 11/Nov
As suggested, I have taken the nano out of any board and it is dangling from the USB cable. I have tried to upload the default sketch.
void setup() {
  // put your setup code here, to run once:

}

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

}

using the settings:

Board Attiny22/44/84
Processor Attiny84
Programmer Arduino as ISP

I still get the problem of programmer not responding. Did this for all 3 nanos I have available.
===
Update - 11/nov
I have now wiped all the IDE from my machine and reloaded. I have attempted to program an ATmega168PA instead of the tiny. Same problem.
Update - 10/nov:
After swapping between 2 different nanos and different capacitors to check that the cap is working. I noticed some different behavour. Nano A fails as below, however Nano B fails, but the message is slightly different. Instead of resp=0x00 I have resp=0xFF
Also on Nano B the L light doesn't flash it is on constantly and the 10 getsync messages go really fast.

I really could do with a solution if anyone has one.
I am trying to upload a sketch into a ATTiny84 with Nano as "Arduinio as ISP". This worked last week, same sketch, no changes. I have attempted to troubleshoot:
Changed ATTiny chips, changed between 3 different Nanos (and even bought another which also failed), I have changed all the USB cables, changed all the wires. I have installed the IDE on different machines.
In summary, I have tried:

3 different machines: Linux, Raspberry Pi, Windows 10
7 different ATTiny84 chips (I have ten, but don't want to use the other 3 in case this is bricking them!)
4 different Nanos
different USB cables, different wires, replaced the capacitors

I have triple checked the configuration. Nothing seems to fix the problem.
I have no issue with any of the Nanos, I can use them directly, but just can't seem to use them to push into the AVR. It worked with the same configuration for weeks, now it doesn't. I'm really scratching my head.
I'm using:

ATTiny core by David A. Mellis
Boards: Attiny24/44/84
Processor: Attiny84
Clock: Internal 1 Mhz
Programmer: Arduinio as ISP
"Upload using Programmer"

Verbose Error messages:
Arduino: 1.8.13 (Linux), Board: "ATtiny24/44/84, ATtiny84, Internal 1 MHz"

/home/rick/arduino-1.8.13/arduino-builder -dump-prefs -logger=machine -hardware /home/rick/arduino-1.8.13/hardware -hardware /home/rick/.arduino15/packages -hardware /home/rick/Arduino/hardware -tools /home/rick/arduino-1.8.13/tools-builder -tools /home/rick/arduino-1.8.13/hardware/tools/avr -tools /home/rick/.arduino15/packages -built-in-libraries /home/rick/arduino-1.8.13/libraries -libraries /home/rick/Arduino/libraries -fqbn=attiny:avr:ATtinyX4:cpu=attiny84,clock=internal1 -vid-pid=1A86_7523 -ide-version=10813 -build-path /tmp/arduino_build_476590 -warnings=default -build-cache /tmp/arduino_cache_440110 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/home/rick/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/rick/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.avr-gcc.path=/home/rick/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/rick/arduino-1.8.13/hardware/tools/avr -verbose /home/rick/Arduino/Light_detector_Example/Light_detector_Example.ino
/home/rick/arduino-1.8.13/arduino-builder -compile -logger=machine -hardware /home/rick/arduino-1.8.13/hardware -hardware /home/rick/.arduino15/packages -hardware /home/rick/Arduino/hardware -tools /home/rick/arduino-1.8.13/tools-builder -tools /home/rick/arduino-1.8.13/hardware/tools/avr -tools /home/rick/.arduino15/packages -built-in-libraries /home/rick/arduino-1.8.13/libraries -libraries /home/rick/Arduino/libraries -fqbn=attiny:avr:ATtinyX4:cpu=attiny84,clock=internal1 -vid-pid=1A86_7523 -ide-version=10813 -build-path /tmp/arduino_build_476590 -warnings=default -build-cache /tmp/arduino_cache_440110 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/home/rick/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/home/rick/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.avr-gcc.path=/home/rick/arduino-1.8.13/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/home/rick/arduino-1.8.13/hardware/tools/avr -verbose /home/rick/Arduino/Light_detector_Example/Light_detector_Example.ino
Using board 'ATtinyX4' from platform in folder: /home/rick/.arduino15/packages/attiny/hardware/avr/1.0.2
Using core 'arduino' from platform in folder: /home/rick/arduino-1.8.13/hardware/arduino/avr
Detecting libraries used...
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny84 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR -I/home/rick/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/rick/.arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny14 /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SendOnlySoftwareSerial.h: [SendOnlySoftwareSerial]
ResolveLibrary(SendOnlySoftwareSerial.h)
  -> candidates: [SendOnlySoftwareSerial]
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny84 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR -I/home/rick/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/rick/.arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny14 -I/home/rick/Arduino/libraries/SendOnlySoftwareSerial /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Using cached library dependencies for file: /home/rick/Arduino/libraries/SendOnlySoftwareSerial/SendOnlySoftwareSerial.cpp
Generating function prototypes...
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=attiny84 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR -I/home/rick/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/rick/.arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny14 -I/home/rick/Arduino/libraries/SendOnlySoftwareSerial /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp -o /tmp/arduino_build_476590/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
/home/rick/arduino-1.8.13/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino_build_476590/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-g++ -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=attiny84 -DF_CPU=1000000L -DARDUINO=10813 -DARDUINO_attiny -DARDUINO_ARCH_AVR -I/home/rick/arduino-1.8.13/hardware/arduino/avr/cores/arduino -I/home/rick/.arduino15/packages/attiny/hardware/avr/1.0.2/variants/tiny14 -I/home/rick/Arduino/libraries/SendOnlySoftwareSerial /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp -o /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp.o
Compiling libraries...
Compiling library "SendOnlySoftwareSerial"
Using previously compiled file: /tmp/arduino_build_476590/libraries/SendOnlySoftwareSerial/SendOnlySoftwareSerial.cpp.o
Compiling core...
Using precompiled core: /tmp/arduino_cache_440110/core/core_attiny_avr_ATtinyX4_cpu_attiny84,clock_internal1_8328ca5f502560caf6997d9e8039b097.a
Linking everything together...
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-gcc -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=attiny84 -o /tmp/arduino_build_476590/Light_detector_Example.ino.elf /tmp/arduino_build_476590/sketch/Light_detector_Example.ino.cpp.o /tmp/arduino_build_476590/libraries/SendOnlySoftwareSerial/SendOnlySoftwareSerial.cpp.o /tmp/arduino_build_476590/../arduino_cache_440110/core/core_attiny_avr_ATtinyX4_cpu_attiny84,clock_internal1_8328ca5f502560caf6997d9e8039b097.a -L/tmp/arduino_build_476590 -lm
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_476590/Light_detector_Example.ino.elf /tmp/arduino_build_476590/Light_detector_Example.ino.eep
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_476590/Light_detector_Example.ino.elf /tmp/arduino_build_476590/Light_detector_Example.ino.hex
Using library SendOnlySoftwareSerial in folder: /home/rick/Arduino/libraries/SendOnlySoftwareSerial (legacy)
/home/rick/arduino-1.8.13/hardware/tools/avr/bin/avr-size -A /tmp/arduino_build_476590/Light_detector_Example.ino.elf
Sketch uses 1666 bytes (20%) of program storage space. Maximum is 8192 bytes.
Global variables use 152 bytes (29%) of dynamic memory, leaving 360 bytes for local variables. Maximum is 512 bytes.
/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -pattiny84 -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:/tmp/arduino_build_476590/Light_detector_Example.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/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/rick/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
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
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

VCC & GND connected
White wire (Pin 9) -> D13
Yellow wire 1 (Pin 8) -> D12
Red wire (Pin 7) -> D11
Yellow wire 2 (Pin 4) -> D10
10 Capacitor between RST & Gnd

The only change I can remember making was adding a library for SerialOutOnly. But I did a clean install on the Windows and Rasberry with only the ATTiny libraries and it still does the same time.
People missed my comment, so I've uploaded a second photo of the entire breadboard. It is powered there are two wires which were out of frame in the first photo.

Yes, the ATtiny is on a breadboad. I used https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json this link to setup the Attiny boards. Then I am using Attiny24/44/84, Processor Attiny84, and internal 1 Mhz clock.

Yes, I have a capacitor between gnd & reset.

I edited the question for a better title and tags. The avrdude output doesn't look to be verbose. did you turn on in Preferences verbose mode for upload?

Yes, for both compilation and upload.

That sounds really frustrating. But if it worked before, something must have changed to make it not work now (sorry, that’s obvious). You’ve as good as ruled out the PC side of things by testing it with different setups. Did you make sure all Nanos have the “ArduinoISP” sketch loaded and the ATtiny fuses match the expected setup? Could you add a picture of your setup?

From your picture, I think your ATtiny84 is not powered (connected to the wrong power rails). The positive (red) and negative (blue) rails on both sides of a breadboard are usually not connected .

At the top of the breadboard, outside the picture, there are two wires connecting the power and ground on both sides.

Having followed all of the suggestions and comments here, I'm not sure what to suggest you do now outside of producing a video showing every last thing you're doing throughout the entire process, including the part of putting the arduinoisp.ino sketch on the nano.  To be clear, the error messages themselves are in avrdude failing to talk to the arduinoisp.ino sketch.  You could, and perhaps should for a sanity check, pull the nano right off the board and see that you get an entirely different error message.  If you don't then there is something wrong with the arduinoisp.ino sketch loaded.

With arduinoisp.ino loaded correctly, with nothing wired to it at all, with the correct options specified during uploading, you would get a failure to check the device signature and not the sync error you are getting now.

You would still need to have reset defeated by cap no gnd, cut trace, or hard pullup, without the other wiring attached.  I have done this here using a 62 ohms pullup (instead of a cap) and it behaved as expected.  Which is to say it failed to check the device's (not attached) signature and NOT an stk500v1 protocol sync error.  I then went on to hook a t85 to it and that worked fine as well.  I /could/ write all this up, but I deeply suspect if I do that you're going to come back with "still not working" because of something going on there that we cannot see.

Well, I'm glad it works for you.  I'm unclear on what changed from what you were doing before to now though.

I think it might have been the "reupload" of the Arduinio as ISP ??

Heh, well, I guess we'll never know.  Generally speaking the arduinoisp.ino sketch itself is reliable.  The process for using it is not terribly clear for most people the first couple times through.

Differences in my environment
I don't have a normal Nano on a ATTiny84 on hand at this moment.
For our purposes, I'm using the ATTiny44, which is essentially what you have, only with smaller memories.  The Nano that I'm using is Nano Clone that I have retrofitted with a ATMega328PB rather than the regular 328P.  To make matters slightly more confusing it is running the regular UNO (rather than NANO) bootloader.  The bootloader lies about the chip signature (saying it is 328P) and uses the UNO baudrate 115200 rather than the Nano's 57600.  So you will see in my screenshots/examples and menu selections "UNO" rather than "Nano", "328PB" rather than "328P", and "ATTiny44" rather than "ATTiny84."
These differences are inconsequential.
Build trust in your RESET-defeating mechanism
Upload reset appearance code
Remove all external circuitry from your Nano.  All means ALL.  That includes
whatever you did to defeat reset as well.
Choose Arduino Nano from the Tools/Boards menu.
Choose your Arduino Nano's port from the Tools/Port menu.
Upload the following sketch:

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

void loop() {
  static bool led_state;
  static size_t toggle_counter;

  if (toggle_counter < 20LU * 6) {
    led_state = !led_state;
    digitalWrite(LED_BUILTIN, led_state);
    delay(50);
    ++toggle_counter;
  }
}

The LED should blink rapidly for 6 seconds and then remain off indefinitely.
The Nano's optiboot bootloader blinks the builtin pin 13 LED three times, but it is a very short event and maybe difficult to distinguish form SPI clock action (which also happens on pin 13).  By contrast, it's hard to miss the blinking that this code produces.
Convince yourself that reset appearance code reliable indicates DTR resets.
Open (or Reopen) the serial monitor and see that it does this again.  Close and
Reopen the serial monitor however many times you want until you feel
comfortable that you're seeing clear indication of the board having reset.
Install your DTR RESET-defeat circuitry for a test.
Unplug your board and install your choice of reset defeating circuitry.
The typical suggestion is a 10uF cap between Arduino Nano RESET and adjacent
GND.  Make sure you don't have your electrolytic cap backwards.
I frequently use a hard pullup of about 60 Ohms.
Plug the board back in and you should see the LED Blink rapidly for the
power-on (not DTR) reset.
Convince yourself that DTR reset has been defeated.
Open (or Reopen) the serial monitor and see that the LED remains OFF.
Reopen the serial monitor however many times and see that the LED stays OFF.
Upload the arduinoisp.ino sketch
NOTE: At time of writing the current IDE version is 1.8.13.  Though, everything
said here should be find for old and likely future IDE/arduinoisp.ino releases.
In the IDE, from menu File/Examples/11.ArduinoISP, choose the ArduinoISP
sketch.  In its current from in IDE 1.8.13 it requires no modifications for a factory-fresh ATTiny84(A) (or pretty much any AVR), that is with its default configuration fuse values.
Break the RESET leg of whatever circuit you chose for defeating DTR reset.
Upload the ArduinoISP sketch.
You should see that the LED does NOT blink rapidly for 6 seconds as it had previously.
This should indicate that you have successfully uploaded the arduinoisp.ino sketch.
Reconnect RESET leg of whatever circuit you chose for defeating DTR reset.
Attempt to program (without target chip attached) to see that you do not get SYNC errors.
Open a new empty sketch.
Choose your target chip's settings from the Boards menu.  That is your D.
Mellis ATTiny84 "board" should be selected.  Or more generally: any compatible "board" from any board support package that supports whatever AVR you want to do this with.
Verify that your Arduino Nano's port is still selected in Tools/Port menu.
From the Tools/Programmer select "Arduino as ISP".  Barring some internationalization effort, it should say exactly that. It should NOT say "ArduinoISP" or "ArduinoISP.org".  Yes, the Arduino people are usually BAD at picking names.
Choose "Upload using programmer".
You should see a signature check error like this:
avrdude: AVR device initialized and ready to accept instructions

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x00ffff
avrdude: Expected signature for ATtiny44 is 1E 92 07
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

You may need to turn on "Verbose" for uploading in preferences.
Because you have not wired anything to the SPI pins the returned device
signature will be pure junk.  The important thing here is you got a device
signature failure and NOT a sync error.  A sync error represents failure of avrdude to talk to the arduinoisp.ino sketch's implementation of the STK500v1 programming protocol.  What you're seeing here is successful STK500v1 communication (to arduinoiso.ino) reporting a perfectly reasonable failure to identify the chip (that you have not even attached yet).
Wire your ATTiny84 (or whatever)
Unplug your Nano and wire AVR to it.  With the exception of your attempt to use VIN, I didn't notice anything wrong with your wiring.
The ATTiny84 should be wired as:
Nano 5V (not VIN) to ATTiny84 pin  1
Nano GND          to ATTiny84 pin 14
Nano PIN 13       to ATTiny84 pin  9
Nano PIN 12       to ATTiny84 pin  8
Nano PIN 11       to ATTiny84 pin  7
Nano PIN 10       to ATTiny84 pin  4

Or more broadly for any ISP supporting AVR tiny/mega:
Nano 5V (not VIN) to ALL AVR (A)VCCs.
Nano GND          to ALL AVR GNDs
Nano PIN 13       to AVR (U)SCK
Nano PIN 12       to AVR MISO
Nano PIN 11       to AVR MOSI
Nano PIN 10       to AVR RESET

You may want to add a pull-up resistor from the target AVR's RESET to its VCC.  This should be not needed for use with arduinoisp.ino sketch, but you might want it for running on the breadboard.  You may also want to add a decoupling cap between your AVR's VCCs and GND.  I've never needed this for just programming on solderless breadboard though.
I don't typically use breadboard power rails when programming AVR devices with single VCC an GND pins.
Generally keep your connection short in any case.  They should not be longer than 20 cm really, and can usually be less than half that. Keep them together with the GND where possible. Your SCK signal should probably receive the most care.  I don't see anything wrong with the length of your connections.
Upload
Plug your Nano (and AVR wired to it) back into USB.
Make sure you power light hasn't gone out on the Nano, that it doesn't drop off the USB bus, and nothing feels hot to the touch.  That nothing smells odd.
Choose whatever you want to upload.  An empty sketch is fine for testing uploading.
Verify that Tools/Port is the port of the Nano.
Verify that the programmer is still "Arduino as ISP".
Verify that the "board" is still whatever it should be for your target chip (not the Nano).
Choose "Upload using Programmer".
You should get a successful output, that would look something like:
/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -pattiny44 -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:/tmp/arduino_build_656744/sketch_nov12b.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/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATtiny44
         Chip Erase delay              : 4500 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        256    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      4096   64     64  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9207 (probably t44)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/tmp/arduino_build_656744/sketch_nov12b.ino.hex"
avrdude: writing flash (286 bytes):

Writing | ################################################## | 100% 0.46s

avrdude: 286 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_656744/sketch_nov12b.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_656744/sketch_nov12b.ino.hex:
avrdude: input file /tmp/arduino_build_656744/sketch_nov12b.ino.hex contains 286 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.22s

avrdude: verifying ...
avrdude: 286 bytes of flash verified

avrdude done.  Thank you.

The above was generated using the process described with my slightly different setup.
With everything being correct in the IDE, if you get SYNC error now you
probably have a wiring issue that's causing the Nano to fail, interfering with its ability to execute the stk500v1 implementation.  This was part of the thinking behind pointing out your VIN connection in the original post:

That gave me a brief glimmer of hope, but I've made that change and it hasn't worked. I've tried a couple of different AT84's and Nanos.

If you watch carefully do you see the L light blink in the way that it does during a reset?  In other words, is your RESET holdup-cap actually doing its job?

Yes the L light is blinking when I attempt to upload the sketch.

Yeah, it would as being SCK.  What I'm getting at is that it will blink three times on a reset.  If it's doing that particular thing when you're trying to upload, it means the cap is not keeping reset from going low.

I don't understand what you mean. I took the capacitor out and tried again. The blinking seems to be the same regardless if the Cap is in or out. I tried a different capacitor. Same result.

It would be subtle when you're running te arduinoisp.ino sketch.  It would be easier to test with a sketch that did nothing at all.  That way if you opened the serial monitor to it and you saw any blinking at all, you'd know it was resetting for sure.  Anyway, other than the VIN bit, your wiring looks fine for programming.  For what it's worth, I tend to use about 60 ohms between resistance between reset and 5v rather than a 10uF capacitor to ground, simply because I have a resistor substitution box I use all the time.

From your picture, it looks like your ATtiny84 is not powered (connected to unpowered power rails).
The positive (red) and negative (blue) rails on both sides of a breadboard are usually not connected. You should either manually connect the power rails on opposite sides of your breadboard or connect your ATtiny power pins (1 and 14) to the corresponding rail on the other side of your board. See below (apologies for the crude drawing).

The power wasn't showing in the first photo it was out-of-frame.

source: Stack Exchange

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

sort: votes


text:
connect USB keyboard to Arduino using clk and data wires
Edit:
What I'm looking for is some kind of library which could be used with an arduino to read the HID protocol output from the Data+ and Data- cables of the USB.
==========
If I cut the cable of a usb keyboard, plug in power and ground can I use the clk and data wires to read keystrokes into the Arduino? If so any pointers to libraries and schematics?
Simple I instructions? The "for dummies" version?
EDIT
Following some of the suggestions below I found this:
https://github.com/julianschuler/USBKeyboard
Which looks like what I want to do, basically hook up the lines into the arduinio and read from the keyboard using the HID protocol in this library.
EDIT 2
That doesn't do what I want. Does anyone know how this could be accomplished?

From what device do you want to read keystrokes? from an USB keyboard?

yes from the keyboard.

I think you can do this using an USB Host shield.

Which looks like what I want to do ... no it isn't ... read it again

If it is possible to make an AVR bit-bang the USB protocol as a device, it may also be possible as a host. Have you tried to find such a library or project?

@thebusybee I have not found one. That is what I'm asking for.

OK. It might be because everyone is using a USB host shield. And since the USB protocol is quite complicated, no-one wrote such a low-level library, most probably. -- Is it really not an option to use a non-USB keyboard? Is this a project for many users, or is it just for you in one "incarnation"?

USB doesn't have data and clock lines. It has a pair of data lines with inverted polarity (D+ and D-). The USB protocol is considerably more complex than you seem to imagine.
However there is a caveat: some keyboards have the ability to work in IBM PS/2 mode. For this you will need a USB to PS/2 adaptor (pictured below) and then use the PS2Keyboard.h library. Your mileage may vary, though, as not all keyboards will work.

Any place I can get information on this protocol? I don't want the adapter, I want to plug in the cables directly and manipulate the data.

I think you don't actually need the adapter. It should just connect the pins of the USB jack to the pins of the PS/2 plug. So you could just directly connect the lines to the Arduino. A very short google search gave some promising results

These adapters only work if the USB keyboard has a dual controller which understands the PS2 protocol as well as the HID USB protocol. (Most modern keyboards don't) I don't have one of those, and I am looking for a library or method for directly interfacing the HID protocol with an Arduino.

Then you will need to invest in a usb host shield.

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


text:
TFT Screen & ATMEGA168
I have a Arduinio nano and a ATMEGA168. I'm using the ST7789 library. The sample code which comes with the library runs perfectly and runs the display when using the Nano, but the same code does nothing on the ATMEGA168. I'm using the official pin mappings, so I sure it isn't the pins. Any suggestions I could try, or will a ATMEAG168 not drive a TFT?
EDIT:
I'm using the library written for adafruit.
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>             // Arduino SPI library

on the nano I'm using:

D13 -> SCL
D11 -> SDA
D9 -> DC
D8 -> RES

on the ATmega:

19 (PB5) -> SCL
17 (PB3)-> SDA
15 (PB1)-> DC
14 (PB0)-> RES

ANSWER TO COMMENTS:
Yes I mean the exact same code without changing the pin numbers. The pin numbers I use on the ATmega are just the same pins connected via the official atmega mapping here: https://www.arduino.cc/en/Hacking/PinMapping168
Yes the ATMega is running, I've used a logic probe on the output pins and there is output on the pin. I've run numerous other programs more sophisticated than blinking LED's and the chips are fine. The clock source is PB0 (pin 14) of the atmega. Reference pinouts in the above link.
I'm not using AC power, high frequencies, or switching subcircuits, so I didn't believe I needed any decoupling. Why do you believe there should be, and where do you believe they should be located?
EDIT: MORE INFO FOR COMMENTORS:
I'm just trying to use the terminology written on the PCB. :)
This is the best I can do and stay under the 2 meg limit for images.
EDIT 3:
Yes, I thought the same and swapped the screens. I also tried swapping all the wires, just in case, and moving everything to a different breadboard and power supply. In addition, I swapped out the atmega since I have a couple of them. It is perplexing.

/*
 * Interfacing Arduino with ST7789 TFT display (240x240 pixel).
 * Graphics test example.
 * This is a free software with NO WARRANTY.
 * https://simple-circuit.com/
 */
/**************************************************************************
  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
  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_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>             // Arduino SPI library

// ST7789 TFT module connections
#define TFT_CS    10  // define chip select pin
#define TFT_DC     9  // define data/command pin
#define TFT_RST    8  // define reset pin, or set to -1 and connect to Arduino RESET pin

// Initialize Adafruit ST7789 TFT library
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

float p = 3.1415926;

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

  // if the display has CS pin try with SPI_MODE0
  tft.init(240, 240, SPI_MODE2);    // Init ST7789 display 240x240 pixel

  // if the screen is flipped, remove this command
  tft.setRotation(2);

  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);
  int 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);
  int 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);
}

"will a ATMEAG168 not drive a TFT?".  An ATMega168 can be used with all kinds of displays.  But somehow I don't think that's the question you actually wanted answered.  To give a useful answer beyond that, more details are needed.  Which exact library? What version of it? Which example? How exactly did you wire it?

If you say "the same code", do you mean without changing the pin numbers in the source?

Do you know if your ATMega168 is actually even running? How are the fuses configured? What is your clock source? Also: where are your decoupling capacitors? I think the problem is not that it can't control the screen, but that it just can't run full-stop. Start by making the 168 blink an LED...

You appear to be confusing I2C and SPI terminology.  What you're calling SCL and SDA are SCK and MOSI respectively.  The wiring image is very low resolution.  Not useless, but pretty bad.  It is a good angle and everything is in frame.  If you could replace with a better resolution image and show what code you're using that would be helpful.

Well, I've been through your wiring and through the library, and if you have the same sketch running on both, I'm not seeing why it wouldn't work.  As a sanity check you might swap the displays and make sure the problem doesn't follow the display.  I don't have a good reason for thinking that it will, but is a very simple test to rule that out.


text:
Can't get 1 second on a ATMega168 timer
  TCCR1A = 0;
  TCCR1B = 0;
  OCR1B =  0xFF00;
  TCCR1A = (1<<WGM10) ;
  TCCR1B = (1<<CS12) | (1<<CS10);; //set the pre-scalar as 1024
  TIMSK1 = (1 << OCIE1A);

This doesn't produce a 1 second timer, it seems to produce a 0.5 second timer? I've calculated it based on the fact that I'm using the internal 8MHz internal clock on the chip.
Where am I going wrong?
EDIT: OK, I truly don't understand anything about timers, this is the first time I've ever tried one. I tried to figure it out using this tutorial: https://exploreembedded.com/wiki/AVR_Timer_programming
All the examples are related to 16MHz, and the calculations are confusing to me because of the switch between formats which I don't know. After a lot of googling I figure out what I should be pushing into the calculator is ((8000000/1024)*1)-1) = 7811.5 (Although what I do with this number is a mystery) I think I'm supposed to subtract this from 65536 or perhaps some other randomly generated number. You then take the result of this and turn it into the hexadecimal equivalent of a boy band name, like E17 use lots of arrows to point away from things that look like the names of radio stations, WGM10 (bringing you all the hits of the 80's and 90's)
I apologize for the sarcasm, I couldn't help myself. What I really need to know is:

How do you actually calculate a 1-second delay one timer 1 when you are using the 8MHz internal clock of the ATMega168PA ? What are the numbers to type into a calculator?
Which switches should I be setting? I thought these were the correct ones.
What does OCIE1A stand for, can't find it in the documentation or the tutorial, only in the example code?

I should probably also add all I am doing is incrementing a count and displaying the count in my loop.
ISR (TIMER1_COMPA_vect)
{
  count++;
}

Re “I tried to figure it out using this tutorial”: This tutorial suggests periodically resetting the timer. This should not be done: it is a sure way of missing ticks. I suggest looking for a better tutorial. And then, this is mandatory, reading the datasheet (just the chapter on Timer 1).

TCCR1B = (1<<WGM10); doesn't do anything, because on the next line, you overwrite TCCR1B. Secondly, for the /1024 prescaler, you need to set both the CS12 and the CS10 bit. So TCCR1B |= (1<<CS12) | (1<<CS10);. I don't understand how your code is actually giving you a .5Hz signal.

Sorry, I was meeting around when editing the question. I've pasted directly from the code.

In normal mode, the timer counts from 0 to 65535 (0xffff), and then
rolls over back to zero. With a prescaler set to 1024, the period is
then 1024 × 65536 = 67108864 CPU cycles.
If you want to control the timer's period, you should not use normal
mode, but rather CTC mode (for “clear timer on compare match”). In this
mode, it counts from 0 to the value stored in OCR1A, and then starts
back at zero. With the same prescaler, the period is then
1024 × (OCR1A + 1) CPU cycles.

I have added the line: TCCR1A= (1<<WGM12) | (1<<WGM13); But this appears to have no effect.

@RickDearman: 1. If you select mode 12 (_BV(WGM12)|_BV(WGM13)), then the TOP of the count is selected by ICR1. Use mode 4 if you want TOP to be OCR1A.
2. The bits WGM12 and WGM13 belong to TCCR1B, not to TCCR1A.


text:
Arduino Power project question?
I saw a project on the Internet (the one in the photo), and I wonder, would it be a problem for me to connect the Vin and GND of the Arduino to the same place where the Servo Motors are being powered? (to power the Arduino together without having to connect it to another source or USB)
And if instead of the batteries I use one of those Breadboard Power Module (photo two) and connect a 12V / 1A power supply in it, would it have problem ? (connect the 4 Servo + the Arduino in it)

The peak current (when starting to rotate) for a servo motor can be 0.5 amps. When you have extra strong servo motors, then it can be a few amps. The arduino should be powered via the barrel jack with at least 7.5v or else a current can flow into the usb port of the computer.

Please provide more information about the power module, or at least a link to it.
But you could supply 12v directly to the Arduino's DC-In barrel-jack. It's not ideal; the Arduino's regulator is likely to get warm, but it would work. This module looks like it regulates its input down to 5v or 3.3v (jumper-selectable). If that is so, then its 5v output would be just right for the Arduino's 5v-In pin. Just make sure your the motors and the Arduino are each directly connected to whatever supply(s) you use. What you need to avoid is trying to power the motors through the Arduino. Your first photo has it right.
Update:
After reading about the supply (using your link), I see that its output is limited to 700ma. Some of that will have to go to power the Arduino (you can use the power supply's USB port for that), leaving a little less for the motors. That will be marginal for one motor and insufficient if the motor is stalled or moving more than a trivial load. It won't be sufficient for more than one motor at a time without scheduling them to prevent simultaneous starts.
You haven't described your motors, so I looked up the Tower-Pro SG-90 hobby servos, one of the simplest and least expensive of the hobby servos. I found a very similar looking one (maybe a clone?) described as being similar to the Tower-Pro, the only one for which I could find current specs. At 5 volts, it draws 100mA with no load and 700ma when stalled. With a stalled motor, the output voltage would likely drop, possibly stopping and resetting the Arduino.
So bottom line is, this supply is marginal, even for one hobby servo in a mechanism that won't stall it. With a larger motor or a heavier load, I don't think it will do the job.

The power module It's like this: https://www.amazon.com/JBtek-Breadboard-Supply-Arduino-Solderless/dp/B010UJFVTU
I know I can use the 4 Servo Motors with it (it was used in the project video).
My question is whether I can power the Arduino together the 4 Servo Motors (In the same place of power through his Vin.), or if I could run out of current for everything and damage something.


text:
Using SoftwareSerial on a Wemos D1 to get data from a GPS Shield
I am trying to use a Wemos D1 R2 to connect to my NEO-6M GPS module. I am able to make the module work fine with an Arduino UNO. I'm having significant trouble with the D1. Based upon other posts I have read here, I have included the appropriate Pins_Arduino.h include file and used the aliased settings. Here is the code I am using:
#include <Pins_Arduino.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>

// The serial connection to the GPS module
SoftwareSerial ss(D2, D3); // Here are the aliased pins
TinyGPSPlus gps;

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

void loop() {
  // put your main code here, to run repeatedly:
  while (ss.available() > 0){

    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      //int value = analogRead(lightPin);
      //Serial.print("Light= ");
      //Serial.println(value);
      Serial.print("Latitude= ");
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= ");
      Serial.println(gps.location.lng(), 6);

      Serial.println(gps.time.value());

      // Hour (0-23) (u8)
      Serial.print("Hour = ");
      Serial.println(gps.time.hour());
      // Minute (0-59) (u8)
      Serial.print("Minute = ");
      Serial.println(gps.time.minute());
      // Second (0-59) (u8)
      Serial.print("Second = ");
      Serial.println(gps.time.second());
      // 100ths of a second (0-99) (u8)
      Serial.print("Centisecond = ");
      Serial.println(gps.time.centisecond());
    }
  }
}

I have ensured that I have the RX and TX pins correct, even reversing them to test the connection. Am I doing something wrong with the pins? Or do I have to just drop seven and punt on the D1 and get an ESP8266 shield for my UNO?
To help explain the ultimate purpose of this project, plan to use an esp8266 based web server to pull geographic based data from other sensors on the board. If I can't get the GPS to work here, I'll need to re-engineer my project.
Thanks. I apologize if this is a duplicate question, but my petrified brain just isn't searching correctly if it is.
Update:
If I use an Arduino UNO, everything works fine. I tried using the WeMos D1 R2 over the weekend and received data for about 5 seconds and then it stopped. I used pins D4 and D5 for RX and TX respectively. I'm not sure if the data was in the serial buffer when I uploaded a new Sketch or if it was actually returned from the GPS.
I'm going to punt on making the WeMos board work for now and ordered an ESP-01S to use with my Arduino UNO. I'm also reaching out to a supplier for assistance on this. Thanks for the help.
I'm going to leave this open for now in case someone else can provide some insight.

what is  <Pins_Arduino.h>? if you select D1 R2 in tools menu, you have the Dx constants. D3 has external pull-up. it could disturb SoftwareSerial. SoftwareSerial of esp8266 doesn't work good in 2.4.x versions

Ah! I am using the 2.4.2 version of the board. Which version would you suggest?

I never used SoftwareSerial with esp8266. I only know from forum and SE about the problems. And I saw some changes for SoftwareSerial in the GitHub repo of the esp8266 Arduino package. Try 2.5 beta version in Boards Manager. And pins D1 D2 (without  <Pins_Arduino.h>)

Post that as an answer. I'll give it a try and accept if it works. As an aside, I only added the Pins... include as a last ditch effort.

try it first. there was other question about SoftwareSerial of esp8266 yesterday without result https://arduino.stackexchange.com/questions/61313/esp8266-to-send-data-to-thingspeak-while-doing-unblocked-read-on-serial-readstri#comment130813_61313

I'd steer clear of D3 (gpio0), D4 (gpio2) and D8(gpio15) unless you know exactly what you're doing and what those pins are for

pins overview https://electronics.stackexchange.com/questions/402066/esp8266-free-gpios-for-relay-switching/404845#404845

does the GPS work over your USB-Serial adapter?

Juraj, post an answer with the Pin Overview. I'll accept it as a co-worker and I just made the bloody thing work. I guess I had to consult a PhD for this to work :)

Wemos board have watchdog to protect the board from infinite loop. Try to add yield() at the end of looping. It will bypass the watchdog. Tell me if it work.

@Madere. How did you make the Wemos work with NEO-6M GPS module?


text:
WaveShare EPaper Display and Adafruit HUZZAH32 ESP32 Feather Board
I'm trying to understand how I could use WaveShare EPaper Display with Adafruit HUZZAH32 ESP32 Feather Board.
With these connections
SDI/SCK -> MOSI
SCK/SCLK -> SCK
CS -> 15
DC -> 33
RST/Reset -> 27
Busy -> 32

and this code
#include <GxEPD.h>
#include <GxGDEP015OC1/GxGDEP015OC1.cpp>    // 1.54" b/w
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <Fonts/FreeSansBold24pt7b.h>

GxIO_Class io(SPI, 15, 33, 27);
GxEPD_Class display(io, 27, 32);

const char* name = "FreeSansBold24pt7b";
const GFXfont* f = &FreeSansBold24pt7b;

void setup() {
  randomSeed(analogRead(0));
  Serial.begin(9600);
  Serial.println("Starting...");
  display.init(9600);
  //display.setRotation(1);
  display.fillScreen(GxEPD_BLACK);
  display.setFont(f);
  display.update();
  delay(2000);
}

void loop() {
  Serial.println("showing randon number...");
  showRandomNumber();
  delay(2000);
}

void showRandomNumber() {
  String randomString = String(random(1, 60));

  uint16_t box_x = 60;
  uint16_t box_y = 60;
  uint16_t box_w = 90;
  uint16_t box_h = 100;
  uint16_t cursor_y = box_y + 16;

  display.setRotation(45);
  display.setFont(f);
  display.setTextColor(GxEPD_BLACK);

  display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  display.setCursor(box_x, cursor_y+38);
  display.print(randomString);
  display.updateWindow(box_x, box_y, box_w, box_h, true);

}

but I don't get any reaction from the display, do you see something wrong in the code or the connections?
thanks a lot for your help
References

https://github.com/dgarrett/BasicEPaperReader
https://danthegeek.com/2019/02/04/iot-calendar-creating-a-custom-featherwing/
https://github.com/juanpabloaj/esp32_waveshare/blob/master/01_update_window/01_update_window.ino

have you tried an example sketch? .... there should be one included with the e-paper library

I tried a similar code with esp32 nodemcu and it works, my problem is with Adafruit HUZZAH32 ESP32
https://github.com/juanpabloaj/esp32_waveshare/blob/master/01_update_window/01_update_window.ino


text:
Programming a servo on an ATtiny85
Board: "ATtiny25/45/85"
Processor: "ATtiny85"
Clock: "Internal 1 MHz"
Programmer: "Arduino as ISP"
I want to run a servo forwards and backwards on an ATtiny85. The servo library is not compatible with the ATtiny85 so I had to write code from scratch. At this point, the code that makes the servo go forwards (clockwise) is:
void setup() {
  pinMode(PB1, OUTPUT);
}

void loop() {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(1000);
  // 1 millisecond determines the servo going forwards
  digitalWrite(PB1, LOW);
  delay(19);
}

And the code that makes the servo go backwards (anti-clockwise) is simply by changing the amount of microseconds to:
delayMicroseconds(2000);

I want to have the servo motor go forwards one cycle for a few seconds and then go backwards for a few. I want this to keep looping. At this point my code is:
void setup() {
  pinMode(PB1, OUTPUT);
}

void loop() {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(1000);
  digitalWrite(PB1, LOW);
  delay(19);
  digitalWrite(PB1, HIGH);
  delayMicroseconds(2000);
  digitalWrite(PB1, LOW);
  delay(19);
}

This however just makes the servo go back and forward at the same spot forever. I do realise I might need a for loop for this but I am confused as how I will do this.

Did you have a try on using 8MHz.

@AllenChak yeah I did try that however, that still doesn't produce the output that i want because I want the servo to spin forwards and backwards in a row rather than separately.

Try this link: https://forum.arduino.cc/index.php?topic=62912.msg459183#msg459183

The servo can't move back and forward in 40 milliseconds. It'll be more like tremble between both.
Try something like this:
// keep sending 0 position for about 400ms
for(int i = 0; i<20; ++i) {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(1000);
  digitalWrite(PB1, LOW);
  delay(19);
}

// keep sending second position for about 400ms
for(int i = 0; i<20; ++i) {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(2000);
  digitalWrite(PB1, LOW);
  delay(18);
}

Hi thanks a lot it really helped and it makes sense too. I just have one question, that delay(19) when changed to delay(20) the servo behaves differently. Why is that delay kept at 19 milliseconds and not something else? thanks again.

The servo expects pulses at 20ms rate (= 50Hz) including High side pulse width.

In trying to find basic code to work a servo, this helped a lot. Thank you!

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


text:
ESP8266 ASyncTCP class example
I am new to ESP programming on Arduino, as before I was developing on eLua. There were some memory problems in Lua, so I decided to move to Arduino.
After looking at some examples, I found a library called AsyncTCP and I was very glad because it provides callbacks for events just like Lua. But I was very disappointed when I found no example of an async TCP server. Instead there is an AsyncWeb Server but I don't want to use an HTTP server: I want a simple telnet server. Does someone have a working example?

There are examples in the ESP8266 library
https://github.com/me-no-dev/ESPAsyncTCP/tree/master/examples

If there are no examples provided with the library then you will have to make do with the example you have :(
If you think about what a web server does it is really just a glorified Telnet server without proper security.  When the web server comes up it creates a waiting socket on port 80, you want port ?? (too long ago).  It sits there waiting for text messages from clients, which is what you want to do.  Every time it receives a message it sends it to a handler.
I don't know how experienced a programmer you are, but you should be able to pick up enough from the webserver code to write your own telnet server.  However with you being new to Arduino you may be much better doing it as a synchronous application to start with.
Another approach is to find a the source for a telnet server and see if you can port that to the ESP.

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


text:
FFT library for Arduino 101?
I am currently trying to get a real-time FFT working for a project on an Arduino 101 which uses the Intel Curie chip. All the FFT libraries (if any) seem to be for the Arduino Uno and architecture dependent (most of them have assembly stuff for optimization).
I was wondering if there is any robust, up do date and most importantly working (with the latest Arduino 101) library. I have tried the PlainFFT library which I read might be compatible with the Arduino 101 (https://forum.arduino.cc/index.php?topic=409791.0).
However this library seems to be out of date, using old extensions of sketch files and old library names in its code (I could not get it to work). Alternatively I wanted to try and tailor a pure C code such as https://github.com/jtfell/c-fft, which seems to have its own Makefile for compilation (this one uses a C99 compiler). I could compile and use this code on a Linux terminal but I am not sure how to go on about making it run inside an Arduino sketch.

I used lightweighted KissFFT (Mark Borgerding) at Arduino Mega and seems it is pure C code so should be running anywhere.

So when I get this library from let's say https://sourceforge.net/projects/kissfft/?source=typ_redirect how do I then use it in an Arduino sketch? Just putting it in the libraries folder and #include it in the sketch (.ino) will not work. What adjustments will I need to make?


text:
mcufriend 2.4 TFT with ESP8266
I have this TFT:

Now, the problem is, I will not use this as a shield (i.e. I will not just put it on top of an Arduino Uno). I will use it with an ESP8266 (NodeMCU). I want to know how to wire them up together. There is this website (and a few more that say the same way). But the problem is I cannot find SDI/MOSI or SDD/MISO on the TFT above.

I also want to program mcufriend 2.4 TFT with ESP8266 did you try it and did it work? can you give me any information? (Library, connection between mcufriend 2.4 TFT and ESP8266)

interessting, did it work on NodeMCU?

You have an 8-bit parallel interface TFT display. It requires 13 GPIO pins - D0-D7 plus reset, chip select, read, write and register select. You can forego the "read" signal and tie it high to save a pin. You can probably do the same with the reset signal, meaning you need a minimum of 11 pins.
I am not sure the NodeMCU has that many available, does it? (maybe it does, I don't have one to hand right now), so you may want to try getting it going with an SPI or I2C IO expander (though slowly).
And then of course you have to find the right library for the chip on the display (there's a few it could be - I have seen at least 3 different ones on the same, or similar, carrier PCB) that works with the NodeMCU.

SD_DI is the MOSI, and SD_DO is the MISO. According to the datasheet.


text:
Very slow to connect to WiFi with ESP32 (minutes, not seconds)
I am having some issues with connecting to WiFi with an ESP32 board. It is very sloooooooooow. The first few times I tried, I left it alone for 20 minutes and it still wasn't able to connect. So I thought it didn't work. So I tried to use MicroPython and ESP-IDF and they both worked, although MicroPython was somewhat slow (~10-20 seconds), but ESP-IDF was instantaneous. Then I went back to Arduino and this time it eventually connected after 260 seconds (> 4 minutes). Another try took 420 seconds (7 minutes). Has anyone else seen similar issues?
What I have tried:

Tried another board of the same model to ensure it's not defective.
Tried a different WiFi AP with the same results.

Although MicroPython and ESP-IDF framework work fine, I am still hoping to stick with Arduino for its simplicity and my hatred for Python, but don't hold it against me if you're fond of it :-).
My board:
ESP-WROOM-32(https://www.amazon.com/gp/product/B0B764963C). In Arduino IDE, I'm choosing "ESP32-WROOM-DA Module". I have also tried "uPesy ESP32 Wroom DevKit" with the same results.
The core version is "esp32 by Espressif Systems" 2.0.11.
My network setup:
TP-Link EAP225, running as a dedicated AP, not a router. My router is Linksys WRT1900ACS running OpenWrt 19.07.2 r10947-65030d81f3.
The other setup I tried is a D-Link DIR-842 running as both an AP and a router, although I didn't connect the upstream port.
My code:
#include <WiFi.h>

const char* ssid = "delingtest";
const char* password = "XxxxxYyyy00";

void setup() {
  Serial.begin(115200);
  Serial.println(millis()); // To time the connection
  Serial.print("Connecting to WiFi network ");
  Serial.print(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  do {
    Serial.print(".");
    delay(5000);
  } while (!WiFi.isConnected());

  Serial.println("done.");
  Serial.println(millis()); // To time the connection
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
}

Additional info:

When I used MicroPython, I connected interactively. Reference: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
For ESP-IDF, I used sample code here: https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station
I checked the log on the DHCP server (running OpenWRT), the time between receiving the DHCP request and offering the IP address was quick (see below).

Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPDISCOVER(br-lan) 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPOFFER(br-lan) 192.168.1.145 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPREQUEST(br-lan) 192.168.1.145 40:22:d8:78:7a:38
Wed Mar 13 16:57:55 2024 daemon.info dnsmasq-dhcp[13394]: DHCPACK(br-lan) 192.168.1.145 40:22:d8:78:7a:38 esp32-787A38

Edit:
I added some code to do a ping to the gateway after establishing the connection:
  IPAddress ip (192, 168, 1, 1);
  bool ret = Ping.ping(ip);

And timed it. Every ping took about 4-5 seconds. So, it's not just slow to connect to the WiFi network, it's also very slow do ping, and probably to do everything else.
Edit on edit:
After turning on verbose logging, I realized that what ping actually does is to the effect of ping -c 5, with 1 second between pings. So, it does take 4ish seconds no matter what. Originally I thought it only sent one ping per call.

Got it. Thanks. It's "esp32 by Espressif Systems" 2.0.11

Welcome to SE/Arduino! Please take the [tour] to learn how this site works, and read some pages of the [help]. Is your comment the solution to your issue? If so, please write an actual answer and mark it as accepted. This is not a forum.

@thebusybee "Is your comment the solution to your issue?" Comments were deleted that would have made it easier for you to see that it isn't an answer to their question. It is a response to being asked for the core version they used, and then having that question about core version explained to them, which is what they then understood ("got it") and then replied with ("2.0.11").

@timemage Then now, after I added this information to the question, where it belongs, that misleading comment can be deleted, too.

That probably should have been done by whoever deleted the comments. Mostly I just didn't want them fighting a re-open over the confusion.

Good you got that figured out but there are lots of hints in the thread at https://github.com/espressif/arduino-esp32/issues/1675#issuecomment-2323495091.

Huh, I just tried a 3rd board and I think I have found the root cause. If the board is inserted in a breadboard. It's slooooooow, or even impossible to connect. But if I pull it out, it seems to connect in a few seconds. So, I guess the problem really is the breadboard interfering with the on-board antenna. I'll probably need to get a 32U with an external antenna connector for the final product.

that's very good troubleshooting ... if the final product does not contain a large metal part, then the external antenna may not be required

Thanks. I'm working on a garage opener, so it'll need to close to the motor which is mounted on the ceiling with angle beams. And the WiFi signal is probably not the best in the house. I'll get the software part figured out first. We'll see.

@DelingRen Not sure if it's an option but if the WiFi signal is no good I like to use Ethernet with ESP32. Olimex makes really nice and affordable boards (ESP32-POE-ISO).


text:
Arduino SerialUSB.print/println is being interrupted by other prints
I have an Arduino M0 connected to a peripheral device.
A PC is connected to the arduino via USB. The mode of operation is that the Arduino receives commands via USB that instruct it to do something with the peripheral device. The data from the peripheral device (a struct) is converted to a JSON string and sent to the PC over USB.
I am using SerialUSB.print();, SerialUSB.println(); to write the JSON data, and then after each part of the JSON message is printed, I call SerialUSB.flush();.
I am noticing that sometimes the next JSON message will "interrupt" the last (the last message will not finish printing before the next starts).
I have already increased my SerialUSB baudrate to the max supported. What are some strategies I can use to ensure that the JSON message is fully printed printing the next?
Here is the relevant code:
typedef struct __attribute__((packed))
{
  uint16_t inner_member1, inner_member2, inner_member3;
  uint16_t inner_member4, inner_member5, inner_member6, inner_member7, inner_member8, inner_member9;
} inner_struct_t;

typedef struct __attribute__((packed))
{
  inner_struct_t i1;
  inner_struct_t i2;
  unsigned long outer_member1;
  uint16_t outer_member2;
  uint16_t outer_member3;
  uint16_t outer_member4;
  uint16_t outer_member5;
  uint16_t outer_member6;
  uint16_t outer_member7;
  uint16_t outer_member8;
  uint16_t outer_member9;
  uint8_t outer_member10;
} outer_struct_t;

void print_inner(inner_struct_t *i)
{
    SerialUSB.print(F("{"));
    SerialUSB.print(F("\"inner_member1\": "));
    SerialUSB.print(i->inner_member1);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member2\": "));
    SerialUSB.print(i->inner_member2);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member3\": "));
    SerialUSB.print(i->inner_member3);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member4\": "));
    SerialUSB.print(i->inner_member4);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member5\": "));
    SerialUSB.print(i->inner_member5);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member6\": "));
    SerialUSB.print(i->inner_member6);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member7\": "));
    SerialUSB.print(i->inner_member7);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member8\": "));
    SerialUSB.print(i->inner_member8);
    SerialUSB.print(F(", "));
    SerialUSB.print(F("\"inner_member9\": "));
    SerialUSB.print(i->inner_member9);
    SerialUSB.print(F("}"));
    SerialUSB.flush();
}

void print_outer(outer_struct_t *o)
{
    SerialUSB.print(F("{\"outer_member10\": "));
    SerialUSB.print(o->outer_member10);
    SerialUSB.print(F(", \"outer_member2\": "));
    SerialUSB.print(o->outer_member2);
    SerialUSB.print(F(", \"outer_member1\": "));
    SerialUSB.print(o->outer_member1);
    SerialUSB.print(F(", \"i1\": "));
    print_inner(&(o->i1));
    SerialUSB.print(F(", \"i2\": "));
    print_inner(&(o->i2));
    SerialUSB.print(F(", \"outer_member3\": "));
    SerialUSB.print(o->outer_member3);
    SerialUSB.print(F(", \"outer_member4\": "));
    SerialUSB.print(o->outer_member4);
    SerialUSB.print(F(", \"outer_member5\": "));
    SerialUSB.print(o->outer_member5);
    SerialUSB.print(F(", \"outer_member6\": "));
    SerialUSB.print(o->outer_member6);
    SerialUSB.print(F(", \"outer_member7\": "));
    SerialUSB.print(o->outer_member7);
    SerialUSB.print(F(", \"outer_member8\": "));
    SerialUSB.print(o->outer_member8);
    SerialUSB.print(F(", \"outer_member9\": "));
    SerialUSB.print(o->outer_member9);
    SerialUSB.print("}");
    SerialUSB.flush();
}

Could you show the code you use (edited into question?)

And if you don't flush() does that improve things?

I see the same symptoms when I remove SerialUSB.flush()


text:
Using an Arduino to rotate a DC motor once a minute (edited)
I’m trying to write an arduino sketch that makes a dc motor turns one full rotation every 60s similar to a clock. The arduino will be connected to the gate of a typical mosfet and the dc motor will be connected to the drain of the mofset  such that the arduino controls the speed of the motor. Any suggestions on how I go about this?
I’m using an arduino mega 2560 in case that’s relevant.

What exactly do you have problems with? Timed things are mostly done via delay() or (better) via millis() (like in the BlinkWithoutDelay example). Have you tried these?

I having trouble balancing the speed and delay of the motor so that it turns one full rotation every 60s.

You can't rotate a dc motor with just an arduino output, as you can't control the acceleration. You need a stepper motor to have a clean 360° rotation. Or an encoder or this sensor: AS5048A to detect the exact position of your motor.

The best way would be to check the datasheet: https://ww1.microchip.com/downloads/en/devicedoc/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdf and set an interrupt on one of the timer.
Example code of this application can be found on this stack here : How to make 1 second delay more accurate?
Another way of doing it if you don't need to do anything between rotation would be to wait by just waiting using delay in a for loop. Be aware that this is less precise than interrupts driven wait.
https://www.arduino.cc/reference/en/language/functions/time/delay/
edit : if you want to complete one full rotation every 60s
int i = 0;
while(1) {
  i++;
  delay(1000);
    if( i == 60){
    doFullRotation();
    i = 0;
    }
}

Sorry my bad, I was not clear in the question. I don’t want it to start turning every 60s, I want it to complete one full rotation every 60s.

oh wait, you mean you want it to rotate one turn over 60 sec? 1 turn per 60 sec?

In that case, you will have trouble with dc motor, since you can't precisely make them turn over a precise angle without feedback from an encoder. Id suggest getting something like a servo or a stepper motor depending on your needs


text:
Streaming integer data from Arduino to Java, integer greater than 0xFF
I need to send how many milliseconds elapsed since the beginning of the time the arduino runs to java using Serial.write(). However, the largest integer that I can throw in there is 255, naturally since the largest 1 byte value we can send is 0xFF.
But if we have an integer like 6000 miliseconds that I want to send into java, how can I do this? I was initially thinking of just checking if the number is greater than 255 then bit shift it by 4 to the left then doing number<<4 & 0xFF00 and also writing (number<<4)>>8 &0xFF
But

that doesn't work for numbers really large and
I believe when I stream these int values into Java they get read as characters...

how do I fix this?
EDIT
I've created a second version as the following
void sendData(int a ){
  while(a>0){
    Serial.write(a&255);
    a = a>>8;
  }
}

on the java side I have to somehow multiply the correct x for 16^(x) to the value that we receive since everything is received backwards I'm not sure if this is the best way to go since we don't necessarily know how many bytes that we'll receive

I'm assuming you will be using the Arduino millis() function for keeping time. The output of the millis() function in the Arduino environment is a 32-bit unsigned integer*.
A 32-bit integer can be split into 4 x 8-bit bytes. To keep things simple you could program the Java receiving side to always expect 4 bytes (or whatever amount you need, see *). Assuming 32 bits is enough, you could use the following:
void sendData (uint32_t uptime) {
    int i;
    for (i = 0; i < 4; i++) {
        Serial.write (uptime & 255);
        uptime = uptime >> 8;
    }
}

On the Java side, you would receive the lowest order byte first, and you could reconstruct the 32-bit value by taking the first received 8-bit value, adding the second value shifted left by 8 bits (=multiplied by 256), adding the third value shifted left by 16 bits (=multiplied by 65536) and adding the fourth value shifted left by 24 bits (=multiplied by 16777216). Java is not my strong point so I will leave that to you.
BTW, is there a particular reason you have to use Serial.write()? It would be much easier to just write the value as a string with Serial.println().
*After 2^32 milliseconds (a little under 50 days of uptime) the 32-bit counter that feeds the millis() function will wrap around to 0. You could keep the amount of times that the timer has overflowed in a separate (integer) variable and make that (i.e. bytes 5 and onward) part of your output.


text:
Combining an NRF24L01 transmitter/receiver with an Adafruit Motor Shield V1?
I'm making a vehicle project as a way to learn Arduino. I've set up motor control for a number of DC-motors plus a servo via an Adafruit Motor Shield V1 that I picked up.
Everything works fine, but now I've started looking at adding wireless control for the setup using a second Arduino and two NRF24L01 wireless units. However, reading up on the specs for the NRF24L01 it seems it requires pin 12 on the Arduino, which is already in use by the motor shield.
So, can I combine a NRF24L01 and an Adafruit Motor Shield V1? And if so, how?
If it's not possible, what would be the pros and cons of slaving the shielded Arduino to a Nano that would carry the NRF24L01, versus replacing the Adafruit motor shield with external DC motor driver(s)?
Edit:
I now found this previous question:
Motor shield and wireless transceiver compete for same pins
A difference in my project is that I'm not using stepper motors, so perhaps that makes a difference?

One of the problems of the Uno is that the hardware SPI pins conflict with some of the PWM pins. If you want lots of motor control then you have it at the expense of no SPI. If you want SPI then you have it at the cost of reduced motor control.
The V1 shield uses a shift register for some of the motor signals, and that has to fit its signals in around the available PWM pins, so that as well has spilled over into the SPI pins (since you can't use SPI because of the PWM pins that really doesn't matter).
So no SPI means no nRF24L01.  Or does it?
You could (though I don't know of any libraries that handle this) use "bit-banged" software SPI on other pins (such as the analog pins) to communicate with the nRF24L01. Your mileage may vary with that, but it is technically possible - as long as you can find (or write) the right software support for it.
Would it be better to throw more hardware at it and have the wireless connection on a dedicated MCU? I would say, yes. Not only does it mean you can use existing libraries to communicate with the nRF24L01 without any worries of conflicting pins, but you get to compartmentalise your software into discrete units that don't interfere with each other. Parallel processing :)
How to communicate between the two? Well, you have I2C available on the analog pins A4/A5, which is well documented and plenty of examples. Or you could use serial, although the 328P's lack of serial ports means that you'd probably be working with SoftwareSerial which is ropy at best.  I'd pick I2C out of those two TBH.