texts:
Please see the comments section if confused.
I am trying to turn a motor on and off once per second, and when the motor is on, the RGB turns green. When the motor is off, the RGB is red. Everything is connected to an arduino UNO.I have the motor connected to pins 0 and 1, and to the 5V and GND. The RGB is connected to pins 4, 5, and 6, and the 5V.
I have two codes; one with a bunch of screwing around with a bunch of different loops and everything else I've tried, and one with the simple motor on/off code.

void setup ()
{
  pinMode(0,OUTPUT); //IB1
  pinMode(1,OUTPUT); //IA1
////  pinMode(2,OUTPUT); //IB2
////  pinMode(3,OUTPUT); //IA2
//  pinMode(4,OUTPUT); //RGB
//  pinMode(5,OUTPUT); //RGB
//  pinMode(6,OUTPUT); //RGB
//  pinMode(A0,INPUT); //lMotor
////  pinMode(A1,INPUT); //rMotor
//  Serial.begin(9600);
}

void loop ()
{
  digitalWrite(0,HIGH);
  delay(1000);
  digitalWrite(0,LOW);
  delay(1000);

//  int lMotor = analogRead(A0);
//  Serial.write(lMotor);
////  int lMotor = analogRead(A1);
////  Serial.write(lMotor);
//
//  if (lMotor>10)
//  {
//    digitalWrite(4,HIGH);
//    digitalWrite(5,HIGH);
//    digitalWrite(6,LOW);
//  }
//  else
//  {
//    digitalWrite(4,HIGH);
//    digitalWrite(5,LOW);
//    digitalWrite(6,HIGH);
//  }
}

And here's this:

void setup ()
{
  pinMode(0,OUTPUT);
  pinMode(1,OUTPUT);
}

void loop ()
{
  digitalWrite(0,HIGH);
  delay(1000);
  digitalWrite(0,LOW);
  delay(1000);
}

What do I need to do? Should I use a "while" loop? If so, how?
Is my circuit put together properly? I'm using a motor relay switch to turn the motor on/off, but I'm pretty sure it's hooked up right.
Any help is appreciated, even if it doesn't answer all of my questions.
Thank you.


texts: How to emulate an RFID tag with the RC522

texts:
Is it possible to emulate an RFID tag with the RC522? (Spec sheet: nxp MFRC522.pdf)
I want the RC522 to act like a NTAG213 nxp.com/documents/data_sheet/NTAG213_215_216.pdf and to be read/write by other readers/writers.
Are there libraries for that purpose?


texts: Check if any of loop's insides returns 1 and hold it until the whole loop is 0 again

texts:
I'm new to this, so, please, don't crucify me.
I have a function that checks if an entry in multilevel array is in a certain range. Using FOR loop I check the whole array with this function, which gives me true/false value for each record.
And now the problem:
I need to check if ANY entry in that loop returns true and hold it until every result of that loop is false again.
Any tips?
Thanks a lot.
There is my for loop:
  for(int i = 0; i < arrayTop; i++){
for(int j = 0; j < arrayDay; j++){
  for(int k = 0; k < arrayTime; k++){
    timeCompare(timeArray[i][j][k][0], timeArray[i][j][k][1], timeArray[i][j][k][2], timeArray[i][j][k][3], timeArray[i][j][k][4], timeArray[i][j][k][5], timeArray[i][j][k][6]);

    //Serial.print(i);Serial.print(j);Serial.print(k);Serial.print(" ");
    Serial.println(compareVar);

    if(i == 0){

      //set water switch
      if(compareVar == 1){
        waterOn = 1;
        Serial.println("Water ON");

        goto bailout;
      }
      else {
        waterOn = 0;
        Serial.println("water OFF");
      }
    }
    else if(i == 1){

      //set light switch
      if(compareVar == 1){
        lightOn = 1;
        Serial.println("Light ON");
        goto bailout;
      }
      else {
        lightOn = 0;
        Serial.println("light OFF");
      }
    }
  }
}

}
bailout:
and this is the called function:
//time compare with ON/OFF switch
int timeCompare(int hrOn, int minOn, int secOn, int hrOff, int minOff, int secOff, int timerSwitch){
  unsigned long int onTime = (hrOn*10000UL) + (minOn*100UL) + secOn;
  unsigned long int offTime = (hrOff*10000UL) + (minOff*100UL) + secOff;
  unsigned long int currentTime = (dt.hour*10000UL) + (dt.minute*100UL) + dt.second;

  if(timerSwitch == 1){
    if(onTime < currentTime && offTime > currentTime){
      compareVar = 1;
    }
    else {
      compareVar = 0;
    }
  }
 else if(timerSwitch == 0) {
    compareVar = 0;
  }

  //Serial.print("compare: "); Serial.println(compareVar);

}


texts: Using 18650 batteries with a 3.7v to 5v boost converter

texts:
I'm looking to set up a 1-meter strip of WS2812B LEDs (60 LEDs) with an off-the-shelf RF LED controller with a remote. The LEDs want a 5V supply - I've tried running them off 3.7v but the colour accuracy goes out the window and they start flickering and doing all sorts of other nonsense.

To work around that I'm considering using a DC boost converter like one of these pololu ones. I'll wire up a couple 18650 batteries in parallel to supply the voltage and my plan is to hook them up to the LEDs via the boost converter.

Idiot question time: is it safe to wire the boost converter directly to the output terminals of the battery/batteries and take the 5V off the +5v pin using a common ground? Or am I doing something dumb?

Also, I'm not 100% sure how to go about charging this setup. One option would be to put the batteries in cases and use an external charger with replaceable cells.

Would it make more sense to get one of these? This should be able to handle both charging AND stepping up the voltage, am I right?


texts:
I am working with an Arduino Due and I am having some issue with the serial Rx buffers size. I am using a GSM module and some of the replies to the Arduino exceed the number of bytes I can store in the buffer at once.

I have read about ways to increase the buffer size by modifying the Arduino default install files but I cannot take this route as my code may then be compiled on a machine with standard buffer sizes in the default install files and the module would not work correctly.

I am not sure if it is possible but I was hoping that someone might know how to increase the serial buffer size using the source code. If I can do it this way the buffer would always be the size I have specified.


texts: 8Ω speaker, what resistor values to use?

texts:
I want to connect 2 speakers of 8 ohm to 2 (different) pins of the Arduino.
However, for this example one speaker is enough.

I came across a lot of circuits without or with a single resistor which on other foras was not adviced, where one pin directly controls the speaker. This way (assuming 0,02A is the max recommended output for a pin), the resulting power is like 0.02A * 5V = 0.1W.

My speaker is 0.5W (8 ohm) and I want to hear how hard that is :-)

But it seems I have to use something with a transistor to isolate the path.
I came across this circuit:

However, when I would calculate the values or R1 and R2 myself I would get:

R2: Afaik, the recommended output for a pin is 0.02 A. This means:
V = I * R <=> 5 = 0.02 * R <=> R = 5 / 0.02 = 250Ω -> 270Ω (nearest higher value)
R1: my speaker is 0.5W, 8Ω.
P = V * I <=> 0.5 = 5 * I <=> I = 0.1A
V = I * R <=> 5 = 0.1 * R => R = 50Ω, which is Rtotal below:
Rtotal = Rspeaker + R1 <=> R1 = Rtotal - Rspeaker = 50 - 8 = 42Ω => 47Ω (nearest higher value)

This result in
V = I * R <=> 5 = I * (R1 + Rspeaker) <=> I = 5 / (47 + 8) = 5 / 55 = 0.0909 A
P = V * I = 5 * 0.0909 = 0.4545 W (so I lose 'just' 10%)

Are my calculations correct, and I assume the +5V pin of the Arduino will not have trouble giving 90.9 mA ?

Update:

I have some more questions regarding the accepted answer:

Would it mean if I use 7 transistors, all my voltages will be used for transistors and nothing is left (7 times 0.7 V which is approx. 5 V?)
**** Answer = No, a transistor will add Voltage so 7*0.7= 4.9Volt added ***
I assume I can better use as less as possible to 'switch' a transistor? * Answer = No, 0.7-Volt required, 5V is fine depending on the rating of the transducer   (but enough to be able to switch it) ? You say R2 can be smaller, but I can better make it higher not to waist voltage?  Answer = Changing the resistor will change the volume, look at the wattage rating for the speaker *
I already built the circuit below (but with a BC547 transistor) ... using a 0,25W R1 resistor. I guess I was lucky (?) * Answer = No, luck has no part, that transistor would work fine within the parameters used, look at the datasheet *
Regarding the base pin of the transistor ... by making the resistor higher (see item 2 above) ... that would help also not to burn the transistor pin? * Answer = No... please view the datasheet and ratings for the hw *
Again about the transistor, so I should make the resistor R2 in such a way that the gain times the mA is driving the speaker? (need to calculate this again) * Answer No, and I think you are thinking of "Gain" the wrong way, "Gain" is a "DB" measure and is for how well AC is transferred between antenna. *
You say to remove R1 completely ... but than I expect V = I * R <=> 5 = I * 8 => I = 0.625A ... P = V * I = 5 * 0,625 = 3.1W which blows the speaker? * Answer = Wrong way of looking at the 8-Ohm Impedance rating, Impedance is AC *


texts:
I am working on a project where I am trying to send data using HTTP and POST method from my Arduino Mega2560 to a website which I host on localhost. I am living to a students' accommodation and thus, I do not have access to the router. However, I have bought a router and have connected it to the wall via the WAN. Also, the Arduino is connected to one of the ethernet plugs of the router via an Ethernet shield and my laptop to another ethernet plug. I am trying to retrieve the data from the website, but I cannot seem to load them.

Arduino Code

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

dht DHT1;
int temperatureSensorPin1 = 25;

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
EthernetClient client;
EthernetServer server(80);

long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 250000;
String data;

long lastUpdate = 0;

void setup() {

  Serial.begin(9600);
  if(Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
  }

  data = "";

  pinMode(temperatureSensorPin1, INPUT);
}

void loop() {

int temp1 = DHT1.read11(temperatureSensorPin1);

switch (temp1)
  {
    case DHTLIB_OK:
        Serial.print("OK,\t");
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print("Checksum error,\t");
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print("Time out error,\t");
        break;
    case DHTLIB_ERROR_CONNECT:
        Serial.print("Connect error,\t");
        break;
    case DHTLIB_ERROR_ACK_L:
        Serial.print("Ack Low error,\t");
        break;
    case DHTLIB_ERROR_ACK_H:
        Serial.print("Ack High error,\t");
        break;
    default:
        Serial.print("Unknown error,\t");
        break;
  }

  currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
  }
  String data="temp1="+String(DHT1.temperature, 0)+"&temp2="+String(DHT2.temperature, 0)+"&temp3="+String(DHT3.temperature, 0)+"&temp4="+String(DHT4.temperature, 0)+"&temp5="+String(DHT5.temperature, 0)
                  +"&hum1="+String(DHT1.humidity, 0)+"&hum2="+String(DHT2.humidity, 0)+"&hum3="+String(DHT3.humidity, 0)+"&hum4="+String(DHT4.humidity, 0)+"&hum5="+String(DHT5.humidity, 0)+"&gas="+gasValue;

  Serial.println(Ethernet.localIP());
  if(client.connect("192.168.0.1", 80)) {
    client.println("POST /home/visualisation.php HTTP/1.1");
    client.println("Host:  192.168.0.1");
    //client.println("User-Agent: Arduino/1.0");
    //client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded;");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.print(data);
    //Serial.println(data);
    Serial.println("We have connection");
  }

  if(client.connected()) {
    Serial.println("We have abc");
    client.stop();
  }

  delay(4000);
}

PHP Code

<?php
$temp1 = "";
if(isset($_POST['temp1'])) {
    $temp1 = $_POST['temp1'];
}
echo $temp1;
?>

Windows ip configuration
[Router ip configuration][2]

Is the connection that I have made the appropriate one? How should I do it in order to work?

P.S.: I would like to clarify that I do not have an extended knowledge regarding networking.

Router ip configuration
LAN
MAC Address: 60-E3-27-E7-70-7A
IP Address: 192.168.0.1
Subnet Mask: 255.255.255.0

Wireless
Wireless Radio: Enable
Name (SSID): TP-LINK_707A
Mode: 11bgn mixed
Channel Width: Automatic
Channel: Auto (Current channel 3)
MAC Address: 60-E3-27-E7-70-7A
WDS Status: Disable

WAN
MAC Address: 60-E3-27-E7-70-7B
IP Address: 100.66.166.2    Dynamic IP
Subnet Mask: 255.255.255.192
Default Gateway: 100.66.166.1

DNS Server: 77.244.128.44 , 77.244.128.45


texts: My Computer Doesn't Realize ESP8266 ESP-05 is Connected or not

texts:
I wired ESP-05 to my usb-to-ttl as images below.

I connected it to USB #2 port, and my computer seems not knowing this.

I also tried to send "AT+RST" through Realterm but, it didn't work neither.


texts: Why is observed clock rate < 3MHz on Arduino Uno?

texts:
I wrote a simple loop to test the processor speed on my Arduino Uno. The numbers I'm getting are much worse than the 16MHz advertised, by a factor of ~5. Trying to figure out what I'm missing.

long counter = 0;
int sum = 0;
uint32_t t = 0;

void setup() {
  Serial.begin(9600);
  t = micros();
}

void loop() {
  sum += counter;

  if (counter == 10000) {
    float usecsPerIteration = (micros() - t) / (counter * 1.0);
    Serial.print(usecsPerIteration);
    Serial.println(" microseconds per iteration");

    // Print result to avoid loop getting optimized away
    Serial.println(sum);
  }

  ++counter;
}

The output is:

3.77 microseconds per iteration

Here's how I'm estimating clock rate from this. The body of the loop involves two additions and an equality check. Even if we assume that these simple operations take 10 clock cycles, the implied clock rate is still just (1 iter / 3.77 us) * (1e6 us / sec) * (10 cycles / iter) = 2.65 MHz.

What am I missing?


texts: How to set sampling rate for digital pin input?

texts:
I have an ADC that have sampling rate up to 40 MSPS, but i use 8 MHz clock so it will be 8 MSPS. The board used is arduino nano. The problem is i have to sampling it just 2 MHz (because the capacity of array variable in arduino Nano, which is around 10.000 elements in array variable). I know that using direct port reading will increase the speed of the digital read, but how can i set the direct port reading to just read every 0.5 us? Micros function cannot do the job of course

Thank you


texts: SPI between Master arduino and Slave arduino

texts:
How can I send the string from Slave SPI to Master SPI?
I want to write code in Bare Metal.
The problem which I am facing is I can't make out what will be my blocking function in Master SPI code when receiving data from slave SPI.
As my SPIF bit is cleared in MAster code as soon as I shift out SPDR register from master to receive byte which is coming from the slave.
#define spi_data_reg SPDR
//Naster read byte function
    uint8_t MA_SPI0_read_byte()
    {
        spi_port &= ~(1<<SS);
        spi_data_reg = 0;
        while(!(SPSR & (1<<SPIF)));                  //Wait until transmission complete
        return(spi_data_reg);                                 //Return received data
       spi_port |= (1<<SS);
    }

    //Slave send byte function
    void SL_SPI0_send_byte(uint8_t data)
    {
        spi_data_direc=(1<<MISO);   //MISO as OUTPUT
        spi_data_reg = data;
        while(!(SPSR &(1<<SPIF)));
    }


texts: How can I control 4 DC motors with an Arduino?

texts: In a few months, I am planning to construct an Arduino robot with multiple sensors etc. I will use an arduino mega and a 4wd chassis like the one here: Chassis.  The chassis uses 4 DC motors. I was planning to use a motor shield, but I realized that it only fits an Arduino Uno(not Mega) and it controls only 2 DC motors. What can I do to make all 4 DC motors move forward and backward? If I use a motor driver board that controls 2 motors, can I connect the 2 right and 2 left motors in parallel together and the control it through the Arduino?


texts:
I am using a NodeMCU ESP 12E board which will be programmed using the Arduino IDE. I intend to use it to send GPS data to the Blynk app server. I also want to interface a Bluetooth module HC-05 to the board along with the GPS module. I am also interfacing a L239D motor driver IC to the NodeMCU in order to control two DC motors. I am also using a metal detector module with analog output which is connected to the A0 pin of the board. Motor driver inputs are given using D0,D1,D2 and D3 pins set as digital out.

I need the NodeMCU to receive data from the GPS module and also send and receive data through the Bluetooth module. So I need 2 UART serial ports. I understand that the UART0 port can be used as the Serial port using Serial.begin(BAUD-RATE). UART1 can be used only for transmission. UART2 can be configured on GPIO13 and GPIO15 as Rx and Tx using Serial.swap(). But this cannot be used along side the UART0 port.

So is there a way I can implement Software serial in the Arduino IDE in order to set 2 ports, one for receiving only and other for both sending and receiving serial data ?


texts: can I design a User Interface to run on the arduino and display it with VGA?

texts: I know you can design a user-interface in any language you choose and Link it with a Arduino via serial Port, but I am asking if I can design user-interface to run on the Arduino WITHOUT the need for an external laptop/desktop and display the user interface on a screen (like via VGA) ? and HOW ?


texts: ESP8266 does not reconnect to WiFi on reboot

texts:
The ESP8266 is supposed to remember the WiFi credentials and reconnect to the network (if it is available) after each reboot.  That was the topic of this question: Does the ESP8266 somehow remember wifi access data?

I was observing that behavior and something has changed, I think when I updated via Board Manager in the Arduino IDE.  Now the credentials are lost each time that the device reboots. I've tried going back to earlier versions, but I have not been able to roll back to a version of the board definition that restores the old behavior.

Here's a sample sketch that I boiled down for testing:

#include <ESP8266WiFi.h>

char ssid[] = "ssid";
char pss[]  = "pass";

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

  Serial.println("Started");

  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Not connected");
    WiFi.begin(ssid, pss);
    digitalWrite(0, LOW);
    digitalWrite(2, HIGH);
  } else {
    Serial.println("Connected");
    digitalWrite(0, HIGH);
    digitalWrite(2, LOW);
  }
}

void loop() {
  Serial.println("Loop");
  delay(500);
}

The first time through, of course, it hits the first case and prints "Not connected."  On reboot, however, I was expecting it to hit the second case and print "Connected".

I'm programming via the Arduino IDE.  The board is the Adafruit Feather HUZZAH ESP8266.  I've tried lwIP v1.4 and lwIP v2 in version 2.4.1 of the board.  I started rolling back versions from there got the same run-time results.

So, questions:

Is this a known bug of the ESP8266 modules in recent versions?
Is there some aspect of the WiFi configuration that's preserved on the board when I upload a new sketch? If so, how do I roll back?


texts: Is an Arduino Uno made in the USA compatible with SunFounder shields?

texts: I bought an Arduino Uno from Radio Shack. I was under the impression it was the authentic model made in Italy. I read on Arduino.cc that the USA version is licensed and essentially the same. I then went to Amazon and ordered an RBG shield, and what I thought was the starter kit that is used with the examples on the IDE. I received the package and it is from SunFounder. Will this work with the IDE on the website and the Arduino I have from Radio Shack?


texts:
I was trying to compile some Arduino code on the PC for testing when I noticed some strange syntax for numerical binary constants.

Convetion seems to be to declare them like so:

    static const uint8_t smiley[] = {
        B00111100,
        B01000010,
        B10100101,
        B10000001,
        B10100101,
        B10011001,
        B01000010,
        B00111100 };

However, when I try to compile this with g++ I get

  error: ‘B00111100’ was not declared in this scope

Now when I exchange this for B for the standard C/C++ prefix 0B it works, but I don't want to change the code that I want so simulate!

Is there some clever macro magic at play here?


texts: How to generate Chirp Signal using Arduino

texts:
i would like to generate Chirp Signal (Frequency Sweep) using Arduino. i have searched a lot in internet but didn't find anything.

Basically, any parameters is also ok. But the concept is what i am searching for.
The signal will be sent to the DAC of the Arduino board.

Edit
I would like to generate sine wave signal from 3kHz up to 100kHz sweep frequency with amplitude peak to peak 1.5 volt.

thanks for your support.


texts:
The following code is the code for UART  receving
Char uart_receive {
  While( ! ( UCSRA & ( 1 << RXC ) ) );
  return UDR;
}

This function will not return the UDR value until the while loop breaks
because its expression evaluates to zero.
My question is: When there is a byte in the receiving buffer,the RXC= 1, so the while loop will be while(1) and it will be infinite loop ,so the function will not return the UDR value.... can any one help me to understand this?


texts: Common button on two Arduinos and two computers

texts: We have two computers giving two presentations that need to    be triggered in sync. I know how to send the space button via Arduino, but I want to check it will be safe for the computers. If each Arduino is connected to their computer via USB, both data pins togeather and both grounds togeather (not sure if I can find a dt momentarily push button in two days). Is there anything I should keep in mind incase both sides are not at the same voltage as eachother?


texts: It is possible to run an entire script on the Linux side? If so, how, what and where to do that?

texts:
I am new to using Arduino Yun and I would like to know if it is possible to run an entire script on the Linux side. In my case the script should execute a HTTP request to a remote server, parse the subsequent HTTP response and return some value that then can be used in the Arduino sketch.

If it is possible, what I have to do? For example, how should I write and run script files? what programming language should I use? where I should put those script files on the Linux side?


texts:
Using an Arduino and an L293D IC, can I control the number of rotations a DC motor makes? Or can I only control the direction and speed of the motor?

I purchased a two-wheeled robot platform to learn Arduino programming and electronics. The platform is here: http://www.robotshop.com/en/dfrobot-2wd-mobile-platform-arduino.html

Each wheel is controlled by a DC motor. I followed Adafruit's tutorial (https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing) to control the motors with the help of an L293D IC.

Now I realize that I can't directly control the rotations of the motor. I can control the direction, voltage, and time of the rotation. For example: turn forward at 50% voltage for 500 milliseconds.

But that's difficult to translate into actual rotations. The speed of the motor varies according to voltage (like if I switch from 2AA batteries to 4AA's) and weight (adding sensors slows the motors down). Every time I change voltage or weight, I have to guess how much voltage/time causes a single rotation.

I think I should just buy stepper motors. Before I do that, I'll ask the community: Is there a way to control DC motors by rotations rather than time?


texts: Any source code for connecting a tinyshield to another tinyshield?

texts:
I recently purchase 2 tinycircuit smart watch. I am wondering if anyone knows if there is any source code for me to reference on how do I connect one tinyshield to another tinyshield. I understand that a tinyshield is both a master and slave. I am trying to connect 2 tinyshield to each other such that I could transmit data between those two tinyshield.
Currently, when I upload the code into two tinyshield, the receiving tinyshield can't seem to be receving any thing, while the sender tinyshield is sending over data
Sender code
#include <SoftwareSerial.h>

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

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  while (!Serial) {
    Serial.print("connecting"); // wait for serial port to connect. Needed for native USB port only
    }
    mySerial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int vert = 200;
  int LDRReading = 100;
  delay(1000);
  Serial.print("LDR : ");
  Serial.print(LDRReading);
  delay(1000);
  Serial.print(" acc: ");
  Serial.println(vert);
  sendData(LDRReading, vert);
}

void sendData(int ldr, int accel)
{
    mySerial.write(((ldr >> 7) & 0x7F) | 0x80); // Upper 7 bytes and first bit
    mySerial.write(ldr & 0x7F); // Lower 7 bytes
    mySerial.write((accel >> 7) & 0x7F); // Upper 7 bytes
    mySerial.write(accel & 0x7F); // Lower 7 bytes
}

Receiver Code
#include <SoftwareSerial.h>
#include <SPI.h>

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

void setup() {
  // put your setup code here, to run once:
 // initialize serial communication:
  Serial.begin(9600);
  while (!Serial) {
    }
    mySerial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int result=0,acc=0;
if (getDataFromSerial(&result, &acc))
{
    // use accel and ldr
}
  if(result!=0&&acc!=0){
    Serial.print(result);
    Serial.print(acc);
  }

}

boolean getDataFromSerial(int *p_ldr, int *p_accel)
{
    boolean foundData = false;

    while ((!foundData) && (mySerial.available() >= 4))
    {
        if (!(mySerial.peek() & 0x80))
        { // If the first byte in the buffer is not a valid start, discard it
            mySerial.read();
            continue;
        }

        *p_ldr = mySerial.read() & 0x7F;
        *p_ldr = ((*p_ldr) << 7) | (mySerial.read() & 0x7F);
        if ((*p_ldr) & 0x2000) (*p_ldr) |= 0xC000; // This is the sign extension

        *p_accel = mySerial.read() & 0x7F;
        *p_accel = ((*p_accel) << 7) | (mySerial.read() & 0x7F);
        if ((*p_accel) & 0x2000) (*p_accel) |= 0xC000; // This is the sign extension

        foundData = true;
        }
         return foundData;
    }


texts:
It is not clear to me whether Pin 13, corresponding to the LED, should be driven by an external voltage or not.

From the documentation,

  LED: 13. There is a built-in LED driven by digital pin 13. When the
  pin is HIGH value, the LED is on, when the pin is LOW, it's off.

However, in the "Blink" example code I am running, the Pin 13 appears to be driven by the ATmega328:

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

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

If I now attach a voltage source to Pin 13, will there be contention issues?


texts:
I have copied this code from Github :

 #include <Wire.h>
 #include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

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

    // Initialize MPU6050
    while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
    {
         //Serial.println("Could not find a valid MPU6050 sensor, check
               wiring!");
     }

     // Calibrate gyroscope. The calibration must be at rest.
     // If you don't want calibrate, comment this line.
    //mpu.calibrateGyro();

     // Set threshold sensivty. Default 3.
     // If you don't want use threshold, comment this line or set 0.
      mpu.setThreshold(1);
   }

   void loop()
      {
       timer = millis();

      // Read normalized values
     Vector norm = mpu.readNormalizeGyro();

     // Calculate Pitch, Roll and Yaw
      pitch = pitch + norm.YAxis * timeStep;
       roll = roll + norm.XAxis * timeStep;
       yaw = yaw + norm.ZAxis * timeStep;

         // Output raw
      //Serial.print(" Pitch = ");
         Serial.print(pitch);
           Serial.print(":");
        //Serial.print(" Roll = ");
     Serial.print(roll);
        Serial.print(":");
       //Serial.print(" Yaw = ");
        Serial.println(yaw);

           // Wait to full timeStep period
      delay((timeStep*1000) - (millis() - timer));
     }

Now the question is, whenever I try to change the baud rate Serial Monitor becomes empty.

How can this be resolved?

Some screen-shots :

Stuck!!!


texts: Use Raspberry and Arduino IDE to programm ESP8266

texts:
I currently use Arduino IDE to generate binaries for ESP8266. Afterwards I copy the binaries with SFTP to my Raspberry Pi and flash the binaries using esptool.py.

These are lots of steps I need to do manually. Is it possible to automate this and use the Raspberry Pi as a programmer known to the Arduino IDE?

The goal is, that the "Upload" button in Arduino IDE does the full job.


texts:
I'm asking this because I'm using a timer to generate a 38KHZ signal to drive an IR diode, and I also need to use SoftwareSerial to talk to an HC-12 radio using serial communication.

The code I'm using was written by Nick Gammon and is here:

//Setup Conter/overflow to create 38KHZ drive for IR38KHZ
//38khz, no interrupts
#define IR_CLOCK_RATE 38000L
// toggle on compare, clk/1
TCCR2A = _BV(WGM21) | _BV(COM2A0);
TCCR2B = _BV(CS20);
// 38kHz carrier/timer
OCR2A = (F_CPU/(IR_CLOCK_RATE*2L)-1);
pinMode(IR38KHZ, OUTPUT);

I'm not quite up-to-date on the timer use on an Arduino (I'm using a Nano), plus I've no idea what the SoftwareSerial library uses.


texts: How to make procedures triggered remotely

texts:
I am installing lights in a model train and there are multiple prototypical lighting procedures that need to be activated. The lights are connected as follows:
Headlight Top - Pin 1
Headlight Bottom - Pin 2
Front Right Marker - Pin 3
Front Left Marker - Pin 4
Rear Right Marker - Pin 5
Rear Left Marker - Pin 6
Rear Left Headlight - Pin 7
Rear Right Headlight - Pin 8
Front Right Ditch Light - Pin 9
Front Left Ditch Light - Pin 10

I would like to simply address a forward procedure which would turn on pins 1, 2, 3, 4, 5, 6, 9, and 10. This is the lighting configuration when the loco is shifted into the forward gear. For reverse, pins 3, 4, 5, 6, 7, and 8 would be activated. There will be a few others too but those are the primary procedures. Is there a way I could set up a variable which names all those pins at once? Or is there some other way I could name a forwards or backwards lighting procedure with a single short name such as "Procedure 2"? I am using Arduino IDE.


texts: More than one port available in Arduino IDE in Ubuntu

texts:
I'm using Jetson AGX Xavier, and in my Arduino IDE, there are dev/ttyUSB0, dev/ttyUSB1, dev/ttyUSB2, dev/ttyUSB3. I'm sure I connect Arduino in USB0, but I cannot download the code. The device is also correct. Even if I disconnect the Arduino, the available ports are the same.
When I googled it, it turns out the port should be only one. Like, should be only "dev/ttyUSB0". So it really confused me.


texts: I have an Arduino clone of a Leonardo and I was just wondering how many keyboard commands I can send to the computer per second via USB. I'm not talking about the delay between send and receive (because that could vary between computer), I'm talking about the minimum possible time between something like stimulating a key press down and key press up as fast as possible.


texts: I'm in charge of creating a code for my class using Arduino an Arduino UNO Board. There are 7 switches total: One acts as an start/stop, which allows it to have power when other settings are chosen. There are 3 switches for the speeds: slow, medium, and fast. There are 3 other switches for interval sizes (space between it spinning again): short, medium, and long. The user has to select one option from each set of 3 switches for it to work (9 total combinations). Somehow I have to code a pulse width modulator into it as well to control the motor speeds. Can someone point me in the right direction with pseudocode or something? Also I have no clue what to do with the PWM. Thank you so much, any help would be very appreciated.


texts: How do I stop a servo motor at the current position when using a serial port? I want it to remain in one position when receiving "0"

texts:
I am working on a project where I would like values received from an Xbox Kinect will activate components on my Arduino. Currently, I am trying to get a servo motor to turn on and rotate when the value is "1" and to remain in one position (currently written as 120degrees) when the value is "0". However, I can turn on the motor and initiate rotation just fine, but when I let go of the mouse (and it shows that the value "0" is being sent in Processing and on the Serial Monitor), the motor just keeps spinning. This is my current code:

char val; // Data received from the serial port
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop() {
  if (Serial.available())
  { // If data is available to read,
    val = Serial.read(); // read it and store it in val
  }
  if (val == '1') { // If 1 was received
    Serial.print ("1");// turn the LED on
    for (pos = 0; pos <= 120; pos += 1) { // goes from 0 degrees to 180 degrees
      // in steps of 1 degree
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
    for (pos = 120; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
    }
  }
  if (val == '0') {
    Serial.print ("0");
    pos = 120;
    myservo.write(pos);
  }
}


texts: Arduino digital output pin controling relay problem

texts:
I try my code to change the state of a relay on pushing a push button buy checking the state of a digital pin.

My code :

const int led1 = 6;
const int enable1 = 7;
boolean led1_OnOff;
long now;
int minSecsBetweenUpdates = 1; // 1 seconds
long lastSend = -minSecsBetweenUpdates * 1000l;

void setup() {
  led1_OnOff = false;
  pinMode(enable1, INPUT);
  pinMode(led1, OUTPUT);
}

void loop() {
  now = millis();
  if (now > (lastSend + minSecsBetweenUpdates * 1000l))
  {
    if(digitalRead(enable1) == HIGH)
    {
      lastSend = now;
      if(led1_OnOff == true)
      {
        led1_OnOff = false;
        //+digitalWrite(led1, LOW);
      }
      else
      {
        led1_OnOff = true;
        //digitalWrite(led1, HIGH);
      }
    }
  }

  if(led1_OnOff == true)
    digitalWrite(led1, HIGH);
  else
    digitalWrite(led1, LOW);
}

But the code keeps on looping and the relay keep changing it's state as if pin 7 is always high, I'm sure of my schematic but I don't know what's wrong with my code.

for those who want my schematic:


texts: Ultrasonic PING: multiple trig on single dig. pin

texts:
This may seem a little stupid, i apologize  if so as i'm new to electronics/arduino.

I have 4, 4-pin ping sensors. I'm running out of available pins on my UNO.

I had a ponder & wondered if it was possible to link all 4 sensor's trig pins to a single digital pin, with the echo pins assigned to their own pin. In my head, on each sensor call (sorry i'm used to programming terms) all 4 sensors would send a pulse, then only the sensor (or echo pin) in question would be read. Is that plausible? each ping sensor is about 20-30 cm separated, but facing internally, in a spiral downwards.


texts: Converting Arduino Uno with Ethernet Shield sketch for Arduino Yún

texts:
I'm new to the Arduino Yun and I'm trying to convert a sketch written for the Arduino Uno with a Ethernet Shield. The sketch does HTTP posts to Azure Mobile Services.

I've added in the Bridge.h and YunClient.h libraries in place of the Ethernet.h one for the Uno.

My modified sketch compiles, however, I don't think the http posts are working. I don't see my table updating in Azure.

    /*
    ** This sample Arduino sketch uploads telemetry data to Azure Mobile Services
    ** See the full article here: http://hypernephelist.com/2014/07/11/arduino-uno-azure-mobile-services.html
    **
    ** Thomas Conté @tomconte
    */

#include <Bridge.h>
#include <YunClient.h>
//#include <Ethernet.h> // removed as not used by Yun
#include <SPI.h>

// not sure if these libraries are required?
#include <HttpClient.h>
#include <Process.h>

// Ethernet shield MAC address (sticker in the back)
//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// 90:A2:DA:F8:28:38

// Azure Mobile Service address
// You can find this in your service dashboard
const char *server = "myhost.azure-mobile.net";

// Azure Mobile Service table name
// The name of the table you created
const char *table_name = "my_data";

// Azure Mobile Service Application Key
// You can find this key in the 'Manage Keys' menu on the dashboard
const char *ams_key = "HJRxFXXXXXXXXXXXXXXXXXXXNQoMcXXXXXXx99";

//EthernetClient client;
YunClient client;

char buffer[64];

/*
** Send an HTTP POST request to the Azure Mobile Service data API
*/

void send_request(int value)
{
  Serial.println("\nconnecting...");

    Serial.print("sending ");
    Serial.println(value);

    // POST URI
    sprintf(buffer, "POST /tables/%s HTTP/1.1", table_name);
    client.println(buffer);

    // Host header
    sprintf(buffer, "Host: %s", server);
    client.println(buffer);

    // Azure Mobile Services application key
    sprintf(buffer, "X-ZUMO-APPLICATION: %s", ams_key);
    client.println(buffer);

    // JSON content type
    client.println("Content-Type: application/json");

    // POST body
    sprintf(buffer, "{\"value\": %d}", value);

    // Content length
    client.print("Content-Length: ");
    client.println(strlen(buffer));

    // End of headers
    client.println();

    // Request body
    client.println(buffer);

}

/*
** Wait for response
*/

void wait_response()
{
  while (!client.available()) {
    if (!client.connected()) {
      return;
    }
  }
}

/*
** Read the response and dump to serial
*/

void read_response()
{
  bool print = true;

  while (client.available()) {
    char c = client.read();
    // Print only until the first carriage return
    if (c == '\n')
      print = false;
    if (print)
      Serial.print(c);
  }
}

/*
** Close the connection
*/

void end_request()
{
  client.stop();
}

/*
** Arduino Setup
*/

void setup()
{
Serial.begin(9600);
Serial.println("Starting Bridge");
Bridge.begin();

}

/*
** Arduino Loop
*/

void loop()
{
  int val = analogRead(A0);

  send_request(val);
  wait_response();
  read_response();
  end_request();

  delay(1000);
}


texts: What is the difference between Accelerometer, Gyro, and Magnetometer Sensor?

texts:
I'm starting in the arduino world and I'm building an autonomous smart vehicle.

So, after some weeks building and adjusting the vehicle, I got to a point in this project that I want to log it's movements. Talking with a friend, he showed me an Gyro/Accel sensor and I really think that it would be an awesome upgrade to my vehicle

After reading some articles, I'm failing to understand the difference between an Accelerometer Sensor, a Gyro Sensor and a Magnetometer Sensor

So what is the main difference between those sensors?


texts: Arduino webserver: faster alternative to "indexof" for parsing GET requests?

texts:
I have a webserver successfully running on an Arduino Mega, but I'm trying to make sure it's parsing the GET requests in the fastest way possible. This is what the relevant code for the GET requests looks like:

String readString;
EthernetClient client = server.available();
if (client) {
  while (client.connected()) {
    if (client.available()) {
      char c = client.read();

    if (readString.length() < 20) {
      readString += c;
    }
    ...
    ...
      if (readString.indexOf("?a1o") >0){
        mySwitch.send(a1o, 24);
      }
      if (readString.indexOf("?a1c") >0){
        mySwitch.send(a1c, 24);
      }

The sketch checks for 40 possible GET variables. I'm running it as a local webserver with the address: http://192.168.0.180.

-Is there a command faster than "indexOf" that I could be using?

-I saw some information suggesting that sometimes "parseInt" can be faster. Is there any way for me to make that work even though my local base URL is already full of integers? I would be willing to convert the commands into integers (like "11" instead of "a1o") if there was a way to use parseInt or another faster command with it.

Thanks!


texts: Will M2.5 screws fit the holes in the Arduino Uno?

texts: I'm developing a sump pump monitor/alarm setup that will include an Arduino Uno as well as a Raspberry Pi. Both boards will be mounted to a piece of wood. The Arduino is designed to take M3 screws, but the Pi is designed to take M2.5 screws. The difference in these two screw sizes is 0.5mm (2.4mm M2.5 vs 2.9mm M3). Is this going to be close enough to be able to use the smaller M2.5 screws for both? Due to cost reasons, I want to avoid having to purchase two different sizes of screws and standoffs.


texts: How to analyse audio and to affect source?

texts: I want to use the audio from my PC and have it going to the speakers and Arduino for some lighting effects. This project is a bit of a struggle because I don't know what the best way of analysing audio is. So for the lights I only want bass frequencies to affect the lights.


texts: Unable to read any SMS's other than the first SMS using SIM908 shield

texts:
I'm using two SIM908 shields to communicate with each other. One of the shields will be connected to a sensor and it should send values contentiously to the second SIM908 (receiver). I'm facing a problem on the receiver side, I'm only able to receive the first SMS and when sending a new SMS it displays the older one.

The code that I'm using is from (cooking-hacks.com) where I bought the shield. In the original code the instructions were in void setup function so I  moved them to void loop function to keep checking for new SMS and print any received values. I also made other minor changes. Here is the code

int8_t answer;
int x;
int onModulePin= 2;
char aux_string[30];
char SMS[200];
float fSMS;
char data[20];

void setup() {
  pinMode(onModulePin, OUTPUT);
  Serial.begin(115200);
  Serial.println("Starting...");
  power_on();
}

void loop() {
  Serial.println("Setting SMS mode...");
  sendATcommand("AT+CMGF=1", "OK", 1000);
  // sets the SMS mode to text
  sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"", "OK", 1000);
  // selects the memory
  answer = sendATcommand("AT+CMGR=1", "+CMGR:", 2000);
  // reads the first SMS (since all other messages are deleted from previous delete statement)
  if (answer == 1) {
    answer = 0;
    while(Serial.available() == 0);
    // this loop reads the data of the SMS
    do {
      // if there are data in the UART input buffer, reads it and checks for the answer
      if(Serial.available() > 0) {
        SMS[x] = Serial.read();
        x++;
        // check if the desired answer (OK) is in the response of the module
        if (strstr(SMS, "OK") != NULL) {
          answer = 1;
        }
      }
    }while(answer == 0);
    // Waits for the answer with timeout
    SMS[x] = '\0';
    /*  strtok(SMS, ",");
    strtok(NULL, ",");
    strtok(NULL, ",");
    strtok(NULL, "\n");
    strcpy(data,strtok(NULL, ""));*/
    Serial.println(SMS);
    //Serial.println(data);
    /*    fSMS= atof (data);
    Serial.println(fSMS, 5);*/
  } else {
    Serial.print("error ");
    Serial.println(answer, DEC);
  }
  Serial.println("AT+CMGDA= \"DEL ALL\"");
  //delete all messages from SIM card
  delay(5000);
}

void power_on() {
  uint8_t answer=0;
  // checks if the module is started
  answer = sendATcommand("AT", "OK", 2000);
  if (answer == 0) {
    // power on pulse
    digitalWrite(onModulePin,HIGH);
    delay(3000);
    digitalWrite(onModulePin,LOW);
    // waits for an answer from the module
    while(answer == 0){
      // Send AT every two seconds and wait for the answer
      answer = sendATcommand("AT", "OK", 2000);
    }
  }
}

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {
  uint8_t x=0,  answer=0;
  char response[100];
  unsigned long previous;
  memset(response, '\0', 100);
  // Initialice the string
  delay(100);
  while( Serial.available() > 0) Serial.read();
  // Clean the input buffer
  Serial.println(ATcommand);
  // Send the AT command
  x = 0;
  previous = millis();
  // this loop waits for the answer
  do {
    // if there are data in the UART input buffer, reads it and checks for the answer
    if(Serial.available() != 0) {
      response[x] = Serial.read();
      x++;
      // check if the desired answer is in the response of the module
      if (strstr(response, expected_answer) != NULL) {
        answer = 1;
      }
    }
    // Waits for the asnwer with time out
  } while((answer == 0) && ((millis() - previous) < timeout));
  return answer;
}


texts:
So I was trying to set up the LCD screen that came with my Genuino starter kit when I noticed that the board screen did not power on at all, unlike a few days ago when it worked.

In order to verify that the UNO was delivering power I simply connected an LED in series with a 220Ω resistor, between the 5V and ground pins. The LED did not power on.

I then, with the UNO still connected over USB, measured the voltage between across the resistor and LED and found it to be around 0.2-0.3V. Going further, reading the voltage between the 5V and ground solder connections on the back of the board and the reading is about the same.

I can power the LED from a digital pin that I set to HIGH, the issue seems to just be with the 5V pin.

Is there anything simple that I am missing (I hope there is) or is there likely a problem with my board? If there is a problem, could I use a digital pin to power a larger circuit such as that with an LCD or would the current supplied be too low?


texts: In my application all of the Arduino Uno LEDs will be invisible inside an enclosure, so I wish to provide panel-mounted Tx and Rx LEDS just replicating their on-board counterparts. Is there a way to drive any of the digital outputs to replicate those LEDs? I seem to recall that the Tx and Rx LEDs are driven directly from the FTDI logic, does this preclude hacking their states and sending them to two digital outputs? How could this be done? I could de-solder the LEDs and hardwire the panel LEDS to their pads, but I think this should be a last resort.


texts: Can I use Arduino to generate a 0 to 15V analog output?

texts: Is it possible to use the analog output pin with some circuit to generate a 0 to 15V analog output?


texts:
Can you use the DFPlayer to write to the SD card?
Link for DFPlayer: https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299

Here's the goal of my project. I have a button that, when pressed, should a- play a song off an SD card that is hooked up to the DFPlayer and b- should log "button is pressed" to the SD card. Unfortunately, the DFPlayer library doesn't seem to have any functions for this, and I wasn't sure how to see whether the DFPlayer has the functionality to support writing onto an SD card. Are there modules that are Read-only for SD cards? If so, is the DFPlayer one of them?

PS - I'm using an Arduino Uno,
Thank you so much for your help! I am a complete novice for SD cards, so any help you give would be very much appreciated!


texts: Gesture sensing TV coffee table - what sensors would you use?

texts:
A 32 inch flat screen was embedded in a coffee table and covered by a protective layer of glass. Sensors around the edge of the glass surface need to be able to detect the precise location of an object on the glass so that a mouse cursor can be controlled with a stylus.

What sensors would you use to ensure accuracy of stylus location above the screen?


texts: Programming an ATmega328P by holding it on an Uno's

texts:
I was looking at this Uno clone, the Nanino and then happened to read this article on "Manhattan style" circuit design. Anyway, that got me thinking...

If I borrowed someone's Arduino Uno, could I hold a blank ATmega328P on top of the identical chip on that Uno and load a bootloader onto the board's chip as well as my chip? The desired result would be to give my blank ATmega328P a bootloader.


texts: Does the Arduino Yun have to be powered exactly at 5V?

texts: I'm working on a senior project and I am using a ATX PSU to supply power to the Arduino Yun and other components. If I'm not mistaken, its powered through the usb. I took a usb cord, strip the sheath and put the proper connections on the breadboard and connected the red wire from the PSU to the breadboard as well. When I measure it, the voltage is 5.1V max. I'm scared to hook it up to the Arduino since I read that if its above 5, it will fry it. Is this voltage fine? If not, will I have to put resistors on it to get it down?


texts: is the Arduino shield pinout a standard, so that any Arduino shield can work with any Arduino board

texts:
I'm new to Arduino and dying to delve in.

There are lots of Arduino base board vendors, and lots of shield vendors.

In general, should I be able to plug any shield into any Arduino board, even with existing shields?


texts:
I have a Sigfox Arduino meassuring some sensors, sending it to the cloud and then falling asleep.

void setup()
{
Serial.begin(9600);
  while (!Serial) {};
  if (!SigFox.begin()) {
    Serial.println("Shield error or not present!");
    return;
  }
  SigFox.debug();
  delay(100);
  SigFox.end();
}

void loop()
{
SigFox.begin();
  delay(100);
  SigFox.status();
  delay(1);
  SigFox.beginPacket();
  SigFox.print("123456789012");
  int ret = SigFox.endPacket(true);

  if (ret > 0) {
    Serial.println("No transmission");
  } else {
    Serial.println("Transmission ok");
  }
  Serial.println();
  SigFox.end();
LowPower.sleep(20000);
}

The Issue I have is that the sending to the backend doesn't work when leaving the sigfox.debug() away and that it doesn't wake up from the sleep. It stays in sleep forever.


texts: Running a DC motor for a set amount of time

texts:
I am trying to run a DC motor for 100ms and then turn it off completely. Here is my code any suggestions on why it might not be working?
My Code
const int pirPin = 9;
const int motorPin = 2;
int switchState = 0;
// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(motorPin , OUTPUT);
  pinMode(pirPin, INPUT);
}
void loop() {
  while (digitalRead(pirPin) == HIGH) {
    digitalWrite(motorPin, HIGH);
    delay(100);
    digitalRead(pirPin) == LOW;
    break;
  }
}


texts: Arduino zero programming port recognized as EDBG USB port

texts:
I am using Arduino Zero with Windows 10. I tried following the procedure listed in Getting started with Arduino to set up my Arduino/environment, however, when I connect the Zero's Programming Port to my laptop's USB 3.0 port, it detects it as "Atmel Corp. EDBG USB Port" instead of "Arduino Zero Prog. Port" (or something similar) as described under the section "Installing Drivers for the Zero" in the above link. Since it is recognized as an EDBG USB Port, I am unable to burn bootloader or upload sketches using the Programming port as it cannot detect CMSIS-DAP.
when I try to upload a sketch I get the following error:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Zero (Programming Port)"
Sketch uses 23496 bytes (8%) of program storage space. Maximum is 262144 bytes.
Global variables use 3536 bytes (10%) of dynamic memory, leaving 29232 bytes for local variables. Maximum is 32768 bytes.
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Error: unable to open CMSIS-DAP device 0x3eb:0x2111
Error: No Valid JTAG Interface Configured.
Error: No Valid JTAG Interface Configured.

When I try to burn bootloader I get the following error:
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Error: unable to open CMSIS-DAP device 0x3eb:0x2111

Error while burning bootloader.

How can I fix this?
So far, I tried

re-installing the IDE several times, and also tried uninstalling the device- but it auto installs the driver when I connect again.
Starting IDE as an admin did not help, although I think the issue is the EDBG CMSIS-DAP is not installed, and instead, the EDBG USB driver is installed


texts:
I'd like to know if it's possible to create a library for Arduino that does not contain a class, just functions.

I know how to create a library with a class, but I'd like to create a library of general purpose functions that don't need to be instantiated to be used. Just used like the standard functions included in the Arduino IDE:  sizeof(), etc..

Is this possible?  If so, can anyone point me in the direction of a template?  I've been searching, but haven't found anything.

Thanks!


texts:
Has anyone been successful in connecting an ESP8266 to the Initial State IoT platform?

On the platform there is only one example with Cactus ESP. I tried it but it did not work because I have a NodeMCU.

Can you please share your Arduino code?


texts:
I tried the tutorial in this link

https://lastminuteengineers.com/sim900-gsm-shield-arduino-tutorial/

to send an SMS message using a SIM900 GSM shield

I completed the section to send AT commands successfully but I can't get
the Arduino Uno to send an SMS. Below is the output I get after doing AT command tests

Initializing...
AT

OK
AT+CPIN?

+CPIN: READY

OK
AT+CSQ

+CSQ: 6,0

OK
AT+CCID

8944500105191448516F

OK
AT+CREG?

+CREG: 0,5

OK
AT+COPS?

+COPS: 0,0,"T-Mobile "

OK
AT+COPS=?

+COPS: (2,"T-Mobile ","T-Mobile ","310260"),,(0,1,4),(0,1,2)

OK

and below are the responses from the SMS code

Initializing...
AT

OK
AT+CMGF=1

OK
AT+CMGS="+1mycellphonenumber"

> Last Minute Engineers | lastminuteengineers.com

so no response from the AT+CMGS command and NO SMS received.
Plug is 5V 2A.

Any idea what might be causing the issue?

Below is the code I used for the Setup() function

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

  //Begin serial communication with Arduino and SIM900
  mySerial.begin(9600);

  Serial.println("Initializing...");
  delay(1000);

  mySerial.println("AT"); //Handshaking with SIM900
  updateSerial();

  mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
  updateSerial();
  mySerial.println("AT+CMGS=\"+ZZxxxxxxxxxx\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
  updateSerial();
  mySerial.print("Last Minute Engineers | lastminuteengineers.com"); //text content
  updateSerial();
  mySerial.write(26);
}


texts: Unable to hear the click sound from the relay

texts:
I am using a 5v 2 channel relay module with arduino nano to turn on and off using RTC. I am able to see the LED on the relay turn on but unable to hear the click sound and the relay does not turn my bulb on.
Here is my code :
#include <DS3231.h>
DS3231  rtc(SDA, SCL);
Time  t;

void setup()
{

  Serial.begin(115200);
  rtc.begin();
  pinMode(4, OUTPUT);

}

void loop()
{
  t = rtc.getTime();
  Serial.println(rtc.getTimeStr());
  delay (1000);

  if (t.hour == 17 && t.min == 00){

    digitalWrite(4, HIGH);
  }
  if (t.hour == 21 && t.min == 00)
  {
    digitalWrite(4, HIGH);
  }
}

my circut is quite simmilar to this:


texts: Can I get around extremely long time to setup WIFI connection WPA2 Personal?

texts:
I'm using the Arduino Wifi Nina Library to connect an Arduino Uno Wifi Rev2 to wifi and then using the Arduino HTTP Client library to make HTTP post calls to the internet.

To connect the Arduino to my home Wifi Network (WPA2 Personal), I use the WiFi.begin() method. This method takes an excruciatingly long 4 seconds to connect to the Wifi. This seems to be a known issue. Since this methods is synchronous/blocking, my sketch is completely unresponsive during this time to any user input such as button-presses etc. I'm trying to create a proof-of-concept for a commercial-grade product. So having it go unresponsive to user-input for several seconds is unacceptable.

Is there any workaround to this? Is there a asynchronous library to achieve the same goal? Is there some other workaround? How do other people deal with this situation?


texts: EthernetClient: HTML table isn't being fully populated

texts:
I have the following code below for an EthernetClient named client. It is supposed to print a 2 row, 9 column table. The headers are ID and Name and are the first cell in each row. The other columns are the associated data. The problem I am having is that it is only printing the first ID and then the rest of the cells for that row are blank. The names all get printed in the row below it without a problem. Why won't it print the other IDs?

Here is the ID array: String ids[16] = {"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111"};

client.println("
");
client.println("
");
client.println("ID	");
for(int i = 0; i < 8; i++) {
  client.print("");
  client.print(ids[i]);
  client.println("	");
}
client.println("
");
client.println("
");
client.println("Name	");
for(int i = 0; i < 8; i++) {
   client.print("");
   client.print(name[i]);
   client.println("	");
}
client.println("
");
client.println("
");


texts: Unable to read data with 16 serial clock cycles

texts:
I am trying to read data from an AD7314 Temperature Sensor that is connected to an Arduino Uno and output that value onto 6 LEDs also connected to the Arduino Uno board. From the image below, the sensor is showing only an output of 0011111111111111 during the streams of 16 clock cycles even after the chip enable goes from low to high before conversion to initiate a new one (it seems that the conversion is stuck). The datasheet says:

  A leading zero and 10 bits of data are transferred during a read operation. Read operations occur during streams of 16 clock pulses. Output data is updated on the rising edge of SCLK. The serial data is accessed in a number of bytes if 10 bits of data are being read. At the end of the read operation, the SDO line remains in the state of the last bit of data clocked out of the AD7314 until CE returns low

I am not sure where exactly I am going wrong during the read operation:

Note: for the Waveform image (Top to bottom):

waveform 1: Chip Enable
waveform 2: Serial Clock
waveform 3: MISO Line
waveform 4: MOSI Line

My code is below:

#include <SPI.h>

const int MOSI_PIN = 11;
const int MISO_PIN = 12;
const int SCK_PIN = 13;
const int Slave_PIN = A0;

// module data
uint16_t myValFromTempSensor = 0;

void setup () {
  SPI.begin ();
  SPI.beginTransaction(SPISettings(125000, MSBFIRST, SPI_MODE0));
  pinMode(5, OUTPUT); //LED 3
  pinMode(6, OUTPUT); //LED 4
  pinMode(7, OUTPUT); //LED 5
  pinMode(8, OUTPUT); //LED 6
  pinMode(9, OUTPUT); //LED 7
  pinMode(10, OUTPUT);//LED 8
  pinMode(MOSI_PIN, OUTPUT); // MOSI to SDI
  pinMode(MISO_PIN, INPUT); //MISO to SDO
  pinMode(SCK_PIN, OUTPUT); //CLOCK PIN to SCK
  pinMode(Slave_PIN,OUTPUT); //Slave pin

  digitalWrite(Slave_PIN, LOW);//Set slave low before communication
  for (int i = 5; i < 11; i++) {
    digitalWrite(i, LOW);
  }
  delay(100);
} // end of setup

void loop () {
  digitalWrite(Slave_PIN, HIGH);  //Set slave high to read data
  myValFromTempSensor = SPI.transfer(0x00); // Read Data from the device
  myValFromTempSensor |= (uint8_t)SPI.transfer(0x00) << 8;// Bitshift to read next 8 bits
  digitalWrite(Slave_PIN, LOW);
  if(( myValFromTempSensor>=0) && ( myValFromTempSensor<=196)) {
    //Range 0C to 60C is  0 to 196
    digitalWrite(5, bitRead(myValFromTempSensor,0));
    digitalWrite(6, bitRead(myValFromTempSensor,1));
    digitalWrite(7, bitRead(myValFromTempSensor,2));
    digitalWrite(8, bitRead( myValFromTempSensor,3));
    digitalWrite(9, bitRead( myValFromTempSensor,4));
    digitalWrite(10, bitRead( myValFromTempSensor,5));
  } else {
    digitalWrite(5, 0);
    digitalWrite(6, 0);
    digitalWrite(7, 0);
    digitalWrite(8, 0);
    digitalWrite(9, 0);
    digitalWrite(10, 0);
  }
}


texts: Equivalent for PORTB in Arduino Mega 2560

texts:
Like I said in the subject, I would like to know the equivalent for the instruction:

PORTB |= 0x01;
PORTB &= ~0x01;

More precisely I was using it to trigger a fast pulse conversion on my shield-ADC on an Arduino Uno. Now I am using an Arduino Mega 2560.

Can you write the exact same instruction for ATMega2560?


texts: Digit LED has single input, multiple outputs for each segment. Concerns about "sinking" 5v supply into digital pins

texts:
The model name is 5161BS

Pins 3/8 are input and the rest are output for each individual segment.

I have connected pin 3 to the 5v pin on the Arduino, and the rest to individual digital pins.

With a simple sketch with the pins set to mode output, all segments are lit.

My concern is that the way I am turning off each segment is by setting the output pin to high.

Meaning

5v pin --> LED <-- Digital pin

Is this dangerous to have two voltage sources going in the same direction? Is there another way to do this?


texts: Flash Arduino Micro code on Atmega32U micro controller

texts:
First of all, I am not an expert on electronics, so forgive me for asking something which is trivial for probably the most of you.

I am trying to get my Arduino (Micro) code running on a custom PCB with the Atmega32U chip on it. The person who made the PCB copied parts of the schematics of the Arduino Micro onto a custom PCB. What he did, is place the Atmega chip on it, and also copied the wiring for the micro USB connector.

That way, I can hook up the PCB to my USB port but now Windows does not recognize the chip as a "Arduino hosted via a COM port", but just as a atmega chip.

I learned that installing Atmel Studio 7 will also provide the correct drivers so that Windows recognizes the chip correctly via USB:

The next step for me was to get my code running on the atmega chip. So with some help from the internet I came to the following steps:

open my sketch in Arduino IDE
compile with verbose output
find the location where the ".HEX" file is stored

But how can I flash this .HEX to the Atmega chip?


texts: Why does avrdude error appear when interfacing GLCD with arduino uno in ubuntu

texts:
I want to interface a GLCD with arduino uno. The GLCD is JHD12864E.   The connections are as shown in this image

I downloaded the OpenGLCD library and uploaded HelloWorld program from it.
I got the error:
        stk500_recv() : programmer is not responding

Then I googled it and also tried to upload using ISP using another arduino. The program uploaded successfully, but i did not get any output on GLCD.

I am not getting this error when uploading any other sketches. Can anyone explain to me why do we get this error? And what is the solution to it?


texts: Working with Seed BLE Shield and Adafruit Feather BLE

texts:
Long story short: I need to pair these devices:

Arduino UNO with Seeed BLE Shield
Adafruit Feather 32u4 Bluefruit LE.

The Seeed shield is configured and able to connect and communicate via the UART to an Android phone by HM BLE Terminal app from Google Play Store.

I can also connect the phone and Feather. The two independent connections work really well but a problem occurs when connecting the Seeed shield with Feather. Connection isn't troubling No errors are reported but I can't send/receive any data via the serial monitor (I'm using bleuart_cmdmode or bleuart_datamode from the Adafruit examples).

Basically my question is how to make them work: HM-11 module with BLE and the Adafruit board (nRF51822 chipset from Nordic).


texts: Can I track 70 pressure sensors from Arduino Mega?

texts: I am a beginner at Arduino which I just received in the mail. My understanding is my Arduino Mega has 54 digital inputs and 16 analog inputs making for 70 inputs all together. I would like to track pressure sensors which are configured to detect simply open or closed. Given I can use my analog inputs as digital inputs can I have 70 pressure sensors? My project differs from others in that I dont need to track a gradation. In regards to the mega wiring what can I do to achieve this? Will I need a separate breadboard for each pressure sensor?


texts: Recommendation for a projector module or approach?

texts:
I am looking to create a projector effect similar to one seen in projector alarm clocks like
https://www.amazon.com/Mooas-White-Projection-Alarm-Projector/dp/B07Q6W53LK/ref=asc_df_B07Q6W53LK/?tag=hyprod-20&linkCode=df0&hvadid=343191208006&hvpos=&hvnetw=g&hvrand=4354131467724049360&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9019795&hvtargid=pla-758051396522&psc=1&tag=&ref=&adgrpid=68752454603&hvpone=&hvptwo=&hvadid=343191208006&hvpos=&hvnetw=g&hvrand=4354131467724049360&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9019795&hvtargid=pla-758051396522
and I am looking for some module that would accomplish it
https://www.mouser.com/ProductDetail/Texas-Instruments/DLPDLCR2000EVM?qs=BZBei1rCqCAQetmBz0G1xQ%3D%3D&gclid=Cj0KCQiA-rj9BRCAARIsANB_4ABW01iyq1W96Kd3piCLku3MSKib7xc_TspaZIa364hTXtJ_kYPSg0AaAvSAEALw_wcB
This is the closest thing I can find to what I am looking for but it's very pricey I would think given how popular these sorts of alarm clocks are there would be something much cheaper and easy to get your hands on out there.


texts: How to print (or store) gps lat, lng value (TinyGPS++) with Bluetooth BLE nRF8001?

texts:
I have a u-blox gps module and I use TinyGPS (http://arduiniana.org/libraries/tinygpsplus/) to get out the lat + lng.

If i write...

Serial.println(gps.location.lat(), 6);

...out in the log I get the correct latvalue.
Right now I however work with a BLE (https://www.adafruit.com/product/1697) and when I try to print it like this:

BTLEserial.print (gps.location.lat()`, 6);

I get a error: no matching function for call to 'Adafruit_BLE_UART::print(double, int)'

If I do this instead, the code runs...

BTLEserial.print ((gps.location.lat(),6));

But I do not get the correct lat, instead I get this value 6.00000000

I have tried to store the lat like this:

double myLat;

myLat = (gps.location.lat(), 6);
BTLEserial.print (myLat);

But with that myLat also has a value of 6.00000000 which is not correct.

I tried this as well:

char sValueOne[16], sValueTwo[16];
char sBuffer[33];

strcpy(sBuffer,dtostrf(((gps.location.lat(),6)), 15, 8, sValueOne));
strcat(sBuffer,",");
strcat(sBuffer,dtostrf(((gps.location.lng(),6)), 15, 8, sValueTwo));

BTLEserial.write((uint8_t *)sBuffer, strlen(sBuffer));

But with that I still get 6.00000000. I am starting to run out of ideas now to make this work. I have tried to send it both directly and store it but nothing works successfully.

So how can I adjust the code to be able to print (or store) gps lat, lng value (TinyGPS++) with Bluetooth BLE nRF8001?

Appreciate every help and tips!


texts: Driving two stepper motors using one stepper motor driver

texts: Using an Arduino Mega, I currently control two stepper motors that never operate at the same time and never will. I am using two EasyDriver stepper control boards with two separate power sources. I was wondering if I could go down to just one stepper control board, one power source but somehow switch the 4 input wires from one motor to another when I need to turn a specific motor. Is there a switch I can control with Arduino where I can plug in 8 wires and say "ok, use the 4 left most wires" or "switch to the right most 4 wires". Does that exist or is that more complicated than what I currently have?


texts: What does the 'arduino' avrdude programmer do?

texts:
The command line that my toolchain (CLion + PlatformIO) uses to program my Arduino (Uno) includes includes

avrdude ... -c arduino ...

but the documentation for this programmer simply reads

  -c programmer-id
           ...
          arduino           Arduino
           ...

What does the arduino programmer do. Does it just correspond to using the bootloader?


texts: LEDs interfering with analog sound detection

texts:
My project is a sound reactive LED display on an Arduino Nano. There are 112 WS2811s in series connected to 5v, Gnd and D5 via 220ohm resistor.

I have a Keyes style sound detection module that has an analog output. It is connected to 5v and Gnd as well, and to A0.

The code reads the analog signal and then maps it to the brightness of the LEDs, in theory causing the LEDs to pulse.

Unfortunately what's happening is the brighter the LEDs, the higher the readings on the analog pin from the sound module.

Power is 5v 3A connected directly to Gnd and 5V with a 1000mF cap across + & - on the barrel adapter. I did this to allow the LEDs to draw the full 3A from the AC/DC converter (and to avoid having to power this via USB)

My suspicion is that as the LEDs get brighter the voltage to the sound module fluctuates which is throwing off the readings. Is there some merit to this hypothesis or is there another possible explanation?

Short of running two separate power lines (one to the Arduino and the other exclusively to the LEDs) are there any other ways I can regulate the voltage to the sound module regardless of the draw by the LEDs?


texts: Arduino Uno: Sensor shield powering multiple servos

texts:
I posted this on the electrical side of stack exchange and they said it was off topic, so I think it will be on topic here and they confused me even more. So if you guys could clear up my confusion, that would help.I know there are sources for this, but I am still lost.  Anyways, here is the run down. I want to control multiple servos (12 of them) using a sensor shield. I need to know what kind of power supply I need. Here is the servo's I am using:

https://www.amazon.com/gp/product/B01NA80LUR/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

Here is the sensor shield I am using:

https://www.amazon.com/gp/product/B01ACKVPTW/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

The servos run at 3-7.2V and 750ma-1000ma full load or another person said they ran only 100-150ma. Also, another question is do I plug that power supply, when I get the right one according to what you say, into the dc jack or the external power on the sensor shield board?

Thank you for your time.


texts: Compilation Error in nodeMCU along with oneWire temperature sensor ds18b20, and 2x16 LCD display (not I2C)

texts:
I am using nodeMCU along with oneWire temperature sensor ds18b20, and 2x16 LCD display (not I2C). I am using Arduino IDE to program nodeMCU. I am getting a compilation error:

C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here"
#error "Please define I/O register types here"
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

What is meant by: "Please define I/O register types here"? Thank you for the help.


texts: How to interface with a mobile phone LCD?

texts: I have a LG mobile phone LCD (model:KG 285). How could I interface with this LCD with an AVR microcontroller? Also, why are there articles on websites showing only interfacing of Nokia LCD?


texts: ESP8266 feather huzzah wiring for MFRC522

texts:
I'm trying to wire the mfrc522 and the huzzah but i can't seem to figure out the rst pin.

I found the pin out diagram but it doesn't show or idk how its labeled as.


texts:
I have something strange going on with an output. When the following code is called the LED goes on, but it stays on, there is no blinking. If I comment out the set HIGH statement the LED never comes on (as expected).

#define devicePin 10

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

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

Could I have damaged the board in some way?


texts: Parse data from sensor without delimeters

texts:
Im using a variant of Arduino Due embedded on a ARM (Udoo). And I have connected a Medlab SPO2 Pearl 200 sensor to Serial1.

Im just trying to parse input from Serial1 to Serial, in a human-readable format (Hexadecimal).

The protocol is described in this image:

And using this Arduino code I reveice two times the "no finger detected line"

int lineLength = 16;
int spo2read[16];
int readed = 0;
 if (Serial1.available()) {
    int inByte = Serial1.read();
    if (readed < lineLength) {
      spo2read[readed] = inByte;
    }
    readed++;
    if (readed == lineLength) {
      Serial.print("SPO2: ");
      for (int i = 0; i <= lineLength; i++) {
        Serial.print(spo2read[i], HEX);
        Serial.print( delimeter);
      }
      Serial.println("");

      readed = 0;
    }

  }

Output with no finger is:

SPO2: A,FB,2,F9,0,FA,0,FC,A,FB,2,F9,0,FA,0,FC,0,

Buf if I put my finger, all is messed up:

SPO2: 7C,74,6B,62,5A,51,4A,42,3B,34,30,2E,2F,30,31,33,0,
SPO2: 36,38,3B,3E,3D,3C,3C,3B,3B,38,34,2F,2C,2B,2B,29,0,
SPO2: 24,21,1E,1D,1E,1E,1F,20,22,24,26,28,2B,2D,30,32,0,
SPO2: 35,37,39,3C,3E,40,42,44,45,4A,4F,53,55,57,59,5C,0,
SPO2: 5E,60,61,F9,0,FA,0,FC,1A,FB,0,F8,62,62,62,63,0,

Sensor doesn't sends a \n or \r so I don't know exactly how to parse the data


texts: threshold voltage level and blinking problem

texts:
I am using arduino pro mini 3.3 V,8 Mhz.vcc of the this arduino is coming from AC-DC converter with regulator 3.3 volt.I am listening analog data from voltage divider approximately 250 milivolts.

I want to basically,If analog voltage will reach 250 milivolts then led on.Otherwise led off.I am using avarage 100 ms for voltage data.

But,I have seen led on blinking for threshold voltage.Such as,The voltage level is changing 248-254.led on,led of,led on...I don't want to blink.

What can you do in such situations?Voltage level and slightly variable voltage?

Thanks


texts:
I am trying to send a char array using Arduino Uno board and nRF24L01 modules
Here is the code for both transmitter and receiver:
 #include <SPI.h> //~ #include <TMRh20nRF24L01.h> //~ #include <TMRh20RF24.h>
 #include <nRF24L01.h>
 #include <RF24.h>

 #define CE_PIN   9
 #define CSN_PIN 10

 // NOTE: the "LL" at the end of the constant is "LongLong" type //
 These are the IDs of each of the slaves const uint64_t slaveID[2] =
 {0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL} ;

 RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

 char
> dataToSend[64]="e7665072be018b6b58ea9e40cf38553d6dc293cda4c9d94cda6e91ca61b3a073";

 unsigned long currentMillis; unsigned long prevMillis; unsigned long
> txIntervalMillis = 1000; int txVal = 0; float ackMessg[2]={1,2}; byte
 ackMessgLen = 4; // NB this 4 is the number of bytes in the 2 ints
 that will be recieved

 void setup() {

    Serial.begin(9600);
     Serial.println("Track Control Starting");
     radio.begin();
     radio.setDataRate( RF24_250KBPS );
     radio.enableAckPayload();
     radio.setRetries(3,5); // delay, count }

 //====================

 void loop() {

     currentMillis = millis();
     if (currentMillis - prevMillis >= txIntervalMillis) {

     radio.openWritingPipe(slaveID[0]); // calls the first slave
                                         // there could be a FOR loop to call several slaves in turn

     bool rslt;
     rslt = radio.write( dataToSend, sizeof(dataToSend) );
     Serial.print("\nRSLT (1 = success) ");
     Serial.println(rslt);
     Serial.print("Data Sent ");
     Serial.print(dataToSend[0]);
     Serial.print("  ");
     Serial.println(dataToSend[1]);
     if ( radio.isAckPayloadAvailable() ) {
         radio.read(ackMessg,ackMessgLen);
        Serial.print("Acknowledge received: ");
        Serial.print(ackMessg[0]);

 #include <SPI.h>
 #include <nRF24L01.h>
 #include <RF24.h>

 #define CE_PIN   9
 #define CSN_PIN 10

 // NOTE: the "LL" at the end of the constant is "LongLong" type

 const uint64_t   deviceID = 0xE8E8F0F0E1LL; // Define the ID for this slave

int valChange = 1;

 RF24 radio(CE_PIN, CSN_PIN);

 char  dataReceived[64];
 int ackData[2] = {12,23};

 void setup() {

     Serial.begin(9600);
     delay(1000);
     Serial.println("Hand Controller Starting");
     radio.begin();
     radio.setDataRate( RF24_250KBPS );
     radio.openReadingPipe(1,deviceID);
     radio.enableAckPayload();
     radio.writeAckPayload(1, ackData, sizeof(ackData));
     radio.startListening();
 }

 void loop() {

     if ( radio.available() ) {
         radio.read( dataReceived, sizeof(dataReceived) );
          for (int x = 0; x <64; x++) {
       //if (dataReceived[x] < 16) {
       //  Serial.write('0');
     // }
       Serial.print(dataReceived[x]);}
       Serial.println();
         radio.writeAckPayload(1, ackData, sizeof(ackData));

         ackData[0] += valChange; // this just increments so you can see that new data is being sent
     }
}

And here is the output that I get

Hand Controller Starting
e7665072be018b6b58ea9e40cf38553d


texts: Programming NEMA 17 2 Phase, 4 Wire Stepper Motor

texts:
I have successfully programmed the Stepper Motor 28BYJ-48 with ULN2003 driver using the code below. But then I replaced the 28BJY-48 with a NEMA 17 Motor then it won't work anymore. I researched that the 28BJY-48 is a 4 phase stepper motor and the NEMA 17 is a 2 phase stepper motor. Is there a difference on how should I programmed a 2 phase stepper motor from a 4 phase stepper motor?

#define A        2                     // the pin connected to the wire A of the coil A (or to the H-bridge pin controlling the same wire)
#define A_bar    3                     // the pin connected to the wire A- of the coil A (or to the H-bridge pin controlling the same wire)
#define B        4                     // the pin connected to the wire B of the coil A (or to the H-bridge pin controlling the same wire)
#define B_bar    5                     // the pin connected to the wire B- of the coil A (or to the H-bridge pin controlling the same wire)
#define x        4000                  // smaller values may make the motor produce more speed and less torque
#define stepsPerRevolution 200         // you can the number of steps required to make a complete revolution in the data sheet of your motor

void setup() {
  pinMode(A, OUTPUT);
  pinMode(A_bar, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(B_bar, OUTPUT);
}

void loop() {
  for (int i = 0; i < (stepsPerRevolution/4) ; i++) {
    digitalWrite(A, HIGH);
    digitalWrite(A_bar, LOW);
    digitalWrite(B, HIGH);
    digitalWrite(B_bar, LOW);
    delayMicroseconds (x);

    digitalWrite(A, LOW);
    digitalWrite(A_bar, HIGH);
    digitalWrite(B, HIGH);
    digitalWrite(B_bar, LOW);
    delayMicroseconds (x);

    digitalWrite(A, LOW);
    digitalWrite(A_bar, HIGH);
    digitalWrite(B, LOW);
    digitalWrite(B_bar, HIGH);
    delayMicroseconds (x);

    digitalWrite(A, HIGH);
    digitalWrite(A_bar, LOW);
    digitalWrite(B, LOW);
    digitalWrite(B_bar, HIGH);
    delayMicroseconds (x);
  }

  /*// Counter Direction
  for (int i = 0; i < (stepsPerRevolution/4); i++) {
    digitalWrite(A, HIGH);
    digitalWrite(A_bar, LOW);
    digitalWrite(B, LOW);
    digitalWrite(B_bar, HIGH);
    delayMicroseconds (x);

    digitalWrite(A, LOW);
    digitalWrite(A_bar, HIGH);
    digitalWrite(B, LOW);
    digitalWrite(B_bar, HIGH);
    delayMicroseconds (x);

    digitalWrite(A, LOW);
    digitalWrite(A_bar, HIGH);
    digitalWrite(B, HIGH);
    digitalWrite(B_bar, LOW);
    delayMicroseconds (x);

    digitalWrite(A, HIGH);
    digitalWrite(A_bar, LOW);
    digitalWrite(B, HIGH);
    digitalWrite(B_bar, LOW);
    delayMicroseconds (x);
  }
  delay(1000);*/
}

I changed the stepsPerRevolution to 200 for NEMA 17 and 32 for the 28BJY-48. NEMA 17 does not work.


texts:
For a project I would like to do, I asked a question about whether to use SD or EEPROM (see Question

I checked how much memory I would need without any restrictions which is like 2 MB (or more) so a SD card seems the best solution.

However, I'm a bit worried about the speed. In one of the answer comments is mentioned that 20 ms is an eternity for a microcontroller. However, I might need to do the following within 20 ms:

Parse a MIDI event (CPU power only, does not take long)
Read one or two SD pages (1/2 times block of 512 bytes)
Change/add/remove the MIDI event (CPU power only, negligible)
Send out MIDI data (barely no time, mostly hardware)

In worst case I can get like 10-20 MIDI events I need to handle within 20 ms. Especially for step 2 I don't know how much time it will.
My plan is to create a big file with a PC program to be stored on the SD card. Than I can let the Arduino read pages of 512 bytes from predefined places (with seek in a file).

I'm intending to keep the file open at all times and use seeks to go to the right place and read 512 bytes every time (assuming it doesn't matter to read 1 or 512 bytes since the page size is 512 bytes anyway).

So my question: is 20 ms enough to read like 50 pages of 512 bytes from an SD card which are located on different (but known) file offsets within a 2+ MB file?

(btw, I want to try first on an Uno, but probably I will later go to a Mega (or add more SRAM to store temporary data).


texts: How do I properly use the WiFi capabilities of ESP8266?

texts:
I am creating a project with an ESP8266 (Arduino IDE) which requires it to serve a webpage to a client. The module will be connected to a WiFi network by default, but when that WiFi network is not available, I need it to turn on its Soft Access Point, so that the user can still access that webpage by connecting to the AP. When the WiFi network becomes available, I want the module to reconnect to the WiFi network and disable the SoftAP.

Here is the chunk of code in my sketch that deals with all the WiFi stuff:

void wifi() {
  if(WiFi.status() != WL_CONNECTED){
    WiFi.mode(WIFI_AP_STA);

    if((unsigned long)(millis() - waitUntil) >= interval){            //this section I used as an alternative to the delay() function, the delay is 3 sec
      WiFi.begin(ssid, password);
      waitUntil = waitUntil + interval;

      if(WiFi.status() == WL_CONNECTED){
        Serial.println("Connection successful! ");
        Serial.print("IP: ");
        Serial.print(WiFi.localIP());
        WiFi.softAPdisconnect(true);
      }
    }
  }

  if(WiFi.status() != WL_CONNECTED && softAPEnabled == false){
    Serial.println("WiFi not connected, enabling SoftAP...");

    WiFi.softAP(softAP_ssid, softAP_password);

    softAPEnabled = true;

    Serial.println("SoftAP ON");
  }
  else if(WiFi.status() == WL_CONNECTED && softAPEnabled == true){
    WiFi.softAPdisconnect(true);
    softAPEnabled = false;
    Serial.println("SoftAP OFF");
  }
}

Here are the problems:

The webpage works fine when the module is connected to WiFi and I go to the IP address from a browser, but when SoftAP mode is enabled, and I connect to the AP and go to 192.168.1.1, it does not work. The next problem may be related to this.
I don't think I'm using WiFi.mode() correctly. I currently have it set to WIFI_AP_STA, but after problem 1 occurred, I tried to change it to WIFI_AP and WIFI_STA individually as I needed each mode, but this still did not work.


texts: Nodemcu 1.0 and boot mode (1,6) after soft reset

texts:
I have a problem with a nodemcu 1.0 (lolin) board. Sometime a soft reset is performed from the watchdog and the board freezes in boot mode (1,6) (I have to manually reset the board to restart it).
I have read many thinks on this topic and I have carefully avoided to use the GPIO0, GPIO2 and GPIO15. I have also verified that these pins are correctly pulled-up (GPIO0 and GPIO2) and pulled-down (GPIO15) but when the board frezes I have noticed that the voltage of the GPIO0 is not 3.3V but 2.0V.
Has anybody experienced a similar problem? Could you help me in solving it?

I wish you all a happy new year.
Cheers.


texts:
I have a problem with my Arduino Uno.  I am uploading the following code to my ESP8266.  It reads temperature values from a sensor (DS18B20), puts them into a database, and prints them on the serial monitor of my Arduino IDE.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWire(0);
DallasTemperature temp(&oneWire);

int ardudata=20;
int statoattuale=0;

const char* serverName = "http://myserver";
String sensorName = "DS18B20";

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

  WiFi.begin("SSID", "PASSWORD");
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);

                                       }

  temp.begin();
}

void loop() {
  //Check WiFi connection status

  if(WiFi.status()== WL_CONNECTED){
    HTTPClient http;

    http.begin(serverName);

    http.addHeader("Content-Type", "application/x-www-form-urlencoded");

    temp.requestTemperatures();
    // Prepare your HTTP POST request data

    ardudata=Serial.read();
    if (ardudata>=0 && ardudata<=12){
    statoattuale=ardudata;}
    String httpRequestData = "sensor=" + sensorName + "&temperatura=" + String(temp.getTempCByIndex(0)) + "&statoattuale=" + statoattuale + "";
   // Serial.print("httpRequestData: ");

    int httpResponseCode = http.POST(httpRequestData);

    if (httpResponseCode>0) {
    Serial.print("temp");
    Serial.println(String(temp.getTempCByIndex(0)));
    }
    // Free resources
    http.end();
  }
  //Send an HTTP POST request every 30 seconds
  delay(30000);
}

But, I fail when I try to read the temperature data in an Arduino sketch, with Serial.readString(); or Serial.read(). What can be the problem?
Wiring
I've wired the ESP8266 to the Arduino and sensor as follows:

ESP8266 Pin
Connected to

VCC
3.3V

GND
GND

TX
TX of Arduino UNO

RX
RX of Arduino UNO (through level converter)

GPIO0
data pin of the sensor

CH_PD
3.3V


texts: First Arduino Project - Need Advice (powering WS2812B LEDs)

texts:
I'm making a long LED display made up of 3 (8x32) LED matrices to go inside of a car. I can't seem to find any in-depth guides on this sort of thing. If anybody has examples that they would like to share please do!
The major issue I'm having is power. I'm extremely new to electronics, and I don't understand how these lights can be powered separately, and still be addressably lit by the Arduino?
Parts:
3* LED matrices (8x32)
https://www.amazon.com/gp/product/B088BTXHRG/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1
1* Mega 2560
Here's the mock-up schema:

I forgot to draw in a switch, and a power line leading to the Arduino. But let's assume there will be a switch before the resistor and a line that feeds power to the MEGA 2560.
What in this schematic doesn't look or sound right?
Thank you all in advance for your help. This is probably not at all how to go about building circuits, and I'm trying my best to learn. All advice is wanted!


texts: Arduino Leonardo as USB Keyboard with WiFi module

texts:
I have two PCs: the first is connected to the Arduino via WiFi, this will instruct the Arduino what keys to send, and the second PC is connected to the Arduino via USB that will act as a USB Keyboard for the PC to receive keystrokes. Is it possible to use Arduino Leonardo as a USB Keyboard connected to a PC with WiFi module connected to another PC? Do I need other components or modules for this to work?

I have searched the possibility of keystrokes and WiFi connection as separate projects but can't seem to find a project that has this scenario.

I also consider using Teensy with WiFi module if it is feasible. If this is not possible, are there any workarounds? Or other devices I can use? Thanks in advance.

EDIT: I am also checking Raspberry Pi Zero as an alternative. Is the project more probable with this or is it better to stick with Arduino?


texts: How to check my Arduino board is working or dead?

texts: When you have a board in your hand but you don't know is it working or not, how to verify if it's working or dead?


texts: How do I send multiple variables via stream to Unity?

texts:
So I currently have this for arduino.ino:

Serial.println(Variable1);

that does this in Unity:

string variable1 = stream.ReadLine();
float x = float.Parse(variable1);
transform.Rotate (0, -x/1000, 0);

My question is; How would I send 3 variables from the Arduino to Unity so I can put each value into the transform.Rotate function at once?

For example in pseudocode:

Arduino.ino
send(Variable1, Variable2, Variable3);

Unity
transform.Rotate(Variable1,Variable2,Variable3);

I hope this makes sense.
Thank you.


texts: "AtLibUsbDfu.dll not found" when using FLIP on Uno R3

texts:
Attempting to flash a new firmware with FLIP results in a "AtLibUsbDfu.dll not found" error and windows says that "Arduino Uno" already has the latest drivers.

How do I fix the AtLibUsbDfu.dll error? All sources say to update the driver to fix this but I already have the latest driver and windows wont let me change it.


texts: State machine sketch to drive a DC motor with limit switches

texts:
I have a DC motor that will need to use two limit switches to detect end of travel in two directions.

I've read that coding a state machine to do this task is the best method, however I have no idea where to even begin.

Below you'll find a fritzing sketch of my experimental configuration for the code once implemented, and a flow chart.


texts: How do I connect an 8x8 LED RGB matrix to an Uno?

texts:
I have this 8x8 LED RGB matrix. How do I get it connected to an Arduino Uno?

It came with no other wires/modules/connectors and has a veritable crap-ton of pins to connect.


texts:
Ì am building speedometer with NEO-6M and have some problems with my code.
The scenario is that I send some data from our Arduino to another device via a TX pin with a delay of 50 ms. This delay of 50 ms needs to be maintained and should not exceed. The issue with GPS data, which arrives from the device, is that it is received every 1 second. This issue will cause the 50ms delay to be longer and exceed to 1050 ms. In my last code change delay is not maintained on 50 ms, it is all 1000 ms. Not sure what I did wrong.
My code is

original

#include <AD9850.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 0, TXPin = 1;
static const uint32_t GPSBaud = 9600;

const int W_CLK_PIN = 8;
const int FQ_UD_PIN = 9;
const int DATA_PIN = 10;
const int RESET_PIN = 11;

double freq = 1;
double trimFreq = 124999500;

int phase = 0;

unsigned int speed = 0;

TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
}

void loop()
{
  // Dispatch incoming characters
  while (ss.available() > 0)
    gps.encode(ss.read());

  {
    digitalWrite(outPin, HIGH);   // sets the pin on
    delayMicroseconds(50);        // pauses for 50 microseconds
    digitalWrite(outPin, LOW);    // sets the pin off
    delayMicroseconds(50);        // pauses for 50 microseconds
  }

  if (gps.speed.isUpdated())
  {
    Serial.print(F("SPEED      Fix Age="));
    Serial.print(gps.speed.age());
    Serial.print(F("ms Raw="));
    Serial.print(gps.speed.value());
    Serial.print(F(" km/h="));
    Serial.println(gps.speed.kmph());
    speed = gps.speed.kmph();
    //calculate the frequency with map()
    freq = map(speed, 0, 100, 0, 160);
    DDS.setfreq(freq, phase);
  }
}

revised

(replying to https://arduino.stackexchange.com/a/45657)
Thank you for help. Is it possible to put GPS speed in this code? https://pastebin.com/LdT7UHBQ I used your code and it works but my boss demands that we modify his code and make it maintain delay with it.

long prevTxTime = 0;
const int delayTime = 51;

void setup()
{
  Serial1.begin(115200);
  Serial2.begin(115200);
}

void loop()
{

  int b, chunk = 0;

  if (Serial2.available())
  {
    b = Serial2.read();
    chunk = b >> 6;
    if (chunk == syncc)
    {
      bytes[syncc] = b & 63;
      syncc++;
      if (syncc == 4)
      {
        syncc = 0;
        tach = bytes[0] + (bytes[1] << 6);
        velocityfreq = bytes[2] + (bytes[3] < delayTime)
        {
          //speed from gps would most likely need to be set here as "speedfromgps"

          SendData();
          prevTxTime = millis();
        }
      }

      void SendData()
      {
        sprintf(charToSend, "%d|%d|%d|%d|%d\n\r",
                data1, data2, data3, data4, speedfromgps);

        Serial1.print(charToSend);
      }


texts:
I am using adxl335 accelerometer with Arduino uno r3 to measure acceleration due to gravity along x axis. I am using 50 ms delay and printing to serial.
I have two questions, which are;

Can I measure fractional values, like .8 in acceleration due to gravity?
when I shake the accelerometer up down along x axis, I don't see any variations in 'g'?

I am using analog pins and 3.3V power supply from Arduino to power the sensor.


texts:
I'm trying to learn how to program a MC, so maybe I didn't know much about a MC. I tried to test interrupt pin of ATtiny85 with this simple code

#include <avr/io.h>
#include <avr/interrupt.h>

void setup()
{
  GIMSK = 0b00100000;
  PCMSK = 0b00000001;
  sei();
  DDRB = 0b00010000;
}

void loop()
{
  PORTB = 0b00010000;
  _delay_ms(500);
  PORTB = 0b00000000;
  _delay_ms(500);
}

ISR(PCINT0_vect)
{
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);
  PORTB = 0b00010000;
  _delay_ms(100);
  PORTB = 0b00000000;
  _delay_ms(100);

}

This is just a blink code with an interrupt to make the LED blink faster 10 times. My question is why sometimes the LED blink faster many times with the interrupt pin is not connected to anything (open)? Didn't it have internal pull up or should I use external pull up in my circuit?

Thank you


texts:
I don't know much about Arduino but I am interested in buying a Due 32bit board. I was wondering if you can program it bare-metal and if this requires a separate debugger or not?
Thanks


texts: Searching for free OTA Server Host list name

texts:
I have seen this video:
Over The Air programming Tutorial
For programming the Arduino modules via internet  OTA system, so I have tried the adafruit account and don't find the AIO_KEY part on it, ( as you can see below):

So I like to know about other web server systems for testing this option on the Arduino module (for me is ESP8266 01!).
So please suggest some free internet website as alternative options  like suggested site via above video ( adafruit).
The codes for making the esp8266 ready to accept the OTA process is accessible here.
Note: Also the https://io.adafruit.com/ server have some Problem right now:
So if possible I like to know is any safe methods exist for the interrupt and server problem
situation like this (adafruit 503 error, seen below) during the Arduino  OTA programming?

Update:
I have found the link of adafruit OTA_Key :
https://io.adafruit.com/ss1/dashboards/<Your_acount_Name>

Thanks.


texts: I am trying to read input from 5th PIN of PORT B?

texts:
In a nutshell i want to read a PORTB 5th pin without using digitalRead API ( i am trying to learn baremetal using arduino-uno-r3)

Just to Learn How internal register works i did not used digitalRead API, instead i have used DDRB register to set the 5 bit of DDRB as Low indicating PORTB 5th pin is in input mode then i am using an if statment to check if 5th bit of PINB is high or low my expection was that when i connect arduino pin 13 to 5v  if statment will become TRUE.

void setup() {
  // put your setup code here, to run once:
  DDRB = DDRB & ~(1<<5);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(PINB & (1<<5)){
     Serial.println("Got data");
    }
}

When i executed above code i am constantly getting if as TRUE


texts:
I have built a prototype that uses RedBear Lab's Blend micro board (http://redbearlab.com/blendmicro/). The board combines Arduino and a BLE chip (Nordic nRF8001). The application is fairly simple

iPhone finds and connects to BLE chip
When user presses a button on iPhone a message is sent to the Blend Micro board
Based on the message (3 choices) the Arduino reads analog input from one of the pins
The reading is passed back to the phone via BLE

Everything works well. My question is

If I were to evolve this into something that can be taken closer to production, do I need the arduino? Seems like the Arduino is only adding a small amount of value in interpreting the message from phone and transmitting the reading
If I don't need Arduino, how do I program the BLE chip (Nordic nRF8001) directly? I have seen some kits on the internet and they all seem much more complex than programming Arduino.

I am a newbie to H/W - deep background in S/W engineering - but definitely motivated and interesting in making my project a reality. Advice and guidance are appreicated.