texts: cannot resolve overloaded function... error

texts:
I started to learn Arduino and I want to get an input from user to blink LEDs. I wrote under the void loop() section input codes. After i compiled it and Arduino IDE gave me this: "Arduino:1.8.5 (Windows 10), Kart:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\Yunus Emre ERYILMAZ\Documents\Arduino\sketch_feb17a\sketch_feb19a\sketch_feb19a.ino: In function 'void loop()':

sketch_feb19a:27: error: cannot resolve overloaded function 'parseInt' based on conversion to type 'int'

 numBlueBlink=Serial.parseInt;

             ^

sketch_feb19a:31: error: cannot resolve overloaded function 'parseInt' based on conversion to type 'int'

 numYellowBlink=Serial.parseInt;

               ^

exit status 1
cannot resolve overloaded function 'parseInt' based on conversion to type 'int'

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

What should i do, how can solve this problem? Thanks.

The code that i wrote:

int blueLEDPin=9;  // Declaring blue led's pin is 9.
int yellowLEDPin=10;  //Decllaring yellow led's pin is 10.
int blueOnTime=250;  // Bue led ontime
int blueOffTime=250; // Blue led offtime
int yellowOnTime=250; // Yellow led ontime
int yellowOffTime=250; // Yellow led offtime
int numBlueBlink=0;
int numYellowBlink=5;
String blueMessage="The blue LED is blinking...";
String yellowMessage="The yellow LED is blinking...";

void setup() {
  String wm1 = "Welcome to";
  String wm2 = " My Program";
  String wm3;
  wm3 = wm1+wm2;
  Serial.begin(115200);
  Serial.println (wm3);
  pinMode (blueLEDPin,OUTPUT);
  pinMode (yellowLEDPin, OUTPUT);

}

void loop() {
Serial.println ("How many times do you want the blue LED to blink? ");
while (Serial.available()==0){ }
numBlueBlink=Serial.parseInt;

Serial.println ("How many times do you want the yellow LED to blink? ");
while (Serial.available()==0){ }
numYellowBlink=Serial.parseInt;

Serial.println (blueMessage);
for (int j=1; j<=numBlueBlink; j=j+1) {
  Serial.print ("   You are on Blink #: ");
  Serial.println(j);
  digitalWrite (blueLEDPin,HIGH);  // Turn first led on
  delay (blueOnTime);  // Wait
  digitalWrite (blueLEDPin,LOW); // Turn first led off
  delay (blueOffTime); // Wait
}

Serial.println (" ");

Serial.println (yellowMessage);
for (int k=1; k<=numYellowBlink; k=k+1){
  Serial.print ("   You are on Blink #: ");
  Serial.println (k);
  digitalWrite (yellowLEDPin,HIGH); // Turn second led on
  delay (yellowOnTime); // Wait
  digitalWrite (yellowLEDPin,LOW);  // Turn second led off
  delay (yellowOffTime);  // Wait
}
Serial.println (" ");
}


texts:
I'm trying to use strtoul() to convert an Arduino String to an unsigned long (like the return of millis();) using the following code snippet:

unsigned long foo (String time)
{
  unsigned long mili;
  char Tim[9]="";
  uint16_t timsize = time.length()+1;
  char TIM[timsize];
  time.toCharArray(TIM,timsize);
  mili=strtoul(TIM,timsize,10);
  return mili;
}

The code seems to work. However, I'm getting the following warning:

  invalid conversion from 'uint16_t {aka unsigned int}' to 'char**' [-fpermissive] mili=strtoul(TIM,timsize,10);

My question is twofold:

Is there a better way to convert a String to unsigned long without first converting to a C string?
If not, how can I eliminate this error?


texts: Are all the pins on Arduino shields available for use?

texts:
Basically, if I put a shield on my Arduino (mine is Uno, but I'm asking generally), can I freely use all the pins that are there on the shield?

I have an Ethernet shield and almost all of the pins that the original Uno has, are available on the Ethernet too.

The best results that I could get from googling are this and this which describe that if a shield uses a certain pin, putting another shield that uses the same pin causes conflict.

But what about using them myself? Can I use all the pins on a shield as Input/Output?

If some pins are unusable, then why are they available on the board? For example why doesn't the Ethernet have pins 10-13 blocked so you can't put any jumper wires in them?

Additional info:

There was also this article which didn't seem very credible to me.
Also I've tried using pins 10-13 to light an LED while the Ethernet was busy transferring data. The result was the LED connected to pin 10 was very dim, 11 was less dim and so on. So my guess is yes, they are unavailable. But the fact that this was so rarely mentioned on the internet and that the pins aren't physically blocked made me doubtful.


texts:
I recently was playing around with Arduino and using dfu-programmer reflashed ATMega16u2 to make the computer think it was a keyboard device.

Well, I wish to put the original Arduino firmware back on, but now dfu-programmer says the device is not present.

The Arduino is listed under /dev/hidraw5 on Ubuntu. Typing lsusb gives the following output for Arduino keyboard:

Bus 004 Device 008: ID 03eb:2042 Atmel Corp. LUFA Keyboard Demo Application

I tried erasing with the command:

sudo dfu-programmer atmega16u2:4,8 erase

and got

dfu-programmer: no device present.

Is there a way to target /dev/hidraw5 using dfu-programmer? Many thanks.


texts: Error declaring two-dimensional array: 'x' was not declared in this scope

texts:
I'm trying to declare a 2-D array where each letter in the alphabet is keyed to a corresponding LED in my LED strip. But when I try to declare the array, Arduino flags the values and gives me a "not declared in this scope" error. I have no idea why. Am I missing a library or is it incorrect syntax?

Some of the places I've looked say to make sure it's declared globally. I've declared the array before void setup but it still doesn't work. Here's what I've got before void setup:

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(50, PIN, NEO_GRB + NEO_KHZ800);

//Create a 2-D array to store each letter and
//its corresponding LED number
char charKey[26][2]={
  {a, 0},
  {b, 2},
  {c, 4},
  {d, 6},
  {e, 8},
  {f, 20},
  {g, 18},
  {h, 16},
  {i, 14},
  {j, 12},
  {k, 10},
  {l, 22},
  {m, 24},
  {n, 26},
  {o, 28},
  {p, 30},
  {q, 40},
  {r, 38},
  {s, 36},
  {t, 34},
  {u, 32},
  {v, 42},
  {w, 44},
  {x, 46},
  {y, 48},
  {z, 50}
};


texts: Can the servo pulse width range be changed?

texts:
I recently found that standard servos only rotate 90deg total rotation for a pulse width range of 1-2 usec.  To rotate 180deg total rotation they need a .5-2.5 usec pulse range.  The arduino is programmed to only output the 1-2 usec range for 0-180 deg rotation.  Is there a way to make the arduino output the .5-2.5 usec pulse range to get full 180deg rotation?

Thanks


texts: Can an Arduino act as a GATT Server (Bluetooth LE)

texts:
I know it's pretty standard to set up an Arduino system as a BLE client, and use something like an app running on a smartphone as the GATT server, which receives the data and does something with it.

In my scenario I have a BLE sensor that is not connected directly to the Arduino system, and I want the Arduino to be able to respond to the sensor output (a wearable accelerometer) and, for example, initiate various lighting sequences depending on the data being received.

I would prefer not to introduce a third component (ie: mobile device as GATT server) into the equation. I'd like for the Arduino to listen to the remote device's services and characteristics, analyze the incoming data and then make some decisions about what LEDs to illuminate based on that analysis.

Can an Arduino run as a GATT server?


texts: Multi MFRC522 Slave AND only mifare read

texts:
Multiple MFRC522 Connections (https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi)
I only get from each slave with an ID card; I want to print a defined barcode on the slave address. Briefly; The MOSI line does not matter! Is the 2nd case daisy chain method in this link suitable for me? would like to ask you, dear friends, how should I go about it?
<Regards


texts: nRF24L01 - Measuring distance using time elapsed

texts:
For school usage, my team and I are working on a wristband that will alert the user if they are too close to another wristband (for social distancing). The problem is measuring distance using radio waves. Since I cannot use signal strength, I'm thinking about calculating distance from time taken to transfer some data and velocity (which will be around the speed of light). I discarded the idea of using ultrasound because it is too easily interfered with by other obstacles.
My plan is along the lines of this:

Sensor 1 and 2 are synchronised to a clock.
Both will run a
"stopwatch", and the time values should be exactly the same at the
same time.
Sensor 1 sends out a message to Sensor 2. The message
contains the time at which the transmission started.
Sensor 2
receives the message, immediately records the time of reception, and
calculates the time taken for data to travel
d = v/t
Vice-versa

If the distance is smaller than the radius, a warning is triggered in the form of a vibration motor.
Limitations include clock speed; I intend on using a Seeeduino XIAO, an Arduino-compatible board. The clock speed is max. 48MHz, meaning that the smallest increments it can measure is 20.82 nanoseconds. I also calculated that it would take 13.33 nanoseconds to travel two metres (the former distance to keep in public). Hence, with the clock speed available to me, I can only measure 3m and beyond.
Assuming I was happy with this distance, would I be able to do this using one single Arduino sketch? I know that Arduino programs can only run one at a time. Would a constant background clock/stopwatch be too complex? Could you give me any other pointers?


texts:
I am just starting with Arduino and was trying to make the LED example work. I changed the script as follows to keep the LED on:

#define LED_PIN 12
#define LED_RX_SIG LED_BUILTIN

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_RX_SIG, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  //delay(1500);                       // wait for a second
  //digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
  //delay(1500);                       // wait for a second
  //digitalWrite(LED_RX_SIG, HIGH);
  //delay(1000);
  //digitalWrite(LED_RX_SIG, LOW);
  //delay(1000);
}

I setup the Nano board, LED and a 220ohm resistor on a breadboard. The D12 port on Nano is connected to one end of the 220ohm resistor using a jumper cable. The other end of the resistor is connected to the positive (longer end) of the LED. The negative end of the LED is connected to the GND pin on Nano. The setup is shown in the image below:

What's wrong with the setup and why the LED is not lit?
Sorry in advance for such novice question and any help will be greatly appreciated. Thanks


texts: How can I fix stuttering motors that are connected to ESC's [Arduino Uno]?

texts:
Been making a few posts about my drone and i am getting closer and closer to my goal to make it work.

Right now I have a problem with stuttering with all four of my motors (sometimes the motors does not even start but they beep instead). This is the motor and esc I use: https://hobbyking.com/en_us/mt1806-brushless-combo-include-esc-5030cw-ccw.html

I put together a very quick schematic on how i have everything connected:

So motor connected to the ESC and the ESC grounds go to arduino Gnd, the signal pins from the ESC goes to different pwm pins and the rest of the esc goes to the power distribution where i also insert my 3s lipo battery. From my power distribution i connect two cables to my arduino uno gnd and vin pin.

When I use this very simple code:

ESC9.write (100);
ESC6.write (100);
ESC5.write (100);
ESC3.write (100);
delay (2000);

ESC9.write (0);
ESC6.write (0);
ESC5.write (0);
ESC3.write (0);
delay (2000);

The motors start like they should but they stutter (some motors move more than others) and as you can see in my code i tell them to stop after 2 seconds to see if i can control them and indeed they stop nicely.

This is a 3 second video on how it looks once I enter my lipo battery:

https://vid.me/XpWg

Is this a case of bad soldering somewhere perhaps or do I need to calibrate my ESC/motor? Codewise I am just using a simple Servo and then I just use the code I posted above. Do I need to add anything else maybe? Since all 4 motors are stuttering/buzzing it is most likely not a problem with the motor/esc i suppose!

My arduino uno is a chinese copy, could that have anything to do with it?

Also I made this post earlier with a little less information but more info about my soldering: All four of my ESC motors stutters when I run it on my Arduino, how can this be fixed?

Appreciate every help and tips!


texts: I am using the FFT library from Open Music Labs and I am trying to analyze frequencies up to 40 kHz. Now I don't understand fully but know that my sample rate has to be at least twice as much, but my question is with the example code fft_adc_serial, how can I adjust the sample frequency to 80kHz? Is it even possible to sample at these high frequencies.


texts: 'SoftwareSerial' does not name a type in Adafruit Feather M0 Bluefruit LE

texts:
I am trying to create a software serial connection between Arduino Uno & Adafruit Feather M0 Bluefruit LE.

I am getting the following error in the M0 sketch:

Arduino: 1.8.1 (Windows 10), Board: "Adafruit Feather M0"

atcommand:60: error: 'SoftwareSerial' does not name a type

 SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

 ^

atcommand:62: error: 'bluefruitSS' was not declared in this scope

 Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,

                               ^

exit status 1
'SoftwareSerial' does not name a type

Here are the modifications I did to the atcommand sketch (in Adafruit BluefruitLE nRF51 library) before uploading to the M0:

#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined (_VARIANT_ARDUINO_ZERO_)
  #include <SoftwareSerial.h>
#endif

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"

#include "BluefruitConfig.h"

// Create the bluefruit object, either software serial...uncomment these lines

SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                      BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);

/* ...or hardware serial, which does not need the RTS/CTS pins. Uncomment this line */
// Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN);

/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
//Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

/* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */
//Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO,
//                             BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS,
//                             BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

I  tried to comment the if statement before #include <SoftwareSerial.h>, I got the following error:

Arduino: 1.8.1 (Windows 10), Board: "Adafruit Feather M0"

C:\Users\hadeel\AppData\Local\Temp\arduino_modified_sketch_612073\atcommand.ino:18:30: fatal error: SoftwareSerial.h: No such file or directory

   #include "SoftwareSerial.h"

                              ^

compilation terminated.

exit status 1
Error compiling for board Adafruit Feather M0.

What is the problem?


texts: Why can't the new Arduino IDE 1.6.7 compile extern "C"?

texts:
Consider:

I having a problem in compiling in extern "C" code in the Arduino IDE 1.6.7 which I don't have on version 1.6.5.

The error is:

  error: conflicts with new declaration with 'C' linkage

It is complaining about the lines containing loop() and start_timer(void);.

This is my code:

#ifdef __cplusplus
extern "C" {
#endif

void start_timer(void);

#ifdef __cplusplus
}
#endif

void start_timer(void)
{
    Serial.println("2");
    Serial.begin(9600);
    delay(2000);
}

void setup()
{
    start_timer();
    Serial.println("4");
}

void loop()
{
    Serial.println("1");
    delay(2000);
}


texts: constant current or constant voltage power supply to use with RGB shield with high power LEDs

texts:
So, I got an arduino uno and a RGB shield from velleman for christmas because I mentioned I might want to do a project with high power LEDs - a neat surprise, but now I have to use it (:
The shield can do PWM on an external power supply and this can be wired through to the high power LEDs itself. I aim to power about 10W of LED light in total, with different colors in order to make good use of the board. Can I go for Option 1? If not, what would you advise?

Option 1

As high power LEDs need a constant current, I am inclined to connect a constant current supply as the external supply of the board (assuming all channels' LEDs need the same current).

Update: I talked to an electrician and a constant current supply typically works on a PWM basis; putting this in series with the PWM of the shield is not smart.

Option 2

Alternatively I could connect a standard constant voltage supply and make sure that the current is within limits:

One option would be to use resistors; but, with 12V DC and 350mA I would need like 33 Ohm resistance dissipating 4 Watts of power, which is inefficient.
Alternatively there are DC voltage to constant current LED drivers which will take care of the constant current for me; I could put those at the exits of the shield for the LEDs. They supposedly have a better conversion efficiency than the resistors, but I do have any knowledge about their performance with PWM as input; but I have serious doubts they would like that type of input. Furthermore, these drivers also often have PWM capabilities. This kind of module would render the shield functionality largely useless.


texts: Arduino Mega - Multithreaded (run two loops simultaneously)

texts:
I am new to Arduino and I am not sure about how to get two loops run parallel to each other. I have tested the individual loops and both of them work perfectly before I combined them together.

One loop will take input from the LCD touchscreen. One loop will take input from vibration sensor which will determine the state (on/off) of LED. Once the LED is turned on, it has to stay at the ON state for 3 seconds before switching to OFF state.

The problem I am facing is that when the LED is triggered to ON state by vibration sensor, I have to wait 3 seconds for the input from LCD to get processed. Is there any way I can combine these two loops in such a fashion that I run them simultaneously, i.e. run two inputs together?


texts:
I'm trying figure out how to make the serial monitor printing specific content based on the user input. For instance if the user has typed '1' it should constantly print ("Hello") and when user has typed '2' it should print ("Bye") and vice versa. I'm new to programming, so I would be grateful if any can help me with this.

  String readString;

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

       void loop()
       {

         if(Serial.available()>0)

         {
            char c = Serial.read();
            readString +=c;
            delay(2);

                   if (c == '1')
                    {
                     delay(1000);
                     Serial.println("Hello");
                     c = "";
                    }

                                 if (c == '2')
                                  {
                                    delay(1000);
                                    Serial.println("Bye");
                                    c = "";
                                  }
             else
            {
             readString= "";
            }
          }
        }


texts: L298N regulated output is greated than 5V

texts:
A few months ago I used a L298N module (actually the Velleman VMA409) and I managed to make my motors working fine.
However now that I want to reuse it for another project something seems off: The regulated 5V output is always equal to the 16V VMS input.
To give more details:

I'm powering the board with 4x 3.7V 18650 batteries in series for an input of about 16V. This should be OK since according to the specs the range for VMS is 5V-35V
I'm reading the output value on the two pins I marked with an arrow in the following picture (using both of the GND pins) and in all cases I get about the same value as what I have on VMS.
This is when I have the 5V_EN jumper in place, if I remove it I get no output at all (Which I think is normal, since that disable the internal regulator)
For now I haven't connected my arduino because I want to understand what's going on before, so the Inx and EnX pins are connected to nothing.

So my questions are:

Is it indicating that I somehow fried my driver board?
Can I get back this 5V regulated output?


texts: Do we have an alternative for millis() function?

texts:
This is actually a follow up question to this question, so basically I'm using DS18B20 temperature sensor which requires Onewire.h library that interrupts millis() function.

Luckily i have a DS3231 RTC module which I'm using it with RTClib library, is there any way to use that module as a timer instead of millis() function?


texts:
I bought a new ENC28J60 module and I tried to communicate with the PC through Arduino Uno board.

When I tried to ping the address that I gave in the program it's not getting the ping. Give me some solution.

I used the web server example that is in the example section of Arduino. I even turned off my firewall setting.

The code that I used is:

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 20);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

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
  }

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");
          }
          client.println("");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}


texts: WS2812B LED Strips last 3 to 5 LEDs not working

texts:
I have plenty of power (5V 60Amps) but out of 6 strips (5Meter 150LEDs each), three of them do not light up all the way to the end...the very last 3 to 5 LEDs do not function.
When I connect another strip to these strips, they also fail to function, even when I add another 5V30Amps to the connections.
Controller has 3 channels and each is set to control 300 lamps.
Should I just cut away the parts that do not function? Or is this an indication of another problem?


texts: What will happen when I use an invalid pin number?

texts:
Related to:
  What happens if there is a runtime error?

This question is similar to the one above, however this is an alternate situation:

int pin = 999;
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);

What would happen in this instance? The compiler might catch it but if you used a random number would the IDE catch it?


texts:
so I've got myself a Arduino Pro Micro ATmega32U4 5V 16MHz and my PC (Win10 64bit) won't recognize it.
So, after I firstly plugged it in, it was detected as a Leonardo, rather than a Pro Micro, afterwards I installed hte drivers as noted by Sparkfun, and added the board to the IDE. Afterwards, my Arduino got detected as an unknown device where I can't use it anymore. I tried installing the drivers as given by sparkfun over the "unknown device" and no luck by trying, I always get an error saying that Windows has already the best drivers for it already installed.
And later, I uninstalled the "uknown device" in hope that it will re-install itself upon pluggin it back it, and it actually disappeard totally and got repalced by "Unknown USB Device (Device Descriptor Request Failed)" under USB controllers in the Device manager.
And I'm stuck here. In the IDE, the Pro Micro is detected as being on "COM1" no matter what COM port it really is, or is it even plugged it at all. Uploading a code results in the bar being filled up and "Uploading..." message, while maybe after a few minutes a very long error pops up without anything specific since you can plug out the board and get the same error.
I also tried a different PC with Windows 7 64bit on it, and instead of getting recognized as a Leonardo, this time it came straight to becoming a "Unknown device". I tried installing drivers multiple times with no luck, also again tried manually overiding the drivers in the Device manager and it always says that the best drivers are already installed.
I'm really stuck here.
Pics of  the board: https://postimg.cc/gallery/rwCDRfv


texts: maximum interrupt-based PWM frequency at 500 Hz

texts:
I need to control a 24 kHz ultrasonic transducer and decided to use an arduino uno I have lying around.

Using tone() or the atmega's hardware pwm is not very suitable because I need two 50/50 square waves with a phase difference of pi (which is equal to two XOR'ed pins) to switch the output polarity of the h-bridge synchronously. As the uC dosen't have anything else to do I wrote the following sketch where I just wait for an interrupt and toggle pins 2&3:

bool do_task=false;
void timer_init () {
  TCCR0A |= (1 << WGM01);
  OCR0A = 83;
  TIMSK0 |= (1 << OCIE0A);
  TCCR0B |= (1 << CS01);
}
ISR (TIMER0_COMPA_vect) {
  do_task=true;
}

bool state=false;
void toggle() {
  state=!state;
  digitalWrite(2,state);
  digitalWrite(3,!state);

}

void setup() {
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  timer_init();
}

void loop() {
  if(do_task) {
    do_task=false;
    toggle();
  }
}

I expected the output to have a frequency of ~24 kHz, but it is 500 Hz instead.

From my understanding:

16 MHz CPU frequency
timer0 prescaler is 8 (TCCR0B |= (1 << CS01))
output compare value (OCR0A) is 83

would result in a frequency of 16 MHz / 8 / 83 = 24096,4 kHz -but as I mentioned- it's 500 Hz and doesn't seem to depend on the prescaler.


texts: How to pass 'Serial' as an input argument in Arduino function?

texts:
I have one integer value which I should pass through Serial1, Serial2, Serial3, and Serial4 after performing some algebraic operation on this integer. For this algebraic operation, I made a function and input arguments is an integer and Serial number.
Simple code is given below: (I deleted every extra part of my code to make easy to understand)

String stringG; int d1; int d;

#include<SoftwareSerial.h>
//Software Serial #1: Rx = digital pin 10, Tx = digital pin 11
SoftwareSerial Serial4(10, 11);

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

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0)
  {
     String  XX = Serial.readString();
    int d1 = XX.toInt();
    Serial.println(d1);
    int yy;
    yy = compareFunction (d1, Serial4);
    Serial.println("Now the final values are:");
    Serial.println(d1);
    Serial.println(yy);
  }

}
int compareFunction (int d, String Serialx)
{

  int ZZ = Serialx.readString(); // I will receive some values from motor using serial4
  //to avoid long code I deleted unnecessary parts
  // I will use ZZ and d values and output will be yy
  return yy;
}

As you see in  compareFunction I receive value using Serial (it may be 1,2,3 or 4) So I have to pass Serial as an input argument in this function. If I can't pass Serial then I have to write 4 functions each for Serial1, 2, 3 and 4 which I want to avoid. Is it possible? How can I do it? when I tried with above code it shows error

  exit status 1 could not convert 'Serial4' from 'SoftwareSerial' to
  'String'


texts:
When trying to upload the blink sketch to my (unofficial) Arduino Uno, I get the following error:

avrdude ser_open() can't set com-state for "\\.\COM3"

I have programmed this Arduino before using this same laptop, but not for quite some time.  I have not changed anything in the Arduino IDE in this time.

I have tried the following:

Reading answers for the following related questions:

avrdude: ser_open(): can't set com-state for "\\.\COM2"
avrdude: ser_open(): can't open device "\\.\COM3"?
Can't upload to my Arduino UNO
avrdude: ser_open(): can't open device "\\.\COM4": Access denied

Confirmed that COM3 was the correct port by going to device manager. I have only one port listed here, COM3, and it disappears when I unplug my Uno and reappears when I plug it back in again.  One strange thing to point out is that it is called RAMPS for some reason?
Tried 3 different USB cables
Tried 3 different USB ports
Restarting the computer
Uninstalled and reinstalled the Arduino IDE
Uninstalled the device from Device Manager
Tried a (previously untested) (also unofficial) Arduino Nano.  When I looked up this in Device Manager, it was also reported as RAMPS on COM3 (strange?)

None of the above fixed the issue and all gave the same error as shown above (except when trying different USB ports which showed the error just for different COM ports).

EDIT: Just tried both the Uno and Nano on another computer and both worked fine. This confirms that both the arduinos and cables I'm using are working properly.


texts: Calculating the time between the signal when its ON and when it gets OFF

texts:
class Channel
{
    private:
        uint8_t _pin;
        uint8_t _state;
        uint32_t _rise;
        uint32_t _fall;
        uint8_t _count;
        uint8_t _channel;

        static uint8_t channelCount;

        void display()
        {
            uint32_t diff = (_fall - _rise) / 1000;
            uint32_t secs = diff % 60;
            uint32_t mins = diff / 60;
          //  Serial.print(",");
            Serial.print(_channel);
            Serial.print(",");
            Serial.print(mins);
            Serial.print(",");
            Serial.print(secs-4);
            Serial.print(",");
            Serial.println(_count);
        }

    public:
        Channel(int pin) : _pin(pin), _count(0)
        {
            _pin = pin;
            _count = 0;
            _channel = channelCount;
            channelCount++;
        }
        void process()
          {
            int s = digitalRead(_pin);
            if (s != _state)
              {
                _state = s;
                if (s == LOW)  // Fell
                  {
                    _fall = millis();
                    _count++;
                    display();
                  }
                else
                  {
                    _rise = millis();
                  }
                }
            }
        void begin()
        {
            pinMode(_pin, INPUT);
        }
};

uint8_t Channel::channelCount = 0;

Channel channels[] = { 3,5 };
#define NUM_CHANNELS (sizeof(channels) / sizeof(channels[0]))

void setup()
{
    Serial.begin(115200);
    Serial.println("Channel,Minutes,Seconds,Count");
    for (unsigned int i = 0; i < NUM_CHANNELS; i++)
      {
        channels[i].begin();
      }
}

void loop()
{
    for (unsigned int i = 0; i < NUM_CHANNELS; i++)
      {
        channels[i].process();
      }
}

This code works normally in some cases, (i.e.) It provides the exact time between the signal when it's ON and when it gets OFF in seconds.

In some cases, it spits out a 10 digit number. The correct value follows the unknown number in the screenshot attached below


texts:
What is the best and most reliable way to detect if a book is pulled out of a book case?
I have a book case which I want to mount sensors to so that I can detect when certain books are pulled out, I don't need to know how much, all I need is a boolean trigger if the book has been pulled out 2+ cm or so (works with lower too). I would preferably also want to know when they have been replaced but that is just a bonus.
The goal of the project is to move a servo which may or may not open a secret door when 3 books are pulled out in a certain order.
The sensors need to be able to work continuously 24/7 for years.
Here is a masterfully drawn picture to explain it even better.

So far I have been thinking of mechanical switches, Ultrasonic Sensor (HC-SR04), or possibly some sort of infrared light and sensor that can detect a change in intensity (where a lower intensity is book being pulled out).
The mechanical switch I could easily do, but I would prefer something that is less obvious, and less "clicky" when it's triggered. I don't want to give away that there is something special with a book if someone picks it up on accident.
Any ideas on how it can be done?
Would love tips for specific components as I'm not native to the arduino world and have a hard time finding exactly what I'm looking for.


texts:
Hi I am trying to get RSSI value from my HC-05 bluetooth module that is in master mode. I wrote some code but it did not work. Can you help me get through this? My HC-05 is in AT command mode and I am trying to get RSSI caused by another HC-05 module across the room. After I get whole RSSI entry I will parse required part somehow.
Code:
#include <SoftwareSerial.h>
//master device 2
SoftwareSerial BT(5, 6); // RX, TX
String data;

void setup() {

Serial.begin(9600);

Serial.println("Enter AT commands:");

BT.begin(38400);

}

void loop(){

BT.write("AT+INQ\n\r");
while(!BT.available()){}
data = BT.read();
Serial.print(data);

delay(5000);
}


texts: difference between output pin high and 5v pin

texts: So this might be a total noob question (which admittedly I am) I have a Motor, if I connect it to GND and the 5V output it runs. Ok so far. But if I connect it to GND and a pin set to OUTPUT and HIGH nothing happens. My multimeter reads 5V for both setups, so if 5V come to the motor one way or the other why does one work and one not?


texts: Switching methods/functions with a button

texts:
I am trying to program a basic counter using 7segment display and a button.
What I am trying to achieve is the following:

Display 0 at the beginning.
When the button is pressed: Start Loop 0-9
Display 0 when the button is pressed the second time.

So basically the button should function as ON/OFF switch for the looping numbers function.

So far I have managed to change the mode from  displaying 0 to looping 0-9, but can't seem to get changing the mode back to displaying 0:

int buttonPin = 10; // Button connected to digital pin 10.
// variable for reading the pushbutton status
boolean buttonPressed = false;
int mode;

void setup() {
    // initialize the pushbutton pin as an input:
    pinMode(buttonPin, INPUT);

    pinMode(1, OUTPUT);
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);
    pinMode(13, OUTPUT);
}

void displayZero() {
    //while (buttonState == true){
    // Displays 0.
    digitalWrite(11,1);
    //button();
    delay(1000);
    //}
}

void displayCounter() {
    // Displays 0.
    digitalWrite(4,1);
    digitalWrite(11,1);
    delay(1000);

    //Displays 1.
    digitalWrite(2,1);
    digitalWrite(3,1);
    digitalWrite(4,1);
    digitalWrite(8,1);
    delay(1000);

    //Displays 2.
    digitalWrite(2,0);
    digitalWrite(8,0);
    digitalWrite(6,0);
    digitalWrite(4,0);
    digitalWrite(9,1);
    digitalWrite(3,1);
    digitalWrite(11,0);
    delay(1000);

    //Displays 3.
    digitalWrite(4,1);
    digitalWrite(9,0);
    digitalWrite(11,0);
    delay(1000);

    //Displays 4.
    digitalWrite(2,1);
    digitalWrite(8,1);
    digitalWrite(3,0);
    delay(1000);

    //Displays 5.
    digitalWrite(6,1);
    digitalWrite(2,0);
    digitalWrite(8,0);
    digitalWrite(11,0);
    delay(1000);

    //Displays 6.
    digitalWrite(4,0);
    delay(1000);

    //Displays 7.
    digitalWrite(3,1);
    digitalWrite(4,1);
    digitalWrite(6,0);
    digitalWrite(8,1);
    digitalWrite(11,1);
    delay(1000);

    //Displays 8.
    digitalWrite(3,0);
    digitalWrite(4,0);
    digitalWrite(8,0);
    digitalWrite(11,0);
    delay(1000);

    //Displays 9.
    digitalWrite(4,1);
    //button();
    delay(1000);
}

void loop() {
    // Check button status.
    int buttonStatus = digitalRead(buttonPin);

    if (buttonStatus == HIGH)
    {
        // Checks if button is pressed and changes buttonPressed from false to true.
        buttonPressed = true;

        // While button is pressed.
        while(buttonPressed == true) {
            // Calls displayCounter method 10 times.
            for (int i=0; i<10; i++) {
                displayCounter();
                delay(30);
                buttonPressed == false;
            }
        }
    }
    else if (buttonStatus == LOW)
        displayZero();
}


texts: When the Arduino is in reset mode are the digital pins high impedance?

texts:
I have an Arduino (Arduino A) hooked up to an external FRAM chip and I want to be able to pull the Arduino A's reset pin to ground to keep it in a constant reset state. Then I want to hook up another Arduino (Arduino B) up to the same lines going from Arduino A to the external FRAM chip and pull data off of the FRAM chip.

I am worried that when I hook Arduino B to the lines running between the FRAM and Arduino A that it will damage Arduino A. If the digital pins are in a high impedance state while I do this though, then it should be fine. I can't find the necessary documentation to figure this out though.

All Arduinos involved are Uno Rev 3s.

Any help would be appreciated, thanks!


texts:
When I load the Arduino IDE with Board: Pololu A-Star 32U4 selected, I see:

The current selected board needs the core 'arduino:arduino' that is not installed.

I installed the board manually via these instructions.

When verifying the initial empty sketch, I see:

Arduino: 1.8.8 (Linux), Board: "Pololu A-Star 32U4"

The current selected board needs the core 'arduino:arduino' that is not installed.
/usr/share/arduino/arduino-builder -dump-prefs -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/ravi/Arduino/hardware -tools /usr/share/arduino/tools-builder -libraries /home/ravi/Arduino/libraries -fqbn=pololu:avr:a-star32U4 -ide-version=10808 -build-path /tmp/arduino_build_299010 -warnings=none -build-cache /tmp/arduino_cache_842714 -prefs=build.warn_data_percentage=75 -verbose /tmp/untitled689103723.tmp/sketch_feb05a/sketch_feb05a.ino

Selected board depends on 'arduino' core (not installed).

Error compiling for board Pololu A-Star 32U4.

How do I prevent this error and compile a sketch?


texts:
I want to control a 7 segment display that has a TM1637 integrated with an ESP32.

Some time ago I created a layout that used an ESP12e but I need more GPIO pins so I'm switching over to an ESP32.

This was how I had it hooked up:

CLK -> GPOI14
DIO -> GPIO12

I think I did it this way because I had to use the special CLK pin tou can see in this pinout.

Only I don't know if I need to hook them up with special pins on the ESP32. I can't find a good tutorial and I don't have the parts yet to test with.

Do you guys know which pin(s) are suitable for the TM1637?


texts: Read car high temperature exhaust pressure sensor

texts: Is it possible to read the exhaust gas pressure of a turbo car with an Arduino, and then control an electric motor based on the pressure?


texts: ESP8266 Soft Access Point: Timeout of request of resource when not responded to in set undocumented time

texts:
I'm experimenting with the ESP8266 chip on a Wemos D1 R2 board. I'm trying to write some code which will allow the user to input a username and password in an HTML form then get a response as to what happened with trying to connect to the WiFi as either they connected or the password was wrong. After I've turned setup Access Point and Station mode on the device using:

    // The field here would be global so other functions can access it
    ESP8266WebServer server(80);
    server.on("/connect", handleConnect);
    server.begin();

In my handleConnect function, I check the body of the request and attempt to login:

    if(!server.hasArg("ssid") || !server.hasArg("password")) {
        server.send(200, "text/html", "You didn't submit a ssid and password");
        return;
    }

    auto ssid = server.arg("ssid");
    auto password = server.arg("password");

    WiFi.begin(ssid, password);

    auto status = WiFi.waitForConnectionResult();

    server.send(200, "text/html", String(status));

When the user inputs the correct password, the function returns the request in time and the request responds with 3 (the connection was successful). However, if the password is wrong, the request times out. I've also tried several approaches to either work-around or fix the problem such as:

Using a while loop and calling WiFi.status() and checking it and responding accordingly. This approach ends with the same request timeout if the password is wrong. An example of this would be:

while(true) {
  delay(1000);
  auto status = WiFi.status();

  if(status == WL_CONNECTED) {
    server.send(200, "text/html", "You're connected!");
  }

  if(status == WL_CONNECT_FAILED) {
        server.send(200, "text/html", "You inputted the wrong password! Try again!");
  }
}

Registering another resource to specifically only return what state the WiFi is in and in the original connect function to send back HTML with some javascript in it which calls this other resource and do the decision making of what text to display client-side but this approach always returns 0 (when the WiFi is in process of changing between statuses, quoted from the docs)

server.on("/checkConnection", checkConnection);

// other code

void checkConnection() {
  server.send(WiFi.status());
}

And finally, I have experimented with using a public field to save the state once it has finished in the main function where the original connection tried to be established and then use the checkConnection function to return this state and this SOMEWHAT works, however, the code is messy, hacky and there must be a better way of doing this otherwise this will have to be my solution until the libraries are updated to fix this or something like that:

// public field for the status

      int status = 0;

      // other code

      void handleConnect() {

        // checking ssid and password

        WiFi.begin(ssid, password);

        // use an interval with AJAX or this to get the connection state
        server.send(200, "text/html", "Go to to check the connection");

        while(true) {
          delay(1000);
          auto s = WiFi.status();
          status = s;
          if(s = WL_CONNECTED) break;
        }

      }

      void checkConnection() {
        server.send(200, "text/html", status);
      }

Has anyone encountered this problem and if so, is there a better way of solving it apart from using a public variable which just makes it a pain in the bum to work with? Thank you.


texts:
I currently can set four PWM pins to around 31 kHz with the following code:

void setup()
{
    TCCR1B = TCCR1B & B11111000 | B00000001; // Set PWM frequency for D9 & D10:
    pinMode(pwmPin9, OUTPUT); // Sets the pin as output
    pinMode(pwmPin10, OUTPUT); // Sets the pin as output

    TCCR2B = TCCR2B & B11111000 | B00000001; // Set PWM for D3 & D11
    pinMode(pwmPin3, OUTPUT); // Sets the pin as output
    pinMode(pwmPin11, OUTPUT); // Sets the pin as output
}

I found this setup somewhere, but I don't know how I can set these four PWM pins to around 25 kHz instead. How is that possible?


texts: ESP 8266 reverse digitalWrite behaviour on which pins?

texts:
I am using a device with an ESP 8266 microcontroller. I have discovered that setting LED_BUILTIN to HIGH turns the built-in LED off and  setting LED_BUILTIN to LOW turns the built-in LED on. This seems to be because the microcontroller can sink more current than it can source.

Before I start using this microcontroller, I would like to know which other pins have this reverse behaviour. I've looked up datasheets for the ESP 8266 but I don't see how to discern this information. I would simply write a sketch to test, but I'm not sure what I might damage, and I'm not sure how to determine when an output pin is in the high-impedance state anyway.

On the ESP 8266, how to know which pins are HIGH -> 0v and which pins are HIGH -> 5v? Are the HIGH -> 0v pins necessarily LOW -> 5v? Where is this documented?


texts: Endurance of Arduino UNO during 24/7 operations and mild power fluctuations

texts:
I am designing an automation system for my research project and planning on using Arduino Uno to do the same. The program is to execute simple instructions based on few input parameters and does not need large computational powers. It is estimated it would take 26 minutes to run the program (26-minute cycle*) and it is expected that it would take anywhere from 3 weeks to 2 months to complete the project (1160 - 3300 cycles before reboot)
My question is as follows:

Is the Arduino Uno capable of surviving the extended service expectancy and execute the program correctly?
What is the influence of small voltage fluctuations on the endurance of electronics on the board?
Is a heat sink needed for this application? How to determine the power draw to choose heat sink size?
Is there any fatigue rating for the cyclic running of the program?

I am planning to power the entire system via a regulated 12V 600-watt battery bank and this bank would be periodically recharged.
*By cycle duration I mean the real word time required for completion of one batch. It is estimated that it's required to complete 1160-3300 cycles/batches for the research


texts: Tried to fix ports on Mac OS X Yosemite. Now nothing works

texts:
I was having an issue very similar to this one:

Arduino compatible's serial port not showing Mac OSX

Basically I have a clone (VISduino) and it's made with a different USB chip so it needed a driver. Installing the driver didn't help.

http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html

Running:

 sudo nvram boot-args="kext-dev-mode=1"

didn't help. So I decided to delete Arduino and reinstall. Then I went through all of the steps again.

Well.... now nothing works. Before doing this I could use:

Adafruit metro
An uno clone
My genuine uno
lightBlue Bean
adafruit trinket and trinket pro
adafruit trinket pro via USB
digikey

I've reinstalled the drivers for these but NOTHING is working now. They were all working before. It just says Arduino Uno on COM1, or digikey on COM1 etc.

And of course my clone (vis duino) isn't working either.

How can I fix this?

The com ports just are not there.


texts:
I am aware of the simplicity of the question.  Nevertheless...

I need to code into the arduino the execution of a file.  More precisely a .exe.
To put things in perspective.  I have little to no knowledge of coding.  Yet I need to put together a photocabin.  I have the arduino to count the coins inserted to my coin collector and I need to take a picture when the precise ammount is reached.  Then reset the ammount to avoid taking more pictures.
here is what my code looks so far: (taken from the examples on the arduino page)

const int coinInt = 0;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.

    volatile float coinsValue = 0.00;
    //Set the coinsValue to a Volatile float
    //Volatile as this variable changes any time the Interrupt is triggered
    int coinsChange = 0;
    //A Coin has been inserted flag

void setup()
{
  Serial.begin(9600);
//Start Serial Communication
  attachInterrupt(coinInt, coinInserted, RISING);
//If coinInt goes HIGH (a Pulse), call the coinInserted function
//An attachInterrupt will always trigger, even if your using delays

}

void coinInserted()

//The function that is called every time it recieves a pulse
{
  coinsValue = coinsValue + 0.05;
//As we set the Pulse to represent 5p or 5c we add this to the coinsValue
  coinsChange = 1;
//Flag that there has been a coin inserted
}

void loop()
{
  if(coinsChange == 1)
//Check if a coin has been Inserted
  {
    coinsChange = 0;
//unflag that a coin has been inserted

   if(coinsValue >= 0.30)
  {
       here goes the code to open a file, then the code to reset coinsValue

  }
  }
}

Thanks a million.


texts: I want to know if controlling the speed of a DC motor with PWM could break (burn out the DC motor. Sorry my English isn't that good.


texts: In what mode does the Esp8266 and flame sensor code has to be executed?

texts:
I had executed Esp8266 code by changing the board to "ESP8266 Generic Board".I have also executed the Flame and smoke sensor by "Arduino Genuino/Uno".Now how should i integrate those two?Which board mode i have to choose?

//Wificode

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
const char *ssid = "AAAA";
const char *password = "BBBBB";
int lo=16.3441;
int la=80.5243;
const char *host = "http://smshorizon.co.in";
void setup()
{
   delay(1000);
   Serial.begin(115200);
   WiFi.mode(WIFI_OFF);
   delay(1000);
   WiFi.mode(WIFI_STA);
   WiFi.begin(ssid, password);     //Connect to your WiFi router
   Serial.println("");

   Serial.print("Connecting");
 // Wait for connection
  while (WiFi.status() != WL_CONNECTED)
  {
     delay(500);
     Serial.print(".");
   }
   Serial.println("");
   Serial.print("Connected to ");
   Serial.println(ssid);
   Serial.print("IP address: ");
   Serial.println(WiFi.localIP());
   String url= "http://smshorizon.co.in/api/sendsms.php?user=XXXX&apikey=aaaaaa&mobile=xxxxxx&message="hello"&senderid=00&type=txt
   http.begin(url);
   int httpCode = http.GET();

   if (httpCode > 0) { //Check for the returning code

       String payload = http.getString();
       Serial.println(httpCode);
       Serial.println(payload);
    }

   else
   {
      Serial.println("Error on HTTP request");
   }

   http.end();
}
void loop()
{}

Code related to Flame and smoke Sensor

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
int RXPin = 2;
int TXPin = 3;
int buzzer= 8;
int flame= A0;
int gas= 7;
float lo=0.000000;
float la=0.000000;
int flag=0;
int GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXPin, TXPin);

void setup()
{
  Serial.begin(9600);
  gpsSerial.begin(GPSBaud);
  Serial.println("Intitializing.......");
}

  void loop()
  {
    if(flag==0)
    {
      Serial.print(".");
      gpsLocation();
    }
    body();
  }

  void printLocation()
  {
      Serial.print("Longitiude= ");
      Serial.print(lo,6);
      Serial.print("Latitude= ");
      Serial.println(la,6);
   }

   void body()
   {
      if(analogRead(flame) < 100)
      {
          Serial.println("Flame Detected....Alarm.......");
          Serial.println("Detecting FALSE-POSITIVE......");
          delay(5000);
          if(analogRead(flame) < 100)
          {
             Serial.print("Flame Detected at ");
             printLocation();

           }
      else
      {
         Serial.println("May be a false flame!!!");
      }

    }

   if(digitalRead(gas) < 1)
   {
      Serial.println("Smoke Detected....Alarm...");
      printLocation();
   }

  }

void gpsLocation()
{
     while (gpsSerial.available() > 0)
        if (gps.encode(gpsSerial.read()))
           displayInfo();
     if (millis() > 5000 && gps.charsProcessed() < 10)
     {
         Serial.println("No GPS detected");
         while(true);
     }
 }

  void displayInfo()
  {
   if (gps.location.isValid())
   {

        Serial.print("Latitude: ");
        Serial.println(gps.location.lat(), 6);
        Serial.print("Longitude: ");
        Serial.println(gps.location.lng(), 6);

        lo=gps.location.lng();
        la=gps.location.lat();
        Serial.println("Location Detected!!!");
        flag=1;
        Serial.println("System Ready");
    }
    else
    {
        Serial.println("re-locating");
       //Serial.println("Location: Not Available");
    }
    Serial.println();
    Serial.println();
    delay(3000);
 }


texts:
I am developing a system where I want to control the direction of the DC motor (12V) from Arduino Mega/Uno. For that, I am using L298N H-bridge chip without the board as shown below.

My question is, do I need to add extra hardware or is it enough on its own?

Thanks in advance!


texts: SR505 PIR sensor Time Delay Using Ticker Library NodeMCU

texts:
I am trying to make the value of PIR sensor value HIGH for certain time using code. SR505 have a default time delay of 8 seconds. But I want to increase it to 20 seconds.

I am thinking of increasing it using TICKER library. I have tried and tested a basic code and seems to be working fine. But I want to implement it with Ticker which will keep the value HIGH for 20 seconds as soon as the timer goes above 20 seconds and PIR is not detecting the motion then it will go set again the timer to 0.

Here is how my code looks like:

#include <Ticker.h>

#define SIGNAL_PIN D2

Ticker flipper;

void setup()
{
  Serial.begin(9600);
  pinMode(SIGNAL_PIN, INPUT);
  digitalWrite (SIGNAL_PIN, LOW);

}

void flip(){
  Serial.println("From callback");
  digitalWrite (SIGNAL_PIN, HIGH);
}

void loop() {
  if(digitalRead(SIGNAL_PIN)==HIGH) {
    Serial.println("Movement detected.");
    flipper.attach(1, flip);
  } else {
    Serial.println("Did not detect movement.");
    flipper.detach();
  }
  delay(1000);
}

Thank you!


texts: How to make the Yun allow access to a resource

texts:
I have replaced /www folder on the Yun (backing it up first), how do I make it so the Yun will redirect to the new index.html? It, right now, gives Access to this resource is forbidden when I go to yun-name-here.local

Edit: I guess it's relevent to add I can do it fine with yun-name-here.local/index.html meaning it works. The real question is how to make it so I don't need to type /index.html (HURRAY LAZINESS!)

Edit II: It's Kittens game


texts: Voltage increasing when charging a battery using arduino

texts:
I am making a solar charge controller using Arduino. So for starting, I thought I should calibrate the voltage so that I am able to read the exact voltage of battery and solar charger. For testing purposes, I do not have any solar panel, so I used a 12V power supply and set its output voltage to 13.56. I used the following calculations for getting exact voltage:

float solarData = 0;
float batData = 0;
float batScale = 0;
float solarScale = 0;
float batPinVolt = 0;
float solPinVolt = 0;
float batVolt = 0;
float solVolt = 0;

Vcc = readVcc()/1000.00;    //getting the exact voltage of arduino
Serial.print(Vcc);
solarScale = analogRead(A0);  //reading solar analog data
batScale = analogRead(A1);    //reading battery analog data
solPinVolt = (solarScale/1024.0) * Vcc;
solVolt = solPinVolt * (9.80 + 2.168)/2.168;    //I used 10k & 2.2k so entered their exact value
batPinVolt = (batScale/1024.0) * Vcc;
batVolt = batPinVolt * (9.80 + 2.168)/2.168;

Initially, I faced few problem regarding the exact voltage of the Arduino which I used as a reference voltage to calculate voltage. But then I found a solution here. So below is the code which calculate the voltage of Arduino

long readVcc()
{
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1125300L / result; // Back-calculate AVcc in mV
  return result;
 }

Now when I uploaded the code, I got the exact values of the voltages.

Now I wrote a logic where if the battery voltage is less than 12V then start charging until it is above 13V. Following is the code:

if((solVolt > batVolt)&& ( batVolt <= 12.00 ))
{
digitalWrite(chargePin,HIGH);  //enable charging
digitalWrite(loadPin,LOW);     //load off
}
else if((solVolt > batVolt)&&(batVolt > 12.00)&& (batVolt <= 13.00 ))
{
 digitalWrite(chargePin,HIGH);   //enable chargin
 digitalWrite(loadPin,LOW);      //load off
}
// // shut down when battery is fully charged or when sunlight is not enough
else if ((batVolt > 13.00) or (solVolt < batVolt))
{
 digitalWrite(chargePin,LOW);    //disable charging
 digitalWrite(loadPin,HIGH);     //load on
}

But when I uploaded the code, the Arduino started showing wrong values of the voltages. Power supply was set to 13.5, but it showed 13.15 and battery voltage was 11.8, but it showed 12.7.

Now due to this what exactly happened was it started charging so the value of battery voltage 12.7 (which is wrong) started increasing. When it was above 13V, Arduino turned off the chargePin. So when the chargePin is low, it shows the exact battery voltage which is low so it again started charging it and this loop keeps on going. This is all because of the wrong values of voltages. Following is the schematic:

I am following the article I found on Instructables. (cannot post more links due to reputation). I want to know why there is change in voltage. Can anyone please help me on what I am doing wrong.


texts:
I need cnc machine to run as smooth as possible.
It receives commands like this "M_XY 10.233 20.123".
If i send command by command there is a slight delay between commands and its noticeable.
I set serial timeout to 5 ms.
I tried to send n commands and store them on arduino, but arduino cant store much in ram. There is a huge delay while sending n commands.
I was thinking about converting letters (machine writes letters) to bezier and sending arc by arc or letter by letter in arcs. Can atmega328p interpolate bezier fast enough?
Would it be faster if i send numbers in bytes instead of strings?
That would be 4 bytes per float and merge with union on arduino.
Is there any better way of doing this i don't know of?
Edit:
This is how string commands are processed.
void addCommByte(const byte b){
  if(commID == MAX_COMM+1){
    commID = 0;
    Serial.println("TOO LONG COMMAND");
    Serial.flush();
    return;
  }

  if(b == '\n'){
    comm[commID] = '\n';
    commID = 0;

    processCommand();
  }
  else if(b == '\r')
  {
    commID = 0;
  }
  else
  {
    comm[commID++] = b;
  }
}

void loop() {
  Serial.flush();
  while(Serial.available() > 0) {
    addCommByte(Serial.read());
  }
}

Edit. Way better way.
C# side. Check for endianness in c#. Arduino is little endian.
        public void MOV_X(float mm)
            {
                SendCharAsByte("q"[0]);
                SendFloatAsBytes(mm);
            }
        public void SendFloatAsBytes(float f)
        {
            byte[] vOut = BitConverter.GetBytes(f);
            serialPort.Write(vOut, 0, 4);
        }

        public void SendShortAsBytes(short f)
        {
            byte[] vOut = BitConverter.GetBytes(f);
            serialPort.Write(vOut, 0, 2);
        }

        public void SendCharAsByte(char c)
        {
            byte[] aaa = new byte[1];
            aaa[0] = (byte)c;
            serialPort.Write(aaa, 0, 1);
        }

Arduino side.
void loop() {
  while(Serial.available() > 0) {
    processV2(Serial.read());
  }
}
// from processV2
if(byt == 'q'){   // mov x
    float mm = readFloat();
    if(X_DIR == 1) mm *= -1.0;

    stepperXY.moveXForMMSync(mm);
    Serial.println("p");
    return;
  }
// merge bytes
union u_tag {
   byte b[4];
   float fval;
} u;

float readFloat(){
  Serial.readBytes(u.b, 4);
  return u.fval;
}

There is no need to flush serial.


texts:
I got a SIM800L, same as the one under this link, Quickstart SIM800 (SIM800L) With Arduino, and played around with an Arduino Nano and Uno. I had a few problems, at the start, not getting it work properly. It turned out that my Nano 5V pin wasn't enough for the SIM unit. It works fine with Uno though.

There is the code I tested the GSM (same link) and got it working somehow, I got simple AT commands and managed to send an SMS. But after I dismantled the connections and the next day I tried again... Nothing. I can see the SIM unit connects to network as the LED blinking slows down to once every 3 seconds but when I type commands in nothing happens in the serial monitor. It doesn't give errors or anything, just nothing happens on the serial monitor.

I did wire it incorrectly, once with the Tx/Rx, but that shouldn't damage the unit, should it?

I tried to upload different programs to my Arduino and they work fine so that shouldn't be the problem. Is there a way to reset the SIM800 unit? Or am I missing something here?


texts: What are patterns of bits sent to or read from GPIO pins called?

texts:
I want to call them “words”, but I’m uncertain if this is how they are referred to in documentation for the use of a header board that might plug into an ardino board.
So if you have a sequence of ONs and OFFs being read or sent from a microcontroller board are those called words?  What are they called?


texts: Why is this extremely simple code not working?

texts:
I have a problem with a for loop, and Serial.print("Its Working") does not appear. Seems simple, I've done it before, now for whatever reason, its not working anymore
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

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

  for (int x = 0; x > 10; x++) {

    Serial.println("Its Working");
    delay(1000);
  }
}


texts:
I am working on a project involving an Aduino and screen.

As i was going through the u8glib (Arduino Monochrome Graphics Library for LCDs and OLEDs), something caught my attention:

#define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
#define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))

How can i interpret this macro for a given x value ?


texts:
We work in groups on a project at school. We had to build an electric scheme with an Arduino to make a small car moving.

We got the parts from our school, except the Arduino (we had to buy it ourselves). We had to use a battery of 11.5 V. We also had electrical resistors to protect the Arduino and the stepper drivers.

The car worked for a while, but then we wanted to change the program and tried to upload new software to the Arduino. Now the Arduino is not recognized by any computer.

We tried several things, like multiple times unplugging the USB cable, hitting the reset button on a specific timed moment (some method found on the internet).

But it still doesn't work. When the Arduino is connected via USB, the 'on' LED on the Arduino is on. After that all we came also to the conclusion that some people made mistakes on building the electric scheme...

Is it possible that the Arduino is broken, since the battery has 11.5 V?
If the Arduino isn't broken, can the problem that it's not recognized by the computer be solved?

(Arduino Uno)


texts:
I am using the Protothread Library from Adam Dunkels.
It is supposed to wait 1 second and then continue. But instead it gets stuck there and everything after that line is not executed.
lastTimeBlink = millis();
PT_WAIT_UNTIL(pt, millis() - lastTimeBlink > 1000);

Why does it get stuck there?
The entire code is uploaded here: https://pastebin.com/jRsuvn54
(The comments are on german)


texts: Esplora: Connecting a 2-Wire Speaker to Arduino Esplora

texts:
I am currently trying to make a simple game system with my Arduino Esplora, however I have noticed something. The Arduino Esplora has no pins for a 2-pin speaker that I get from a RadioShack store (Click here for item description). How would I go about connecting the speaker because I am also using the TFT LCD screen, or is there a workaround with the output TinkerKit pins on the top?

Any help is greatly appreciated. Thanks!


texts: how to write Arduino code for a stepper motor to move an arm back and forth 180 degrees

texts:
I am currently working on a project which involves picking up plastic balls and depositing them in a box. I am trying to use a stepper motor to move an arm which is attached to a square piece of plywood which has Pringles cans on it. This is how I plan to collect the plastic balls.

The stepper motor needs to move the arm back and forth 180 degrees to collect and deposit the plastic balls. But I am unsure as to how to write the code to accomplish this as I am quite new to Arduino coding. Any form of help would be greatly appreciated. Thank you in advance.


texts: Accessing a C++ static variable from gcc inline asm

texts:
For some reason I want to mix a bit of assembly with C++ (not C).
To allow the code to be compilable using the standard Arduino IDE, I don't want to use direct assembly source.
I don't want to use a wrapper C file either.
My problem is as follows:
I have a class with a single instance (implementing some kind of driver) that looks like this:
class cDriver {
public:
    char ISR_param;
    // ...
};

cDriver Driver;

If I want to access the ISR_param of this single instance from within an ISR, I can do something like:
ISR (TIMER2_COMPA_Vect) {
    do_something_with (Driver.ISR_param);
}

This works like a charm: the address of Driver.ISR_param beign a constant, the compiler simply generates an lds r24, &Driver.ISR_param instruction to load the proper byte as a parameter for do_something_with.
Now when I try to replicate the same mechanism with inline assembler, things get a lot more complicated.
The address of Driver.ISR_param is only known to the C++ compiler as an mangled label, and I can't find a way to pass it to the inline assembler to generate the equivalent lds r24, <&Driver.ISR_param>.
trying to remane the variable
The renaming of variables for assembly like so:
char global_var asm("my_var");

and an attempt to use it like so:
asm ("lds r24, my_var\n");

will compile, but produce a linker error (my_var is undefined).
Looking at the object symbol table, the only label for global_var is a C++-like mangled name.
However hard I tried this renaming trick, I could not bring the compiler to generate a my_var label.
trying to use asm constraints
A constraint like
asm (lds r24, %0\n" : : "I"(&global_var));

will simply not compile. I scoured the possible parameter types and could not find a way to let the assembler know about this bloody address.
a terribly awkward workaround
The only way I found to make the compiler generate this dreaded lds r24,... instruction is to perform an actual function call.
So you can do something like:
__attribute__((always_inline)) give_me_my_friggin_variable(char data)
{
    asm volatile ("cmp  %0,%0\n"::"r"(data));
}

ISR (TIMER2_COMPA_Vect, ISR_NAKED) {

    <some prologue to save SREG and all needed registers>

    //...

    give_me_my_friggin_variable(Driver.ISR_param);

    // continue assembly code with r24 properly initialized
}

That will generate:
    lds r24, <the proper address> // added by the compiler...
    cmp r24,r24                   // ...because of the register constraint here

Well, that sort of works, but at the cost of generating a totally useless instruction.
so my question is...
Is there a simpler way to let the assembler know about addresses of C++ static variables?


texts:
I bought today an Arduino Uno R3, and I'm looking forward to make it an HID device. I have seen many projects using a serial USB type B port. As I want to build a little gamepad, I would like to use the smaller USB mini type B port to achieve similar results. Looking it up did not seem to bring significant results.

Am I missing anything? Do I have to use a serial port similar to the one used by Arduino or can I reproduce the project using the aforementioned port?


texts: Arduino Mega not receiving data from Neo-6M

texts:
I am using the trying to get data from the Neo-6M GPS module with an Arduino mega, but, the condition 'While (gpsSerial.available() > 0' is being met. I believe this means the no bytes are being transferred from the module to the serial port but I'm not sure why.
The light on the Neo-6M was blinking which means it getting a lock but not giving out the data.

#include <SoftwareSerial.h>

// Choose two Arduino pins to use for software serial
int RXPin = 19;
int TXPin = 18;

//Default baud of NEO-6M is 9600
int GPSBaud = 9600;

// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);

void setup()
{
  // Start the Arduino hardware serial port at 9600 baud
  Serial.begin(9600);

  // Start the software serial port at the GPS's default baud
  gpsSerial.begin(GPSBaud);
  Serial.write("123");
}

void loop()
{
  // Displays information when new sentence is available.
  while (gpsSerial.available() > 0)
    Serial.write(gpsSerial.read());
}

I had it working on an Uno by connecting to pins 2,3 rather then 18 and 19. I have also tried swapping the 18 and 19 pins over but still noting.

Thanks for the help

EDIT:
I have the RX and TX plugged into the mega at pins 1 and 2, however, it will only print GPS information when the reset button is pressed or held down


texts: Issues programming Arduino Uno with Sparkfun's MAX3232 breakout board

texts:
I'm having an issue programming the Arduino Uno with Sparkfun's MAX3232 breakout board attached.  Sometimes the Arduino IDE won't see the Uno plugged in.  I'm thinking of  connecting a switch to the GND or the 3V - 5.5V pin so I don't have to disconnect the breakout board when programming.  Are there any better solutions?

Sparkfun link: https://www.sparkfun.com/products/11189


texts:
I want to know how I can use case statement for each array.

Below is my code:

int incomingByte = 0;

void setup()
{
  Serial.begin(115200);
  for (int thisPin = 2; thisPin < 6; thisPin++)
  {
    pinMode(thisPin, OUTPUT);
  }
}

void loop()
{
  int button1[] = {0xFF, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05};
  int button2[] = {0xFF, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06};
  int button3[] = {0xFF, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08};
  int button4[] = {0xFF, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C};

  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();
  }

  switch (incomingByte)
  {
    case button1:
      digitalWrite(2, HIGH);
      break;
    case button2:
      digitalWrite(3, HIGH);
      break;
    case button3:
      digitalWrite(4, HIGH);
      break;
    case button4:
      digitalWrite(5, HIGH);
      break;
    default:
      for (int thisPin = 2; thisPin < 6; thisPin++)
      {
        digitalWrite(thisPin, LOW);
      }
  }
}


texts: concurrent display of BMP file and text on Arduino TFT LCD screen

texts:
I am using an Arduino TFT LCD screen (1.7'') on Arduino Due for displaying .bmp file of 80X60 pixels. Is it possible to display a .bmp image on the lcd screen and also display text/draw an object such as a rectangle, simultaneously in the extra free space available on the screen?
The code I'm using is from the examples section in arduino IDE. File->Examples->TFT->Arduino->TFTBitmapLogo


texts:
I am not actually using ad arduino but an atmel chip. but my question is c microprocessor related

I am reading an uart which returns data in the form uint8_t [100]
I can print the  return just fine, the return is "OK"

but when I try to use strcmp(read, "OK")
I do not get the expected value, I get a mismatch ( strcmp returns 13, not 0)

uint8_t  sigfox_rd_buf[100] = {0};
uint8_t sig_rd = 0;

io_sigfox->read(io_sigfox,&sig_rd, 1);
while(sig_rd != 10) // read until end char
 {
     sigfox_rd_buf[i] = sig_rd;
     i++;
     io_sigfox->read(io_sigfox,&sig_rd, 1);
 }
 if(strcmp((char *)sigfox_rd_buf,"OK") == 0 )
 {
  do_something()
 }
 else
{
complain();
}

and I always end up in complain for some reason.. please help!! :)


texts:
I am using a lot of different boards(uno, teensy, nano, esp8266, esp32) with the Arduino IDE. Quite often I forget to change it, which causes problems and sometimes even bricked devices.
Is it possible to check in the code if the correct board type is set? I managed to test the architecture with for example

#ifndef ARDUINO_ARCH_ESP8266
#error Wrong architecture!
#endif

but I did not manage to test the particular board. (For example 'Generic ESP8266 Module' versus 'WeMos D1 R2 & mini'.
Even better if I could check the correct Flash size settings.


texts:
Firstly i printed input[16] then encrypted it and printed the cipher and finally decrypted and printed input[16] but why my result is not matching after decryption ???????

I tried with different baud rate and also different input output array but not working.

Library Used: https://rweather.github.io/arduinolibs/classCBC.html

#include <CBC.h>
#include<AES.h>
CBC<AES128> cbc;

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

 uint8_t key[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 uint8_t iv[16] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t input[16] = {0,1,2,3,0,0,0,0,0,1,1,1,2,2,3,3};
size_t len = 16;

cbc.setKey(key, 16);
cbc.setIV(iv, 16);

for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.encrypt(input, input, len);
delay(1000);

Serial.print("input:");
for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.decrypt(input, input, len);
delay(1000);

Serial.print("input:");
for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.clear();
}

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

}


texts: DHT11 thermometer connected to a LCD and 2 servos connected to joysrick

texts:
Im trying to find a way to run two codes from the one arduino me being an absolute begginer doesnt even know where to start the DHT11 thermometer is connected to a LCD showing temperature and humidity and uses a "DHTlib" library whereas the joystick controlling 2 servos has no library. I have two seperate working codes but putting them together and getting them to work is a big problem.
The concept is to control a space rover for my school project there will be a camera attathced to the servos so it can move along 2 axes and the thermometer is to prove the rover can gather imformation.


texts: I have created a algorithm and using arduino harware, and I don't want that users of my hardware could read or copy the Program so is there any security code or something that I could use. But I must access it whenever I needed to. It should be like admin and users.


texts: Using SDA and SCL with analog inputs at the same time

texts:
I'm trying to build a robot arm based on Arduino UNO and PCA9685 controlled by few potentiometers. The easiest way that I figure out and find on internet is using two Arduino's, one as master and second as slave.
This is where my question comes from, there is a way to use single Arduino UNO instead of two by using at the same time SDA and SCL with analog inputs? Maybe there is another way to do that?

That's my actual code:

#include <Arduino.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwmDriver = Adafruit_PWMServoDriver(0x40);

void setup()
{
  pwmDriver.begin();
  pwmDriver.setPWMFreq(51);
}

int tempPotVal = 0;
int adcPin[4] = {A0, A1, A2, A3};
int pwmRisingTime = 0;
int pwmFallingTime = 0;

void loop()
{
  for (int id = 0; id < 4; id++)
  {
    tempPotVal = analogRead(adcPin[id]);
    pwmFallingTime = map(tempPotVal, 113, 842, 102, 512);
    pwmDriver.setPWM(id, pwmRisingTime, pwmFallingTime);
  }
}


texts: 16 by 2 lcd display is not showing any character

texts:
I am trying to interface 16by2 lcd with msp432p401m controller but my 16 by 2 lcd is not showing any character. I have attached schematic and code for reference. By using same schematic and code 20 by 4 lcd is working properly.
please help me...


texts: can i use bluetooth from a speaker as a bluetooth module?

texts:
i have a Bluetooth speakers that i don't want,and i was wondering if i can use its Bluetooth as a Bluetooth module to use it with Arduino.
if so how what pins should i use. here is a pin diagram for the module.


texts:
I have a GSM/GPRS shield for Arduino. It uses a SIM800 from SIMCOM. I've done several projects using it. Previously I used to send SMS from the same module. which were delivered appropriately. Since yesterday, whenever I am sending an SMS to my Android mobile, all what I receive is:

<<Content not supported>>

I also tried sending it to a basic mobile. It displayed:

Content can't be displayed

I tried changing the encoding using the AT command.

AT+CSCS="UCS2"
AT+CSCS="GSM"

It didn't work for any encoding.

The command I use to send SMS is:

---> AT+CMGF=1
<--- OK
---> AT+CMGS="10 digit number"
<--- >
> Hello!
^Z

Can someone please tell me what is going wrong? Thank you in advance!


texts: Losing top brightness when using tip120 and PWM with 70w LED panel

texts:
I have been experimenting with pwm dimming using TIP120 on various high powered LED's, and have noticed a marked drop in the top level brightness compared to original connection without the tip 120 in line.
For instance a 70w panel connected with heavier gauge cable (not using jumper cables) no longer reaches full brightness with pwm set too full.
im using tasmota on a nodemc8266.
Is there something inherent the hardware set up causing the loss that I am missing or is there a software limitation with PWM?
curious

thanks


texts:
I have a plant growing box, fully controlled with arduino.

Youtube: ESP8266 IOT Flora

All things are under control, besides the air temperature.
I can cool it down running fans, but cannot find a way to heat it up.

Need to keep the temperature between 25-28 C all the time.

I was thinking of:

8x8 (64) Leds - maybe this can heat up the temperature, how much ?
Dedicated Module - is there any 5v heating module available ?


texts:
I'm using Serial.read(); to read keyboard input from the serial monitor.
It only sends the characters after hitting enter or clicking the "send" button.
Is there a way to read keyboard input without having to use "enter"?


texts: I am new to arduino and need some help. I just baught light bars for my jeep and wiring harnesses with them, the harnesses come with buttons and I wanted to replace the button and have them controlled on my phone. The harnesses come with a relay and a fuse and a button all 12v, How would i go about using my raspberry pi or udoo x86(which has built in adruino) to basically replace the rocker switch so i can then turn things on and off without needing to have actual switches.


texts: When I use Mouse.move() method (https://www.arduino.cc/en/Reference/MouseMove), what are units of xVal and yPos parameters?


texts: Erasing all flash on boards with over 64kb of program memory

texts:
I'm using a Mega2560 board.

My project needs to store some large constant data. To preserve the first 64kb flash chunk, I write these data on addresses beyond this limit.

But there is either an issue doing that or I'm doing something wrong...

After writing data the first time, I can read all bytes without no problem, but if I rewrite these data with new ones, the new data are not written correctly. It seems that, before reprogramming, the flash over 64kb are not erased.

Is this correct? How can I resolve this issue?

Note that, to access the data over 64kb, I use a far address.

Reading inside the bootloader source (stk500v2) code, I found that it doesn't erase pages whose addresse falls over 64kb to preserve the bootloader area. It seems that the bootloader is placed at the boundary of the first 64kb.

The following is the relevant the portion of the bootloader source:

// erase only main section (bootloader protection)
// APP_END is below 64KB
if (eraseAddress < APP_END )
{
    boot_page_erase(eraseAddress);  // Perform page erase
    boot_spm_busy_wait();       // Wait until the memory is erased.
    eraseAddress += SPM_PAGESIZE;   // point to next page to be erase
}

/* Write FLASH */
do {
    lowByte     =   *p++;
    highByte    =   *p++;

    data        =   (highByte << 8) | lowByte;
    boot_page_fill(address,data);

    address =   address + 2;    // Select next word in memory
    size    -=  2;              // Reduce number of bytes to write by two
} while (size);                 // Loop until all bytes written

boot_page_write(tempaddress);
boot_spm_busy_wait();
boot_rww_enable();


texts:
I am trying to learn how to make a shift register work. I have been working off of the Arduino ShiftOut tutorial.

My issue is that the shift register isn't working when the circuit is powered and I am not sure what is wrong. I suspect the issue is with pins 10-13 on the 74HC595?

I have done this with an actual board and the 123d.circuits.io simulator with the same result:

http://123d.circuits.io/circuits/444111-shift-register

The code is very simple and taken from the tutorial:

// SH_CP; 11
const int clockPin = 9;
// DS; 15
const int dataPin = 8;
// ST_CP; 12
const int latchPin = 10;

void setup() {
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(latchPin, OUTPUT);

  Serial.begin(9600);
  Serial.println("reset");
}

void loop() {
  for (int number = 0; number < 256; number++) {
    Serial.println(number);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, number);
    digitalWrite(latchPin, HIGH);
    delay(500);
  }
}


texts: Getting the "Device has problem: 0x0a: CM_PROB_FAILED_START." error code 10 while installing device driver for Arduino Uno

texts:
After uninstalling and reinstalling Arduino IDE, my Arduino Uno is not recognized by my PC. When I connect it to my PC all lights are glowing in my board but my PC is not showing anything connected to USB.

When I tried to install drivers manually I'm getting the error device cannot start code 10. I have used the default drivers for Arduino, which I downloaded with the IDE. I tried installing them manually. I don't have any idea about chipset interface whether it is CH or FTDI. I have looked at all the possible solutions but my problem wasn't solved.


texts: Use mobile charger as power suppy to ESP8266 wifi module with 3.3v converter

texts:
I am using this FTDI connector to power and flash code inside ESP8266 module.

Now I am done with adding code to ESP8266, now I just want to power it.
but when I connect the mobile charger(5v output) instead of FTDI connect it gives only "?????? ???? ????" this output.
can't I use this as VCC and GND ??


texts: How do I properly trigger the ATMega328 reset pin via software so that the bootloader runs and the firmware can be updated via RX/TX pins?

texts:
I am programming my Atmega328P chip via a USB to TTL converter (https://www.amazon.com/gp/product/B075N82CDL/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1)

I am able to upload hex files via the command line and the Arduino IDE when I have the RTS pin of the adapter and a capacitor attached to the !RESET pin of the Atmega. (http://www.electronics-lab.com/wp-content/uploads/2018/09/programming-Uno-on-breadboard.png)

I am also able to upload via the command line when I have a push button attached to the !RESET pin and manually pull it low then begin uploading the firmware within a few moments. (https://cdn.instructables.com/F0L/2F6U/J7AQSHD1/F0L2F6UJ7AQSHD1.LARGE.jpg)

My problem is that for my application I will only have the TX/RX/Vcc/GND pins available (no RTS or push button) and need to reset the micro controller so the bootloader runs and listens to be programmed with updated firmware.

So far I have written a batch file that sends a command to restart the Arduino, and then calls avrdude to upload a hex file. I have tried two methods of restarting the micro controller. I have told it to go to memory location zero, and I have attached an IO pin to the reset and dropped it low (although it stays low until reset, so the reset doesn't really work until I manually remove the wire between the IO pin and the !RESET pin)

My sequence is as follows:

Have Arduino running code:

    int recvByte;
    int delayS = 400;
    int resetPin = 9; //bttom right pin of uC

    void setup() {
      // put your setup code here, to run once:
    pinMode(txPin, OUTPUT);
    pinMode(rxPin, INPUT);
    pinMode(resetPin, OUTPUT);
    digitalWrite(resetPin, HIGH);
    Serial.begin(57600);
    Serial.write("Booted/reset");
    Serial.write("This setup was uploaded with batch");
    }

    void(* resetFunc) (void) = 0;

    void loop() {

    if (Serial.available() )
    {    // get incoming byte:
        recvByte = Serial.read();
        if (recvByte==int('r'))
        {
        Serial.write("resetting");
        delay(10); //wait for last message to send
        //digitalWrite(resetPin, LOW); //commented out because this method stays low until wire is removed
        resetFunc();
        Serial.write("should not see if reset properly");
        }

    }

    delay(100);
    }

2.I then run my batch file.

echo Running upload bat, sending reset command then calling avrdude
cd "C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\"
python "path\sendR.py"
.\avrdude.exe -C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM6 -b57600 -D -Uflash:w:"path\Atmega328code.hex":i

The python sendR.py is to send the "r" character, which the Arduino views as the reset command.

import serial
ser = serial.Serial("COM6", baudrate=57600)  # open serial port
bytes = "r".encode()
ser.write(bytes)
ser.close()
print("End python script")

When I send "r" via Tera Term or python the setup code runs again, but I have not been able to upload with the .\avrdude.exe -C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM6 -b57600 -D -Uflash:w:"path\Atmega328code.hex":i command inside the batch file. If I use the pushbutton to do a hardware reset, this command works without issue.

How can I upload new firmware via the RX and TX pins using software to reset the microcontroller and listen for new code as the bootloader runs?

New ideas tried:
Use a uniform baud rate of 57600 in python and atmega serial setup. I chose this value because the Arduino IDE output this baudrate in avrdude.exe -C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM6 -b57600 -D -Uflash:w:"path\Atmega328code.hex":i


texts: SoftWire Library Programming Questions for I2C with Digital Pins

texts:
I am trying to use 3 TOF10120 Laser Sensors with one Arduino that all have the same, fixed I2C Address. I don't believe it is possible to change the I2C address of the TOF10120, but if I am wrong, please let me know (also, I need 3 different addresses). This being said, I am trying to use the SoftWire Library (https://github.com/stevemarple/SoftWire - very interesting library, but not great documentation) to help me to use my three sensors with Digital Pins. Does anyone have any experience with the SoftWire Library and how to get readings from a laser sensor?
I can provide the code I have, but it probably wouldn't be very helpful anyway. I am particularly curious as to how to use the DigitalWrite() and DigitalRead() functions for I2C with SoftWire.
Thanks for all the help in advance!


texts: Clearing string buffer with memset after a serial read

texts:
In using the SerialTransfer.h / pySerialTransfer libraries to send commands between my laptop and an Arduino Mega, I am sending multiple sequential strings between the devices. However, I'm having trouble "clearing" the receiving buffer on the Arduino side - it never shrinks, despite a few different attempts to clear the string (memset; a for loop).

I'm sending a string to the Arduino of the format , where there are anywhere from 1 to 5 asterisks.  Then the Arduino is simply sending the exact same string back, without any processing (as of yet).  And in the python terminal, I'm printing it all out; this is what I get:

SENT (17 bytes): <rand_len_str=**>
RECD (17 bytes): <rand_len_str=**>

SENT (18 bytes): <rand_len_str=***>
RECD (18 bytes): <rand_len_str=***>

SENT (19 bytes): <rand_len_str=****>
RECD (19 bytes): <rand_len_str=****>

SENT (17 bytes): <rand_len_str=**>
RECD (19 bytes): <rand_len_str=**>*>

SENT (18 bytes): <rand_len_str=***>
RECD (19 bytes): <rand_len_str=***>>

SENT (18 bytes): <rand_len_str=***>
RECD (19 bytes): <rand_len_str=***>>

As long as the string is growing, all is well - but see the error in the 4th pair, with the extra *> characters, etc.

The following is my Arduino code; I've tried to reset the receiving string using memset, but this seems not to be working.

#include "SerialTransfer.h"

SerialTransfer myTransfer;

const int CMD_LEN = 200;
char buff[CMD_LEN];
char received_str[CMD_LEN];

void setup()
{
  Serial.begin(115200);
  myTransfer.begin(Serial);
}

void loop()
{
  if(myTransfer.available())
  {
    //////////////////////////////////////////////
    // handle call from Python

    memset(received_str, '\0', CMD_LEN*sizeof(char));
    myTransfer.rxObj(received_str, CMD_LEN);

    sprintf(buff, "%s", received_str);
    //////////////////////////////////////////////

    //////////////////////////////////////////////
    // send response
    myTransfer.txObj(buff, strlen(buff));
    myTransfer.sendData(strlen(buff));
    //////////////////////////////////////////////
  }
  else if(myTransfer.status < 0)
  {
    Serial.print("ERROR: ");

    if(myTransfer.status == -1)
      Serial.println(F("CRC_ERROR"));
    else if(myTransfer.status == -2)
      Serial.println(F("PAYLOAD_ERROR"));
    else if(myTransfer.status == -3)
      Serial.println(F("STOP_BYTE_ERROR"));
  }
}

I didn't see anything in SerialTransfer.h about clearing the rxObj; I can always just use the first terminating > character to parse the command - but I imagine there is a cleaner / better solution in clearing the buffer, or at least, I'd like to understand what's going on! Thanks in advance.


texts:
I'm trying to interface with a master I2C device that doesn't exactly follow the normal I2C protocol.

The only difference really is in the read request. A "normal" I2C read operation looks like this ([M]aster, [S]lave):

S | SLA+R | ACK | Data | Ack | Data ...some number of bytes... Nack | P
^M  ^M      ^S    ^S     ^M    ^S                              ^M     ^M

But this device expects to do a read like this:

S | SLA+R | ACK | Data | Ack | Data | Ack | Data | Ack | P
^M  ^M      ^S    ^M     ^S    ^S     ^M    ^S     ^M    ^M

Essentially a read request goes to the slave device, and then the master sends an 8-bit register address, and then the master expects 2 data bytes back from the slave with the Master responding with an ACK on both.

I've been able to set up a master device to do this style of protocol pretty easily by just manipulating the I2C registers directly. But I can't seem to find a way to get the slave device to accept that it is going to receive a data byte after it has been selected by a SLA+R, which leads to a bus contention problem and the slave not giving the master an ACK.

Is this possible to do with the built in I2C hardware on the Atmel chips? Is there any alternative if it can't (bit-banging)?


texts: Need documentation for Soil Sensor from DIYmore

texts:
Does anyone have any documentation on this device?
Im just curious how it work out of the box and how to reference the on board temp and soil sensors.
Its a (for lack of a better name)a "ESP32 DHT11 WIFI Bluetooth Soil Temperature Humidity Sensor18650"
SKU:012592
Item on DIYmore site


texts: How to prevent Wire.requestFrom from hanging?

texts:
I'm trying to read data from an Arduino Uno I2C slave via Wire.requestFrom() on an Arduino Uno master. The slave's onRequest handler is simply:

void I2C_Send()
{

  byte myArray[4];

  myArray[0] = lowByte(acount);
  myArray[1] = highByte(acount);
  myArray[2] = lowByte(bcount);
  myArray[3] = highByte(bcount);

  Wire.write(myArray, 4);

}

It seems to work fine for a few iterations, but eventually something happens and the master's requestFrom() call hangs indefinitely. What's causing this and how do I prevent it?

I've tried setting various levels of timeout with Wire.setTimeout(x); but that has no effect.


texts: how to implement PWM LED fading into a random case switch?

texts:
Ive recently bought my self a arduino Mega 2560 and managed to get a sort of RANDOM function to work with different cases which go of by the number selected.
My question is is there a way to also make a PWM sequence in such a case? so that the LED is fully light to dark and then the the next case starts?  IS there a more random sequence wich i could then also expand if neccesary?

Mark.

int ledcolor = 0;
 int a = 500; //this sets how long the stays one color for
int b = 2000;
int brightness = 255;    // how bright the LED is
int fadeAmount = 25;    // how many points to fade the LED by

 void setup() { //this sets the output pins

 pinMode(11, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(9, OUTPUT);
 pinMode(8, OUTPUT);
 }

 void loop() {
 int ledcolor = random(1,16); //this randomly selects a number between 1 and 15

 switch (ledcolor) {

 case 1: //if ledcolor equals 1 then the led on pin 11 will turn on etc.
 analogWrite(11, brightness);
 brightness = brightness - fadeAmount;     break;
 case 2:
 digitalWrite(10, HIGH);
 delay(a);
 digitalWrite(10, LOW);
 break;
 case 3:
 digitalWrite(9, HIGH);
 delay(a);
 digitalWrite(9, LOW);
 break;


texts: Direct 5V current based on analog signal

texts:
I would like to manage many LEDs from my Arduino - 12 or so - but I do not have the available digital pins to do this. Only one LED needs to be on at one time. Instead, I was hoping to control these with an analog pin. I was wondering if there is some sort of switch out there which can take an analog signal and, based on the value, direct a 5V current to a certain LED.

I realize that I could use a second Arduino for this, but I am trying to avoid that.

Thanks in advance for any help!


texts: Did I overheat my Arduino while soldering to perfboard?

texts:
So this is the second time that I've had a circuit that worked perfectly on a breadboard, but as soon as I connected it to a perfboard and soldered the joints together, the Arduino stopped working and wouldn't let me upload sketches (though I could see a COM port for it).

I'm using lead-free solder for the first time, and had the temperature at 750 deg Fahrenheit, and I'm thinking that while I had quick joints to connect the Arduino to the perfboard, when bridging two joints with solder, the iron might have been heating the header pin for 4-10 seconds... Is that enough to break the board?

(note - I'm using jumper wires on the other side to connect everything up, and I've already checked the board's connections using a multimeter and they're all as intended, and there are no accidental shorts/bridges)


texts: Wiring a RT314F12 latch relay to an Arduino

texts: I want to automate the lights in my house. To do this, I want to use a latching relay, so it will only use current when switching. I found a quite cheap latching relay RT314F12 but I do not know how to wire it up to an Arduino. Can any one please give a wiring example?


texts: What's the difference between a clone and a counterfeit Arduino?

texts: I've been hearing a lot about clones and counterfeits. What are the differences between the two?