texts:
I’m trying to output 2 separate frequencies using 2 output pins from an Arduino using the Timer 1 library. A snippet of the code is show below.

void setup()
{
 Serial.begin(9600);
 pinMode(button,INPUT_PULLUP);
 pinMode(button2,INPUT_PULLUP);
 pinMode(sig_out, OUTPUT);
 pinMode(sig_out2, OUTPUT);
Timer1.initialize(1000);
Timer1.pwm(sig_out,512,period);
Timer1.pwm(sig_out2,512,period2);
}

The issue is the way I’ve wrote this makes sense as I’ve initialised 2 outputs and 2 inputs but the ‘period’ is getting overwritten as there’s 1 timer and I’m not sure how to stop this. I was thinking about storing them in variables (like 'T1=' 'T2=') but it would still use the same timer.

I just wanted to know if there’s a way to use 2 timers so the Arduino outputs the frequencies separately.


texts: How to build (concat) a string with big numbers

texts:
new to arduino I'm struggling with what sounds like fairly n00b problem...
I've wired up a adafruit GPS-board to my Arduino and it is working as it spits out GPS data to the serial port with Serial.print(GPS.latitude, DEC)

I Now want to concat a string which I can process (read: I want to sent it via an ethernet client.)
This is what I got already:

......
String vnnt = "$VNNT,";

if (GPS.fix) {
   vnnt += "GPS,";

   //this works:
   vnnt.concat(GPS.fix);

   //but this not:
   vnnt.concat(GPS.latitude);

}else{
   vnnt += "INFO,Acquiring Sats";
}

Serial.println(vnnt);

The error message is: Call of overloaded 'concat(float&)' is ambiguous
When I Serial.print(GPS.latitude, DEC) it results in: 4418.5937996050

So it is probably to big or something...

How can I concat the vars and create the long string?


texts:
for unknown reason, my Arduino IDE 1.8.12 stopped starting up ( worked OK before ).

Can anyone share some steps understanding why ?

edit1
after executing ./arduino

guy@desktop:~/arduino-1.8.12$ ./arduino
Picked up JAVA_TOOL_OPTIONS:
Set log4j store directory /home/guy/.arduino15
Gtk-Message: 17:15:18.630: Failed to load module "canberra-gtk-module"
java.lang.NullPointerException
    at cc.arduino.contributions.packages.ContributionsIndexer.parseIndex(ContributionsIndexer.java:134)
    at processing.app.BaseNoGui.initPackages(BaseNoGui.java:483)
    at processing.app.Base.<init>(Base.java:273)
    at processing.app.Base.main(Base.java:150)
guy@desktop:~/arduino-1.8.12$


texts: Arduino: How to get the board type in code

texts:
I want to write a sketch that can be compiled on different Arduino boards.
I want to display on the PC which board is currently connected.

This means that the user connects the PC via USB cable to the Arduino/Teensy board in which runs my sketch and my sketch tells the PC via Serial which board is connected. On the PC runs my C# application which receives this data and displays it.

Therefore I need the board that has been selected when the sketch has been compiled:

I found the code on https://github.com/backupbrain/ArduinoBoardManager
but it does not give correct results (apart from the fact that several boards are missing).

Here a snippet from the code:

static const uint8_t BOARD_MICRO= 0x04;

....
#elif defined(__AVR_Atmega32U4__) // Yun 16Mhz, Micro, Leonardo, Esplora
  static const uint8_t BOARD = 0x04;
  static const uint8_t NUM_BITS = 8;
  static const uint16_t CPU = __AVR_Atmega32U4__;
  static const unsigned long SRAM_SIZE = 2500;
  static const unsigned long EEPROM_SIZE = 1000;
  static const unsigned long FLASH_SIZE = 32000;
#elif defined(.....

So this code gives the same result (BOARD = 0x04 = Micro) for Yun 16MHz, Micro, Leonardo y Esplora.

Is there any way to get in my C code exactly the string that the user has selecetd in the menu of the Arduino compiler?


texts: Chips & High voltage: Connected in Series?

texts:
I have 3 micro-controllers that will be connected to a battery, and I need to provide each of them between 3 and 5 volts maximum.
I have 3V batteries but they do not seem to provide enough power, while putting to of them in series would fry the chips as it busts the 6 volts max.
My question is, if I provide 9 volts to 3 chips connected in series, would current drop be distributed evenly to 3V across all chips, or would for example fry the first one?

simulate this circuit – Schematic created using CircuitLab


texts:
I'm using an AdaFruit CC3000 Wifi shield as an HTTP server with an Arduino Uno.

I have a script which works fine -- logs into my Wifi and listens for connections as it should.

However, I want to use an infrared library which writes to the CC33000 default IRQ 3, so to avoid conflict I change the following setting:

#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!

to the only other Interrupt pin

#define ADAFRUIT_CC3000_IRQ   2  // MUST be an interrupt pin!

The device hangs at "Initializing" .. or at least I see neither of the subsequent lines in the following code on my serial monitor:

Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }

  Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }

I've stripped everything back down to just the example code for HTTPServer to ensure it's not a conflict with my own code or the IR Library. I've changed the setting from 2 to 0 and 1 thinking there was some confusion over literal IRQs vs Pins, but those settings generate the "Couldn't begin" error trap.

Is there any other setting that I need to vary in order to get the CC3000 to opearate on IRQ 2 or is this a hardware bug and I'm out of luck if I want to use Pin 3?


texts: Make one Arduino fire interrupt on another

texts:
Problem

I have an Arduino Duemilanove which needs to communicate with an Ardiuno Mega.  The only pin available on the Duemilanove is D13.  The Duemilanove is in charge of driving state on my robot, and the Mega is in charge of sensor readings and navigation.  The Mega needs to send drive state updates to the Duemilanove.  I2C, PWM, Serial, anything requiring different pins on the Duemilanove is out of the question at this point.

Idea
I plan to have the Duemilanove send the "pipe" pin high, triggering an interrupt on the Mega.  The ISR will send the current drive state to the Duemilanove which will change pinmode and read a digital pulse.  The length of the pulse is the drive state.

Roadblock
I am having trouble finding an example of how to set this up.  I can't get the ISR to fire, and I'm not sure why.

Mega Code

int pipe = 18;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(pipe, INPUT);
  attachInterrupt(digitalPinToInterrupt(pipe), driveStateISR, CHANGE);
}

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

}

void driveStateISR(){

  Serial.println("ISR fired");
  pinMode(pipe, OUTPUT);

  digitalWrite(pipe, HIGH);
  delay(50);
  digitalWrite(pipe, LOW);

  Serial.println("Pulse sent!");

  pinMode(pipe, INPUT);

}

Duemilanove Code

int pipe = 13;

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

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(pipe, HIGH);
  delay(30);
  pinMode(pipe, INPUT);

  unsigned long duration = pulseIn(pipe, HIGH);

  Serial.println(duration);

  delay(3000);
}

Nothing happens at all.  I'm thinking the main framework is here, but since there aren't many examples of this out there I'd love to get some other eyes on the issue.  Thanks!


texts:
I am working on a project where i need to store as fast I can following :

1 - Acceleration on X

2 - Acceleration on Y

3 - Acceleration on Z

4 - timestamp

5 - A value from some other sensor

Because I need to get these as fast as I can I am thinking to not do any calculation while acquire values and just store them for 30 -60 seconds and then when the "test" is complete to compute calculations.
My question is if will be better to create 5 arrays and put these values there or create a matrix and store values there.
I need these values to be stored like they are "connected"
e.g. on reading 1 i get 5 values and put them on array[0] , then on reading 1 and so on
Also an important thing to mention, this will run on a esp32.

Thank you


texts: Is it necessary to set a function with always_inline attribution when the function would work maybe once?

texts:
I'm going through a library for the ILI9488 running by SPI and want to copy this library in my version.
In the beginning of the source file, there's a guard for the SPI_HAS_TRANSACTION that if the library would run in Arduino compiler then it would use the SPI functions, otherwise it should run from another platform SPI libraries.
Library link:
jaretburkett / ILI9488
This is the part of code I have questions about:
// If the SPI library has transaction support, these functions
// establish settings and protect from interference from other
// libraries.  Otherwise, they simply do nothing.
#ifdef SPI_HAS_TRANSACTION
static inline void spi_begin(void) __attribute__((always_inline));
static inline void spi_begin(void) {
#if defined (ARDUINO_ARCH_ARC32)
  // max speed!
  SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));
#else
    // max speed!
  SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE0));
#endif
}
static inline void spi_end(void) __attribute__((always_inline));
static inline void spi_end(void) {
  SPI.endTransaction();
}
#else
#define spi_begin()
#define spi_end()
#endif

My questions:

why the programmer first declare the function in source file not in header file ?
why to use always_inline attribution for a function that's is most the time used once in program file and it's not likely to be used many times during operating time ?
what does this define means ARDUINO_ARCH_ARC32 and where to find it ? I searched in all files in arduino folders and didn't find it. Is it dedicated for fast boards or the usual 16MHz arduino boards ?

Edit:
I want to add another question for the same library.
This function content:
void ILI9488::spiwrite(uint8_t c) {

  //Serial.print("0x"); Serial.print(c, HEX); Serial.print(", ");

  if (hwSPI) {
#if defined (__AVR__)
  #ifndef SPI_HAS_TRANSACTION
    uint8_t backupSPCR = SPCR;
    SPCR = mySPCR;
  #endif
    SPDR = c;
    while(!(SPSR & _BV(SPIF)));
  #ifndef SPI_HAS_TRANSACTION
    SPCR = backupSPCR;
  #endif
#else
    SPI.transfer(c);
#endif
  } else {
#if defined(ESP8266) || defined (ARDUINO_ARCH_ARC32)
    for(uint8_t bit = 0x80; bit; bit >>= 1) {
      if(c & bit) {
    digitalWrite(_mosi, HIGH);
      } else {
    digitalWrite(_mosi, LOW);
      }
      digitalWrite(_sclk, HIGH);
      digitalWrite(_sclk, LOW);
    }
#else
    // Fast SPI bitbang swiped from LPD8806 library
    for(uint8_t bit = 0x80; bit; bit >>= 1) {
      if(c & bit) {
    //digitalWrite(_mosi, HIGH);
    *mosiport |=  mosipinmask;
      } else {
    //digitalWrite(_mosi, LOW);
    *mosiport &= ~mosipinmask;
      }
      //digitalWrite(_sclk, HIGH);
      *clkport |=  clkpinmask;
      //digitalWrite(_sclk, LOW);
      *clkport &= ~clkpinmask;
    }
#endif
  }
}

what I understood from this is that the programmer wants the library to be more versatile to support AVR chips programmer by another IDE than Arduino, also supports ESP8266 and anything else should be handled by softSPI, actually pretty smart coding I guess.
My question here, is does #if defined (__AVR__) checks for either AVR/Arduino in general and when specifies SPI_HAS_TRANSACTION means Arduino SPI library specifically ? right ?


texts: I use Visual Studio 2015 extensively for work, so it would seem like a logical choice for getting started with Arduino programming (though my C/C++ is rusty, that may take some time to get back). From what I understand the Visual Micro Plugin is popular. Is that sort of the de facto choice for those who come from VS? Does it tie into everything so that I can handle debugging, breakpoints, deployment etc from Visual Studio? Much obliged!


texts: Replacing atmega8 with atmega328 on Arduino Single-Sided Serial Board

texts: i want to know that if i use atmega328-pu instead of atmega8 on this design provided by "https://www.arduino.cc/en/Main/ArduinoBoardSerialSingleSided3", will it works fine on this design or i have to use only atmega8 ?


texts: 3.3 V Pro Micro clones flashing LEDs after 1200 bit/s touch

texts:
I have several Pro Micro clones.

This morning I uploaded a sketch into one of them (that was previously unprogrammed, so it stayed in bootloader mode) and when I wanted to upload the sketch a second time, the problem began:

When I now run the reset procedure for Arduinos with integrated USB (open the COM port of the Pro Micro for example in PuTTY at 1200 bit/s and close it again), the LEDs start flashing rapidly and the Arduino disappears from the Windows Device Manager.

Hover for a (slightly annoying) image:

So then I grabbed a second, identical Pro Micro and uploaded the Blink sketch into it. It was also previously unprogrammed. The sketch executed, but when I now do the reset procedure, it exhibits the same behavior now (flashing LEDs).

I can still upload sketches just fine, by setting the COM port to a different (arbitrary) COM port to prevent the reset procedure from reaching the Pro Micro and resetting the Pro Micro manually after starting the upload procedure.

This only happens with the 3.3 V/8 MHz variant, not with the 5 V/16 MHz variant. I have selected the appropriate variant in the IDE.

How can I repair the automatic reset function?


texts: What are ideal delay times between commands for RF24 lib

texts:
Am working on a WiFi based irrigation system that utilises the RF24 lib for comms.
Have got prototype of remote sensor up and running which has a standby current of 0.036mA and transmits data every hour using around a peak of 12mA.
While running the prototype I see various retry attempts which seem to vary with every transmission – despite the setup being under the same conditions all the time. I have coded a retry loop to limit this to 10 tries connecting to the master – don’t want the sensor to continuously be sending without getting a confirmation from the master

What I am trying to find is the ideal delay required between various RF24 commands to limit transmit times as much as possible to conserve power usage.
Any ideas??
(code snippets attached)

   pinMode(mostureSensorVCC, OUTPUT);
   digitalWrite (mostureSensorVCC, HIGH); //VCC to sensor
   pinMode(mostureSensor1, INPUT);      //moisture sensor on
   delay(10);
   int sensorValue1 = analogRead(mostureSensor1); // read the input on analog pin
   Serial.print("Current Value Sensor 1 is : "); // debugging
   Serial.println(sensorValue1); // print out the value you read:
   msg[0] = sensorValue1;
    digitalWrite(mostureSensor1, LOW);
    digitalWrite(mostureSensorVCC, LOW);
      while (message != sensorValue1)
        {

          Serial.print("sensorValue in while loop is "); // debugging
          Serial.println(sensorValue1);                   // debugging
          Serial.print("Message One is ");                // debugging
          Serial.println(message);                        // debugging
          radio.powerUp();
          delay(70);

          radio.stopListening();
          delay(50);
          radio.write(msg, 2);
          delay(40);
          radio.startListening();
          delay(50);

         Serial.println(d);               // debugging

          if (radio.available())
            {
             Serial.println("Radio available");     // debugging
              radio.read(msg, sizeof(msg));
              message = msg[0];
              Serial.print("Check Message received from master ");// debugging
              Serial.println(message);

            }
            if(d>=10)
            {
              Serial.println("Unable to send to master");
              break;
            }
       d++;
  }

delay(1000);
radio.powerDown();
message = 0;
msg[0] = 0;


texts:
Hey guys I have run my example with esp8266 2.4.2 version now I'm getting following error while compiling- C:\Users\Shree\Desktop\FirebaseDemo_ESP8266ex\FirebaseDemo_ESP8266ex.ino:21:29: fatal error: FirebaseArduino.h: No such file or directory #include  ^ compilation terminated. exit status 1 Error compiling for board NodeMCU 1.0 (ESP-12E Module).

I'm trying to run FirebaseDemo_ESP8266 example but getting problem to compile that code. plzzz help me to solve this issue.


texts:
I currently have a setup where I take serial output from Arduino 1 and push it through a transmitter to the receiver of Arduino 2 where it is fed back into the serial input and further processed. I want to ensure that there is as little error as possible and recover the data wherever possible.

I have come across the syndrome decoding technique which seems to be the ideal one for me, but I am confused as to how I would go about implementing it.

I know that the Arduino Serial transfers data byte by byte, each being 8 bits, but do not know how this data is sent over the serial connection (i.e. how the start & stop bits & parity is implemented).

I would assume that a solution to this could either involve modifying the data in the buffer or reading it from the buffer and then operating upon it. I could also use adjacent bytes of data for error correction, but this seems wasteful.

How should I proceed with this?


texts: Term for Two-Channel Analog Switch Module/Digital MUX

texts:
I'm looking for this 16-channel item:

...But just 2 channels. Basically one lead tells if the singal lead should travel down path A or path B. The advantage it has over the 16-channel is that it only needs a single lead instead of 4 to do the switching.

I can't find anything like that, but it seems like it should exist. Is there a term for this?


texts: cannot show free space of SD card with arduino nano

texts:
I'm using a nano v3, the SD module and a 64GB microSD card.
Writing to the card works fine.
But I can't print out the free space left on the card.

I'm using this code:

/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
//#include <SD.h>
#include "SdFat.h"
SdFat SD;

#define csPin 4
File myFile;
SdFat sd;

int startMillis;
int duration;

uint32_t freeKB;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.print("Initializing SD card...");

  if (!SD.begin(csPin)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
  if (myFile) {
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  myFile = SD.open("test.txt", FILE_WRITE);

  for (int j = 0; j < 1000; j++) {
    myFile.println(j);
  }
  myFile.close();
  startMillis = millis();
  ShowFreeSpace();
  duration = millis() - startMillis;
  Serial.print("Took ");
  Serial.print(duration);
  Serial.println("ms to calculate");
  delay(1000);
}

void ShowFreeSpace() {
  // Calculate free space (volume free clusters * blocks per clusters / 2)
  long lFreeKB = sd.vol()->freeClusterCount();
  lFreeKB *= sd.vol()->blocksPerCluster()/2;

  // Display free space
  Serial.print("Free space: ");
  Serial.print(lFreeKB);
  Serial.println(" KB");
}

What am I doing wrong?


texts:
Can someone explain, step by step, along with all software I must use for using Windows command prompt to build an Arduino sketch (.ino file )?

I've followed these steps but I can't.


texts: LED does not blink - Arduino UNO+WiFi R3 ATmega328P+ESP8266 board

texts:
As I am learning the Arduino coding, I want to see if my program can turn on the LED light. I have tried all the things, but the code does not start the LED light I have installed on the board.
The code compiles successfully and upload on the board, but nothings happens after that. See the output logs as below:
See all the configuration of board as below:
The board I have:
UNO+WiFi R3 ATmega328P+ESP8266 CH340G Board compatible with Arduino
https://robocraze.com/uno-wifi-r3-atmega328p-esp8266-ch340g-board-compatible-with-arduino
Board switch settings:
5,6,7 => ON (to upload the code from Arduino IDE)
Yellow LED installed:
13 => Positive, GND => Negative
Board setup:

Arduino IDE Setup:

Program:
void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  digitalWrite(13, HIGH);
  delay(2000);
  digitalWrite(13, LOW);
  delay(2000);
}

Output logs after uploading the code:
esptool.py v2.8
Serial port COM8
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:3e:2e:6f
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 261472 bytes to 193134...
Wrote 261472 bytes (193134 compressed) at 0x00000000 in 17.1 seconds (effective 122.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

As you can see, the last message is Hard resetting via RTS pin....
Would anyone please tell me what is happening here? Why the program does not start the LED light even after everything looks fine?
Any help would be greatly appreciated.
Thanks.


texts: Connecting to the Sparkfun Redboard on Mac OS X Sierra

texts:
I'm trying to connect to my Sparkfun Redboard (Arduino UNO compatible) on Mac OS X 10.12.3 (Sierra). The board comes with a USB mini to USB A FTDI cable. The board lights up and gets power over USB, but I don't see the right USB serial port in the Arduino IDE (I only see the Bluetooth port).

I've installed the VCP FTDI drivers v2.3 to no avail. When that didn't work, I also installed the CH340 CH341 drivers (but I doubt I need those). Rebooting the computer didn't help either.

I can only load the FTDI VCP v2.3 drivers using an explicit command sudo kextload /Library/Extensions/FTDIUSBSerialDriver.kext/. When I run kextstat | grep FTDI, I get:

 155    0 0xffffff7f83892000 0x7000     0x7000     com.FTDI.driver.FTDIUSBSerialDriver (2.3) ECC3AF36-431D-370D-86F2-5237785E9CF8 <127 41 5 4 3 1>

But it still doesn't show up in the Arduino IDE.

I've heard that Apple's own USB FTDI drivers (AppleUSBFTDI) could cause problems, but it seems these are never loaded. If I try to unload the Apple FTDI driver (sudo kextunload –b com.apple.driver.AppleUSBFTDI), I get the following:

(kernel) Kext com.apple.driver.AppleUSBFTDI not found for unload request.

Failed to unload com.apple.driver.AppleUSBFTDI - (libkern/kext) not found.

Any tips are welcome. Thanks!


texts: Stm32 Blue Pill Internal ADC Voltage Reference Configuration

texts: I am programming an STM32F103C8T6 Board in Arduino IDE. I want to change the value of the internal Voltage Reference for the ADC. How can I achieve this in Arduino ide?


texts: Turn led on after ringing once, off after two rings when hung up SIM800

texts:
I'm trying to make something that has one led and a gsm module which is SIM800L, I'm using seeeduino GPRS library.
What I'm trying to do is that when I call the GSM module and hung up after ringing once (about 2 seconds of ringtone) the led turns on, and when I call again and hang up after the second ringing sound (about 5 seconds of ringtone) the led turns off;
Note that the SIM800 module when starts receiving a call it prints on the serial every ringing period (about 2.5sec):

  RING

  {number 0664xxxxx}

then it shows up again telling, 2 times for one rington, 3 times for two ringtons, and when I stop calling the GSM the module prints:

  NO CARRIER

Here's my code as start:

#include <SoftwareSerial.h>
String inData;
char incomingByte;
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8

//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7

//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);

  //Being serial communication witj Arduino and SIM800
  serialSIM800.begin(9600);
  delay(1000);

  Serial.println("Setup Complete!");
}

void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(serialSIM800.available()){
    Serial.write(serialSIM800.read());
    incomingByte = serialSIM800.read();
    inData += incomingByte;
  }

if(inData != "")
   {
     if (inData.indexOf("RING") >= 0) {
      delay(4000);
      serialSIM800.println("ath"); // Hang up at command
      inData = "";
     }
  }

  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){
    serialSIM800.write(Serial.read());
  }
}

I did this code so it hangs up 4 seconds after calling printing the message "RING", but it didn't work, can you please help guys, thanks!


texts: Arduino 3.5" TFT Display going blank after sending data through I2C

texts:
I'm trying to use I2C to send and receive commands between an Arduino UNO R3 and an Arduino Mega R3, with a 3.5" TFT display connected to the Mega. I have verified that my display is fully functional without using I2C by running the MCUFRIEND_kbv graphics tests where they perform exactly as I expect, but when I try to use I2C in combination with the TFT shield, I run into an issue where the display goes completely white and does not change. Could this be caused by the I2C interrupting the tft functions causing it to fail? Any advice would be greatly appreciated!

Here is the i2c code on the mega:

void sendInputs(){
  for(int i = 0; i < NUM_BUTTONS; i++){
    btnArr[i] = digitalRead(btnPinArr[i]);
    Wire.write(btnArr[i]);
  }
  digitalWrite(13, HIGH);
  p = ts.getPoint();
  digitalWrite(13, LOW);
  tsArr[0] = p.x;
  tsArr[1] = p.y;
  tsArr[2] = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  for(int i = 0; i < NUM_TS_INPUTS; i++){
    Wire.write(tsArr[i]);
  }
}

void getDrawData(){
 graphicsBufferSize = Wire.read();
 for(int i = 0; i < graphicsBufferSize; i++){
    graphicsBuffer[i] = Wire.read();
 }
 drawGraphicsBuffer();
}

Where drawGraphicsBuffer(); parses the array of ints into draw functions

The I2C code on the Arduino UNO is:

void sendGraphics(){
     Wire.beginTransmission(slaveID);
      Wire.write(graphicsBufferSize);
      for(int i = 0; i < graphicsBufferSize; i++){
        Wire.write(graphicsBuffer[i]);
      }
      Wire.endTransmission();
      graphicsBufferSize = 0;
    }

void getInputs(){
  Wire.requestFrom(8, NUM_BUTTONS + NUM_TS_INPUTS);
  for(int i = 0; i < NUM_BUTTONS; i++){
    btnArr[i] = Wire.read();
  }
  for(int i = 0; i < NUM_TS_INPUTS; i++){
    tsArr[i] = Wire.read();
  }
}

void loop(){
  getInputs();
  delay(1000);
  if(btnArr[0]){
    screen.addFillScreen(0);
  }
  if(btnArr[1]){
    screen.addCircle(50, 50, 50, 50);
  }
  screen.sendGraphics();
}

Where the screen methods just populate the graphicsBuffer array to be sent to the Arduino mega.

Edit:  Here is the exact screen I'm using


texts:
I am using ATmega8 with 12MHz crystal, on my breadboard. I can use SDA and SCL pins with default arduino library wire.h, and it works. But I want another pins to use I2C protocol.

I tried this library, even on real SDA and SCL pins, but it doesn't work.

I have pull up resistors, I tried with 10k and 4.7k without any success. (But those resistors worked with hardware I2C | TWI)

What am I doing wrong? (All connections is fine, because hardware TWI works but software does not.) Thank you for your help.

(Fuses are ok, because the Atmega won't respond if I remove the crystal oscillator, the LED blinking duration is ok.)

What i want to run (that doesn't work):

#define SDA_PORT PORTC
#define SDA_PIN 4
#define SCL_PORT PORTC
#define SCL_PIN 5

//#define I2C_TIMEOUT 100

#include <SoftI2CMaster.h>

uint8_t ADDR  = 0x68;

void setup(void) {

  Serial.begin(19200);
  Serial.println("Initializing ...");
  i2c_init();

  if (!i2c_start(ADDR | I2C_WRITE)) Serial.println(F("Device does not respond"));
  if (!i2c_write(0x00)) Serial.println(F("Cannot address reg 0"));
  i2c_stop();
}

void loop (void) {
  unsigned int low0, high0, low1, high1;
  unsigned int chan0, chan1;
  unsigned int lux;
  int state1;
  int state2;

  delay(1000);
  i2c_start(ADDR | I2C_WRITE);
  i2c_write(0x00);
  i2c_rep_start(ADDR | I2C_READ);
  low0 = i2c_read(false);
  high0 = i2c_read(false);
  low1 = i2c_read(false);
  high1 = i2c_read(true);
  i2c_stop();
  Serial.print(low0);
}

And the code with hardware TWI that works:

#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}
void setup()
{
  Wire.begin();
  Serial.begin(19200);
  pinMode(13, OUTPUT);
  pinMode(5, INPUT);
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}

Schematic is the same as: https://www.arduino.cc/en/main/standalone.

Except instead of 16MHz, I use a 12MHz and ch210x serial.

Arduino's bootloader works well, I compiled it from source.


texts:
I'm trying to save GPS coordinates to an EEPROM.

In this example I feed it the latitude of 56060066 as the argument float x

void writeFloat(unsigned int addr, float x)
{
  byte seriesOfBytes[3];
  *((float *)seriesOfBytes) = x;
  // Write all four bytes.
  for(int i = 0; i < 4; i++)
  {
    i2c_eeprom_write_byte(0x57, addr, myFloat.bytes[i]); // Write byte to EEPROM
    Serial.println(seriesOfBytes[i],BIN);  // Debug line
  }
}

I'm expecting to receive the following four bytes from the serial print:

00000011
01010111
01101000
10100010

Instead I'm getting these:

00101000
11011010
01010101
01001100

I've tried changing all sorts of parameters, but can't seem to find the problem. Can anyone spot the issue?


texts: What are the tools that I need to program the Arduino in C?

texts:
The Arduino IDE by default is oriented towards C++. The linker for example requires .cpp files and not .c files, otherwise it leads to errors during the linking process. See name mangling if you want to know more.

So, what are the tools that I need to setup a C environment? Can this be done from the Arduino IDE itself?

I work on a Linux system (Ubuntu 12.04).


texts: How to fix: Invalid conversion from 'const char*' to 'char*' [-fpermissive]

texts:
I'm trying to upload the code from here to work with an ESP8266. So I copy/pasted the code to the Arduino IDE and I get this error:

  C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:79:9: error:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)' [-fpermissive]

  int begin(char* ssid, const char *passphrase);
         ^

  exit status 1
  invalid conversion from 'const char*' to 'char*' [-fpermissive]

Can anyone help me with this?


texts:
I recently purchased Bluno Beetle (basically a smaller Arduino with a BLE chip). It is based on the Bluno: Wiki I know that its Bluetooth Chip, the TI CC2540, supports the Broadcast mode: Official page

However I can't find any AT commands that would allow me to set it to this mode, does anyone of you have an idea? I am trying to relay the messages they are sending (sensor readings), essentially building an interconnected network.


texts: Increasing number of iterations not increasing time

texts:
I am using Arduino Uno with Atmel Atmega328. I am using micros() function in Arduino IDE to measure time taken for execution. Here is my code:

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

void loop() {
    unsigned long a = micros();
    for (unsigned long j = 0; j < 100; ++j);
    Serial.println ((micros() - a));
    delay(1000);
}

The output comes as 4. But if I increase the number of iterations in the for loop to say around 1000000000 it still shows that for loop takes same time of 4. Is there a function which I can use to measure time properly in arduino?


texts: switching two relays without delay using millis

texts:
I have an Arduino-uno and two relays. Each relay has two switch on for two seconds at regular intervals.
total loop time relay 1 and relay2 is 1800 seconds.
relay 1 - 2 on,360 off,2 on,600 off,2 on,430 off,2on,402 off.
relay 2 - 12 off, 2 on, 358 off, 2 on, 606 off, 2 on, 478 off, 2 on, 338 off.
Can somebody help me on a code for this please.


texts: How can I enable the security bit of a teensy board?

texts:
I want to prevent someone from connecting an arduino device to a computer and downloading the code (yes, the hex-dump code) because I want to embed a wifi password inside a device that should be kept secret

With that said, I stumbled upon this answer that mentions a security bit

I would like to ask for more details regarding it - i.e. how can I use it, enable it, what are it's limitations, etc. (Preferably for a Teensy v3.2 board, but if it's standard/generic, I would accept such an answer as well).


texts: Can the Arduino Due be used as a serial to USB converter?

texts: The Arduino due exclusively runs on 3.3V, so I am wondering if this can be used as a USB to serial converter just like the Arduino Uno could, or do you need to do level shifting?? Will I ruin the board if I just hook up RX and TX to a 5v device?


texts: Serial input values only working for very short seconds

texts:
I just made a very basic circuit with a LED and a resistor. I also wrote a program that's supposed to take an input for how long to keep the LED on for. It works fine for shorter times like 10 seconds but as soon as I try to input a time like 120 seconds the LED never turns off.
My code's below. What could be wrong?

int light=9;

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

void loop() {
  Serial.println("How long do you want the light on for (in seconds)?");
  while(Serial.available()==0){}
  int on_time = (Serial.parseInt() * 1000);
  digitalWrite(light, HIGH);
  delay(on_time);
  digitalWrite(light, LOW);
  Serial.print("The light was just on for ");
  Serial.print(on_time/1000);
  Serial.print(" seconds. ");
}


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

texts:
I'm using an arduino UNO, and i want to turn a motor a set number of revolutions, i'm trying to read the clicks of the encoder which has a resolution of 360 clicks/ revolution, my logic is that i count the number of clicks until i get to the desired number which represents the the number of revolutions * the resolution of the encoder:

1 revolution ==> 360 clicks
5 revolutions ==> 360*5 (desired number)

i'm a beginner with arduino so here is my code:

volatile int counter=0;
int motor=5;  // motor is connected to pin 5

void setup(){
  pinMode(motor,OUTPUT);
  attachInterrupt(0, count,RISING); // attaching encoder on interrupt 0
}

void loop(){
  while(counter< 360*5){
    analogWrite(motor,255);
  }
}

void count(){
  counter++;
}

This code is not working at all, how can i fix it?


texts:
With reference to the Arduino Uno, Mega2560, Leonardo and similar boards:

How does SPI work?
How fast is SPI?
How do I connect between a master and a slave?
How do I make an SPI slave?

Please note: This is intended as a reference question.


texts: The arduino can't seem to output correctly

texts:
i am a beginner at python and I am average at Arduino and I had the idea of using both of them together for a project. I have been trying to make a Arduino + Python car which I can control with my computer. I have used Pyfirmata and the code seems perfect to me. When I run the code from CMD i have a weird bug/issue.
I have uploaded Standard Firmata to the arduino UNO. I get no errors while uploading or running its just that its output is messed up.

Here's the Python Code:

from pyfirmata import Arduino, util
import time

board = Arduino("COM3")

MotorLeft = board.get_pin('d:10:o') # Assigning output to PIN
MotorRight = board.get_pin('d:11:o') # Assisging output to PIN

play = True

while play:
    control = input(
        print("Enter W, A or D to move forwards, left or right. Enter 0 to exit"))

    if control != 0:
        if control == "W" or "w":
            MotorRight.write(1)
            MotorLeft.write(1)
            time.sleep(1)
            MotorRight.write(0)
            MotorLeft.write(0)

        if control == "A" or "a":
            MotorLeft.write(1)
            time.sleep(1)
            MotorLeft.write(0)

        if control == "D" or "d":
            MotorRight.write(1)
            time.sleep(1)
            MotorRight.write(0)

        else:
            print("Invalid Commmand")

    else:
        print("Exited Succesfully")

    play = True

Currently I have not built the car, I am using a pair of LEDs to do what the motors function and to test out the code.

Heres the CMD response:

Here is the link for the output video. I entered "W" which should ideally turn on both of the LEDs however, both of them turn on then off and then turn on off one by one.

https://youtu.be/DjUkkpzF0so


texts: Following on ESP8266 Board pins, how do they map on the motor shield?

texts:
Here is the answer: All pins corresponding to the G row are connected to ground. All Pins corresponding to the V row are connected to NodeMCU's 3V3 pin.

D row pins tagged from 0 to 8 correspond to NodeMCU's D1-D8 pins. D row pins tagged with SD2, SD3 corresponds to NodeMCU's SD2, SD3 pin
UTART/SPI section:

Tags corresponding to the pins are self explanatory.
Near the white-colored power switch we have a pin called "AD". I couldn't figure how this motor shield's "AD" pin is interfaced to NodeMCU. Do you have any idea?

Following on Basic Question - ESP8266 Board Pins, I can't seem to map the pins on its motor shield to software (the ones named UART/SPI, the GPIOs and the Analog Inputs). See the third image, with a NodeMCU installed.

The GPIOs seem to conflict with the motors on Arduino, and I have no idea what to do here. Documentation is pretty much useless.


texts: avrdude: stk500_recv(): programmer is not responding, arduino pro

texts:
I'm trying to upload a sketch to upload the blink sketch to an arduino pro using a SparkFun Serial Basic Breakout (on Ubuntu 18.04).
setup
Within the arduino IDE I have the following set-up:

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

I have connected:

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

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

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

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

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

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

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

SparkFun Serial Basic Breakout - CH340C and USB-C


texts: Where can I find the complete list of Arduino Serial Command & Query Strings?

texts:
I am planning to use the Arduino as a replacement for a USB-Controlled Digital I/O device, which will be integrated into an existing C++ software package that I created. I understand that the Arduino acts like a Serial device to a PC. Every serial device can be controlled by its own set of commands and queries. However, the only commands and queries that I've found for the Arduino involve flashing one-time programming to it from the "inside" rather than providing real-time automated control from the "outside."

Can anyone tell me where can I find the complete list of Arduino serial command & query strings? Thanks.


texts: Can you put Ardupilot on any flight controller?

texts: Some FC's say that they support cleanflight and have no mention of Ardupilot. Is this just because its what's recommended or because it's all that works?


texts: "return" not working to break out of a loop

texts:
I'm fairly new to this, and I haven't been able to find any answers after searching repeatedly.

I have a Startscreen() function that I run during my setup sequence, and within that function i use various while loops and if/else conditionals. This function runs the startup screen of my program on my touch screen.

Well, when certain conditions are met inside a switch case, inside a while loop, I want to load my main screen and then immediately stop the whole Startscreen() function, like this:

LoadMainScreen();
return;

However, I end up seeing my main screen load up, and then my Startscreen() function continues!

Apparently, "return;" does not work as advertised. If I wanted to break out of the current loop, I'd use "break;", right?

So my question is, does it matter that I'm using return; inside a while loop, inside a switch case? How do I exit the whole top-level function completely?

I already tried breaking out of the function and going straight to my main loop this way:

LoadMeasScrn();
loop();
return;

and the same thing happens.

So here's (most of) my entire code:

//////////REMOVED/////////THANKS FOR YOUR ANSWERS/////////////


texts:
Doing a little project for work and trying to get the Arduino hooked to an RC car to read the throttle channel output and send that via bluetooth to a nearby laptop which will output an animation based on that speed.

Initial test worked very well and signals from my airplane Tx were solid with very little variance. Once the proof of concept worked, we went ahead and purchased a Traxxas car. I have a wire going from pin 5 to the signal wire on the Rx. With the serial monitor up and arduino powered via my usb cable, the #s jump from the 1400 (where its supposed to be) to 6000 and sometimes 11000.  Even more interesting, is when I engaged the throttle via the transmitter, values went down to 30-50...?? I removed the Rx from the car and powered it via the 5v on arduino...#s are solid.

So, it appears the battery or esc is giving a lot of interference. Do I need to use a different kind of wire? If so, what kind of wire? Or ground it somehow?


texts:
Hello programmers out in the world.
I am doing a capstone project for an RF sniffer to capture RF signals from Key fobs within an OEM manufacturing plant. I want to be able to decode this RF signal to show me what the battery state of the key fob is. I have the protocol, so I know what data I should be receiving. However, I have tried many libraries on the Arduino UNO and none have worked.
This Key fob specs are FSK modulation. Frequency of 433 Mhz, Bit rate -> 9.6Kbit/s, baud rate of 19.2Kbaud/s and coding is manchester.
Any help would be greatly appreciated.


texts: cannot open source file "WProgram.h" in VSCode

texts:
So I started typing out this question, but in the process of taking screenshots and looking up sources for the question I figured out the answer :P
That said, this problem has been a snag for me for a while and I've asked multiple people about it with no solution. Because it seemed kind of daunting for me and I haven't seen many well explained reasons I figured I'd finish out the post here to help anyone that is running into this or will run into it in the future.

The snag
I'm using vscode for my editor and I've had this snag for a while but it's finally driving me nuts enough to ask for help.
When in include certain libraries I get error squiggles under the include.

In this case the squiggle is popping up because of the error:

cannot open source file "WProgram.h" (dependency of "Adafruit_MPR121.h")C/C++(1696)

At first I though the snag was because my include path needed my arduino libraries directory so I added that for the project, but I still get the snag.

I did a computer wide search for the WProgram.h file but was not able to find it.

The thing is, all of my sketches still compile and upload fine so for the most part I'm just able to ignore it ... but the squiggle!!!!!!.
Any ideas of how I can resolve this?


texts: How to split a binary data to form two split binary data?

texts:
I want to split a received binary data into two binary data.

Take the following received binary data for instance:

uint32_t data = 0xFFFF0001;

In binary format it is: 11111111111111110000000000000001

If we need to split this above binary into two new binary data how could it be done?

As an example from the 0xFFFF0001, how can we obtain the first 17-bit as as data1 = 11111111111111110 and then the remaining 15-bit as data2 = 000000000000001 ?


texts: Looking to interface height and weight sensor based on I2C Protocol

texts:
I have interfaced a height sensor and a weight sensor. The I2C address of the height and weight sensors are 0x29 and 0x2A respectively. I have merged the example of both the sensors.
This is the first time I am working with I2C and need help on this.
Do let me know about any mistakes or any sort of example which can help me to learn coding different I2C addresses, sensors, and interfacing.
#include <Wire.h>
#include "SparkFun_VL53L1X.h"
#include "SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h"

NAU7802 myScale;
SFEVL53L1X distanceSensor;

//Optional interrupt and shutdown pins.
#define SHUTDOWN_PIN 2
#define INTERRUPT_PIN 3

void setup() {
  Serial.begin(9600);
  Wire.begin(0x2A);
  if (myScale.begin() == false) {
    Serial.println("Scale not detected. Please check wiring. Freezing...");
    while (1);
  }
  Serial.println("Scale detected!");

  Wire.begin(0x29);
  if (distanceSensor.begin() != 0) { //Begin returns 0 on a good init
    Serial.println("Sensor failed to begin. Please check wiring. Freezing...");
    while (1) ;
  }
  Serial.println("Sensor online!");
}

// put your setup code here, to run once:

void loop() {
  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  while (!distanceSensor.checkForDataReady()) {
    delay(1);
  }
  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.clearInterrupt();
  distanceSensor.stopRanging();

  Serial.print("Distance(mm): ");
  Serial.print(distance);

  float distanceInches = distance * 0.0393701;
  float distanceFeet = distanceInches / 12.0;

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);

  Serial.println();
  if(myScale.available() == true) {
    long currentReading = myScale.getReading();
    Serial.print("Reading: ");
    Serial.println(currentReading);
  }
}


texts: Shortest time interval that Arduino Uno R3 can read

texts:
I am doing a light speed determination experimsmt. Lightspeed is around 3*10^8 m/s. For this, I need to measure time interval between 2 light sensors in nanoseconds, Somewhere about 50ns. Is this possible using the Uno R3? I know the clock is 16MHz only but is the clock irrelevantto the topic? If it is not possible, Some tips would be helpful. Thank you.

Sorry for irrelevant tags. No suitable tags found.


texts: ESP8266 EEPROM seems not working, saved data are different when I try to read them

texts:
I'm working on project which require to save some data into the EEPROM.
As I read online the ESP8266 has no real EEPROM, it use a section of FLASH just after the SPIFFS. Due to this read/write is quite different from standard Arduino, you need to call EEPROM.commit(). You also have to call EEPROM.begin(size) (I used size = 512) before start to use it.

I follow different tutorials online and I made some tests but it seems not working at all. When I try to save a value and then read it, values are different. I tried with

EEPROM.write(..)
...
EEPROM.read(..)

and with

EEPROM.put(..)
...
EEPROM.get(..)

but nothing change.

Is there any configuration on the board I need to set into Arduino IDE/Board Configuration?

EDIT: here's the code

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

    EEPROM.begin(512);
    EEPROM.write(0, 62);
    EEPROM.write(10, 103);
    //EEPROM.commit();
    EEPROM.end();
    Serial.print("Read at 0:"); Serial.println(EEPROM.read(0), DEC);
    Serial.print("Read at 10:"); Serial.println(EEPROM.read(10), DEC);
}

I always read 0 in the output.


texts:
When pushing a button I want to read the value...once.
If I push(hold) the button I get a continuous print of button1Pushed
    if(button1State == LOW) {
     Serial.println("button1Pushed");
  }

But if I try to solve it like this, nothing happens, not a single print. What am I missing?
 int button1State = digitalRead(button1);
  int lastButton1State;

  if(button1State != lastButton1State){
      if(button1State == LOW){
        Serial.println("button1Pushed");
               }
        }

  lastButton1State = button1State;


texts: How would one send radio signals from Arduino at a non-standard frequency

texts:
TL;DR: How would one send a fixed radio signal at 447,54MHz with Arduino?
Background: I recently purchased a (receive only) SDR and recorded my garage door fob. I found it sends a fixed signal at the frequency 447,54MHz, which I was able to decode. Now I want to try activating the garage door via Arduino. The standard 433MHz senders obviously don't work, since they have a totally different frequency.
I tried searching for senders of my frequency (447MHz) and also for senders with different or variable frequencies. I didn't really find much. Also I read in some post (that I don't remember currently), that building an own sender circuit is not easy (since the exact PCB design plays a big role in the behavior in the ciruit). It didn't seem, that this would be a valid way for me.
Has someone here experience with such frequencies? While I know, that this site doesn't do product recommendations, maybe I just searched for the wrong term and you can help me with that. Or maybe there are no (or very very few) "maker-ready" products for this out there currently. Maybe the creator of the garage door system wanted a non-standard frequency for security-through-obscurity (since that doesn't protect against attackers with a sending SDR).
Also I researched about frequency bands. Normally I would think of a garage door fob as a Short Range Device (SRD), but instead my frequency is right above (and outside) of the band PMR. Maybe this is because the system is really old (can easily be between 15 and 30 years).
I'm kinda lost on how to proceed here, or if proceeding is even viable here.


texts: 12V 28BYJ-40 motor is not generating enough torque

texts:
I am attempting to use a stepper motor to rotate one of my split-flap displays. However despite the thing the motor is rotating weighing probably half a pound, it struggles to do so. It really can rotate the module at all.
Why is my motor struggling so much?
My circuit is an Arduino powered by 5V from a wall outlet, connected to a ULN2003 driver that is powered by a 12V wall outlet. The driver is connected to the stepper motor.
This is my code, it uses the Accel stepper library:
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <Stepper.h>

AccelStepper stepper2(AccelStepper::FULL4WIRE, 4, 5, 6, 7);

void setup()
{
    Serial.begin(9600);
    pinMode(0, OUTPUT);
    pinMode(1, OUTPUT);
    pinMode(A0, OUTPUT);
    pinMode(A1, OUTPUT);
    pinMode(A2, OUTPUT);
    pinMode(A3, OUTPUT);
    pinMode(A4, OUTPUT);
    pinMode(A5, OUTPUT);

    stepper2.setMaxSpeed(100);
    stepper2.setAcceleration(10);
    stepper2.moveTo(-24000000);

}
void loop()
{
    // Change direction at the limits
    //printletters();

    if (stepper2.distanceToGo() == 0)
        stepper2.moveTo(-stepper2.currentPosition());

    stepper2.run();
}

Edit: Here is the schematic, I'm sorry its terrible but I dont know how to make it better

simulate this circuit – Schematic created using CircuitLab


texts: Sending MIDI CC to multiple midi Channel

texts:
Hi so i would like to send CC messages to different MIDI Channel (volume control). The CC messages are coming from one knob.

The solution i found kind of work but i'm pretty sure is not ideal and seems to introduce drift or lag: the volume isn't getting the same value from one channel to another.

My question is: is there a better way to do it than what i have done.

I use and tweak the following exemple provided in the Teensy Exemple library "USB MIDI AnalogControlChange Example"

The exemple was using this line of code to send CC (controlChange) to a specific channel:

MIDI.sendControlChange(controlNumber, controlValue, channel);

As i wanted to have multiple target channels for the third parameter i tried things like this:

MIDI.sendControlChange(controlNumber, controlValue, 1-2-3);

or

MIDI.sendControlChange(controlNumber, controlValue, (1,2,3));

or

MIDI.sendControlChange(controlNumber, controlValue, 1+2+3);

But it didn't worked. I didn't find in the documentation if this parameter could accept more than one number.

What worked is to multiply analog read of the same knob and multiply the sent message. It's not elegant (i'm new to programing of course) but also i noticed i strange latency or drift if you will: the volume of the channel did went from 0 to full volume but the one on channel 2 didn't go to zero, so the purpose failed. The idea here is to have all the midi channels (1 to 8) but the 11 to be affected by the volume knob.

Hope you can help, in advance, thanks

    /* USB MIDI AnalogControlChange Example

   You must select MIDI from the "Tools > USB Type" menu
   http://www.pjrc.com/teensy/td_midi.html

   This example code is in the public domain.
*/

#include <Bounce.h>

// the MIDI channel number to send messages
const int channel = 11;

// the MIDI continuous controller for each analog input
const int controllerA9 = 1; // param 1
const int controllerA8 = 2; // param 2
const int controllerA7 = 3; // cutoff
const int controllerA6 = 4; // reso
const int controllerA5 = 16; // volume (for channel 11)
const int controllerA4 = 16; // volume (for other channels exept 11

void setup() {

}

// store previously sent values, to detect changes
int previousA9 = -1;
int previousA8 = -1;
int previousA7 = -1;
int previousA6 = -1;
int previousA5 = -1;
int previousA4 = -1;

elapsedMillis msec = 0;

void loop() {
  // only check the analog inputs 50 times per second,
  // to prevent a flood of MIDI messages
  if (msec >= 20) {
    msec = 0;
    int n0 = analogRead(A9) / 8;
    int n1 = analogRead(A8) / 8;
    int n2 = analogRead(A7) / 8;
    int n3 = analogRead(A6) / 8;
    int n4 = analogRead(A5) / 8;
    int n5 = analogRead(A4) / 8;
    int n6 = analogRead(A4) / 8; //i duplicated this to be able to have a different channel target
    // only transmit MIDI messages if analog input changed
    if (n0 != previousA9) {
      usbMIDI.sendControlChange(controllerA9, n0, channel);
      previousA9 = n0;
    }
    if (n1 != previousA8) {
      usbMIDI.sendControlChange(controllerA8, n1, channel);
      previousA8 = n1;
    }
    if (n2 != previousA7) {
      usbMIDI.sendControlChange(controllerA7, n2, channel);
      previousA7 = n2;
    }
    if (n3 != previousA6) {
      usbMIDI.sendControlChange(controllerA6, n3, channel);
      previousA6 = n3;
    }
    if (n4 != previousA5) {
      usbMIDI.sendControlChange(controllerA5, n4, channel);
      previousA5 = n4;
    }

    if (n5 != previousA4) {
      usbMIDI.sendControlChange(controllerA4, n5, 1);
      previousA4 = n5;
    } // 1 here is the channel who's different from the int channel = 11

     if (n6 != previousA4) {
      usbMIDI.sendControlChange(controllerA4, n6, 2);
      previousA4 = n6;
    } // 2 here is the channel who's different from the int channel = 11

  }

  // MIDI Controllers should discard incoming MIDI messages.
  // http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
  while (usbMIDI.read()) {
    // ignore incoming messages
  }
}


texts: WifiClientSecure connect returns 0 ( fail ) except for www.google.com which connects

texts:
So to wile away the long lockdown and curfew hours I decided to get out a stack of Wemos D1 mini ESP8266 boards and build simple indoor temperature and humidity sensors ( using an SHT30 and feeding the data into Graphite or Influx ). I'm using the WifiClientSecure library but its connect() function returns 0 ( false/fail ) every time I try this except when I connect to www.google.com. I've tried connecting to various other servers, both port 80 and 443 but they all fail. I can connect to all of these server absolutely fine from my network so it's not a firewalling issue. The D1 does get an IP and has DNS ( in fact, in my full sketch I'm using NTP with pool.ntp.org and that works fine ).
I've created a simple test ( https://gist.github.com/mkraats/1d1b11691c179793c799fcbb21e5debe ) with just the connect to WiFi and connect() but I still get the same results.
This code:

    char servername[]="www.google.com";

    int connectval;
    connectval = client.connect(servername, 443 );
    Serial.println("...");
    Serial.println(connectval);
    Serial.println("...");
    delay(12000);

}

Works fine while this:
void loop() {

    char servername[]="graphite-us-central1.grafana.net";

    int connectval;
    connectval = client.connect(servername, 443 );
    Serial.println("...");
    Serial.println(connectval);
    Serial.println("...");
    delay(12000);

}

Does not. What stupid mistake am I making that I am not seeing? :-)


texts: How to verify that my FTDI bridge for ESP8266 is communicating with my PC?

texts:
As I couldn't make my ESP8266 be programmed using an Arduino board as FTDI bridge, I decided to buy an FTDI232 board to upload code directly to ESP module via USB. However, when new I connected it to my PC and nothing happened, no new device's notification, not listed on Device Manager; then I downloaded the chip and VCP drivers, installed them, and it keeps not communicating and not even showing its port as busy at Arduino IDE. Actually, I just disabled driver signature enforcement, repeated the process but communication between FTDI and PC keeps dead.

By testing uploading code to an Arduino Micro via FTDI (no USB connected to Micro), I checked Tx/Rx signals with an oscilloscope and both were not responding.

May it be a problem of communication PC<--->FTDI board? Or could it be that FTDI's chip is fried?

Thanks.


texts: Relay starts trigger about 6 times when connecting arduino to laptop

texts:
I have a fairly simple code to turn a relay on-off every 2 seconds
When i attach the USB of the arduino Uno to the laptop, it goes into a frenzy and the relay triggers on off for 6 times within 3-4 seconds and then it settles down.
This however doesnt happen when connecting directly to the power output.
Is there something that needs to be wired to stop this happening ?
I am using an arduino Uno with a relay JQC-3FF-S-Z connected directly to the arduino pins.
const int ONOFF_TRIGGER_PIN = 2;

void setup() {
  // put your setup code here, to run once:
  pinMode(ONOFF_TRIGGER_PIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(ONOFF_TRIGGER_PIN, LOW);
  delay(2000);
  digitalWrite(ONOFF_TRIGGER_PIN, HIGH);
  delay(2000);
}


texts:
I am doing a simple circuit with a 12V power supply to power a 12V LED strip. I'd like to be able to switch ON/OFF the strip with a relay connected to my Arduino. I'd like to know if I can power my Arduino directly from the VIN pin using 12V source. I saw that the Arduino can support up to 12V.

Thank you in advance for the help.


texts: What is the difference betwen “ESP8266Wifi.h” and “WiFiEsp.h” libraries?

texts:
I'll start a project using NodeMCU V3 WiFi Module, which uses esp8266 chip. However, I am undecided as to which library to use. I don't want use a serial bridge with an arduino, I think it is better to use NodeMcu in Standalone mode.

So, here's my question: which library should I use? And, regarding the type of use, what is their difference? (both libraries reference looks like the same for me)

p.s.: I also heard about the "WiFi.h" library. Does it work only on WiFi shields for arduino or does it also work on esp8266?


texts: Arduino Nano -- cannot download, no /dev/tty*** device

texts: It appears to me that each Arduino has (should have?) a unique /dev/tty...USB... number assigned. Why this isn't explained anywhere (that I can find) is a mystery. When I plug my problem Nano into a USB port on my iMac no /dev/tty... for it appears. It used to work. Have I fried it? Can this be fixed?


texts: Controlling water temperature accurately

texts:
I have following setup:

Arduino Duemilanove
Small water heater connected with optical relay (PWM is ok)
Waterproof DS18B20 temperature sensor
Unknown amount of water (but temperature sensor and heater are always underwater).

How can I accurately control water temperature, based on temperature sensor readings? By accurately, I mean up to accuracy of temperature sensor (in this case, ±0.5°C). Everything should run on Arduino, so no additional data storage or processing power is available. For debugging, I can obviously use computer.

I have tried running PID, but it seems really hard to

Avoid overshooting - going over target temperature either initially, or when (cold) water is added
Stabilize properly after adding cold water.


texts: Can anyone recommend a breadboard for the new Arduino 101?

texts:
I just got an Arduino 101 board. I was told that it's practically the same as the UNO. But have no experience using the UNO and I've only done super simple things on the 101 board without using a bread board.

What I want to do is have 2 servos connect to the board. I've only connected one servo without using a breadboard. I've looked on Instructables.com and other places that connect at least 2 to up most 12 servos. They all use different breadboards without specify if the brand, model, or if size even matters. I don't know how breadboards work and which holes I plug the wires into. Furthermore, I haven't found any videos on people working on the 101 board.

Next, I'm not sure if the servos will share the same volt port. There's only 3V and 5V on my Arduino 101 board. If they all need 5V, I'm not sure how to make both servos share. I don't know how they will share the same ground port as well. I know for sure, they will have their own analog port.

A list of recommendations would be nice. Thanks.


texts:
I just got an Idea of trying to code rain simulation with arduino and Adafruit OLED display. When I finished it was quite messy code so I thought That maybe doing it Object Oriented would help. This code is just a sketch that MAYBE works. The thing is that I need to create an array of objects(drops) and then display them. I have tried to display just one drop and it does not seem to do anything, even Serial wont print the pos_y. I have never wrote an Arduino code with objects so I just made a quick research and tried. here is the code:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

class Drop{
  private:
  int pos_x = random(0, 128);
  int pos_y = random(-5, -20);
  int len = random(3, 7);
  int speed = random(6, 13);
public:
 void fall()
{
 display.drawFastVLine(pos_x, pos_y, len, 1);
 pos_y = pos_y + speed;
 delay(5);
 Serial.println(pos_y);
 display.display();
 display.clearDisplay();
}

};

Drop* drop = new Drop[50];

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
}

void loop() {
  drop[1].fall();
}

I will appreciate any suggestion or solution, spent almost entire day doing this "simple thing"..


texts: How to receive more than 64 bytes on Arduino?

texts:
I am receiving about 90 bytes on the serial port. But Arduino has a serial buffer of 64 bytes only. Because of this limitation I am unable to receive further bytes.

char c;

void read_response() {
  while(Serial.available > 0) {
    c=Serial.read();
    Serial.print(c,HEX);
    Serial.print(",");
  }
}

I tried using the above function to read the serial data, but it is able to read only 64 bytes.

Another approach I tried as follows:

char rxdata[]={};

void read_response() {
  while(Serial.available > 0) {
    int len= Serial.readBytes(rxdata, 90)
  }
}

With this approach too, I was receiving only 64 bytes.

Serial.flush() also doesn't work as it waits for current transmission to finish. And I do not have control on transmission. The transmitter is sending 90 bytes continuously.

Please give me some suggestions.


texts: Arduino Mega: which Digital pins are already used for something?

texts:
I got an Ethermega, and learned that Pin 13 already has a LED.

Are there other digital pins with special circuitry or already allocated to a specific function? (like usb,serial,ethernet,sd, etc)

I need about 30 inputs so I can skip some if that would avoid headaches.


texts:
I'm trying to get the Arduino IDE (1.8.13) installed on MacOS BigSur 11.0.1 and am unable to compile and run an Arduino sketch. There are no ports available in 'Tool' menu; the port item is grayed out.  The error message states that the IDE "Could not initialize class sun.security.ssl.SSLContextImpl$DefaultSSLContext".  I have installed the following Java code:
java 16.0.1 2021-04-20
Java(TM) SE Runtime Environment (build 16.0.1+9-24)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)

Any insight would be most appreciated.  Thanks in advance.


texts: How to NOT repeat a piece of code again and again?

texts:
I have a VERY long code:

  Sketch uses 30468 bytes (92%) of program storage space. Maximum is
  32768 bytes.

I've been trying to reduce it's size so i can write more code, one of my main part of code which repeated many times in switch cases or in if statements is related to de-bouncing the buttons.

Here's a piece of my code as an example:

  case 12:
    if ((millis() - millistimer) > BounceD) {
      if (receivedValue == RFb) {
        magnetDistance += 5;
        millistimer = millis();
        receivedValue = 0;
      }
    }
    if ((millis() - millistimer) > BounceD) {
      if (receivedValue == RFd) {
        magnetDistance -= 5;
        millistimer = millis();
        receivedValue = 0;
      }
    }
    break;

The de-bouncing actions happens in each and every case and for each and every button.

There's two buttons which in each case increase/decrease different values.

How to avoid repeating the de-bouncing action for every button?

EDIT:

The recievedValue is updated via RC buttons value once any button is pressed on the remote.


texts:
My project aims to send HTTP GET request to web page(using Arduino UNO and ESP8266-01) then receive response, extract wanted values from response and react with(for example turn on LED1,LED3) then resend led's status to another web page to be inserted in mysql database using HTTP POST in order to make sure that Arduino received the command and executed successfully (in an infinitive loop).
Each request HTTP GET or HTTP POST works fine alone, but when trying to do that in a sequence HTTP GET then HTTP POST inside the loop I got bad result shown in serial monitor like unknown strange characters.
Here is my loop :

void loop() {
  if (millis() - lastTimeMillis > 40000) {
    lastTimeMillis = millis();
    ESP8266.println("AT+CIPMUX=1");
    delay(1000);
    printResponse();
    ESP8266.println("AT+CIPSTART=4,\"TCP\",\"" + server + "\",80");
    delay(1000);
    printResponse();
    String cmd = "GET /ard/sensor.php HTTP/1.1\r\nHost: localhost";
    ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
    delay(1000);
    ESP8266.println(cmd);
    delay(1000);
    ESP8266.println("");
  }
    if (ESP8266.available()){
    Serial.write(ESP8266.read());
    }
  Value1=(digitalRead (LED_PIN1));
  Value2=(digitalRead (LED_PIN2));
  Value3=(digitalRead (LED_PIN3));
  Value4=(digitalRead (LED_PIN4));
 data = "Value1=" + Value1 + "&Value2=" + Value2 + "&Value3=" + Value3  + "&Value4=" + Value4;
  httppost();
}

And here is

  httppost()

void httppost () {

    ESP8266.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");
    if( ESP8266.find("OK")) {
    Serial.println("TCP connection ready");
    }
    String postRequest =
    "POST " + uri + " HTTP/1.0\r\n" +
    "Host: " + server + "\r\n" +
    "Accept: *" + "/" + "*\r\n" +
    "Content-Length: " + data.length() + "\r\n" +
    "Content-Type: application/x-www-form-urlencoded\r\n" +
    "\r\n" + data;
    String sendCmd = "AT+CIPSEND=";
    ESP8266.print(sendCmd);
    ESP8266.println(postRequest.length() );
    delay(5000);
    if(ESP8266.find(">")) { Serial.println("Sending.."); ESP8266.print(postRequest);
    if( ESP8266.find("SEND OK")) { Serial.println("Packet sent");
    while (ESP8266.available()) {
    String tmpResp = ESP8266.readString();
    Serial.println(tmpResp);
    }
    ESP8266.println("AT+CIPCLOSE");
    }
    }
}

When uploading this code it seems like only HTTP POST works fine in a loop while HTTP GET having a trouble. So how to make them both work fine in a loop?
Thanks in advance


texts:
I have a recurring problem that when I'm controlling leds, I make several different functions for different fx and just want to trigger them randomly but having a hard time to formulate it in an intelligent way and end up hardcoding every function call.

ex: I have let's say 10 functions called anim1();, anim2();, anim3(); etc
and would like to called them randomly in that fashion :

randNumber = random(1,11);
anim[randNumber]();

I know that it's not that type of brackets I need to use but I can't find the proper syntax and I'm wondering if it's possible to do that..
I'm sure there must be a way ;)

thanks for your help


texts: I'm trying to made a program that turn on and turn off leds with an input and send the coordinates of joystick, but, in the loop, the arduino makes one at a time, and i want make this in the same time. How can i make that?


texts: What to use instead of a USB to serial converter

texts: The usb to serial converter i found was $4 .maybe i could use something less expensive,like jus a port.I need serious help ,the serial port was about $1


texts: sim 900a mini status led glowing constantly instead of blinking

texts: I am using sim 900a module for the first time(sim900a). Initially when i powered it with the arduino 5v supply, the power led of the board glow but the network status led never glow. After searching online for answers they showed to use external power supply with 5v 2A, then i used the specified power supply. It worked actually now the status led started to glow but it does not blink for ever 1sec or 3sec instead it glows continuously. I connected the module with the tx and rx of arduino and called the inserted sim the serial monitor detected the call and gave the output, but i cannot make a call or send sms from the module to other numbers. Pls help me out.


texts: What methods are there for tracking presence in rooms?

texts:
Im wanting to automate the lighting in my house, e.g. turn on lights when entering a room without having to fumble around with my phone or switches.

I have looked at audio, PIR and radar sensors, are there any more alternatives? For example using a wifi mesh to triangulate which room a phone is in.

Any suggestions welcome.

P.s. I may end up with one of the earlier options, I just want to see what is out there.


texts: Weird behavior (Couldn't pull the pin LOW)

texts:
I was trying to implement my own code to control a stepper motor on arduino uno, however I noticed that the pins were always HIGH despite what was written to them. I started to erase the code to leave only the crucial part to troubleshoot it and was left with the following

#define IN1  8
#define IN2  9
#define IN3  10
#define IN4  11
long int *period;

void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
*period=256;
}

void loop() {
 digitalWrite(IN1, LOW);
 digitalWrite(IN2, LOW);
 digitalWrite(IN3, LOW);
 digitalWrite(IN4, HIGH);
}

The period statements were leftovers from the previous code, and didn't think of them too much but once I deleted them the code started working. More over, the code worked if the period value was below 256. Once it reached 256 the pins weren't pulling low.

The problem is solved now, however I am interested why would a value of a variable cause such a behavior?


texts:
I have setup two arduinos, one supposed to fetch data from my website and feed it to a topic. The other board supposed to subscribed to that same topic and reads fetched data
I was able to get data from my website and published to the topic:
(9:06:44 PM) /motioncha@hotmail.com/out: hello world #183
(9:06:46 PM) /motioncha@hotmail.com/out: hello world #184
(9:06:48 PM) /motioncha@hotmail.com/out: hello world #185
(9:06:50 PM) /motioncha@hotmail.com/out: hello world #186

In the receiver side I have the following code:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = "Connect4G";
const char* password = "******";
const char* mqtt_server = "mqtt.dioty.co";
const char* mqtt_user = "motioncha@hotmail.com";
const char* mqtt_pass = "*****";
const char* otc = "/motioncha@hotmail.com/out";

WiFiClient espClient;
PubSubClient client(espClient);

unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

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

  while (WiFi.status() != WL_CONNECTED) {    delay(500);  Serial.print(".");  }

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");  Serial.print(topic);  Serial.print("] ");
  for (int i = 0; i < length; i++) {    Serial.print((char)payload[i]);  }
  Serial.println();
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
  if (client.connect("arduinoClient", mqtt_user, mqtt_pass)) {
      Serial.println("connected");
      client.subscribe(otc);
    } else {      Serial.print("failed, rc=");      Serial.print(client.state());      Serial.println(" try again in 5 seconds");      delay(5000);    }
  }
}

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  unsigned long now = millis();
  if (now - lastMsg > 500) {
    lastMsg = now;
  }
}

However, there is no data displayed in the monitor except for reconnecting:
connected
Attempting MQTT connection...connected
Attempting MQTT connection...connected
Attempting MQTT connection...connected
Attempting MQTT connection...connected


texts: A library for manipulate Intel Hex data?

texts:
For a project i need to extract some data from an external eeprom and then store it somewhere. Suddenly after some manipulations (not necessarly with Arduino board) i need to put them in an external eeprom.

What I would do is to convert the extracted data from the EEPROM in Intel Hex data and vice versa.
To do this I wanted to know if there is already a library for that purpose "ready to use" made for Arduino boards.

thanks


texts: Multiple serial monitors with the same arduino mega

texts:
I’ve got mega 2560.
In my project serial port is used for communicating with PC.
However, I’d like to see debug info in serial monitor. Mega has a few hardware Serial ports. How to use one of them got extra serial monitor?


texts: Can Arduino be used as an FDTI Programmer?

texts: I would like to program my ESP 8266 WiFi module. But I don't have an FDTI right now is there any way to use Arduino Uno as FDTI Programmer then use ESP without it.


texts:
I'm basically trying to combine my servo code and my LED code but whenever I add my servo code the LED refuses to turn on at all.
I am super new to arduino sorry if this doesn't make any sense!

Servo myservo;

const int pushbutton_PIN = 2;
const int POT_PIN = A0;
const int LED_PIN = 3;

int pos = 0;
int buttonState = 0;
int lastbuttonState = 0;
int analogValue = 0;
int lightState = false;
int brightness = 0;

void setup() {
  myservo.attach(9);
  pinMode(pushbutton_PIN, INPUT);
  pinMode(POT_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  light();
  servo();
  }

void servo(){
        for (pos = 0; pos <= 180; pos += 1) {
    // in steps of 1 degree
    myservo.write(pos);
    delay(15);
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos);
    delay(15);
  }
}

void light() {
      buttonState = digitalRead(pushbutton_PIN);
  if (buttonState != lastbuttonState) {
    if (buttonState == HIGH) {
      delay(300);
      lightState = true;
      light_on();
    }
  }
  lastbuttonState = buttonState;
}

void light_on() {
  while (lightState == true) {
    analogValue = analogRead(POT_PIN);
    brightness = map(analogValue, 0, 1023, 0, 255);
    analogWrite(LED_PIN, brightness);
    buttonState = digitalRead(pushbutton_PIN);
    if (buttonState != lastbuttonState) {
      if (buttonState == HIGH) {
        lightState = false;
        delay(300);
        analogWrite(LED_PIN, LOW);
        loop();
      }
    }
    lastbuttonState = buttonState;
  }
}


texts:
I've got an interesting idea to realise using my PC and Arduino, but I'm not sure whether it is possible to realise, so I'm asking for your advice. I'm a novice in programming, so my question may seem noob-ish.

I have an XML file on a server (not mine), which keeps updating several times a day. It looks like

<x>timestamp1;timestamp2;timestamp3</x>
<y>value1;value2;value3</y>

, where the value1,2,3... are the values of a parameter at the specified time (for example value1 is a value at timestamp1 etc.).

The thing I want to do is to take the last value from the <y></y> block and to transfer it in some way to Arduino (maybe through the serial port, as my PC will be turned on at the time) - and then repeat the operation after some time (for example 2 or 3 hours) to get an updated value. The remaining part (to send it to the display) will be easy.

Do you have any ideas or any links to some related materials or tutorials?
Thanks for any help!

Paul.


texts:
i have a custom atmega328p board which have connected to pin 9 the gate of a MOSFET.
If i run a simple sketch like:

void setup() {

}
void loop() {
  analogWrite(9,70);
}

The motor connected to the mosfet works just fine, from 70pwm to 255pwm.

On the other sketch i'm receiving serial data from an android app via bluetooth. Ive 2 Servo motors and a DC motor connected to the mosfet.
The 2 servos works like expected, the DC motor doesn't spin unless i use a 255pwm.

void loop() {
  if(Serial.available() > 0){
      state = Serial.read();
  }
  if (state == 'S') {
      servoONE.write(90);
      servoTWO.write(90);
      analogWrite(MOSFET,MOSFET_LOW);
  }
  else if (state == 'F') {
      analogWrite(9,70);
      servoONE.write(90);
      servoTWO.write(90);
  }
  else if (state == 'L') {
      servoONE.write(MAX_SERVO);
      servoTWO.write(MIN_SERVO);
  }
  else if (state == 'R') {
      servoONE.write(MIN_SERVO);
      servoTWO.write(MAX_SERVO);
  }
  else if (state == 'Q') {
      analogWrite(MOSFET,MOSFET_HIGH);
      servoONE.write(MAX_SERVO);
      servoTWO.write(MIN_SERVO);
  }
  else if (state == 'E') {
      analogWrite(MOSFET,MOSFET_HIGH);
      servoONE.write(MIN_SERVO);
      servoTWO.write(MAX_SERVO);
  }
}

Do you know why the same motor works on the first sketch with any pwm above 70 and on the second sketch it only works at 255?


texts:
I am working with an Adafruit Feather 32u4 FONA board. I want to connect a GPS module I have worked with before (3.3V required) but am not having much luck. I have studied the pinout of the board and have tried the 3.3V pin but it is far too erratic in nature and cannot sufficiently power the module. There is a pin called USB which supplies 5.0V from the pin if a micro USB cable is connected. I have used an LM317 and a potentiometer to make a voltage regulator circuit to convert the 5.0V from the USB pin to the 3.3V I need for the GPS module. This works, as I have measured 3.3V successfully using a multimeter.

The problem is that when I connect the VCC and GND pins of the GPS module to the 3.3V regulated output, the module still doesn't get any power. I measured a significant drop to around 0.89V across GND and VCC after I connect the module. What could be causing this strange behavior?

The bottom left rail is what I am trying to use to power the GPS module, before I connect it I get 3.3V as mentioned earlier, which is the required level.


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

texts:
so the scenerio is i am making a bluetooth controlled car(voice control)+obstacle avoidence function.I am using arduino uno with L298n motor driver and a HC-05 BT module in the sensors i am using the ultrasonic sensor and a IR sensor for the back and a servo motor is aslo used to rotate the ultrasonic sensor.so the problem is when i am sending command "turn left" the servo moves left and nothings happens and the other command i.e turn right,move backward,move forward are not working at all.
circuit diagram and code is given plz guyz guide me where is the lacking if i have done  something wrong with the code or else my motor driver or wiring is creating te issue
CODE :
'''
#include <NewPing.h>
#include<Servo.h>
#define TRIGGER_PIN A1
#define ECHO_PIN A0
#define MAX_DISTANCE 300
#define IR A2
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
Servo myservo;
String voice;
void setup() {
Serial.begin(9600);
myservo.attach(8);
myservo.write(90);
pinMode(IR, INPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
int distance = sonar.ping_cm();
if (Serial.available() > 0) {
voice = "";
delay(2);
voice = Serial.readString();
delay(2);
Serial.println(voice);
if (voice == "turn left") {
  left();
} else if (voice == "left") {
  left();
} else if (voice == "turn right") {

} else if (voice == "right") {

}

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

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


texts:
I've got a CNC machine and I recently started using a spindle for it. At first it was running smoothly with no issues, but after the first brush pair wore off (I've replaced them later on) it started interfering with the Arduino/gshield and pc monitor. The monitor displays a "no signal" message, although after turning off the spindle or turning it to a low speed the signal comes back. The other problem is that after running a long job, sometimes the gshield disconnects and the job stops midway.

What part could be causing all this interference?
How can I shield that part so it stops interfering with other electronics?

I am using the following hardware:

600 watt spindle
600 watt power supply with variable speed
the wires from the spindle to the power supply are not shielded, although Ive tried covering them with aluminium foil, not sure if that should be of any benefit, I've read it somewhere so I gave it a try.
Gshield with Arduino, connected to a Raspberry pi.

All the electronics are within 70 cm radius.


texts: Do I need third party s/w to export to a spreadsheet? I have built a heat flux sensor meter and wish to log my data.


texts: How to post HTTP POST requests on my website?

texts:
I am working on a NodeMCU board to post sensor data on my website service. Basically my project is about POST and GET requests both in single code.

I am succeeding in sending GET requests from my website. However, I just can't post data to my website.

To post I have 2 different links (asp services): one will post data and another will be used to get data same as transmitted by first link.

Here is my code, and also how to post 2 variables in http post request?

#include (ESP8266WiFi.h)
#include (ESP8266HTTPClient.h)

const char* ssid = "oppo";
const char* password = "11111111";
int giSwitchNum = 1, buttonPin = 2;

void setup () {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  pinMode(D1, OUTPUT);
  pinMode(D2, INPUT);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print("Connecting..");
  }
  giSwitchNum = 1;
  Serial.print("Connect");
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    HTTPClient Post;
    Post.begin("http://lemontechnologies.net/Services/Service.svc/SetData");
    Post.addHeader("operator", "text/plain");
    Post.POST("Key=hi&val=jagrut1");
    String payload = Post.getString();
    Post.end();
  }
  delay(500);
}


texts: Arduino uno wifi rev2 error compiling sketch to board

texts:
I'm having an irritating situation with my Arduino Uno wifi rev2 board.
I made an installation with an LCD, keypad and little servo motor. I first wrote the code for my regular Arduino Uno and everything worked fine. Now I migrated my installation to my new Arduino Uno wifi rev2 because I needed it to make a request. But the problem is when I try to upload my code to the wifi rev2 it gives me a compilation error. I tried to upload a blink test sketch to see if it would work and it did but somehow it doesn't want to compile this code:

#include <Wire.h>

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

LiquidCrystal_I2C lcd(0x27,16, 2);
Servo myservo;
const byte ROWS = 4;
const byte COLS = 3;

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

byte rowPins[ROWS] = {3, 4, 5, 6};
byte colPins[COLS] = {9, 8, 7};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
String value = "";

void setup(){
  lcd.begin();
  Serial.begin(9600);
  myservo.attach(A0);
 lcd.backlight();
 //myservo.write(0);

}

void loop(){
    lcd.clear();
    char customKey = customKeypad.getKey();   // get the key pressed
    value = value + String(customKey);
    lcd.print("Geef bestelcode");
     lcd.setCursor(0,1);
    lcd.print("in: " + value);
 // char customKey = customKeypad.getKey();   // get the key pressed
 if(customKey=='#'){
        if(value == "1234#"){
          myservo.write(0);
          }
     // int pos = value.toInt();             // convert value to int
     // myservo.write(pos);                 // rotate the servo
         else{exit;}                   // clear the string
    }

     if(customKey=='*'){                       // 'D' works as "enter"
      myservo.write(90);                   // rotate the servo
      value = "";                           // clear the string
    }

 /*
  if(customKey && customKey!= '#'){         // if the key pressed is not 'D'
      value = value + String(customKey);    // concatenate the number to value
      //Serial.println(value);
  }*/
   delay(175);
}

The output of my error console :

In file included from C:\Users\TONES-PC\Documents\Arduino\sketch_dec15a_parcelbox_tester\sketch_dec15a_parcelbox_tester.ino:5:0:

C:\Users\TONES-PC\Documents\Arduino\libraries\Keypad/Keypad.h: In member function 'virtual void Keypad::pin_write(byte, boolean)':

C:\Users\TONES-PC\Documents\Arduino\libraries\Keypad/Keypad.h:88:81: error: cannot convert 'boolean {aka bool}' to 'PinStatus' for argument '2' to 'void digitalWrite(pin_size_t, PinStatus)'

  virtual void pin_write(byte pinNum, boolean level) { digitalWrite(pinNum, level); }

                                                                                ^

Several libraries found for "Wire.h"
used: C:\Users\TONES-PC\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\Wire
Several libraries found for "LiquidCrystal_I2C.h"
used: C:\Users\TONES-PC\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
Several libraries found for "Servo.h"
used: C:\Program
Several libraries found for "Keypad.h"
used: C:\Users\TONES-PC\Documents\Arduino\libraries\Keypad
exit status 1
Error with compiling for board Arduino Uno WiFi Rev2

Any thoughts on how to solve this?


texts:
I have been gradually converting many devices from i2c to spi for various reasons.  I noticed in tutorials like this from arduino.cc that SPI.beginTransaction is explicitly called out.  Then they link to examples such as this and this where they don't use SPI.beginTransaction.  In working through my own devices I found that I could often (almost always) forgo the use of SPI.beginTransaction.  The only case where I found problems was when I had 2 devices that used different SPI settings.
I went to Google and other searches for a simple reason for SPI.beginTransactions and found discussions of interrupts and locks and settings.  There was much discussions about users applications wrapping all calls with SPI.beginTransaction and SPI.endTransaction.  There were bugs when libraries didn't wrap everywhere.
This leads me to the conclusion that making calls to SPI.beginTransaction are only needed when the SPI settings need to change, but in practice you should always do it.  Is there documentation or examples that definitely state the purpose and proper (best practice) usage of it?


texts: Can I connect an Arduino wifi module directly to my android phone?

texts: I would like to use my arduino even where there's no wifi router. I've only found people saying that it needs to connect to a router, but isn't the phone like a router when it's in tethering mode? Do I still need a mobile internet connection or can I do it directly?


texts: How to approach an complex Arduino Uno project (Serial, SPI, Ethernet) in pure C, without libraries?

texts:
I have a college assignment where I need to get serial output, the Ethernet shield and SPI communication with other boards to work. We are not allowed to use any existing libraries, though we can use them as strong inspiration, as long as we are able to explain every line we have in our final code.

Since there appears to be a lack of C resource I spent lots of time trying to reverse engineer the CPP libraries but I am hopelessly overwhelmed by anything beyond getting a pure C blinky to run.

Do you have any idea how I should approach this? Are there C resources about the Ethernet shield and Arduino SPI?


texts: Can BUS Shield on Arduino Leonardo - Can't init CAN

texts:
I'm hoping to get some help with this as I am unable to get the CAN to Initialize.

I have the sparkfun Can-Bus shield: https://www.sparkfun.com/products/13262

and an Arduino Leonardo board.

I'm using the following code to try to connect my 2008 Audi S6 to the Arduino board:

#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
#include <Canbus.h>
char UserInput;
int data;
char buffer[456];  //Data will be temporarily stored to this buffer before being written to the file

//********************************Setup Loop*********************************//

void setup(){
Serial.begin(9600);
while(!Serial);
Serial.println("CAN-Bus Demo");

if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the  specified speed */
  {
Serial.println("CAN Init ok");
  } else
  {
    Serial.println("Can't init CAN");
  }

  delay(1000);

Serial.println("Please choose a menu option.");
Serial.println("1.Speed");
Serial.println("2.RPM");
Serial.println("3.Throttle");
Serial.println("4.Coolant Temperature");
Serial.println("5.O2 Voltage");
Serial.println("6.MAF Sensor");

}

//********************************Main Loop*********************************//

void loop(){

while(Serial.available()){
   UserInput = Serial.read();

if (UserInput=='1'){
 data=Canbus.ecu_req(VEHICLE_SPEED, buffer);
 Serial.print("Vehicle Speed: ");
 Serial.print(data);
 Serial.println(" km/hr ");
 delay(1000);
}
else if (UserInput=='2'){
 data= Canbus.ecu_req(ENGINE_RPM, buffer);
 Serial.print("Engine RPM: ");
 Serial.print(data);
 Serial.println(" rpm ");
 delay(1000);

}
else if (UserInput=='3'){
 data= Canbus.ecu_req(THROTTLE, buffer);
 Serial.print("Throttle: ");
  Serial.print(data);
 Serial.println(" %% ");
 delay(1000);

}
else if (UserInput=='4'){
 data =Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);
 Serial.print("Engine Coolant Temp: ");
 Serial.print(data);
 Serial.println(" degC");
 delay(1000);

}
else if (UserInput=='5'){
 data=Canbus.ecu_req(O2_VOLTAGE, buffer);
 Serial.print("O2 Voltage: ");
 Serial.print(data);
 Serial.println(" V");
 delay(1000);

}
else if (UserInput=='6'){
 data=Canbus.ecu_req(MAF_SENSOR, buffer);
 Serial.print("MAF Sensor: ");
 Serial.print(data);
 Serial.println(" g/s");
 delay(1000);

}
else
{
  Serial.println(UserInput);
  Serial.println("Not a valid input.");
  Serial.println("Please enter a valid option.");
}

}
}

Overall, I just can't get the CAN to initialize. I've looked online and just can't seem to find a solid solution. I've tried other libraries as well to no avail.

Please assist!


texts: Why does Arduino Tone example with 8 ohm speaker make USB port fail?

texts:
I'm using an Arduino Nano and attempting to run the basic sample program at:
https://www.arduino.cc/en/Tutorial/toneMelody

When I build the circuit they way they show (extremely simple) using an 8 Ohm speaker and connect the power to USB the Nano begins to power (never fully powers up) and then the USB port fails (I believe as a protection mechanism).

Is the schematic provided with that sample incorrect?
They say it can be used with an 8 Ohm speaker but they show it hooked up with e piezo.
Here are the comments from the Sketch:

Is it possibly overdrawing current with the 8 Ohm speaker?
Is the circuit incorrect in some way?
NOTE: Without the speaker connected the Nano powers up with no problem. I am also building other circuits with the Nano and they work fine.


texts:
so I am testing out the PulseSensor code from here: https://github.com/WorldFamousElectronics/PulseSensorAmped_2_Sensors/tree/master/PulseSensorAmped_2_Sensors_1.5.0

In the interrupt.ino file, there is a function interruptSetup() which initializes the timer settings. However, I want to undo these settings first, as I have found out that this function is affecting my other readings. What is the default settings for the timer?


texts: Can I control an Adafruit Trinket M0 from a computer

texts: I understand that the Adafruit Trinket M0 isn't an Arduino, but I figured it might still be appropriate here. I'll keep it simple. I have an Adafruit Trinket M0 that will be used to control an RGB led light. I have a custom program on a PC that controls the sequence of the light. Can I control the Adafruit Trinket M0 through the usb port? Meaning, can I continuously input data from the computer into the M0 that will in real time control the light? I don't necessarily need a tutorial, but I am more interested in whether or not the hardware is capable of that. If the hardware isn't capable of that can you also recommend a similar inexpensive Microcontroller that is capable of this. Thank you.