texts:
The logo is a derivative of the Arduino Community Logo licensed under Creative Commons license CC-SA-BY-NC 3.0

Update: Winners Announced

The winners of the contest have been announced. Please see the Meta post for details.

To celebrate 10 years of Arduino, we are proud to announce the first event ever on Arduino Stack Exchange.

  Get your boards and soldering equipment out, dig out the ICs and
  resistors. The first Arduino Stack Exchange contest is just round the
  corner. We will be looking for interesting projects that are built
  using Arduinos. The contest is aimed towards sharing, discussing and
  providing feedback on projects that you and other members are working
  on. See announcement post

Details:

The prize is an official Stack Exchange t-shirt
Limit two entries per person. If more than two are provided, only the first two will be considered.
Clones are allowed.
Projects for consideration will be accepted through March 29th, 2014 at 4:00 UTC. The question will still remain open in case someone wants to show off their project they made on Arduino Day 2014.

Visit the Meta post for discussion about this event and further information.

Answer Format

You may post up to two projects (as two separate answers) as entries for the contest. All extra entries will be deleted. Consider following the following template for entries:

  Project Title

  Very Brief Description

  Description

  What is your project? What does it do? What problem does it solve?

  Design

  Things to include in this section:

  Schematics and other design documentation. Fritzing is a good tool for drawing breadboard schematics like the one shown in the
  project logo above.
  Components used to build the project
  Pictures or video

  Conclusion

  Final thoughts. What did you learn from doing this project? What would
  you do differently if you had to start over?

You can copy/paste the following text if you want to use this template.

# Project Title
**Very Brief Description**

# Description
What is your project? What does it do? What problem does it solve?

# Design
Things to include in this section:

- Schematics and other design documentation. [Fritzing][8] is a good tool for drawing breadboard schematics like the one shown in the project logo above.
- Components used to build the project
- Pictures or video

# Conclusion
Final thoughts. What did you learn from doing this project? What would you do differently if you had to start over?

Prizes

There are two prizes! The winner will be the submission getting the maximum number of upvotes (downvotes do not count) and will get a Stack Exchange T-shirt*! There will be something for the runner-up as well. The runner-up will be decided at the discretion of the event organizers.

*Certain restrictions may apply. International shipping may take a few weeks.

Where do I submit my projects?

Post your projects as answers to this post.


texts: Error on Uploading Program to ESP8266 via Foca v2.2 (USB to TTL Adapter)

texts:
BACKGROUND

To test the capability of uploading program to ESP8266,  I use an empty program with only a blank setup function and a blank loop function. The result showed me that there are a espcomm_sync error and a espcomm_open error. Any idea to solve this problem?

HARDWARE

PIN CONNECTION

  Foca v2.2 <-> ESP8266
        TXD <-> RXD
        RXD <-> TXD
        DTR <-> RST

Arduino UNO <-> ESP8266
        GND <-> GND
       3.3V <-> Vcc

PIN DIAGRAMS

Foca v2.2

ESP8266

ON LINUX UBUNTU 15.04

ON WINDOWS 10

REFERENCE

Bring IoT to Arduino, together [Getting Started] - http://www.arduinesp.com/getting-started


texts:
I have programmed Attiny88 with Arduino IDE 1.6.5 using https://github.com/SpenceKonde/ATTinyCore . I chose Attiny88 because it's the cheapest Attiny (as low as $0.5) and at the same time has 28 pins with dedicated SPI.  I wrote a code for arduino to work as SPI master, and a code for Attiny88 as SPI slave but I get only 0 as answer from Attiny.

SPI master code for ARduino UNO

#include <SPI.h>

// set up the speed, data order and data mode
SPISettings settingsA(2000000, MSBFIRST, SPI_MODE0);
const int slaveAPin = 10;

void setup() {
  // set the Slave Select Pins as outputs:
  Serial.begin(9600);
  Serial.println("SPI ON");
  pinMode (slaveAPin, OUTPUT);
  SPI.begin();
}

uint8_t stat, val1, result;

void loop() {
   // read two bytes from device A
   SPI.beginTransaction(settingsA);
   digitalWrite (slaveAPin, LOW);
   // reading only, so data sent does not matter
  stat = SPI.transfer(0);
  val1 = SPI.transfer(0);
  digitalWrite (slaveAPin, HIGH);
  SPI.endTransaction();
  Serial.println("data");
  Serial.println(stat);
  Serial.println(val1);
  Serial.println("end");
  SPI.endTransaction();
  delay(300);
}

SPI slave code for Attiny88:

#include <SPI.h>

// set up the speed, data order and data mode
SPISettings settingsA(2000000, MSBFIRST, SPI_MODE0);
const int slavePin = 14;
const int ledPin = 9;

uint8_t stat, val1, val2, result;

void setup() {
  // set the Slave Select Pins as outputs:
  pinMode (slavePin, INPUT);
  pinMode (ledPin, OUTPUT);
  // initialize SPI:
  digitalWrite(ledPin, HIGH);
  delay(1000);
  SPI.begin();
  stat =128;
  val1= 1;
}

void loop() {

  if (slavePin==LOW) {
    SPI.beginTransaction(settingsA);
    SPI.transfer(stat);
    SPI.transfer(val1);
    result = SPI.transfer(0);
    digitalWrite(ledPin, result);
    SPI.endTransaction();
  }

}


texts: Set clockspeed of Arduino Pro Micro a. k. a. AtMega32u4

texts:
Is it possible to change clock speed when running sketch?

Low-power lib drops the current consumption from 20mA to 9.5mA at 8MHz, it is still too much. Is there a way how to set clockspeed (for example) to 1MHz, go to sleep, after interrupt wake up, set clockspeed back to the 8Mhz (for 3v3), do some stuff and then go sleep again?

Thanks


texts: Streaming audio from PC to Arduino over WiFi

texts:
Say I wanted to, purely hypothetically, set up a pirate radio station by connecting an Arduino to a WiFi network away from home, streaming music to the Arduino, decoding it, and broadcasting it with an FM transmitter.

Given an Arduino (Genuino) Uno, a Sparkfun ESP8266 Thing Dev breakout board for WiFi connectivity, and an Adafruit Si4713 Stereo FM Transmitter breakout board, how would I go about the actual streaming of music (in MP3 or WAV format) from a (Windows) computer to the Arduino over WiFi? Would an Arduino Uno be powerful enough for this? Which components would I need to decode the audio?


texts: Arduino IDE/Visual Micro - Undefined reference to constructor

texts:
I am using Visual Studio Community 2015 with the newest version of the Visual Micro Arduino Plugin, however I also tried compiling my code in the Arduino IDE.
When compiling my code, there is the following error:

Compiling debug version of 'Autonomous_Car' for 'Arduino/Genuino Uno'
Autonomous_Car.cpp.o:In function `setup
Autonomous_Car.ino:undefined reference to `List<UpdateAble>  List()
Autonomous_Car.ino:undefined reference to `List<UpdateAble>  ~List()
collect2.exe*:error: ld returned 1 exit status
Error creating .elf

Some info

Adding #include "List.cpp" fixes the error, however this does not seem like valid C++.
The files do not lay in any sub-directory
In my Project Explorer both List.h and List.cpp are added to the project.
I also removed both files from the project, deleted them and added them again
I deleted the ´%AppData%\Local\Arduino15´ directory
I am fairly new to C++ and Arduino, there might be something obvious, what I just can't find

Autonomous_Car.ino

#include "List.h"
#include "UpdateAble.h"

void setup()
{
    List<UpdateAble>* myList = new List<UpdateAble>();
    myList->GetCount();

    delete myList;
}

List.h

#ifndef _LIST_h
#define _LIST_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif

template <class T>
class List {
public:
    void Add(T &item);
    bool Contains(T &item);
    bool Remove(T &item);
    void Clear();
    int IndexOf(T &item);
    T* GetItem(int index);

    inline int GetCount() { return count; };
    inline int GetCapacity() { return capacity; };

    List();
    ~List();
private:
    void EnsureCapacity(int capacity);

    int count;
    int capacity;
    T** items;
};

#endif

List.cpp

#include "List.h"

// Constructor
template <class T>
List<T>::List() {
    List::capacity = 4;
    List::count = 0;

    List::items = new T*[List::capacity];
}

// Cleanup
template <class T>
List<T>::~List() {
    delete[] List::items;
}

template <class T>
void List<T>::EnsureCapacity(int capacity) {
    if (List::capacity < capacity) {
        // Kapazität verdoppeln
        List::capacity = List::capacity * 2;

        // Speicher für neues array reservieren
        T** newArray = new T*[List::capacity];

        // Array kopieren
        for (unsigned int i = 0; i < List::count; i++) {
            newArray[i] = List::items[i];
        }

        // Speicher von alten array freigeben und neues array zuweisen
        delete[] List::items;
        List::items = newArray;
    }
}

// Adds a new item to the list
template <class T>
void List<T>::Add(T &item) {
    List::EnsureCapacity(count + 1);

    List::items[count] = item;
    List::count++;
}

// Gets whether the list contains an item or not
template <class T>
bool List<T>::Contains(T &item) {
    return List::IndexOf(item) != -1;
}

template <class T>
bool List<T>::Remove(T &item) {
    int index = List::IndexOf(item);

    // If the item does not exist, we cannot remove it
    if (index == -1) return false;

    // Move every item behind our item one further
    for (int i = index + 1; i < List::count; i++) {
        List::items[i - 1] = List::items[i];
    }

    List::count--;
}

// Release the heap
template <class T>
void List<T>::Clear() {
    for (int i = 0; i < List::count; i++) {
        delete List::items[i];
    }

    delete[] List::items;
}

// Gets an index of an item, -1 if not found
template <class T>
int List<T>::IndexOf(T &item) {
    for (int i = 0; i < List::count; i++) {
        if (List::items[i] == item) {
            return i;
        }
    }

    return -1;
}

template <class T>
T* List<T>::GetItem(int index) {
    if (index < List::count && index >= 0) {
        return List::items[index];
    }

    return 0;
}

I'd be very glad, if we can find the solution.


texts: How to convert Unicode char to “Unicode HEX Position” in Arduino

texts:
How to convert Unicode char to "Unicode HEX Position" in Arduino or C
i will share a picture here :

for example in JavaScript you can do that with charCodeAt(); ! this function will return exactly the char-code and then you can convert it to hex!
for example in JavaScript i can do that like this to return exact table value
 var inpString = 'س';
    var myChar=0;
    var output = 0;
    myChar = inpString.charCodeAt(0);
    output = (ToHex((myChar&0xff00)>>8 )) + (ToHex( myChar&0xff ));

    function ToHex(i)
    {
        var sHex = "0123456789ABCDEF";
        var Out = "";
        Out = sHex.charAt(i&0xf);
        i>>=4;
        Out = sHex.charAt(i&0xf) + Out;
        return Out;
    }
 alert(output);

So how can i do that in Arduino ? its using to send unicode char in PDU mode in Arduino
i just need to convert unicode char like this -> 'س' to correct Unicode HEX Position that i shared in the picture above
for example 'س' is 0633 or 'A' is 0041 or 'ب' is 067E


texts: RGB LED using potentiometer and push button

texts:
I'm currently working on an assignment which has to turn on an RGB LED using a potentiometer and button. The problem I currently have is that the button is supposed to change the color I want the LED to display (presses one time: red (pin9), again green (pin10), again blue (pin11)). As I'm changing through the ports with the potentiometer, the potentiometer will read it with as analogWrite. For example, if I move the potentiometer all the way to the left and press the button the LED will display red and move it back all the way to 0 and press the button twice the LED will stay red (do nothing). If I press it one more time it will turn off. Another example, I turn on red again, then use green and turn off blue using the potentiometer and button giving me orange. How do I make it so to accomplish all of this while using both and combining colors?
THIS IS A HW QUESTION AND NOT ASKING FOR A WHOLE SOLUTION BUT RATHER WHERE TO START BECAUSE I ALREADY GOT STUCK AND WANT TO RESTART PER SE
Edit:I solved my doubt! Thanks for the help!


texts:
My intention is to write a code that asks a user to enter the name and then the age. The code should then simply display the persons name and age. To do that, I have written a simple code. I find it difficult to get it to work.

char temp = 0;
char ArrayName [50];
int positionArray = 0;
int age =0;

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

void loop() {

    positionArray = 0;
    Serial.println ("What is your name?");

    do {

        while (Serial.available()==0);
        temp = Serial.read ();
        ArrayName [positionArray++] = temp;
    } while (temp != '\r');

    ArrayName [--positionArray] = '\0';

    Serial.print ("Your Name is: ");
    Serial.println (ArrayName);

    // clear the UART Buffer
    while (Serial.available()==1){
        temp = Serial.read();
    }

    Serial.println ("What is your age?");
    while (Serial.available()==0);
    temp = Serial.read ();
    age = temp;

    Serial.print ("You are ");
    Serial.print (age);
    Serial.println (" Years old.");

    while (Serial.available()==1){
        temp = Serial.read();
        delay (10);
    }

}

The error I receive is that the program already outputs age without me even typing it.  Would it be possible to know the error?
I use both NL and CR to send in characters to Arduino and the Arduino IDEs default UART terminal.

EDIT:

Listening to advice gotton from answers I got the code to work but in a very weird way. My new code works! but it proves the clearing of buffer cannot be done by just reading it. This is in contrast to Arduino documents. My new code is as follows.

char temp = 0;
char ArrayName [50];
int positionArray = 0;
int age =0;

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

void loop() {

    positionArray = 0;
    Serial.println ("What is your name?");

    do {

        while (Serial.available()==0);
        temp = Serial.read ();
        ArrayName [positionArray++] = temp;
    } while (temp != '\r');

    ArrayName [--positionArray] = '\0';

    Serial.print ("Your Name is: ");
    Serial.println (ArrayName);

    // clear the UART Buffer **WHY IS THIS CODE NOT EFFECTIVE?**
    while (Serial.available() >= 1){
        temp = Serial.read(); // performing dummy reads untill buffer empty.
    }

    temp = Serial.read();
    delay (1000);
    temp = Serial.read();
    temp = Serial.read();
    temp = Serial.read();

    Serial.println ("What is your age?");
    while (Serial.available()==0);
    temp = Serial.read ();
    temp = temp - 48;
    age = temp*10;
    delay (1000); // providing the user a day to enter next digit of age

    if (Serial.available()){
        temp =  Serial.read ();
        temp = temp - 48;
        age = (int) temp + age; //whatever that is added have to be of same type. Else they need to be cased to same type.
    }

    Serial.print ("You are ");
    Serial.print (age);
    Serial.println (" Years old.");

    while (Serial.available() >=1 ){
        temp = Serial.read();
        delay (10);
    }

}


texts:
Is it possible using an arduino to control more than 4 PWM fan at 25khz ?

I have found this but 4 PWM limited with an UNO

https://arduino.stackovernet.com/fr/q/8407

An other arduino, like a 2560 could be used ?

Thanks
Best regards
Sébastien


texts: Teensy 2.0++ SDA SCL pins not accesible using ARDUINO software

texts:
Hi I was looking to interface Teensy++ 2.0 with MPU6050 for a simple IMU project.
I have done this previously using Teensy 3.1 by trying the project of kriswiner however I also wanted to try it out on my Teensy++ 2.0 board.

But when I went to check the pin assignments for Teensy++ 2.0 on the pjrc website it has been mentioned that the pins PD0 and PD1 can be used as SDA and SCL using C Language but there is no assignment of SDA SCL on Teensy ++ 2.0 using Arduino Software

Does that mean we cannot use these pins using Arduino software at all? Or is there a workaround to this?


texts:
While using NEO 6M and getting close-to-perfect accuracy, connecting the 3dr uBlox LEA 6H shows incoming characters, but gibberish data (at 38400) like it is connecting to a wrong baud rate (although it isn't, i've checked it with u-center and works when connected to Ardupilot).
So i guess it is some kind of configuration to show only certain parts of NMEA (if it is showing NMEA and not something else).


texts:
I've got an Adafruit Bluefruit NRF52 hooked up to the Adafruit BNO055 9-axis orientation sensor, but when I use Serial.write to send the data, serial monitor displays blank values only. The scroll bar drops so something I definitely appearing, it just seems to be empty.

Serial.print works fine, but I cannot use this for my application, as it uses too much memory.

I'm gathering 3 axis of absolute orientation plus 3 axis of acceleration (6 floats in total) plus a three digit number representing the calibration of each sensor.

Each line should look something like

303 68.69   4.19    -2.19   -0.12   0.14    -0.40

My code:

void displayCalStatus(void)
{

  uint8_t system, gyro, accel, mag;
  system = gyro = accel = mag = 0;
  bno.getCalibration(&system, &gyro, &accel, &mag);

  /* Display the individual values */
  Serial.write(gyro);
  Serial.write(accel);
  Serial.write(mag);
  Serial.write("\t");
}

void loop()
{
  imu::Vector<3> accel = bno.getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);

  /* Get a new sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  displayCalStatus();

  /* Display the floating point data */
  Serial.write(event.orientation.x);
  Serial.write("\t");
  Serial.write(event.orientation.y);
  Serial.write("\t");
  Serial.write(event.orientation.z);
  Serial.write("\t");

    /* Display the floating point data for Linear Acceleration */
  Serial.write(accel.x());
  Serial.write("\t");
  Serial.write(accel.y());
  Serial.write("\t");
  Serial.write(accel.z());
  Serial.write("\n");
}


texts: Can I run arduino on Windows Embedded Compact 2013?

texts: I'm actually working on a robotic project for which I'm planning to use arduino to drive the wheels.For this, I want to send signals from my Onboard embedded computer (which has Windows Embedded Compact 2013 OS) to arduino. Is this possible? If not possible, what are the other alternatives?


texts:
I have a little problem dealing with ultrasonic sensor
I want a simple thing , when the sensor read High pulse then after it low pulse , turns on the led
so I try to make it with a 5cm distance and a flag , but it's dose not work
help me please!
    #define echoPin 5
    #define trigPin 7
    int GREEN = 2;
    int YELLOW = 3;
    int RED = 4;
    int pos = 0;
    int flag = 0 ;
    long duration;
    int distance;
    void setup() {

  // put your setup code here, to run once:
    pinMode(GREEN, OUTPUT);
    pinMode(YELLOW, OUTPUT);
    pinMode(RED, OUTPUT);
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
    pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
     }

    void loop() {

    ultra();

    if ( distance <= 5 && flag == 0)
    {//H
      flag = 1 ;}
    } //high pulse (When the distance <=5)

    if ( distance >5 && flag == 1)
    {//L
      red_light(); }

    }//the led should turned on when low pulse appears (When the distance >5)

    void red_light()
    { digitalWrite(GREEN, LOW);
    digitalWrite(YELLOW, LOW);
    digitalWrite(RED, HIGH); }

    void ultra()
    { digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    distance = duration*0.034/2; }

//this is my code


texts:
I am working on an anemometer project using Arduino. I don't know barely anything from Arduino and I am following this tutorial.
I have some doubts on the making part. This is what I have to make:
and this is the code:
//anemómetro con LCD
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

float veloc1 = 0; // entrada A0
int tiempo = 0;
int cnt = 0;
float v1 = 0;
float v2 = 0;

void setup() {
  lcd.begin(16, 2); // Fijamos el numero de caracteres y filas
  lcd.begin(16, 2); // Fijamos el numero de caracteres y filas
  lcd.print("Anemometro EC"); // Aqui va el mensaje
  analogReference(INTERNAL);// pone como referencia interna 1.1V
}

void loop() {
  v1 = (analogRead(0)); // lectura de sensor a0
  veloc1 = (v1 * 0.190); // 0,190 corresponde a la pendiente de la curva aca deben poner el numero que calcularon
  lcd.setCursor(0, 1); // Ponte en la line 1, posicion 0
  lcd.print(veloc1); //muestra la velocidad del viento en el LCD
  lcd.setCursor(4, 1); // ponte en linea 1, posicion 5
  lcd.print("Km / h");
  lcd.setCursor(9, 1);
  lcd.print("Max");
  if (veloc1 > v2)v2 = veloc1, lcd.print (v2, 1); // muestra la velocidad maxima que alcanzo
  delay(1000);
}

What is the potentiometer doing here? Why is it necessary?
My lcd screen doesn't show anything. Does anyone knows why??

Thanks in advance.


texts:
I'm running the WiFiWebClient example which comes preloaded with Arduino IDE 1.6.7. I'm using Arduino Uno board with WiFi Shield Model R3.

/*
  Web client

 This sketch connects to a website (http://www.google.com)
 using a WiFi shield.

 This example is written for a network using WPA encryption. For
 WEP or WPA, change the Wifi.begin() call accordingly.

 This example is written for a network using WPA encryption. For
 WEP or WPA, change the Wifi.begin() call accordingly.

 Circuit:
 * WiFi shield attached

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe
 */

#include <SPI.h>
#include <WiFi.h>
#include <WiFiClient.h>

char ssid[] = "Vanilla Sky"; //  your network SSID (name)
char pass[] = "mypass";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

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

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 80) == 0) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: keep-alive");
    client.println();
  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

It gets my WiFi shield connected to Vanilla Sky but doesn't fetch the HTTP request (see image below). What is getting wrong here?


texts: How to compile Arduino Framework with GNU

texts:
I'm wondering if it's possible to use GNU (g++) to compile a arduino Sketch.

I wanna be able to unit test my code with catch2.

g++ -std=c++11 <filename> works well with catch2, but I obviously does not recognize Arduino's framework (Strings, Serial etc).

What I think is, maybe if I use Arduino's compiler [ which is compatible with -std=c++11 I would be able to do run the catch2 with the Arduino framework.

Does anyone knows where to find Arduino's compiler? or how to make GNU accept Arduino's framework?


texts: PWM water pump flow control - in percent

texts:
I want to control flow level on 12V water pump with PWM pin, I'm using IRF520N MOSFET for that (and dedicated 12V power supply).

I'm assuming, that setting PWM to full byte should give me about 100% or 12V. But how to set proper value on PWM pin so the flow equals to eg. 10%, 25% or 50%? Is it some logharitmic equation?


texts: Fading the brightness of LEDs using MAX7219 and PWM

texts:
I am doing a project with bi-color led matrix 8x8 and MAX7219 as the LED driver. I want to implement a fading effect on the LEDs, like mixing the two colors by varying the individual duty cycles.

My idea is the use of the Iset parameter; I would connect the PWM pin from Arduino through the Rset resistor and feed that into the Iset of the MAX7129 instead of 5V supply. Please suggest whether or not this is possible, if not what can be the alternative approach?


texts: Detecting if a push button was pressed and released

texts:
I want to detect if a push button was pressed and released again. So I thought the right approach would be to first wait while the pin yields LOW and then wait while the pin yields HIGH:

void push(int pin) {
  // wait until button was pushed down...
  while (digitalRead(pin) == LOW);
  // ... and released again
  while (digitalRead(pin) == HIGH);
}

That function can be easily reused. The code works fine, but I am just wondering if that solution is considered clean and a good practice.


texts:
I thought I was buying an Arduino Uno board and received a "WDLEle WDLduino uno" board.  I think I got ripped by China, but can anybody tell me what driver to use, where to get it, or what the heck this board is?

HELP


texts:
I'm using TTGO ESP32 and I've got an MFRC522 from AliExpress.
I've soldered connector pins to the board itself (both for ESP32 and MFRC522) and I'm using jumper wires female-to-female to connect themselves.
However, using an example sketch (DumpInfo) from miguelbalboa's RFID library, it says communication failure and scanning 3 different key cards or the key fob doesn't output anything.
Firmware Version: 0xFF = (unknown)
WARNING: Communication failure, is the MFRC522 properly connected?

This is my current pinout scheme:
(MFRC - ESP32)
SDA (SS) -> 33
SCK -> 25
MISO -> 27
MOSI -> 26
RST -> 32

And, of course also GND to G and 3.3V to 3.3V.
I've also tried SDA and SCK to connect to 21 and 22, respectively but no luck.
Though I have a DS1307 RTC module and microSD card adapter module and connected accordingly and it's working fine, by using Dupont wires, with the same method.
A manufacturer's defect or still I'm making an error somewhere?
You can see TTGO's ESP32 pinout diagram and also a picture of MFRC522 here  wired using jumper wires. I may be using (again) the wrong pins. The red LED on the MFRC522 is stable, though.
Thank you in advance.


texts:
I have these 3 wires coming from a servo motor. They're very thin and flimsy and despise staying in a breadboard.

Is it possible to add headers to these wires to make them easier to put in a breadboard? (Like the attached image) And if so, where would one procure such a thing?


texts: I2C communication problem with two slaves (atlas scientific) and one Nano (official)

texts:
I'm working on a project using an arduino Nano (official) and two peripherals from Atlas Scientific (pH and DO) communicating via i2c. Everthing works fine when i use a usb alimentation connected to the PC or to a 5V adaptater (typically a phone charger).

I want to use a 12V battery and a 12V DC 1.5A adaptater to power up my system, the problem is that it works fine for a moment (30 to 40 seconds) and then the pH start having problem with the communication and the led becomes red and the TX/RX leds from the arduino (which are connected to nothing start going crazy. I use 4.7k pull up resistors and an L7805ACV voltage regulator to go from 12 to 5V.

Attach, a part of the system schematics.

If you have any clue, starting to be new idealess

EDIT : Here is the part of the program concerning the i2c communication :

#include "Wire.h"

/*********************************************************************************************************
 *                                               Address
 *********************************************************************************************************
 */
int pH_address = 99;
int DO_address = 97;

/*********************************************************************************************************
 *                                         i2C CONFIGURATION
 *********************************************************************************************************
 */

byte received_from_computer = 0;
char sensor_data[20];
byte in_char_sensor = 0;
byte j = 0;
byte code = 0;
int time_ = 850;

void setup()
{
  Wire.begin();
}
void loop()
{
  pH = Get_i2C(pH_address);
  delay(200);
  DO = Get_i2C(DO_address);
  delay(200);
}

/**********************************************************************************************************
 *                                                  i2C
 * ********************************************************************************************************
 */

float Get_i2C(int address)
{
  char computerdata = 'R';
  Wire.beginTransmission(address);
  Wire.write(computerdata);
  Wire.endTransmission();

  delay(time_);

  Wire.requestFrom(address, 16, 1);
  code = Wire.read();
  while (Wire.available())
  {
    in_char_sensor = Wire.read();
    sensor_data[j] = in_char_sensor;
    j += 1;
    if (in_char_sensor == 0)
    {
      j = 0;
      break;
    }
  }
  return atof(sensor_data);
}


texts: Can't Turn Off Internal I2C Pull-Ups on ESP32

texts:
I've designed a custom ESP32 board around the WROVER-IE module. To keep power low, I'm using a GPIO-controlled high-side FET to turn off unused peripherals when in deep sleep mode.
The issue: I've pulled up an SSD1306 I2C OLED to this AUX rail. It works great when the device is awake. On setup() I start the OLED via ssd1306.begin() and from that point on, the SCL and SDA pins (22, 21) are always tied to 3.3V until I reset the ESP32.
The I2C bus always being tied to 3.3 ends up bleeding through the pull-up resistors and into the AUX rail, resulting unwanted current draw when in sleep mode.
Is there any way to turn off the internal I2C pullups on the ESP32?
Things I've tried so far:

Setting SDA, SCL as OUTPUT and writing LOW (does not work)
Setting SDA, SCL as INPUT and/or writing LOW (does nothing)
Calling gpio_hold_dis(gpio_num_t(SDA));(does nothing)

I'm now trying to dissect the esp32-hal-i2c.c lib but am not finding any fixes. Any help is greatly appreciated!
Edit, added diagram:

-N


texts:
I bought the below FTDI programmer for use with my 3v3 arduino pro mini. But even when the switch is set to 3v3 it is powering the board with 5v, (hence the IO voltage is also 5v). Note that when the pro mini is powered by batteries on the RAW input the IO voltage is 3v3 as expected. The problem is that when programming at 5v, any 3v3 peripherals (such as the BMP180) will be surely damaged.

http://www.ebay.co.uk/itm/301597777458?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

Now on the eBay description it says:

  This board ship default to 5V, but you can cut the default trace and add a solder jumper if you need to switch to 3.3V

Which trace needs to be cut, and where does the jumper need to connect to/from?


texts: Arduino libraries development and Eclipse Soleber

texts:
I have a project on Arduino IDE. A .ino sketch with some extra .h/.cpp files and 2-3 libraries that I keep in ~/Arduino/libraries.

In addition to the IDE I do open the libraries as generic project in eclipse, of course this means no symbols resolution and no indexing which is bad for me.
So I wanted to give Solebera try. I can see that Soleber includes the directory above however when compiling, I can clearly see it doesn't include any of those libraries! Also trying to add them doesn't work as the preference screen doesn't allow it/lists it.

So you help please,

how can i make it even compile?
will eclipse index it? I mean if I press 'ctrl + shift + r' and start typing RH_RF95 (radiohead rf95 driver cpp file) will it let me open it? (it does for Platformio).


texts:
Can we use just a analog Read without storing it
i hear it it a good practice to take two reads
for better accuracy
example:
// Read extra analog inputs
    for (int i = 0; i < 8; i++)
{
    // Read analog pin to nothing.
        analogRead(i]); // analog-read is not writing to anything
}

// Read the analog inputs
for (int i = 0; i < length; i++)
{
    // Write the state of the analog pin to the response buffer.
    slave.writeRegisterToBuffer(i, analogRead(analog_pins[address + i]));
}


texts:
My problem is when I run code like this:

char directioN;

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

void loop()
{
  if (Serial.available())
  {
    directioN = Serial.read();

    switch (directioN)
    {
      case 'F':
        break;

      case 'B':
        break;

      case 'R':
        break;

      case 'L':
        break;

      default :
        break;
    }

    Serial.print("direction is:");
    Serial.println(directioN);
  }
}

My serial monitor add another input, but the second one is empty; this happened here with char both as with int.

But when i tried the same code in tinkercad it worked fine.

So do I really need a new ATMEGA328 or it can be done by software or something?

**I use an Arduino Uno


texts: Connect Arduino to Socket IO Webserver via Esp8266

texts:
As part of a project I want to receive data on my arduino uno via a sensor, which is working fine. This data should be sent to a webserver where a node js with socket io is running. Therefore i bought a esp8266 and the corresponding adapter (https://www.amazon.de/gp/product/B01LZLVEJ4/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1).

In the IDE I have the following code:

    #include <SoftwareSerial.h>

    SoftwareSerial esp8266(2, 3);

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

      Serial.println("Started");

      // set the data rate for the SoftwareSerial port
      esp8266.begin(115200);
    }

    void loop() {
      if (esp8266.available()) {
        Serial.write(esp8266.read());
      }
      if (Serial.available()) {
        esp8266.write(Serial.read());
      }

    }

I use the serial monitor to perform my AT Commands and it seems to work some times, however there seems to be a problem with the output, for example if I type the command AT+CWLAP to display the Access Points. If I do so, it outputs something like:

    +CWLAP:(3,"WLAN-32CC39",-73,"10:c6:0f:2c:32:cc",1,65,0)
    +CWLAP:(3,"F1e:,:oMc:0(x8:1LN⸮⸮⸮:b),k7:,(-,36Ao-2,
    (e0e,C".66,Cwe8:"+L,:"+27:6L W79",944,Ab,::0(ot230( -5,CTO940PBc,63+3y8:")3,dc3
    "P4-ze6P!"80,3716

I should also note, that even if I input the same, the response differs, and sometimes it is just single characters that are wrong, e.g. "wigi" instead of "wifi". I tried different baud's for the esp8266 but the current one produces the least problems. So my questions here are:

1: Is there anything I am currently doing wrong while connecting to my local wifi network?

2: If there is a connection made, is there any way to connect to a socket io server as a client? Most Tutorials I have found have the arduino as a server. However, I want to have it as a client which communicates to a server. Therefore it should both be able to send and receive messages to/from the server.

Thanks in advance!


texts:
I have function to start an NTP service, right after obtaining wifi connection ( using ESP8266 board ).

from time to time, I get an error saying date and time is01-01-1970... which I assume is due to not reaching the server as intended.

A retry counter was added to give few more retries, but somehow I does not do the trick since I never get the expected message NTP CHECK: # and retry number ( while get an invalid date ).
I know that NTP.begin() returns a bool to describe success/ failure obtaining a NTP server

EDIT1: using NtpClientLib

How can it be done ?

void startNTP() {
        int counter = 0;
        while ( !NTP.begin("pool.ntp.org", 2, true) && counter <=2){
          Serial.print("NTP CHECK: #");
          Serial.println(counter);
          counter +=1;
          delay(1000);
        };
        NTP.setInterval(clockUpdateInt); // in seconds
}


texts:
In the following code from an Arduino sketch will it run the first "for" statement before enacting the second "for" statement. Also how does it know go run the first stamens again? Will it continue to run till both statements are true?

for(int r = 0; r < 8; r++){
    for(int c = 0; c < 8; c++){
        lc.setLed(0, r, c, HIGH);
    }
}


texts: How to remove the sketch for the LCD and retaining the sketch for the MPU6050?

texts:
I just got this from the internet and I only want to use the sketch for the MPU6050. Can someone help me to remove the code for the LCD? I'm sorry, I'm just noob when it comes to programming.

Here is my source: Earthquake Detector using Arduino and MPU-6050

Here is the sketch:

#include <LiquidCrystal.h>

#include <Wire.h>

#include <MPU6050.h>

#define minval -5

#define maxval 3

MPU6050 mpu;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

{   lcd.begin(16, 2);

Serial.begin(115200);

pinMode(7,OUTPUT);

pinMode(8,OUTPUT);

lcd.print("   EarthQuake ");

lcd.setCursor(0, 1);

lcd.print("   Detector");

delay (2000);

lcd.clear();

// Initialize MPU6050

Serial.println("Initialize MPU6050");

while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

{ Serial.println("Could not find a valid MPU6050 sensor, check wiring!");

delay(500);}

mpu.setThreshold(3);

// Check settings

checkSettings();

}

void checkSettings()

{

Serial.println();

Serial.print(" * Sleep Mode:        ");

Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled");

Serial.print(" * Clock Source:      ");

switch(mpu.getClockSource())

{case MPU6050_CLOCK_KEEP_RESET:     Serial.println("Stops the clock and
keeps the timing generator in reset"); break;

case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external
19.2MHz reference"); break;

case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external
32.768kHz reference"); break;

case MPU6050_CLOCK_PLL_ZGYRO:      Serial.println("PLL with Z axis
gyroscope reference"); break;

case MPU6050_CLOCK_PLL_YGYRO:      Serial.println("PLL with Y axis
gyroscope reference"); break;

case MPU6050_CLOCK_PLL_XGYRO:      Serial.println("PLL with X axis
gyroscope reference"); break;

case MPU6050_CLOCK_INTERNAL_8MHZ:  Serial.println("Internal 8MHz
oscillator"); break;

}

Serial.print(" * Gyroscope:         ");

switch(mpu.getScale())

{case MPU6050_SCALE_2000DPS:        Serial.println("2000 dps"); break;

case MPU6050_SCALE_1000DPS:        Serial.println("1000 dps"); break;

case MPU6050_SCALE_500DPS:         Serial.println("500 dps"); break;

case MPU6050_SCALE_250DPS:         Serial.println("250 dps"); break:}

Serial.print(" * Gyroscope offsets: ");

Serial.print(mpu.getGyroOffsetX());

Serial.print(" / ");

Serial.print(mpu.getGyroOffsetY());

Serial.print(" / ");

Serial.println(mpu.getGyroOffsetZ());

Serial.println();}

void loop()

{   Vector rawGyro = mpu.readRawGyro();

Vector normGyro = mpu.readNormalizeGyro();

Serial.print(" Xraw = ");

Serial.print(rawGyro.XAxis);

Serial.print(" Yraw = ");

Serial.print(rawGyro.YAxis);

Serial.print(" Zraw = ");

Serial.println(rawGyro.ZAxis);

if(normGyro.XAxis > maxval || normGyro.XAxis < minval && normGyro.YAxis >
maxval || normGyro.YAxis  < minval && normGyro.ZAxis > maxval ||
normGyro.ZAxis  < minval)

{ digitalWrite(7,HIGH);

digitalWrite(8,HIGH);

delay(300);

digitalWrite(7,HIGH);

digitalWrite(8,HIGH);

delay(300);

lcd.clear();

lcd.print("***EarthQuake***");

delay (1000);

lcd.clear();}

else{digitalWrite(7,LOW);

digitalWrite(8,LOW);}

Serial.print(" Xnorm = ");

Serial.print(normGyro.XAxis);

Serial.print(" Ynorm = ");

Serial.print(normGyro.YAxis);

Serial.print(" Znorm = ");

Serial.println(normGyro.ZAxis);

delay(10);}


texts: how to convert the following code into one using direct port manipulation

texts:
Following is the program for scanning a keyboard for MIDI transfer.
At present the code works fine, but it could be faster.
I need to know how to use direct port manipulation inside the for loop.
boolean keypressed[6][6]; //for storing key states
int midinote[6][6] ={ 60 ,61 ,62 ,63 ,64 ,65
                 ,66 ,67 ,68 ,69 ,70 ,71
                 ,72 ,73 ,74 ,75 ,76 ,77
                 ,78 ,79 ,80 ,81 ,82 ,83
                 ,84 ,85 ,86 ,87 ,88 ,89
                 ,90 ,91 ,92 ,93 ,94 ,95  }; //code for various midi notes C3 to C6

void setup() {

   Serial.begin(38400);
   for(int i=0; i<6; i++){
      pinMode(i+2,OUTPUT);
      digitalWrite(i+8,HIGH);
   }
   for(int i=0; i<6; i++){
      pinMode(i+8,INPUT);
      digitalWrite(i+8,HIGH);
   }
   for(int i=0; i<6; i++){
      for(int j=0; j<6; j++){
          keypressed[i][j] = false;
          }
      }
   }
void loop() {

   for(int i=0; i<6; i++){
      digitalWrite(i+2, LOW);
      for(int j =0; j<6; j++){
         if ((digitalRead(j+8) == LOW) && !keypressed[i][j]){
            Serial.write(0x91);
            Serial.write(midinote[i][j]);
            Serial.write(127);
            keypressed[i][j] = true;
           }
         if ((digitalRead(j+8) == HIGH) && keypressed[i][j]){
            Serial.write(0x91);
            Serial.write(midinote[i][j]);
            Serial.write(0);
            keypressed[i][j] =false;
         }
      }
digitalWrite(i+2, HIGH);
   }

 }


texts: ESP8266 GET OR POST Request Timeout Error

texts:
i am using ESP8266 module serially with PC and i also tried it using uno
I am stuck at the following point
I am able to made connection to server but when i will send the following command

POST /test.php HTTP/1.1\r\nHost: 192.168.1.36\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 5\r\n\r\nb1=ON\r\n\r\n

every time i get the following server timeout error after 3 sec

+IPD,4,500:HTTP/1.1 408 Request Timeout
Date: Tue, 08 Mar 2016 14:10:07 GMT
Server: Apache/2.4.9 (Win64) PHP/5.5.12
Content-Length: 305
Connection: close
Content-Type: text/html; charset=iso-8859-1

408 Request Timeout

Request Timeout

Server timeout waiting for the HTTP request from the client.

Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

4,CLOSED

And i am getting same issue whether i will use local server or online server


texts:
I'm attempting to re-write a library for the CD74HC4067 multiplexer.  There is a library available for this device on the Arduino Playground, however, it's limited in its functionality.

I have this as a private data member in the class header file:

uint8_t channelSelects[16][4];

And this in the class constructor:

CD74HC4067::channelSelects[16][4] = {
    { 0,0,0,0 }, // channel 0
    { 1,0,0,0 }, // channel 1
    { 0,1,0,0 }, // channel 2
    { 1,1,0,0 }, // channel 3
    { 0,0,1,0 }, // channel 4
    { 1,0,1,0 }, // channel 5
    { 0,1,1,0 }, // channel 6
    { 1,1,1,0 }, // channel 7
    { 0,0,0,1 }, // channel 8
    { 1,0,0,1 }, // channel 9
    { 0,1,0,1 }, // channel 10
    { 1,1,0,1 }, // channel 11
    { 0,0,1,1 }, // channel 12
    { 1,0,1,1 }, // channel 13
    { 0,1,1,1 }, // channel 14
    { 1,1,1,1 }  // channel 15
};

And I'm getting this error:

cannot convert '<brace-enclosed initializer list>' to 'uint8_t {aka unsigned char}'

Could someone please explain what I'm not understanding here ?

Many thanks in advance.


texts: Serial loop stopped after a while, I don't know why

texts:
I am very new to Arduino. I wrote a program in order to read some registers in a I2C device. I receive HEX datas.

So the Arduino LEONARDO is connected to the external board using the 2-wires-bus.
Then informations are sent to my computer by using Serial.println.

My problem is my Arduino stops working after a while, maybe 25 or 30 loops. Sometimes I loose communication and I have to reboot the Arduino.

I guess it's an overflow issue or I'm loosing connection randomly :

int dt = 500;
int dt2 = 1000; // used for delay duration
#include "Wire.h"
#include <Process.h>
#define pot_address 0x25 // each I2C object has a unique bus address, the MCP40

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

}

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

  Wire.beginTransmission(pot_address);
  Wire.write(0); //
   Wire.endTransmission();
  Wire.requestFrom(pot_address,8);
  byte b = Wire.read();

  Wire.beginTransmission(pot_address);
  Wire.write(1); //
   Wire.endTransmission();
  Wire.requestFrom(pot_address,8);
 byte c = Wire.read();

   Wire.beginTransmission(pot_address);
  Wire.write(2); //
   Wire.endTransmission();
  Wire.requestFrom(pot_address,8);
 byte d = Wire.read();

  Wire.beginTransmission(pot_address);
  Wire.write(3); //
   Wire.endTransmission();
  Wire.requestFrom(pot_address,8);
 byte e = Wire.read();

  Wire.beginTransmission(pot_address);
  Wire.write(4); //
   Wire.endTransmission();
  Wire.requestFrom(pot_address,8);
 byte f = Wire.read();

  Serial.print("b");
  Serial.println(b, HEX);
  Serial.println("-");
  Serial.print("c");
  Serial.println(c, HEX);
  Serial.println("-");
  Serial.print("d");
  Serial.println(d, HEX);
  Serial.println("-");
  Serial.print("e");
  Serial.println(e, HEX);
  Serial.println("-");
  Serial.print("f");
  Serial.println(f, HEX);
  Serial.println("-");

 delay(dt2);

}


texts:
For a project I am working on, I need to connect my ESP32 board to another server via MQTT protocol. I am using the Mosquitto MQTT Broker and it is presently on my laptop. Following is the test code I am using, which I'll build around this program.

#include <WiFi.h>
#include <PubSubClient.h>

const char* ssid = "*****";              //WiFi Name
const char* password = "********";      //WiFi Password
const char* server= "***.***.**.***";    //RPi or Machine IP on which the broker is

WiFiClient espClient;
PubSubClient client(espClient);

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

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("Attempting MQTT connection...");
  client.connect("esp32");
  if (client.connect("esp32")){
      Serial.println("connected");
    }
    else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
    }
    return 0;
}

int reconnect() {
  unsigned long startAttemptTime = millis();
  while (!client.connected())
  {
    Serial.println("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("esp32")){                 //if (client.connect("esp32", MQTT_USER, MQTT_PASS)) {
      Serial.println("connected");
    }
    else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
  return 0;
}

int send_mqtt(){
  setup_WiFi();
  char sss[15]="Hello World";
   if (!client.connected()){
    reconnect();
  }
  client.publish("esp32/test", sss);    //send message
  WiFi.disconnect(true);
  Serial.println("Sent");
  return 0;
}
void setup() {
  Serial.begin(115200);
  client.setServer(server, 1883);   //mqtt server details
  setup_WiFi();
  reconnect();
  send_mqtt();
}

void loop() {
  send_mqtt();
  delay(10000);     //Wait 10 secs before next transmission
}

I tried connection but got this error

Attempting MQTT connection...failed, rc= -2

What am I doing wrong? Any changes I need to make to the .conf file about which I don't know?
Guide me.
Thank You in advance


texts: How to control segway motor with arduino uno?

texts:
I salvaged segway motor with 8 wires. I did completed basic connection of 5 hall sensors and power from 36V lipo battery in the image  below. When I connect self-learning wires then motor starts rotating so connecting must be right. So now how do I control the motor with arduino?

Controller is kkmoon motor regulator 350W - link

didn't find datasheet about motor but here are some Information:-
Type: BLDC Motor
Voltage: 36V
no of wires:- 8 (3 wires  for 3 phase, 5 for hall sensor)
Power:- 300W


texts: Control multiple WS2812B strips with different leds count

texts:
First of all, my English is not that good so sorry if I made any mistake.

I'm using the WS2812FX, an awesome WS2812 effect library base on Adafruit NeoPixel library to make a small controller for the lightning in my bedroom.

The question here is how do I use this library to control multiple WS2812b led strip with different leds count, like one strip with 30 leds the other with 55 leds but the effect will just cycle through each individual led of each strip.IF somehow I can add one more output pin to this.

Example : There is an effect call "Larson Scanner" will light up one led then it run from the first led to the last led and go back, I want it to do the same on both strips, on the 30 leds strip it goes from first led to 30th led then go back & on the 55 leds strips it goes from first led to the 55th led at the same time.

Hope you guys understand what I'm asking :(

Link to the library : https://github.com/kitesurfer1404/WS2812FX


texts:
When I put "c" inside setColor(c);

it tells me:

error: too few arguments to function 'void setColor(int, int, int)'.

I understand that I should put 3 arguments. What I don't understand is that the serial is correctly displaying the 3 arguments (255, 000, 000) so why it keeps telling me this error. What am I doing wrong ?

int rPin = 11;
int gPin = 9;
int bPin = 10;

void setup() {
    Serial.begin(9600);
    pinMode(rPin, OUTPUT);
    pinMode(gPin, OUTPUT);
    pinMode(bPin, OUTPUT);
}

void loop() {
    if (Serial.available() > 0) {
            delay(100);
            while (Serial.available() > 0) {
                char c = Serial.read(); // serial will display an rgb code, for exemple: 255, 000, 000 (red color)
                setColor(c);
            }
        }
}

void setColor(int red, int green, int blue) {
    analogWrite(rPin, red);
    analogWrite(gPin, green);
    analogWrite(bPin, blue);
}


texts: Possible to connect 3 MPU9250 to Node MCU without multiplixer?

texts:
Is the idea of connecting AD0 pins of MPU9250 is still valid like the 2nd answer of this question? - How to change i2c address for mpu9250?

I have connected 2 sensor as test. SCL & SDA of both parallel with D1 & D2 of node mcu. Then connected AD0 of both sensors to different I/O pin of node mcu but it didnt work. What could be the solution?

Code to control 1 sensor:- It worked when I set AD0 to high and changed address to 0x69

#include "MPU9250.h"

// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
MPU9250 IMU(Wire,0x68);
int status;

void setup() {
  // serial to display data
  Serial.begin(115200);
  while(!Serial) {}

  // start communication with IMU
  status = IMU.begin();
  if (status < 0) {
    Serial.println("IMU initialization unsuccessful");
    Serial.println("Check IMU wiring or try cycling power");
    Serial.print("Status: ");
    Serial.println(status);
    while(1) {}
  }
}

void loop() {
  // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelY_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelZ_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroX_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroY_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroZ_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagX_uT(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagY_uT(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagZ_uT(),6);
  Serial.print("\t");
  Serial.println(IMU.getTemperature_C(),6);
  delay(100);
}

Code to control 2 sensors:-

#include "MPU9250.h"

// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
MPU9250 IMU1(Wire,0x68);
MPU9250 IMU2(Wire,0x68);

int status;

void setup() {
  // serial to display data
  Serial.begin(115200);
  pinMode(D7, OUTPUT);
  pinMode(D8, OUTPUT);

}

void IMU_1() {
  digitalWrite(D7, LOW);
  digitalWrite(D8, HIGH);
  IMU1.begin();
  IMU1.readSensor();
  Serial.print("IMU 1 is active: "); Serial.print(IMU1.getAccelX_mss(),6);
  digitalWrite(D8, LOW);
}

void IMU_2() {
  digitalWrite(D7, HIGH);
  digitalWrite(D8, LOW);
  IMU2.begin();
  IMU2.readSensor();
  Serial.println("IMU 2 is active: "); Serial.print(IMU2.getAccelX_mss(),6);
  digitalWrite(D7, LOW);
}

void loop() {

IMU_1();
IMU_2();

  delay(500);

}

Result:- It Shows reading on one sensor but the 2nd sensor shows '0' every time.

What's the best way to use 3 I2C sensors when there is only 1 I2C bus?


texts:
I own a UDOO Quad board which features two CPUs (SAM3X8E like Arduino Due and a ARM Cortex-A9) connected with an internal OTG USB.

I am trying literally for months to use the USB Host Shield Library (https://github.com/felis/USB_Host_Shield_2.0/) in order to make the Due act as a USB host to the other CPU (which runs Android). The Due runs well a piece of code collecting some data every X milliseconds within a built-in timer's ISR.

What I want to achieve is to send this data collected by the ISR to the other CPU via the USB connection of the two; but there seems to be an issue with the Usb.Task() call. This Usb.Task() needs to be executed from within the Loop() but it seems to need much more time than the timer's frequency. So eventually it is never executed.

Please note that all of the above work when the interrupt is not involved; Usb.Task() works perfectly from the Loop() (data to/from the other CPU can be both sent and received).

Bits from the code:

void readPlantStatus() {
  if (analogRead(E2_STATUS)*(3.3/1023.0) > 2.0) e2_reached = true;
  else e2_reached = false;
  if (analogRead(F2_STATUS)*(3.3/1023.0) > 2.0) f2_reached = true;
  else f2_reached = false;
  if (analogRead(T2_STATUS)*(3.3/1023.0) > 2.0) t2_reached = true;
  else t2_reached = false;
  if (analogRead(E3_STATUS)*(3.3/1023.0) > 2.0) e3_reached = true;
  else e3_reached = false;
  if (analogRead(F3_STATUS)*(3.3/1023.0) > 2.0) f3_reached = true;
  else f3_reached = false;
}

void TC3_Handler() {
  TC_GetStatus(TC1, 0);
  readPlantStatus();
  writeToController();
  readFromController();
  controlPlant();
}

void loop()
{
  Usb.Task();
}

Any help would be greatly appreciated!


texts:
I am trying to make a simple debounce function as explained here but the condition if((millis()-timeCheck)>reboundDelay) is never met.

As you can see in my code below, I am trying to control a PWM with two push buttons. I am currently sending it on a LED.

With AS7 and vMicro I put some breakpoints and realized that timeCheck was stuck at 0 and was an unsigned int instead of the unsigned long I declared. With the debugger I looked inside of the millis() function and saw that timer0_millis wasn't increasing neither, stuck at 0.

Here is my short code (it's a sketch, it can surely be rewritten in a more efficient way) :

int PWM=9;
int dutyP=2;
int dutyM=3;
int duty=123;
bool stateP=0;
bool stateM=0;
bool prevStateP=0;
bool prevStateM=0;
unsigned long reboundDelay=500;
unsigned long timeCheck=millis();

void setup() {
  pinMode(PWM,OUTPUT);
  pinMode(dutyP,INPUT);
  pinMode(dutyM,INPUT);
}

void loop() {
  stateP=digitalRead(dutyP);
  stateM=digitalRead(dutyM);
  if(stateP != prevStateP || stateM != prevStateM) {
    timeCheck=millis();
  }
  if((millis() -  timeCheck) > reboundDelay) {
    if(stateP==1) {
      duty=duty+25;
    } else if(stateM==1) {
      duty=duty-25;
    }
    analogWrite(PWM,duty);
    prevStateP=stateP;
    prevStateM=stateM;
  }
}

And finally, the strange part. When I upload it on my Genuino Uno for like 30 seconds, the pushbuttons do nothing (it may be that the if works) and afterwards I can increase and decrease the duty cycle but without the delay that the condition should bring (the LED flashes really fast due to an overflow in analogWrite).

Any help is welcomed, the strange part is secondary to me but I would really like to make millis() work properly.


texts: Using an Android bluetooth terminal to change preset states on 8x8 LED matrixes

texts:
I'm trying to create eyes for a project, and while I have been able to properly program the different expressions, and have them triggered by commands from the COM3 terminal, I have not been able to make any commands from the Bluetooth Terminal on my phone work.

Details:

Mega2560

2x 8x8 LED Displays - MAX7219

HC-05 Bluetooth Transceiver - default Baud - 9600

Using LEDControl.h, SoftwareSerial.h

This is the loop on my device, when I type the commands A, B, etc. into the COM3 terminal it works just fine, but the same commands on the phone are just interpreted as ASCII, even when I put parentheses around them.

void loop()
{
  // Feed any data from bluetooth to Terminal.
  if (EEBlue.available()){
  Serial.write(EEBlue.read());
  }
  if (Serial.available())  //verifies if there is serial data available
  {
    char cmd = Serial.read();

    if(cmd == 'A') {
      display_eyes(eye_neutral_l, eye_neutral_r);
    }
    if(cmd == 'B') {
      display_eyes(eye_shock_l, eye_shock_r);
    }
    if(cmd == 'C') {
      display_eyes(eye_love_l, eye_love_r);
    }
    if(cmd == 'D') {
      display_eyes(eye_suspicious_l, eye_suspicious_r);
    }
    if(cmd == 'E') {
      display_eyes(eye_happy_l, eye_happy_r);
    }
    if(cmd == 'F') {
      display_eyes(eye_hurt_l, eye_hurt_r);
    }
    if(cmd == '1') {
      display_eyes(eye_mad_l, eye_mad_r);
    }
  // Feed all data from termial to bluetooth
  EEBlue.write(Serial.read());
  }
}


texts: Adafruit ESP32 device working on OSX 10.13 but not on OSX 10.11 on older machine

texts:
I'm new to Arduino - just got an ESP32-based Adafruit Feather HUZZAH32. I got it up and running on my Macbook Air (High Sierra) with no problem, following the instructions at this page linked from the Adafruit page on the HUZZAH32:

https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/mac.md

Basically, install the Arduino IDE, install the Espressif stuff using a big shell command, and install the driver for the CP2104 USB->UART bridge.

Worked like a charm on the Macbook Air, no problem. But different story when I went to install it on my 2009 vintage Mac Pro running El Capitan. Everything seemed to install ok, and the Arduino IDE runs and shows "Adafruit ESP32 Feather" (under Tools->Board). But when I try to upload a sketch (the "Blink" built-in example), it compiles ok but seems to hang while uploading, eventually finishing after about 5 minutes.  But the sketch isn't there, a one I previously uploaded from the HighSierra machine still executing. Furthermore, it does weird things to the Mac: the System Profiler (About This Mac) no longer runs (shown as "Not Responding" in Activity Monitor), even after I've quit the IDE; occasionally I can't even seem to quit the IDE; and next time my computer sleeps, it can't be woken up (I have to restart with the power button).   Another thing: when I start the upload, the kernel-task (PID 0) starts using over 100% of the CPU (from Activity Monitor).

Maybe it's a version compatability issue with the Espressif uploader ?   Or maybe I screwed up with the CP2104 driver, first installing the one here:

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

as pointed to by the howto at Adafruit, and when things did not work, and the uninstall shellscript for the driver failed too, I just deleted what seemed to be the relevant files before then installing the "legacy" driver, which also did not work.

Looked at some of the debugging stuff here ... The CP2104 driver shows up under USB in System Profiler, and both cu.SLAB_USBtoUART and tty.SLAB_USBtoUART show up under /dev (in Terminal).   So nothing seems wrong there.

Here is a screen grab (with verbose output for upload selected):

    Archiving built core (caching) in: /var/folders/qr/2l7_tnqx0m34h2sfbp218ykw0000gp/T/arduino_cache_759917/core/core_espressif_esp32_featheresp32_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_4423141e818963094868f9e8ffa4e8ec.a
Sketch uses 136741 bytes (10%) of program storage space. Maximum is 1310720 bytes.
Global variables use 10908 bytes (3%) of dynamic memory, leaving 284004 bytes for local variables. Maximum is 294912 bytes.
/Volumes/MainHD/Users/jge/Documents/Arduino/hardware/espressif/esp32/tools/esptool --chip esp32 --port /dev/cu.SLAB_USBtoUART --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 /Volumes/MainHD/Users/jge/Documents/Arduino/hardware/espressif/esp32/tools/partitions/boot_app0.bin 0x1000 /Volumes/MainHD/Users/jge/Documents/Arduino/hardware/espressif/esp32/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 /var/folders/qr/2l7_tnqx0m34h2sfbp218ykw0000gp/T/arduino_build_212318/Blink.ino.bin 0x8000 /var/folders/qr/2l7_tnqx0m34h2sfbp218ykw0000gp/T/arduino_build_212318/Blink.ino.partitions.bin

Let me know if the formatting of this screen grab is too hard-to-read, and I'll try to format the screengrab some before I insert it.  It just seems to be a very long command line to run esptool, and then ... nothing.

I'm at a loss (and I've asked at Adafruit forums:

https://forums.adafruit.com/viewtopic.php?f=57&t=128986

... and filed an "issue" at the github page too:

https://github.com/espressif/arduino-esp32/issues/983

Thanks for any help !


texts: Is possible use Macro F() with Integer and Other types of variable?

texts:
i have a sketch that is using very memory RAM of my Atmega2560 (is a giant project), and i need use various "println" because i have a TFT screen and i need to show data on the screen to user see. So, i'm using macro F() to use less RAM memory (example: Serial.println("Hi Naruto-kun") to Serial.println(F("Hi Naruto-kun")). But, it only work if the data entered in F() were to Const String, when i need, by example, show a array of integers, nothing work.

Example:

tft.print(F(mediaTotPg[1]));

This do not work because mediaTotPg is a Integer Array and the errors returned are:

" #define F(string_literal) (reinterpret_cast(PSTR(string_literal))) "

Finally, is possible show integers not const with Macro F()?


texts: Arduino Pro Mini stopped working / broken

texts:
I need help, currently I am working in final project about portable monitoring system. I am using Arduino Pro Mini 5V/16MHz as microcontroller and a Li-Po battery to power it up through XL6019 boost converter. I have created the PCB and assembly all components but suddenly when I turned it on, the Arduino Pro Mini suddenly stopped working. Recently I am adding a feature to measure the battery capacity so I connected the battery voltage to arduino pro mini Analog Pin, is that the problem? But I have tested the method of measuring battery capacity using Arduino Uno before and it worked fine. .
I am confused right now about what is the main problem.. and also is there any way to repair the Pro Mini? The Pro Mini used in project can't be reseted and I can't upload any program to it.
Pls help.


texts:
I'm a beginner in Arduino. I just installed Arduino IDE (arduino-1.0.5-r2-windows) but when I try to run its not responding and crashes after few minutes. I tried re-installing it and removing the temporary files but none of those helped.

Can anyone tell me what causes this problem and how to debug it?


texts: "port" is greyed out in 1.6.13, running win 10 for an Uno R3

texts:
I am new to this, and my kid got an Elegoo smart robot car kit v2.0 for Christmas. We assembled the car, but after downloading the software, the program always states:

  Arduino: 1.6.13 (Windows Store 1.6.13.0) (Windows 10), Board: "Arduino/Genuino Uno"

  Sketch uses 2,242 bytes (6%) of program storage space. Maximum is 32,256 bytes.

  Global variables use 210 bytes (10%) of dynamic memory, leaving 1,838 bytes for local variables. Maximum is 2,048 bytes.
  avrdude: ser_open(): can't open device "\.\COM1": The system cannot find the file specified.

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

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

I don't know what other information is important. Can somebody please help me?

Thank you.


texts:
Arduino: 1.8.8 (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

libraries\TimerOne\TimerOne.cpp.o (symbol from plugin): In function `TimerOne::isrDefaultUnused()':

(.text+0x0): multiple definition of `__vector_13'

libraries\Timer1Fast\Timer1Fast.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Timer1Fast.h"
 Used: D:\apps\Arduino\libraries\Timer1Fast
 Not used: C:\Users\biril\Documents\Arduino\libraries\pwmTest
Multiple libraries were found for "TimerOne.h"
 Used: D:\apps\Arduino\libraries\TimerOne
 Not used: C:\Users\biril\Documents\Arduino\libraries\TimerOne-master
Multiple libraries were found for "LiquidCrystal_I2C.h"
 Used: C:\Users\biril\Documents\Arduino\libraries\LiquidCrystal_I2C
 Not used: C:\Users\biril\Documents\Arduino\libraries\NewliquidCrystal
 Not used: C:\Users\biril\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
 Not used: D:\apps\Arduino\libraries\LiquidCrystal
Multiple libraries were found for "Wire.h"
 Used: D:\apps\Arduino\hardware\arduino\avr\libraries\Wire
 Not used: D:\apps\Arduino\libraries\Wire
exit status 1
Error compiling for board Arduino Nano.

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


texts: How much power can a proto board handle?

texts:
I have been working on a project where I will be powering an Arduino and some LED light strips (2 x 3 Meter strips w/ 30 LEDs per meter). I am powering all of it from a 5v 10amp power supply.

Currently I have split the power cable and have it running to the board and the LED's in separate runs.

As I move from a breadboard to a more permanent proto-board, it would be great to add a barrel connector onto the proto-board and just have a single plugin for power so I can easily disconnect it.

Will this cause any issues if all of the power comes from the proto-board? Thanks!


texts: Will Nodemcu support 4AAA batteries which is 6v approx, or should i go with 3AAA batteries which is 4.5V approx. And one more question , is it ok to use AA instead of AAA ?


texts: Brushless motor vibration/jitter/noise - arduino uno

texts:
I am currently using these motors and driving them off these drivers and an arduino uno, and alternatively trying to make them turn using the setup in step 6 (both with l298n and without) in this instructable. I have 4 motors and all are exhibiting the same behaviour.
Using the drivers, I just sent a constant PWM via PWM pin, and the motor would only spin at high values around 255, but even then only when I touch the motor does it start spinning. This spinning is then not even smooth, it pauses a bit every second or so and results in a sort of jittering. After a bit more, plugging the motors in it now just makes an increasingly louder whining noise, kind of like it's getting ready to take off but doesnt really spin. Code used here is just basic as below:
void setup () {

pinMode(9, OUTPUT);

}

void loop (){

analogWrite(9, 255);

}

Using the instructable setups, I've wired exactly the same way (wiring for l298N version is in step 10, wiring for discrete steps is just directly pwms to the motor), but the motors will not spin like theirs do (same poles and slots, 12n14p). Mine just jitters back and forth in tiny steps and looks like it's just twitching. Code used is exactly as at the end of 'step 6'.
Imgur album of issues


texts: Why do I keep blowing up Nanos when I solder them?

texts:
I have blown up 2 Arduino Nanos and I'm trying to figure out what I'm doing wrong.

In both cases, I was powering the boards with a 16V supply (I know this is high, but the regulator datasheet says it is good to 25V, and the regulator was not damaged). I unplug the supply and USB cable and then start soldering to one of the pins (A6). When I plug the board back in, the L LED does not flash, indicating the bootloader has been erased. The POW light is on and I still measure 5V, indicating the regulator is working. When I connect the board to my PC, the serial port pops up just fine. But when I try to upload a sketch, the IDE times out and says it cannot communicate with the board.

I attempted to reprogram the bootloader using a raspberry pi but avrdude also says it cannot find the device either. It looks like the microcontroller is blown.

My iron tip is grounded, so my best guess is some residual power in the supply travels through the microcontroller to my iron and shorts something out. But this seems unlikely seeing as A6 is an input and grounding it should be just fine even when the supply is fully on.

Any ideas what I could be doing wrong? FYI, I am cross-posting this on the Arduino forums.


texts:
I have two arduinos (An UNO R3 and a Mega 2560), and I need to communicate them via two ESP8266 modules to exchange some values.

In one arduino I'll use a SW-420 vibrarion module, and I need to send a value wirelessly to the other board, which it'll have an LCD screen that will display a message when a value is recieved.

How can I do that with that specific WiFi modules? Thanks in advance


texts: Why Firmata Test doesn't allow me to choose a port?

texts:
I'm a beginner and, sorry, also I don't speak English very well. However, I'm going to try to explain my problem.
I'm working on Ubuntu 14.04.2 and Arduino Uno R3.
I downloaded Firmata Test binaries for Linux 64 bit, I gave it permissions with chmod 754 <file>. Also I uploaded StandardFirmata from Arduino IDE to the board. Afterwards, I quit Arduino IDE and ran Firmata Test with ./file. But, the Port menu has no items within. I tried restarting the board and the application as well.

What can I do?


texts:
I know that Vin can be used to power the board but have also been reading that it can be used as a 5V output. Is it possible to assign Vin as an output as I would any other GPIO?

If I want to power an LED from GPIO 12, I would assign GPIO:

const int LEDpin_0 = 12; // D6, LED power pin

...and in the setup:

pinMode(LEDpin_0, OUTPUT);

I can then turn on and off the LED based on whether or not GPIO 12 goes HIGH or LOW.

Can I do the same with Vin without resorting to relays or other hardware?


texts:
I am trying to install/include Jan Breuer's SCPI parser. I was not able to find any documentation to accomplish this. I copied the contents on of the GIT zip file to my Libraries directory, but when I try to include the library I get a message that the header file could not be found. What do I need to do to install/utilize this library?

Here is the error message I am getting:

Specified folder/zip file does not contain a valid library

-Tim


texts:
I'm powering a NodeMCU with 4 x AA batteries (6v, ~9,600mAh).  I am running  ESP.deepSleep([milliseconds]) to minimize power consumption.  Even with deepSleep I am seeing a precipitous drop off in battery voltage.  I've gone from 6.00v to 5.62 in 28 hours.  Does this make sense?  I was expecting the board to consume SIGNIFICANTLY less power and I'm at a loss.

I have the reset/wakeup pins (D0, D3, and D4) set connected to 3.3v with resistors and I've jumped the reset pin to D0 to make the wakeup call.  Nothing else is connected!  Does this power draw make any sense??

As far as the operation goes, it's waking up and posting data just fine.

I've researched various power saving techniques and the best description I've found is here.  I really don't want to start hacking up ESPs though.  That is time consuming and presents a real opportunity (ahem...guarantee) for me to destroy a lot of boards!

My questions:
1.) Are there other SW-based methods for improving power use on the NodeMCU 12E?
2.) Where do I probe a 12E to read current draw with a multimeter
3.) Are there "dumber" ESP8266 modules that have a reset pin, a few? GIPOs and a VIN capable of handling a 6v input with either a 5v and/or 3.3v output?  Product recommendation...I know...I'm hard up though and need some guidance.

I'll make these separate questions if necessary.

I am going to by an in-line current reader.  I need to stick with a multimeter for now.


texts: How to add additional millisecond delay to microsecond delay generator

texts:
I am trying to make a delay generator. I already found an excellent example in Generating a short pulse after a delay that works in the range from ~5-32767 microseconds (it is limited by a 16 bit microsecond counter divided by 2).

How would I go about extending that range into the millisecond range (say up to 1s or so)? Since this example is interrupt-based, adding delay() statements do not really seem to work.

I have also tried changing the timer prescaler, but then the jitter is also scaled up in an unacceptable way.

This is the code I have now. Send commands via the arduino serial console, D500 for 500µs delay, L100 for a 100µs long pulse. Letters M and N change the prescaler.

uint16_t pulse_delay = 10; //half-microseconds
uint16_t pulse_length = 10;
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete
long read_value = 0;
long ms_delay = 0;

void printvals() {
  Serial.print(F("Delay: "));
  Serial.print(pulse_delay / 2);
  Serial.println(F(" µs"));
  Serial.print(F("Length: "));
  Serial.print(pulse_length / 2);
  Serial.println(F(" µs"));
}
long getcommandvalue(String inputstring) {
  inputString.remove(0,1);
  return inputString.toInt();
}
void setup(){
  pinMode(8, INPUT);
  pinMode(9, OUTPUT);
  TCCR1A = 0;
  TCCR1B = _BV(ICNC1)  //input capture noise cancel
      | _BV(ICES1) //positive edge
      | _BV(CS11); // /8 prescaler
  TIMSK1 = _BV(ICIE1); //enable input capture interrupt
  Serial.begin(9600);
  inputString.reserve(200);
  Serial.println(F("RDY"));
  printvals();
}
void loop(){
  if (stringComplete) {
      switch(inputString.charAt(0)) {
        case 10: //\n (Newline; Line Feed)
          // previous line ending was CRLF, so now LF was carried to the next string
          break;
        case 63: //?
          //print current vales
          printvals();
          break;
        case 68: //D (Delay)
          read_value = getcommandvalue(inputString);
          if (read_value >= 1) {
            pulse_delay = 2 * read_value;
            printvals();
          }
          break;
        case 76: //L (Length)
          read_value = getcommandvalue(inputString);
          if (read_value >= 1) {
            pulse_length = 2 * read_value;
            printvals();
          }
          break;
        case 77: //M (additional prescaling)
          TCCR1B = _BV(ICNC1)  //input capture noise cancel
            | _BV(ICES1) //positive edge
            | _BV(CS10) // 64 prescaler
            | _BV(CS11); // /8 prescaler
          break;
        case 78: //N (8x prescaling)
          TCCR1B = _BV(ICNC1)  //input capture noise cancel
            | _BV(ICES1) //positive edge
              | _BV(CS11); // /8 prescaler
          break;
        case 79: //O
          ms_delay = getcommandvalue(inputString);
          // I don't know where to execute this ms_delay
          break;
      }
      inputString = "";
      stringComplete = false;
  }
}

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:Z
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if ((inChar == '\n') or (inChar == '\r')) {
      stringComplete = true;
    }
  }
}

ISR(TIMER1_CAPT_vect){
  TCCR1A = _BV(COM1A0) | _BV(COM1A1); //set OC1A on match
  TIFR1 = _BV(OCF1A);  // clear interrutp flag
  TIMSK1 |= _BV(OCIE1A); //enable match interrupt
  OCR1A = pulse_delay; //pulse begin time

  TCNT1 = TCNT1 - ICR1; //TCNT1 now contains time since input pulse, even if
                        //the interrupt isn't run immediately
}
ISR(TIMER1_COMPA_vect){
  TIMSK1 &=~ _BV(OCIE1A); //disable match interrupt
  TCCR1A = _BV(COM1A1); //clear OC1A on match
  OCR1A = pulse_delay + pulse_length;
}


texts:
My esp32 program is working ok, well there's some bugs i'm trying to solve, so i connected my project to a standalone serial monitor, and i've tried a few (now i'm using coolTerm).
They all works for a while just fine, and than couple hours latter start printing garbage, but the software still running ok, still turning lights on and off, but only garbage on the serial monitor
here is a sample of the project (this function works perfectly, even when serial monitor start printing garbage):
void operateDispositive(String name, bool state) {
  Serial.println();

  if (name == "all") {
    filterState = state;
    lightState = state;
    airPumpState = state;

    if (state) {
      digitalWrite(relayLight, LOW);
      digitalWrite(relayFilter, LOW);
      digitalWrite(relayAirPump, LOW);
      Serial.println("Light, Filter and Air Pump ON.");
    } else {
      digitalWrite(relayLight, HIGH);
      digitalWrite(relayFilter, HIGH);
      digitalWrite(relayAirPump, HIGH);
      Serial.println("Light, Filter and Air Pump OFF.");
    }
  } else if (name == "light"){
    lightState = state;
    if (state){
      digitalWrite(relayLight, LOW);
      Serial.println("Light ON.");
    } else {
      digitalWrite(relayLight, HIGH);
      Serial.println("Light OFF.");
    }
  } else if (name == "filter") {
    filterState = state;
    if (state) {
      digitalWrite(relayFilter, LOW);
      Serial.println("Filter ON.");
    } else {
      digitalWrite(relayFilter, HIGH);
      Serial.println("Filter OFF.");
    }
  } else if (name == "airPump") {
    airPumpState = state;
    if (state) {
      digitalWrite(relayAirPump, LOW);
      Serial.println("Air Pump ON.");
    } else {
      digitalWrite(relayAirPump, HIGH);
      Serial.println("Air Pump OFF.");
    }
  } else {
    Serial.println("Invalid dispositive.");
  }
}

Can anyone give me a hint on this?
I'm using win 8.1 and the baud rate of the esp32 is 115200


texts: How can I add some additional 5 volt power

texts:
I have an Arduino which is being powered by a 9v, 2 amp power supply.  I have about 20 relays which are powered by 5 volts each.  I do not want to over work the voltage regulator on the board, so I would like to add another (possible 2) 5 volt regulator that I bought on amazon.  I am planning to:

Connect the regulators VIN to the Arduino's vcc (9 volt)
Connect the regulator's GND to the Arduino's GND.
Connect the regulator's VOUT to the Relay's VCC

At this point, can I also connect the regulator's VOUT to the Arduino's 5volt out?

Also, is it possible (or advisable) to add second voltage regulator to the first in a parallel configuration?


texts: How to display tilt sensor data on an LCD?

texts:
I'd like for a 16x2 LCD monitor from Sparkfun to display sensor data from a 4-directional tilt sensor from Parallax. The Arduino board is a Duemillanove. The board will run and power both programs and modules, but the serial monitor displaying the tilt sensor data will not relay the info to the LCD display. Any suggestions?

Here are the two pieces of code I am trying to get to work together—they are both from Arduino:

For the tilt:

void setup() {
   Serial.begin(9600);
}
void loop() {
   Serial.print("Photo 1: ");
   Serial.print(digitalRead(6), DEC); // Display Out 1 value
   Serial.print("; ");
   Serial.print("Photo 2: ");
   Serial.println(digitalRead(7), DEC); // Display Out 2 value
   delay(250); // Wiat 1/4 second
}

For the LCD:

#include <SoftwareSerial.h> // Attach the serial display's RX line to digital pin 2
SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused)
void setup() {
  mySerial.begin(9600); // set up serial port for 9600 baud
  delay(500); // wait for display to boot up
}
void loop() {
  mySerial.write(254); // move cursor to beginning of first line
  mySerial.write(128);
  mySerial.write(" "); // clear display
  mySerial.write(" ");
  mySerial.write(254); // move cursor to beginning of first line
  mySerial.write(128);
  mySerial.write("movement recorded");
  while(1); //
  wait forever
}

Update:

I'm still tinkering with the suggested program from @Ariser shown below, but keep getting a compile error:

tilt_lcd_ase.cpp: In function ‘void loop()’:
tilt_lcd_ase.cpp:24:43: error: expected ‘)’ before ‘;’ token
tilt_lcd_ase.cpp:25:43: error: expected ‘)’ before ‘;’ token

I've done some research and one person had a similar problem, but it was within #include not void loop. The search continues, but if anyone has a suggestion please chime in. The liquid crystal library is also turning up similar errors but it needs a closer look.


texts:
,this is the error I encounter when i try to upload my code
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK  "your-password"
#endif

const char* ssid     = STASSID;
const char* password = STAPSK;

const char* host = "192.168.1.1";
const uint16_t port = 3000;

ESP8266WiFiMulti WiFiMulti;

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

  // We start by connecting to a WiFi network
  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP(ssid, password);

  Serial.println();
  Serial.println();
  Serial.print("Wait for WiFi... ");

  while (WiFiMulti.run() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

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

  delay(500);
}

void loop() {
  Serial.print("connecting to ");
  Serial.print(host);
  Serial.print(':');
  Serial.println(port);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;

  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    Serial.println("wait 5 sec...");
    delay(5000);
    return;
  }

  // This will send the request to the server
  client.println("hello from ESP8266");

  //read back one line from server
  Serial.println("receiving from remote server");
  String line = client.readStringUntil('\r');
  Serial.println(line);

  Serial.println("closing connection");
  client.stop();

  Serial.println("wait 5 sec...");
  delay(5000);
}


texts: EMI resets atmega on switching ON relay with inductive load like a 230v fan

texts:
I am making an automation device. I am using an atmega8a to control 6 relays. The setup is standard, 220v load, 5v dc coil, flyback diode and an NPN transistor to trigger with atmega pin. The problem is when I turn ON the relay, there is 10-20 MHz noise on the DC side and the atmega restarts. Switching OFF relays doesn't create a problem. i am guessing this is happening because of EMI. Is there a way i can protect my atmega from this and not have it restart everytime I start a relay.
The SMPS is 5v 2A
I have star tracks from SMPS
Is there a way to solve this?
Update: Had to switch from atmega chip to arduino nano. That seems to be working fine.


texts:
I'm trying to run ADC on channel 0 triggered by TIMER1_COMPB.
Everything seem to work ok but basic arithmetics is not working and variables inside ISR and even main loop don't get updated (x == 2 all the time)

Can somebody explain me why is it so? Even volatile variable was not changing...
Arduino UNO,
IDE v 1.8.6

#define SAMPLES_SIZE  205

const int adc_channel = 0;
const uint16_t t1_load = 0;

// 250 corresponds to 8kHz
const uint16_t t1_comp = 25000;

uint16_t samples[SAMPLES_SIZE];
volatile uint8_t samplePos = 0;

static int x = 0;

void initADC() {
  // Init ADC free-run mode; f = ( 16MHz/prescaler ) / 13 cycles/conversion
  ADMUX  = adc_channel; // Channel sel, right-adj, use AREF pin
  ADCSRA = _BV(ADEN)  | // ADC enable
           _BV(ADSC)  | // ADC start
           _BV(ADATE) | // Auto trigger
           _BV(ADIE)  | // Interrupt enable
           _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); // 128:1 / 13 = 9615 Hz
  ADCSRB = _BV(ADTS2) | _BV(ADTS0);              // Timer/Counter1 Compare Match B
  DIDR0  = _BV(adc_channel); // Turn off digital input for ADC pin
}

void initTimer() {
  // Reset Timer1 Control Reg A
  TCCR1A = 0;

// Set CTC mode
  TCCR1B &= ~(1 << WGM13);
  TCCR1B |= (1 << WGM12);

// Set prescaler to 8
  TCCR1B &= ~(1 << CS12);
  TCCR1B |= (1 << CS11);
  TCCR1B &= ~(1 << CS10);

// Reset Timer 1 and set compare value
  TCNT1 = t1_load;
  OCR1B = t1_comp;

// Enable Timer 1 compare interrupt
  TIMSK1 = (1 << OCIE1B);
}

void setup() {
  cli();
  initADC();
  initTimer();
  sei();

  Serial.begin(115200);
}

void loop() {
  while(ADCSRA & _BV(ADIE)); // Wait for audio sampling to finish
  cli();
  x = x + 2;
  Serial.print(samples[0]);
  Serial.print("\t");
  Serial.println(x);
//  for (int i = 0; i < SAMPLES_SIZE; i++) {
//    Serial.println(samples);
//  }
//  samplePos = 0;

  ADCSRA |= _BV(ADIE);       // Resume sampling interrupt
  sei();
}

ISR(ADC_vect) {
  int16_t sample = ADC;

  samples[0] = sample;
//  samplePos++;
  ADCSRA &= ~_BV(ADIE); // Buffer full, interrupt off

  if(samplePos >= SAMPLES_SIZE) {
    ADCSRA &= ~_BV(ADIE); // Buffer full, interrupt off
  }
}

//ISR(TIMER1_COMPB_vect) {
//}

Thanks in advance


texts:
Unfortunately I have yet to learn C++ though I have experience with C# and other non-C languages. After trying for the past 5 hours to pick up what I can from Stack and other sites I haven't found a workable solution that actually works with Arduino IDE (hence why I'm posting here and not stackoverflow).

Im trying to create a simple library to handle some analog inputs. I need to be able to compare the value from a pin to a list of values and handle the result accordingly. I can easily send the number of the pin to the constructor and read it. My issue is actually defining that list from the setup() function.

The list can be variable in length so I can't hard code an array in the library class and then pass values one by one. I can pass the length in the constructor but then I'm not really sure how to use it to initialize the array length without having the values to assign.

In C# or other languages I'd either use a list or pass the array directly. Neither of these seem to be an option with C++ (or at least I couldn't pass the array correctly). How could I solve this problem? If it helps I'm using a teensy++ 2.0.


texts:
I’m sorry if I sound ignorant and naive, but I’m brand new to Arduino;  very keen, but know very little.

I started with a Sainsmart Arduino Uno clone board.  I downloaded the software, which opened OK (or at least seemed to), but the Serial Monitor kept telling me that there was a communication error, and a yellow light kept flashing on the Sainsmart board.

I got hold of a genuine Arduino (from Jameco), uninstalled everything Arduino, and started again from scratch.

Now I get the message:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"
Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

And after enabling the verbose output, got:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"
Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)

Tried again, and:

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"
Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)

I’m using a MacBook Pro, using Yosemite 10.10.5.


texts: Both red and blue led of ESP8266 stays on

texts:
I've connected ESP8266 to Arduino UNO. After a getting a huge trouble I successfully managed to run some AT commands. I have also tested AP mode.

Then I got some trouble with software serial communication with Arduino and decided to change baud-rate to 9600 (previously it was 115200).

I used AT+IPR=9600 command to change it.

After that blue led of esp stays on and not taking AT commands any more, but output some gibberish to serial monitor with few ascii text like below:

ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 1396, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4
tail 8
chksum 0xc0
csum 0xc0

2nd boot version : 1.4(b1)
SPI Speed      : 40MHz
SPI Mode       : DIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

Note: I know it consumes a lot power tried external 3.3V power supply and voltage divider for rx pin.

Any help would be appreciated.


texts: power consumption higher after XKC-Y25-V detects water

texts:
I am using an Arduino Pro Mini and a non-contact liquid sensor (XKC-Y25-V).  I have the positive of the liquid sensor connected to pin 5, its sensor to pin 3 and ground to ground.  I turn on the device digitalWrite (5,HIGH);, and then read pin 3 .  When the sensor senses water it is ON and I have The Arduino turn on another pin for a second and then turn it back off, then I turn off the power to pin 5 disabling the sensor.  If no water is present nothing happens and I turn off the sensor.  After everything is turned off I put the Arduino in sleep mode.My problem is when the sensor detects water and everything is turned off the multimeter says the power consumption is 110mA in sleep mode where as if the sensor doesn't detect water and it turned off the power consumption is 20-30mA in sleep mode.  I have checked all the pins and none are powered up. I have unplugged the sensor and its power when the Arduino is in sleep mode and nothing changes.  I have tried putting digitalWrite (2,LOW); to disconnect the sensor from the board after the sensor is turned off.  Still the same.
What could be activated so that it draws power even after everything is turned off.
Some code;
int valA = 0;

void setup() {

   pinMode(3,INPUT);

   pinMode (5,OUTPUT);

   pinMode(9,OUTPUT);
}

void loop() {
digitalWrite (5,HIGH);
int val = digitalRead(3);
delay(1000);
 digitalWrite(5,LOW);

if (valA ==1){

 delay(500);
 digitalWrite(9,HIGH);

 delay(1000);

 digitalWrite(9,LOW);

   Delay = 2;
  }

if(Delay ==2){
lowPower();
}
}

void lowPower(){

  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

I have an older model of this and it works without using so much power 20mA after detection or no detection.  The only difference I can see is the original has no capacitors (there are four now) the wiring is .5mm copper where now it is either .25mm copper for power and everything else is .25mm 1oz copper PCB tracings. and instead of HK19 relays I use r70-5d1-5.  Could the capacitors or small wiring cause this problem?  I just don't understand what I drawing current since when I disconnect the sensor 3 and power 5 from XKC it still draws the same amount.  Hope this helps.
I removed the capacitors, no change.  Enlarged wire it sensor, no change.  Ran old code on new device, no change.  Larger relays are using more power to run but shouldn't cause a problem when power cut to XKC.  Using a power boost to power antenna and HT12E with pin 9 if water detected but no power to them when 9 is pulled LOW.  Where can bleed of power consumption be.
If anyone has any idea, questions, has solved this before I would really appreciate some help.


texts:
Now I have these Arduino Pro Mini from Sparkfun. They are the latest version that I know (yeah, it's the one that have those horrible misaligned pins). Now they are designed around the ATmega328P and have a 16MHz crystal on them.

Now, my question is: Can I run an ATmega328 with a 16MHz crystal while supplying ONLY 3.3V.

The reason I'm doing this is because 5V / 16MHz Pro Minis from China are way cheaper then 3.3 / 8MHz.

Facts that I already know:

If I follow the datasheet to the the letter, this configuration should not work. BUT... After some test, it did work.

Also, I want an answers based on personal experience (NOT OPINIONS) and not datasheet and specs.

[EDIT] Including a way to use the internal clock (at 8MHz) of the ATmega328P would really help!


texts: Define preset colors using FastLed library

texts:
I'm using an addressable 150 led strip and an Arduino Nano to control it, using FastLed library.

I'm tring do create a function turn_on_leds, which gets 4 parameters:

1) delay time for lighting a led in the loop, 2) direction ( not relevant for now), 3) color index for colors array , 4) brightness percentage.

Problem #1: a color array is defined to select from a preset definitions of colors (Fastled reference, but when selecting col_indx =2, meaning colors[2], leds are not lit in Red as they should, AND when setting leds[i]=0xFF0000, the right result is set.

Problem #2: at loop there is a for intended for raise bightness from 0 to 100, BUT the results are 0 for first iteration and 9 for all others.

Appreciate any HELP!!

Guy

Code:

#include <FastLED.h>

#define NUM_LEDS 10
#define BRIGHTNESS  55
#define DATA_PIN 7

char *colors[] = {0x000000,0xFFFFFF,0xFF0000,0x008000,0x0000FF}; // black, white,r,g,b
CRGB leds[NUM_LEDS];
int t = 0;

void setup() {
  Serial.begin(9600);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  //  FastLED.setBrightness(BRIGHTNESS);
}

void turn_leds_on(int del_1, bool dir_1, int col_indx, int bright_1) {
  if (dir_1 == true ) { // start to end
    for (int i = 0; i <= NUM_LEDS; i++) {
      leds[i] = 0xFF0000;//colors[col_indx];
      FastLED.setBrightness(bright_1*255/100);
      FastLED.show();
      delay(del_1);
    }
  }
}

void loop() {
  Serial.println(t);
  turn_leds_on(50, true, 2, 100);
  delay(1000);
  //  turn_leds_on(50, true, 0, t);
  //  delay(1000);

  if (t < 100 ) {
    t += 10;
  }
  else {
    t = 0;
  }
}


texts: How fast is flash reading compared to SRAM?

texts:
I'm working on a project that will eventually scale to 864 LEDs on WS2815 LED strips (three rows of 288 LEDs). I'm currently running it on an Arduino Uno with a single test strip of 144 LEDs.

FastLED stores its data in 3-byte structs, so I obviously cannot simply hold all of the data in SRAM and work with it directly (at least not without upgrading to a controller with more memory). I'm going to use a Raspberry Pi to send the Arduino data, one section at a time. To further save memory, I want to implement an RGB color lookup table in flash, then instead of

CRGB pixels[PIXEL_COUNT];

taking up over 2KiB of memory 800+ values, or

CRGB pixels[PIXEL_BUFFER_COUNT];

with a buffer of 288 RGB values consuming most of my working memory (864 bytes), I would have

CRGB *pixels[PIXEL_BUFFER_COUNT];

Where each pointer would reference a location in a PROGMEM 256-entry table of CRGB values. This is a more manageable 576 bytes in SRAM.

I realize FastLED does not work this way. There's a  lot of work ahead of me if I do this, but before I get started, my question:

Will I run into issues with reading the actual data from flash memory while sending to the LED strips? As currently implemented in FastLED, RGB data is in SRAM, but each pointer dereference will require reading from flash. Is the subsequent delay enough that it will cause an issue with sending data to the strips?


texts: Adafruit motor shield + Adafruit stepper not working

texts:
I have the Adafruit Motor Shield V2 and an Adafruit stepper motor. I have not soldered the shield onto the Arduino (which is an Uno) yet because I don't want to make anything permanent yet. I have the Arduino plugged into a DC wall adapter and have the VIN jumper in the shield, and the green power light on the shield is lit. This is how the stepper is connected.

As you can see in the picture, all the wires from the stepper are plugged in. The order of the wires is what it says it should be on the website, which is orange-pink-red-blue-yellow.  My sketch's code is an adapted version of the StepperExample from the Adafruit motor library. Here's the full code

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_StepperMotor *myMotor = AFMS.getStepper(513, 2);

void setup() {
  Serial.begin(9600);
  Serial.println("Stepper test!");

  AFMS.begin();
  myMotor->setSpeed(5);
}

void loop() {
  myMotor->step(100, FORWARD, SINGLE);
}

But the stepper still doesn't move. Can anyone point out what I'm doing wrong here?