texts: Let Servo rotate when file has been uploaded to webpage

texts:
I'm building an installation with a NODEMCU 1.0 where I want a servo motor (MG90S) to rotate when a file has been uploaded to a webpage.
For my first step I have used this tutorial: Build an ESP8266 Web Server – Code and Schematics (NodeMCU) .
With this code I can turn LED's on/off through a button on a webpage. For my next step I want to change the on/off button on the webpage to the upload button. Any ideas on what I have to change in the code for this?


texts: Shield interfere with Serial Communication

texts:
I'm new to arduino. I have nexus duino robot as described in http://www.aliexpress.com/item/3WD-48mm-Omni-Wheel-Mobile-Arduino-Robot-Kit-10019/688287804.html, the shield connected with motors and support xbee.

With simple serial comm sketch, I'm able to communicate between arduino and PC if the shield not inserted, but not if I insert the shield as it seem arduino can't receive serial data (still can send data to PC tough). Someone says that the shield might be use RX TX so it interfere with serial comm.

My Questions are, is there a way to check whether the shield use RX TX? If yes, can we make it not interfere with serial comm? Could be other problem causing this serial comm problem?
Thanks in advance.


texts:
I'm trying to read a voltage in from a power supply to an Arduino Micro, then send it to an oscilloscope through an I2C (MCP4725). I would use the default pins on the Micro but I want to wire three I2C and the default bus only allows two. As such, I'm trying to use the SoftI2CMaster library

I've looked through examples and documentation but I can't seem to get it to send any data. I've been successful scanning (from examples) and finding the I2C addresses, so I assume that the trouble is at the end of my code.

Any tips would be greatly appreciated!

#define SDA_PORT PORTD
#define SDA_PIN 4 // = A4
#define SCL_PORT PORTC
#define SCL_PIN 6 // = A5
#include <SoftWire.h>

#define I2C_7BITADDR 0x62 //MCP4725

SoftWire Wire = SoftWire();

int aPin;

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

void loop(void){
  aPin = analogRead(A0); //read in from power supply
  Wire.beginTransmission(I2C_7BITADDR);
  Wire.write(aPin); //send voltage to osc.
  Wire.endTransmission();
}


texts:
I'm a newbie at Arduino, and I'm trying to make a project with ultrasonic sensor, I'm using the grove ultrasonic ranger, not the HC-SR04, and I already did test with distance and it worked very well, but now I need help with the code.

I need to create a vector that save the values of the distance to after calculate the speed using distance/time calculus, but the case of my project its to use in open places, so will be times that the distance will be "max" because there's nobody in the range, so I need a condition to exclude those values of the array (the maximum distance printed when the sensor can't feel nothing is 516 cm)
I'm not experienced with Arduino coding, so please help me, in anex is my code for basic scanning.

#include "Ultrasonic.h"

Ultrasonic ultrasonic(7);
void setup()
{
    Serial.begin(9600);
}
void loop()
{
    long RangeInCentimeters;
    Serial.println("The distance to obstacles in front is: ");

    // two measurements should keep an interval
    RangeInCentimeters = ultrasonic.MeasureInCentimeters();
    if(RangeInCentimeters > 400)
    Serial.print ("distancia nula");
    else
    Serial.print(RangeInCentimeters);//0~400cm
    Serial.println(" cm");
    delay(1000);
}


texts: Want to play short voice recordings, with fast switching between them

texts:
I want to output a chosen sound (e.g a singer singing a D, or E, or F note) which I have recorded.  I can change the filetype to whatever is neccessary, e.g mp3 or whatever.  The recording could be 10ms, or longer if that helps.

I want to be able to switch between notes quickly (ideally 1ms delay), is this possible?  I read about using a WTV020-SD Mini but this has a gap of 20ms between tunes sadly.

At the very least I don't want a 20ms noiseless 'gap' as it switches between one note to the next.  If it plays the old noise that would be ok, but ideally i'd like it to be able to switch between the notes in a millisecond or so.

What is the best way to accomplish this?

Ideally, the solution would be narrow, to fit in a 10mm radius cylinder, up to 100mm in length, although ideally smaller.


texts: Wireless serial communication. Sending 4 different continuous values

texts:
I am trying to control 4 motors using 2 joysticks.

I want to send continuous analog values of 2 joysticks (x & y both).

I am using bluetooth HC-05. I am using the basic logic that is sending a character before each analog value and thus sending all 4 values.

My problem here is at the reception end, data is not received correctly. Error rate is very high.

Is their any other way or improved program to do that?

//this is my part of the code at the transmitter side

#include <SoftwareSerial.h>
int a,b,c,d;
int ry = A0; // forward backward
int rx = A1;//rotate
int lx = A3; //right left
int ly = A4;
SoftwareSerial blu(10, 11); // TX,RX

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

void loop()
{

   a = analogRead(ry)/4;
   d = analogRead(rx)/4;
   c= analogRead(ly)/4
   b = analogRead(lx)/4;

   blu.write("w");
   blu.write(a);
   blu.write("x");
   blu.write(b);
   blu.write("y");
   blu.write(c);
   blu.write("z");
   blu.write(d);
      }

}

// Code at the reciever side

#include <SoftwareSerial.h>

SoftwareSerial mySerial(12,13); // tx,rx

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  digitalWrite(gnd1 , LOW);
  digitalWrite(gnd2 , LOW);

  pinMode(motor1, OUTPUT);
  pinMode(motor2, OUTPUT);

  pinMode(dir1, OUTPUT);
  pinMode(dir2, OUTPUT);
  pinMode(dir_1, OUTPUT);
  pinMode(dir_2, OUTPUT);

}

void loop()
{
    if (mySerial.available())
  {
    a=mySerial.read();
        if(a=='w' || z=='x' || a=='y' || a=='z')
        {
          if(a=='w')
        c_b=mySerial.read();
        b=map(c_b,0,255,-255,255);
        motorspeed1(b);
      }
   if(a=='x'){

            int c_c=mySerial.read();
            b=map(c_c,0,255,-255,255);
            motorspeed2(c);

          }
if(a=='y'){
 int c_d=mySerial.read();
            d=map(c_d,0,255,-255,255);
            motorspeed3(d);
  }
if(a=='z'){
 int c_e=mySerial.read();
            e=map(c_e,0,255,-255,255);
            motorspeed3(e);

}
}

//motor speed function takes care of the direction and the pwm. my problem is at the receiving end the values are not proper . error is very high mySerial.read() gives false values


texts:
What I want to do is allow Arduino A to send some constant value to Arduino B.

I sense something inherently wrong with my approach, but I cant figure out what it is.

So in the diagram below you will see Arduino A setting its Analog Pin 0 as OUTPUT and write a value 2 every 500ms. On Arduino B we have Analog Pin 0 set as INPUT to receive and print data to Serial. The GND pins of both Arduinos are also connected.

When this setup is executed, Arduino B is constantly receiving data in the form of a 3 digit number starting with 3XX. I am starting to believe this is voltage value?

What is inherently wrong with this idea?


texts: Trying to print "occur = 1" in an if statement but it wont work

texts:
Cant seem to get this code to work with my arduino, and yes its all hooked up properally, even used leds to show that the button is being pressed, what am i doing wrong or dont know?

const int digitalInPin3 = 8;     //switch
int Occur = 0;
int Switch = 0;

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

void loop() {
int Switch = digitalRead(digitalInPin3);

if (Switch == 1){
  int Occur = 1;
}

else {
 int occur = 2;
}

   Serial.print("\t Switch =");
   Serial.print(Switch);
   Serial.print("\t occur =");
   Serial.println(Occur);

  delay(1);
}


texts:
I am controlling 4 motors using the PWM ports on an Arduino Uno (3,9,10,11). For some reason, the motor hooked up to port 11 doesn't move with my current code. I know it's a code issue because I can create a new basic code that just moves the motor and it works fine, but for some reason it doesn't in this code.

#include <SPI.h>
#include <Pixy.h>

Pixy pixy;

int personX = 0;
int offCount = 0;

void setup()
{
  pinMode(3, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  pixy.init();
}

void loop()
{
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32];

  blocks = pixy.getBlocks();

  if (blocks)
  {
    personX = pixy.blocks[0].x;
  }

  if (blocks){
    Serial.println(personX);
    if (personX < 110){
      analogWrite(11, 130);
      analogWrite(3, 130);
      analogWrite(9, 250);
      analogWrite(10, 250);
    } else if (personX > 190){
      analogWrite(11, 250);
      analogWrite(3, 250);
      analogWrite(9, 130);
      analogWrite(10, 130);
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
    offCount = 0;
  } else {
    if (offCount < 1000){
      offCount = offCount + 1;
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
  }
}

Also, when I take the motor and swap it with another, the old one works in the new PWM port, but the new one stops working once I put it in port 11.


texts:
I need to implement callback in my C++ library. The "proper" C++ way of doing it would be to create an interface (or pure abstract class) and pass it to interested party. I'm wondering though, would that be optimal?

My analysis:

Function pointer - occupies 2 bytes in memory (+code of function)
Class derived from abstract one - occupies 2 bytes in memory PLUS 2 bytes for VMT (since we have derived method) PLUS size of VMT table (if any) (+code of method).

Is optimizer smart enough to compile abstract class with single method as method pointer? Which solution is more optimal in regard of memory and speed? Is my analysis correct?


texts: How to exclude a ino/pde file from Arduino projects

texts:
I would like to be able to exclude from the auto-including process of the current project (without renaming the extension or delete it) a sketch with pde or ino extension that is used in certain circumstances only.

How can I do this?

I currently use Visual Micro to manage projects on Arduino.


texts:
I recently upgraded my MacBook Pro to Mojave. Now I'm not able to connect to my Arduino board with ch340g usb-to-serial chip. It is a Arduino board with AtMega 328 and ESP8266 integrated. I downloaded the drivers from the Chinese website for the ch340 and also removed old installations, like some tutorials tell me. I just can't get a /dev/cu.* port (besides the /dev/cu.Bluetooth-Incoming-Port.

I do have an external FTDI usb to serial board. I didn't get to it to try to connect it.

Does someone know how to get the ch340 to work on MacOS Mojave, or as a last resort: use the FTDI to program/monitor the Arduino board?


texts: Accessing one code using another code on RobotDyn Uno+WiFi board

texts:
Ok so I've been trying to do this for quite some time now. Still couldn't get it to work. I am trying to read a ESP8266 WiFi program from a normal Arduino Uno program. I've seen some people do this:

#include <SoftwareSerial.h>

Then

SoftwareSerial esp8266(2,3);

Let me see a working example of this?

Thanks for everything.


texts: Programming ATMega328p using VP812 programmer (for AVR/Atmel chips)

texts:
I bootloaded an ATMega328p (the one that uses the basic Arduino bootloader). Then, I used the VP812 for dumping other programs written in C (in Atmel Studio).

The process of erasing, blank test, programming and verification are all working fine and it seems that the program is actually being flashed. However, when I insert the same chip (controller) back in the Arduino Uno board, the controller doesn't function as programmed. Also, I am not able to dump any other example sketches.

Does this mean that the chip is damaged?
Does using the bootloaded chip with VP812 cause such problems?

Also, I used the "Write Fuse" option with the standard fuse configuration (all marks checked) in the VP812 configuration dialog box. Did this setting in any way create the problems I am facing now?


texts: Can you use an Arduino to control the output current and voltage of a DC/DC converter?

texts:
I am using an arduino to create a device that outputs a specific current and voltage. I was wondering if there are any devices out there such as dc/dc buck boost converters that can be controlled by arduino to output desired powers. I am looking for something rated for at least 50 watts  that can carry at least 3 amps of current.

Thank you all in advance!


texts: How do I use the prototyping area on a SparkFun MicroSD Card shield?

texts:
I'm having trouble figuring this out. I'm using this popular shield: https://www.sparkfun.com/products/12761

There is a breadboard area in the middle of the shield. But what confuses me is the lack of lines (order). On normal breadboards you can tell which row would be at the same voltage. If I wanted to put something on this prototyping area, how would I connect it? For example an LED, which would have a resistor attached to the positive side going to 5V and the negative side going to ground?


texts: Car freaks out on CANBUS shield connection

texts:
So, I'm trying to connect to my car's CAN-BUS (via the OBD2). I initially ordered a cheep shield then an even cheaper module to provide connection between my uno and the car.

Using the module I was able to use some of the example libraries to successfully connect to the car and even get some IDs out. There was no data alongside the IDs so I figured my module needed upgrading.

I bought the seeedstudio shield and used their libraries. At first I had the CANH and CANL connected into the car before starting it but that seems to have overwhelmed the car and I couldn't start it, it behaved as if the battery was dead.
Eventually when it recovered I tried again, this time the car was already running. Havig the CANL&H connected and the shield attached to the arduino and using the example sketches, when I provided power to the Arduino via the USB port the car started freaking out. The dials went crazy and started moving left to right and all sorts of warning messages started appearing on the dash - "check airbag", "engine motion something.." Disconnecting the shield from the car stops the freaking out and removes the errors displayed.

Any idea what's going on ?

Also should any of these be soldered to each other as the manual suggests there's some cutting and soldering there but I haven't cut nor soldered anything and this is how the shield arrived.

Worth pointing out that I tried connecting to both Pin6 as the proper CANH and also Pin1 as that one was discovered to also provide CANBUS data for the cabin. Here's the obd2 diagram pinout for my car.


texts: Can I generate 5 sec delay within an interrupt program?

texts:
void buttonPressed()
{
  if(ledOn)
  {
    ledOn = false;
    digitalWrite(13,LOW);
  }else
  {
    ledOn = true;
    digitalWrite(13,HIGH);
  }

  vout=analogRead(sensor);
  vout=(vout*500)/1023;
  tempc=vout; // Storing value in Degree Celsius
  tempf=(vout*1.8)+32; // Converting to Fahrenheit
  lcd.setCursor(0,0);
  lcd.print("ROOM TEMPERATURE");

  lcd.setCursor(0,1);
  lcd.print("C = ");
  lcd.print(tempc);

  lcd.print("  F = ");
  lcd.print(tempf);
  Serial.print("f ");
  Serial.print(tempf);
}

here is the code of interrupt and i want to monitor the sensor value for about 5second.


texts: ESP-12e, Arduino IDE, NeoPixel Strip - Flickering

texts:
I have a NeoPixel RGB strip connected directly to my NodeMCU ESP12-e board. I'm using Arduino IDE with the NODEMCU 1.0 ESP 12-e module to programm the board.

ESP12-e | NeoPixels
GND    ---> GND
3.3V   ---> +5V
GPIO0  ---> Din

With the 3.3V output I have a strange flickerin on the LEDs.
When I use the VIV 5V output of the ESP12-e the flickerin is gone, but the lights turn off after a few seconds and some lights turn on with strange behavior.

I guess 5V is to much for the board? What can I do to get rid of the 3.3V flicker?

EDIT: I'm using WS2812B LED Strip Band with 224 LEDs 5050 SMD connected directly (see above) to a NodeMCU ESP-12e (http://learn.acrobotic.com/uploads/esp8266_devkit_pinout.png)

I'm using:

#include <ESP8266WiFi.h>
#include <Adafruit_NeoPixel.h>

I'm turning LEDs on for example like this:

#define PIN 0
#define NUMPIXELS 224

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int individualPixels[NUMPIXELS];
  void allOn(){
      for(uint16_t i=0; i<pixels.numPixels(); i++) {
        individualPixels[i]=1;
        pixels.show();
      }
    }

   for (int i=0; i<sizeof(individualPixels); i++){
    if (individualPixels[i]==1){
      pixels.setPixelColor(i, pixels.Color(red,green,blue)); //Set Neopixel color
    }
    else{
      pixels.setPixelColor(i,pixels.Color(0,0,0));
    }
  }
  pixels.show();

The ESP12-e is plugged in via USB Power

Thanks in advance


texts: Upload application from Visual Studio 2019 with PlatformIO

texts:
How upload application from Visual Studio? I can’t find upload process from standard VS in documentation https://docs.platformio.org/en/latest/ide/visualstudio.html

I hate VS Code.


texts:
I am trying to both send and receive data using bluetooth module.

Receiving data works fine with this code:

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

void loop() {
    if (Serial1.available()) {
        Serial.println(Serial1.read());
    }

    delay(20);
}

But I cannot send any data. This is what I am doing:

void loop() {
    if (Serial1.available()) {
       Serial.println(Serial1.read());
    }

    delay(20);

    if (digitalRead(bluetoothInput) == HIGH) {
        Serial1.write("2");
        // only "send" prints. Nothing in android terminal
        Serial.println("send!");
        delay(1000);
    }

    delay(20);
}

What am I doing wrong?

I am using Arduino Leonardo and Bluetooth terminal app on Android device.


texts:
The following circuit is a simplified version of a more complex system. For testing purposes, the 555 Timer was added to serve as a test signal source with frequencies set by the resistors in series. Each arbitrary signal is indicated by a push button and the Arduino needs to be able to distinguish what button has been pushed. Unfortunately, there can only be 3 buttons and more cannot be added. This is where the problem occurs. How can you reliably indicate which push button has been pressed without interfering with the arbitrary waveform?
At first, my original thought was to have the Arduino sample the signal based on that sample the Arduino would be able to tell which button is pressed.
When button 1 in the pink is pushed the Arduino receives a takes the following
sample of the signal.

843
848
849
849
849
849
   // Time 0 when button is pushed
532
414
500
373
463
346
425
370
386
476
346
442
642
788

Moving the input

    // At t = 0 the Serial Monitor reads zero
    998
    998
    998
    998
    998
    0
    0
    0
    0
    0
    998
    0
    0
    0
    0
    0
    0
    0
    0
    0
    998
    0
    0
    0
    0
    998
    0
    0
    0
    998
    998
    998
    0
    998
    0
    0
    0
    998
    0
    0
    0
    0

Moving the analog input does not make it any easier to distinguish which button was being pushed. Which is why I decided to ask the community on how to deal with this. I have tried using a relay and simply hard coding all of the cases but the result is a system is not very robust and is vulnerable to easily break over time.


texts:
The Arduino should read data from a PLC. Has anyone experience with this? What would be possible interfaces?

I would prefer OPC-UA, but all the research I did, only OPC-DA was mentioned.

Thanks in advance for your suggestion(s).


texts: Changing function to work with Midi controller instead of buttons

texts:
I am trying to change up this function to work with a midi controller instead of buttons most of the code for the function i will be using as is. it just the parts of the code the deal with button that i am finding a bit tricky to translate to work with a midi controller. any advice or suggestions would be a great help. here's the code for the function:

long currentMillis = 0;
long previousMillis = 0;

// Returns the position of Button pressed (0, 1, 2, or 3) or -1 if no button is pressed in the time period.
int waitForButton(int delay)
{
  int buttonPressed = -1;
  int input;
  boolean buttonBackUp = false;

  currentMillis = millis();         // The number of ms since the program started running
  previousMillis = currentMillis;   // Records the point when we start spinning the loop.

  // Keep spinning the loop until "delay" seconds have passed.
  while (currentMillis - previousMillis < delay & buttonBackUp == false)
  {
    // Read the button and record when it has been pushed down.
    for(int pin = 0; pin < 4 & buttonBackUp == false; pin++)
    {
      if(digitalRead(buttons[pin]) == HIGH)
      {
        buttonPressed = pin;

        // Show the LED pushed.
        digitalWrite(leds[pin], HIGH);

        // It is possible the button is still being pushed.
        // This loop spins until the button is let up.
        while (currentMillis - previousMillis < delay & buttonBackUp == false)
        {
          input = digitalRead(buttons[pin]);
          if(input == LOW)
          {
            buttonBackUp = true;
          }
          currentMillis = millis();
        }

        // Turn the LED pushed off.
        digitalWrite(leds[pin], LOW);

        // See if they took to long.
        if(currentMillis - previousMillis > delay)
        {
          buttonPressed = -1; // They took to long to let the button up so they lose.
        }
      }
    }

    currentMillis = millis();
  }

return buttonPressed;


texts: Arduino fried? Onboard blink ok; offboard blink not ok

texts:
EDIT :

I have plenty of weird bugs. I will open another thread, and come back to this one when I have better understanding, rather than completely modify this one halway through. Sorry to every answerer for my electronic incompetence which led me to ask the wrong questions; I hope the other thread makes more sense.

I have recently exhumed an arduino from a cupboard, and can't seem to make even a blinking LED circuit work correctly.

Here's the sketch :

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

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

This has been tried without the circuit, on pin 13, using the onboard LED, and it worked.

However, using the following circuit, it did not result in a blinking LED, using several pins (8, 9, 12, 13) and LEDS.

May I assume the arduino is fried?

Here is a thumbnail of the circuit :


texts: Junk values in EEPROM. while writing large values

texts:
Facing an issue while writing a large value (like 2000-5000) to EEPROM using EEPROM.put().
For example, While writing 2000 values to address 5 of EEPROM. Some junk values are written automatically to a nearby address (address 4, 6, 7...).
Note : Not trying to write an array of 2000 elements
Board Used : Arduino Uno (Atmega328P)
Q1 : What is the typical range of a each address by using EEPROM.put() . Like EEPROM.write() has range limit of 0-255.
Q2 : How to write large value EEPROM addresses without effecting the nearby address.


texts: Simple compiler design help: Variable length arrays in Arduino?

texts:
I'm trying to write a simple compiler in the Arduino language that I am making up for my lab.  The compiler will have to be able to turn a string like this:

"do command_one 3 times"

into a data structure that represents this:

<command_one>, <command_one>, <command_one>

it should also be able to turn something more complicated like this:

"do do c_one do c_two 2 times 2 times c_thr 2 times"

into a data structure that represents this:

<c_one> <c_two> <c_two> <c_one> <c_two> <c_two> <c_thr> <c_one>
                <c_two> <c_two> <c_one> <c_two> <c_two> <c_thr>

Another function will then read the commands out one by one.

These examples show all of the functionality that I would want from the compiler.

I'm having design issues for the compiler that I want to create.  Initially, I just wanted to do some string manipulation and turn the input string into an array of integers representing commands.  However, since the compiler will be outputting an arbitrarily large number of commands, and since arrays in Arduino need to be initialized with a length, this could be a problem.

I am not fluent in Arduino so I am hoping that an Arduino whiz can show me a quick solution.  I have already come up with the suggested solution on my own in Python, however, my solution in Python has to do with the ability to change the length of lists on the fly.

You will also notice that I posted the same question in the C++ stackexchange.  I am trying to write the same code for an Arduino and in C++.  I know that Arduino code is based on C++, if the answer is the same in Arduino as it is in C++ that would be very helpful.


texts: Micro servo is not working with Arduino UNO

texts:
I am new to Arduino and trying to do some basic tasks. I want a micro servo to rotate but it's not working, only slightly virbating when I launch a sketch. Below on the photos is how it is all assembled: I have a jumpwires connected to GND, 5V and #8 ports just as in the tutorial. I use micro servo SG-90 and Funduino UNO. Does anybody have any ideas what might the problem be? Here is also the sketch.

#include <Servo.h>

Servo servo;

void setup() {
  // put your setup code here, to run once:
servo.attach(8);
}

void loop() {
   // put your main code here, to run repeatedly:
servo.write(0);
delay(2000);
servo.write(90);
delay(2000);
}


texts: Send information from computer to Arduino via USB (basic clock)

texts:
I've created a small project using an Uno. I usually mess around with ESP8266 chips, because they have WiFi and are relatively easy to work with. However, this time I've decided to go right back to the Uno.

I've made a clock using a bunch of MAX7219 matrix displays (32x8 total). I want to be able to sync the time from the computer to the Arduino, no matter which PC is connected.

My thought was to create a small program, that detects the connected Uno, then sends the data over serial. However, there's probably a more clever way to do that, which requires very little programming on the PC side.

Any clues? The Arduino is connected via USB. Would love this to work on both Windows and MacOS.


texts:
I've looked it on the forum and I haven't found it!.

I am trying to control an aquarium with an Arduino. But, when I connect everything, the LCD doesn't show correctly the data on the 2nd line. It is possible to see the data on it, but it is really hard to read it. I have tried with a 9V battery source (also 3 and 5) and even with a mobile phone battery.
The LCD is a typical 16x2 display.

I would like to know how to fix this intensity problem. I use a Mega 2560.

Thank you very much! Kind Regards.


texts:
I'm training kids programming Arduino. We're gonna use Serial for debugging purposes, so we started with a simple HelloWorld program. I let them try various stuff, including changing the speed.

Now, one of the outcomes was as simple as

void setup() {
  Serial.begin(115200);
  Serial.println("Hello");
}

void loop() {
  Serial.begin(115200);
  Serial.println("world");
  Serial.begin(9600);
  Serial.println("world");
}

My expectation was, that the Arduino does exactly as written, but the serial monitor of the Arduino IDE will become a bit consufed. When the monitor is set to 115200 baud, I expected to see

Hello
world
_#&%$"    < some garbage
world
_#&%$"    < garbage again
...

However, the real output is only one line

H⸮⸮⸮⸮C

Why is that? Is it impossible to change the baud rate in between?

The official documentation does not say we can use Serial.begin() only once.

I'm using Arduino Uno and Arduino IDE 1.8.9


texts: Trinket works with USB but not with wall adapter

texts:
My Adafruit 5V Trinket works fine when powered via USB connected to my computer (and the power going in to the Trinket is 5V), but if I use a 9V wall adapter with a microUSB adapter, it just powers on but doesn't seem to actually run the program on the Trinket.

Am I over powering the Trinket and sending too much voltage to everything? If that's the case, is there some way to decrease the voltage?


texts: Arduino tone frequency isn't always precise

texts:
I'd like to play an asynch 'beep' sound (2.5kHz, pin 8) on an Arduino Mega with several other modules connected. I write them here, just for the record: SDCard reader and RFID reader through SPI bus, RTC through I2C, GSM module through hardware Serial 1. And I use PWM on two other pins (11,12) for controlling LEDs brightness.

It works well, however, sometimes (1 of 10) the beep frequency is about half-tone higher.

The code itself is good, because I use a constant in the tone() function call for specifying the frequency.

Does anybody have an idea what can influence the tone's PWM frequency such way, maybe on hardware level?


texts:
Why in the piece of code below we use "static volatile bool"?

static volatile bool wifi_connected = false;

taken from here: https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino


texts: Problem getting data from Arduino pro mini

texts:
I am currently working on a drone project using multiwii.
I m using mpu6050 as gyro and accelerometer sensor with i2c protocol. I was able to read data coming from mpu6050 while using Arduino Uno through multiwii but can't get it work with Arduino pro mini. I was able to get data with pro mini while using i2c scanner and mpu6050 test codes available on web but can't see any data from sensor on multiwii platform though it shows that Arduino is connected. I tried using pull up resistors and try with another pro mini but with no luck. One note is that because I will be using this with a 1s lipo battery ,I bootloaded both pro mini with 8mhz internal oscillator at 3.3v and even tried using external oscillator 8mhz but with no luck (I actually modified both of them cause 3.3v Mini's are not available in my country). I am using Arduino Uno without ic to program the pro mini board and its having no problem while programing or while reading data on serial monitor but only with multiwii. I tried multiwii with my Uno and nano and both worked just fine so right now I m wondering if on board programmer effects this but I have seen some people using pro mini with multiwii
My connections are not lose at all cause I soldered them directly to the Uno board.


texts:
Hello,

I have an Arduino Yun and I brew beer.

I would like to log the temperature of the beer at all time during the fermentation process (final stage).  This means the thermometer would have to remain in the beer during this time (10 days).  The temperature would be < 40 degrees Celsius (probably around the 20 degree mark).

Question: What temperature sensor would be best suited to this task?

It must be:

Food grade
Can be used in alcohol for extended periods
Can be hooked up to Arduino (i.e. add a library and ready to go)

Thanks, Dan.


texts: Printing elements of char array from PROGMEM

texts:
Given:

const char* PROGMEM names[] = {"Foo","Bar"};
Serial.print(names[0]);

I get garbage output. Is there some function that will print the string from PROGMEM? E.G.:

Serial.print(<function name>(names[0]);


texts: How to sample incoming 600khz pin and divide it by 4 and generate low frequency signal at output pin of arduino

texts:
I am trying to divide a incoming high frequency signal 600kHz by 4 and output wave at arduino MEGA2560 digital pin.

The input to arduino comes from incremental Encoder which is connected to motor that runs at 9000 rpm and the generates 1024 pulses per rotation.
I am trying to downsample the frequency I am getting from arduino to 250kHz or less.
I tried following approaches :

a. I counted the rising edge of the incoming wave and a interrupt is triggered as number of rising edge reaches certain value and ISR toggle an output pin.
b. I tried to get hardware counter work at T0 pin but I was not able to hit ISR when the count has reached specific value.

The problem with approach 1 is: As my frequency of incoming wave increases the output wave starts missing some pulses and generates one half cycle for 6/8/10 pulses of incoming wave. It should actually generate one half cycle for 4 pulses.

Here is approach 2 code:

#define outPin1 10
volatile short encoder = 4;

void setup ()
{
   pinMode (outPin1, OUTPUT);
   Serial.begin(9600);
   cli();
   // reset Timer 0
   TCCR0A = 0;
   TCCR0B = 0;

 }  // end of setup

 ISR(TIMER0_COMPA_vect)
 {
     digitalWrite(outPin1, !digitalRead(outPin1));

 }

 void loop ()
 {
    TCNT0 = 0;      //counter to zero

    // set compare match register to desired timer count:
   OCR0A = encoder;
    // turn on CTC mode:

   bitSet(TCCR0A, WGM01);
   // Timer 0 - counts events on pin D4

  bitSet(TIMSK0, OCIE0A);    // interrupt on Timer 0 CTC
   // start Timer 0
  // External clock source on T0 pin (D4). Clock on rising edge.

   bitSet(TCCR0B, CS02);
   bitSet(TCCR0B, CS01);
   bitSet(TCCR0B, CS00);
}

Please someone help me out with this issue


texts: Max no of UART on SAMD21G18(Sparkfun Mini Board)

texts:
I am currently working on a project where I need to communicate with 5 different sensors via UART alternatively & upload the data to PC.Currently the Setup is running using a Arduino Uno using Software Uart(With one sensor only)but I have chosen SAMD21G18 board from Sparkfun(Sparkfun Mini) for the final design.Although,I don't have the board currently with me.The problem is,i am unable to understand how many UART ports can be configured on the particular board??So far my inderstanding goes,I can configure the below mentioned pins for UART ports.

PA10 - SER0:2/2:2 - Tx  // SER0:2 means Sercom 0,Pad2/Sercom-Alt 2,pad2
PA11 - SER0:3/2:3 - Rx

PA09 - SER0:1/2:1 - Rx
PA08 - SER0:0/2:0 - Tx

PA14 -  SER2:2/4:2 - Tx
PA15 - SER2:3/4:3 - Rx

PA20 -  SER5:2/3:2 - Tx
PA21 - SER5:3/3:3 - Rx

PA06 -  SER0:2 - Tx
PA07 - SER0:3 - Rx

PA16 - SER1:0/3:0 - Tx
PA18 - SER1:2/3:2 - Rx

PB09 - SER4:1 - Rx
PB08 - SER4:0 - Tx

Is my understanding correct?If so,then my next query is ,should I configure Ser0,1,2,3,4 i.e pins from different Sercom# for Different UARTs or can i configure two different pins from same Sercom#?


texts: Arduino Leonardo isn't detected by Linux Mint on serial port /dev/ttyACM0

texts:
I'm working on Linux Mint 18 Sarah (earlier Ubuntu 16.04 LTS) system. I've installed Arduino IDE using command sudo apt-get install arduino and I've added me dialout group using sudo usermod -aG dialout $(whoami). This is results of executing groups command:

hubert@hubert-SATELLITE-C660D ~ $ groups
dialout adm cdrom sudo dip plugdev lpadmin sambashare hubert

When I try upload following code to Arduino Leonardo:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

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

orange LED marked with L letter on my board blinks and next I get following error:

Wielkość binarna szkicu: 4 736 bajtów (maksymalnie: 28 672 bajtów)
processing.app.debug.RunnerException: Couldn’t find a Leonardo on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.
    at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:153)
    at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
    at processing.app.Sketch.upload(Sketch.java:1671)
    at processing.app.Sketch.exportApplet(Sketch.java:1627)
    at processing.app.Sketch.exportApplet(Sketch.java:1599)
    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
    at java.lang.Thread.run(Thread.java:745)

On my IDE Arduino shows on /dev/ttyACM0 serial port. When I try running this IDE on root privileges, I get the same error. On root privileges serial port is changing from /dev/ttyACM0 to /dev/ttyACM1, from /dev/ttyACM1 to /dev/ttyACM2 etc. I tried different USB cabels and reset Arduino but these ways nothing help. On Windows 7 my Arduino works and Arduino IDE uploads code without problems. Can anybody help me?


texts: My GSM900A module is not connecting to the network. IT continuously blinks(1 sec). The power was given by the Arduino Uno board. Then I tried connecting an external battery(4.2V , 4200mAH). But it didn't work. What kind of a solution would be suitable for this issue?


texts: How to control Arduino using mBlock and Bluetooth?

texts:
Is it possible to control an Arduino using mBlock and Bluetooth?

Assuming yes, I tried various things, but was not able to come to a conclusion.

I am trying to get this combination working using a HC-05 Bluetooth module. I am not sure if my Bluetooh setup is the problem or is mBlock is not able to recognize the COM port provided by Bluetooth.

I can see the COM device (in fact two?) when I pair HC-05 with PC. I have the following questions based on whatever I have tried so far:

When I connect HC-05, should I connect TX to TX OR reverse them?
There are varying articles describing both ways of connection.
How much baud rate do I need to set on the Bluetooth device?
Do I need to use the voltage divider for RX? Again there are varying tutorials.
Is mBlock default Arduino firmware sufficient for such setup?


texts:
Im trying to power a brushless DC Motor (Tamiya 300054358) through the l298n attached to an Arduino.
The l298n is powered by an external 9V source and the logic of the l298n is powered by the Arduinos 5V, wich is also powered by the 9v.
Both components using the same ground.
The code looks good and i can successfully adjust the power-output for the motor between 6-9V.
As soon as is attach the Motor, the volage drops do somewhere around 0-1V and the motor isnt turning.
When i attach the motor directly to the power source, it runs fine, so the power should be enough. (in the original RC car its powered by an 7V battery).
I tried some smaller motors just to be sure and the problem is similar. The motor is turning, but very slowly.
I also tried to connect the batterypack instead of the extern power source just ending up with the same result.
Do you have any ideas, where the problem could be at?
Thanks in advance


texts:
I see a lot of people, but also libraries, defining constants (like pin numbers, length of items etc) as #define:

#define LENGTH 5

While it is recommended to use in this case static const int:

static const int LENGTH = 5;

I did a test and for memory it does not make a difference.

Is there some specific Arduino reason why #define is (mis)used so often?


texts: max7219 chained display showing mirrored text

texts:
I'm using a max7219 like this one max7219. When I first tested my circuit, I used an 8x8 display and the code worked just fine. Now, after I modified the code with the one that can be found online at arduino code and changed the display with the chained one, the text appears to be mirrored on the matrix display.

.

Below, I'll attach part of the code. Please help me find the problem.

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// Define the number of devices we have in the chain and the hardware interface

#define MAX_DEVICES 4
#define CLK_PIN     13
#define DATA_PIN    11
#define CS_PIN      10

// Hardware SPI connection
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

void setup(void)
{
  P.begin();
  P.displayText("Hello", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
}

void loop(void)
{
  P.displayAnimate();
}


texts: Using timer2's ISR instead of timer1's in Arduino wiring.c breaks Serial object

texts:
I want to change timer0 frequency because I need to use 4 PWM pins at a frequency lower than 500Hz and the SPI on an ATmega328. So I changed timer2 to Fast PWM with 64 divisor, enabled the overflow interrupt for timer2 and disabled the overflow interrupt for timer0:

  TCCR2A = _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(CS22);
  TIMSK2 |= (1 << TOIE2); // enable overflow interrupt for timer2
  TIMSK0 &= ~(1 << TOIE0); // disable overflow interrupt for timer0

and changed the ISR vector in wiring.c from ISR(TIMER0_OVF_vect) to ISR(TIMER2_OVF_vect).

But delay doesn't work. What can be the problem?


texts:
As per this SO:

Is the MKS GEN V1.2 compatible with Arduino IDE as Arduino MEGA Board?

the MKS GEN board is an Arduino MEGA board mixed with other circuits.

My questions is how does it correlate with the Arduino Mega Board pinouts, especially the ones encircled in red below:

E.g. for connector Jc_M2 where does the EN, STEP and DIR pins connect to the ATmega2560 controller? And also for the other servo controller pins.


texts: Adding Attiny to Arduino IDE - attiny\variants\platform.txt file missing

texts:
I followed this guide to program AtTiny using Arduino as ISP. The problem is that it has some file missing:

java.io.FileNotFoundException: C:\...\arduino-1.6.8\hardware\attiny\variants\platform.txt

The attiny directory is clone of this repository. How do I make it work?


texts: What Arduino board with WiFi should I choose

texts:
I want to implement an Arduino module with some sensors and send the info through WiFi to a server. I'm looking for the best board or component combination to make this. What is the best board or solution you would use in my case? Maybe Arduino Yun or Intel Edison Kit for Arduino...¿?

I've developed a sensor module with Redbear Blend board which use Bluetooth to communicate with an Android app to send sensor data, but now looking for WiFi connection.

Sorry if it's a stupid question, I'm new in this Arduino world. Thanks in advance!


texts:
I have tried to get the Ai-Thinker ESP8266 working at all. If you hook it up to an Uno you have garbage returned no matter what the baud rate is. Tried softwareSerial on D3 and D4 (switching pins doesn't help) and over D0 and D1 with no sketch (to send AT commands directly to the device because softwareSerial wasn't working).

I'm using a logic converter from 5v to 3.3v to handle the voltage correctly.

I also know for a fact you can do that. I've done it a bunch with Bluetooth. HC-05.

NOTE: Pins in the wrong order won't return anything, in order to get garbage it needs to be wired correctly.

I also have a FTDI module that functions as another passthrough unit for this. It has a jumper for 3.3v to 5v and will stay on 3.3v as these units are unable to handle 5v.

I used PuTTY in order to view the boot information of this chip. On boot it returns this information.

So here's my issue.

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

wdt reset
load 0x40100000, len 816, room 16
tail 0
chksum 0x8d
load 0x3ffe8000, len 788, room 8
tail 12
chksum 0xcf
ho 0 tail 12 room 4
load 0x3ffe8314, len 288, room 12
tail 4
chksum 0xcf
csum 0xcf

2nd boot version : 1.2
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size : 4Mbit
jump to run user1

sd▒C▒
Ai-Thinker Technology Co. Ltd.

invalid

At the end of the day this invalid line means that the wifi information (from what I understand) is corrupted. It also refreshes this information over and over and WILL NOT accept AT commands so I can't seem to chase it down.

I am afraid that by attempting to update it if this kind of issue happens it will be bricked.

Both of these modules are opened today and I have tested another 8266 with similar results.

Any help would be appreciated.


texts: Connect arduino with C# Desktop application wireless using esp8266

texts: I am using wifi module esp8266 , what is easiest way to communicate arduino with desktop application and make a wireless communication between them. Please refer any useful resources


texts: I'm an amateur and I wish to use timers in my project. I'm using an Arduino Mega 2560 with a touch-sensitive screen with six  DS18B20 temperature sensors and a DS1307 RTC (real time clock). I would like to query my sensors every 1 or 2 minutes to refresh the screen for temperature acquisition. I do not how to program timers to schedule the readings and which timers to use?


texts:
I have a HDMI switcher which uses a TL1338 IR LED that's connected via a 3.5mm audio jack. It has its own remote for switching between the inputs, but I want to use my TV remote.

In order to do that I want to connect the IR led to an ATTiny85 to receive the input and send the 'translated'code to the switcher.

When analysed with an oscilloscope it seemed that Arduino Libraries output a PWM signal, while the TL1838 outputs a digital signal. Is there a way to simulate a TL1838 signal?

Original situation:

Goal situation with ATTiny85.


texts: Loops fail after ~5 minutes when making two API calls every 10 seconds using WiFi client

texts:
I am running into an issue with a loop call on an Arduino MKR1000. I have tried the solutions suggested in this question and it usually works for 5 minutes and then collapses.  I am trying to make two calls to different APIs every 10 seconds and update something on the Arduino accordingly, but the loops seem to be getting out of sync after a few minutes. Here is the code - I tried to shorten it...

#include <Time.h>
#include <SPI.h>
#include <WiFi101.h>
#include "arduino_secrets.h"

// put your local wifi info here
const char* ssid     = SECRET_SSID;
const char* password = SECRET_PASS;

const char* host = "bustime.mta.info";

void setup() {
  Serial.begin(9600);
  delay(10);
 // connecting to a WiFi network
  WiFi.begin(ssid, password);

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

void loop() {
  Serial.println("START THE LOOP");
  // Use WiFiclient class to create TCP connections
  WiFiClient client;
  WiFiClient client2;
  char * serviceDeliveryString = new char[40]();
  strcpy(serviceDeliveryString, "/ServiceDelivery");
  char * responseTimestampString = new char[40]();
  strcpy(responseTimestampString, "<ResponseTimestamp>");
  char * TString = new char[40]();
  strcpy(TString, "T");

  if (!client.connect(host, 80)) {
    lcd.clear();
    lcd.gotoXY(0, 0);
    lcd.string(connectionFailed);
    delay(2000);
    return;
  }

  //connect to schedule data
  if (!client2.connect(host, 80)) {
    lcd.clear();
    lcd.gotoXY(0, 0);
    lcd.string(connectionFailed);
    delay(2000);
    return;
  }

  char * req1full = new char [100]();
  strcat(req1full, "GET /api/siri/stop-monitoring.xml?key=KEY&OperatorRef=MTA");
  strcat(req1full, " HTTP/1.1");
  client.println(req1full);
  client.println("Host: bustime.mta.info");
  client.println("Connection: close\r\n");

  char * req2full = new char [100]();
  strcat(req2full, "GET /api/where/schedule-for-stop/MTA_");
  strcat(req2full, stopNum);
  strcat(req2full, ".xml?");
  strcat(req2full, "key=KEY HTTP/1.1");
  Serial.println(req2full);
  client2.println(req2full);
  client2.println("Host: bustime.mta.info");
  client2.println("Connection: close\r\n");

  //Pause long enough for the connection to happen. Make this longer if you have issues.
  delay(1000);

  while(client.available()){
    if (client.findUntil(responseTimestampString, serviceDeliveryString)){
      Serial.println("inside client...");
      client.findUntil(TString, serviceDeliveryString);
      String mtaTime = client.readStringUntil('.');
      Serial.println(mtaTime);
    }
    delay(10);
  }

  while(client2.available()){
    if (client2.findUntil("<currentTime>", "/data")){
      Serial.println("inside client2...");
      String mtaTime2 = client2.readStringUntil('<');
      Serial.println(mtaTime2);
    }
    delay(10);
  }

  client.stop();
  client2.stop();
  delay(9000);

}

The output starts out looking good:

START THE LOOP
GET /api/where/schedule-for-stop/MTA_306762.xml?key=KEY HTTP/1.1
inside client...
22:13:38
inside client...
22:13:38
inside client2...
1541211218146
START THE LOOP
GET /api/where/schedule-for-stop/MTA_306762.xml?key=KEY HTTP/1.1
inside client...
22:13:51
inside client...
22:13:51
inside client2...
1541211231815
START THE LOOP
GET /api/where/schedule-for-stop/MTA_306762.xml?key=KEY HTTP/1.1
inside client...
22:14:04
inside client...
22:14:04
inside client2...
1541211244465

But eventually something seems to happen with the loops and this is the final output, when it should keep running:

inside client...
22:19:02
inside client...
22:19:02
START THE LOOP
GET /api/where/schedule-for-stop/MTA_306762.xml?key=KEY HTTP/1.1
START THE LOOP
GET /api/where/schedule-for-stop/MTA_306762.xml?key=KEY HTTP/1.1
START THE LOOP

Any suggestions for how to fix this?


texts:
I downloaded arduino-1.8.4-linux32.tar.xz and ran install.sh as outlined (the very sketchy instructions) in https://www.arduino.cc/en/Guide/Linux

This seemed to work OK, so I removed 354M of what I thought was the installer, only to discover that I had deleted arduino.

The so-called install.sh on closer inspection seemed only to create links into the uncompressed download in my home directory.

The whole process seems very un-Linux like; I had assumed that it would be installed in /usr/share/ like most Linux programs.

I realise I could extract into /usr/share/ and set permissions for other users, but surely there must be others who have wanted to do the same. The macOS version seems to have a proper installer; does one exist for Linux?


texts: Sending a character 'A' through blinking led

texts:
How do i code to send a character 'A' to the arduino through a blinking led?
   i am doing a project about data transmission. i really need help&some guide.
   Material used are arduino uno r3,white led and a resistor.

MY OUPUT IN SERIAL MONITOR

Insert letter:

01000001 65  - Character A

00001010 10  - when i send/enter

CODE

 int LEDTrans = 13;
int timeWaitOn = 1000; //milisec (1 sec)
int timeWaitOff = 1000; // milisec (1 sec)
byte byteRead;

void setup() {
// Turn the Serial Protocol ON
  Serial.begin(9600);

 Serial.print("Insert letter:");
 Serial.println(" ");
}

void loop() {

digitalWrite(LEDTrans,HIGH); //turn the led on
delay(timeWaitOn); //delay in millisec (1 sec)
digitalWrite(LEDTrans,LOW); //turn the led off
delay(timeWaitOff); //wait a sec

   /*  check if data has been sent from the computer: */
  if (Serial.available()) {

     byteRead = Serial.read();
    // will print the binary representation of 'byteRead' as 8 characters of '1's and '0's, MSB first.
for ( uint8_t bitMask = 128; bitMask != 0; bitMask = bitMask >> 1 ) {

      if ( byteRead & bitMask ) {

    Serial.write('1');
  } else {
    Serial.write('0');
  }
}

Serial.write("    ");
Serial.println(byteRead);    //send back the actual ASCII code
}

}


texts: Controlling 5V PWM Fan with Potentiometer

texts:
Alright so I wanted to make myself a Deskfan using Arduino and a potentiometer. The reason for using arduino is that I want to display the current temperatur and the fan speed either through rpm or with %. Currently it seems to work fine using the potentiometer to control the pwm. But either i'm just not believing that it works correctly or it really isn't. My only problem is that I think the fan is not outputting 100% of its power with the pwm signal. Maybe about a few % less. But I don't really know if there is something that I am missing or if it really is outputting 100%.  The fan in question would be a Noctua NF-A14 5V PWM (+-1500 MAX).

Edit: Is it possible  that I'm not using full 100% of the fan?
 If so what would I need to change if that were the case. I heard something about changing to 25khz pwm but yeah..

Here is my code without the lcd stuff.

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

void loop() {

  int potValue = analogRead(A5);

  int newpotValue = map(potValue, 0, 1023, 0, 255);
  Serial.println(newpotValue);
  analogWrite(9, newpotValue);
}


texts:
I'm making a desk lamp out of 2x WS2811 strips (attached to the triple ports at top right of board below). The brightness of the strips is controlled by a potentiometer, and the colour by a switch. Each press of the switch cycles through red, blue and white:

Here's the code I've come up with:

#include <FastLED.h>

#define strip_pin     7
#define NUM_LEDS    15

CRGB leds[NUM_LEDS];
int distance;
int brightness;
int brightnesspin = 2;
int pin_switch = 3;

// variables to hold the new and old switch states
boolean oldSwitchState = LOW;
boolean newSwitchState1 = LOW;
boolean newSwitchState2 = LOW;
boolean newSwitchState3 = LOW;
byte state = 0;

void setup()
{
  Serial.begin(9600);
  FastLED.addLeds<WS2811, strip_pin, BRG>(leds, NUM_LEDS);
}

void loop()
{
  delay(500);
//  Colour control
//##############################################
    newSwitchState1 = digitalRead(pin_switch);
    delay(1);
    newSwitchState2 = digitalRead(pin_switch);
    delay(1);
    newSwitchState3 = digitalRead(pin_switch);
    // if all 3 values are the same we can continue
    if (  (newSwitchState1==newSwitchState2) && (newSwitchState1==newSwitchState3) )
    {

        if ( newSwitchState1 != oldSwitchState )
        {

           // has the button switch been closed?
           if ( newSwitchState1 == HIGH )
           {
                // increase the value of state
                state++;
                if (state > 3) { state = 0; }
                for (int i = 0; i < NUM_LEDS; i++)
                {
                if (state==1) { leds[i].red = 100;Serial.println("Red"); }
                if (state==2) { leds[i].blue = 100;Serial.println("Blue"); }
                if (state==3) { leds[i].red = 100; leds[i].blue = 100; leds[i].green = 100;Serial.println("White");}
                }
                FastLED.show();
            }
           oldSwitchState = newSwitchState1;
        }

//    Brightness control
//##############################################
  brightness = analogRead(brightnesspin);  brightness = map(brightness, 0, 1024, 0, 255);
    for (int i = 0; i<NUM_LEDS; i++)
      {
        FastLED.setBrightness(brightness);
      }
  FastLED.show();
  Serial.print("Brightness: ");
  Serial.println(brightness);
    }
}

The brightness control works fine, and the switch cycles through the colours once, but the strip stays white once it's there, even though the serial monitor shows the switch changing state. How can I get the strip to cycle back round to red?


texts: How can I add phonebook entry to sim card using Arduino GSM shield?

texts:
I am using Arduino GSM Module and Arduino UNO

I want my GSM module to be stand alone once I programmed it. It will store the phone number of the user if he sends a correct passcode. Since I want the data to available even after I power off my module. I need to store it to my sim. I don't want to use an SD card shield or store data to arduino's EEPROM.

I have read Getting the contacts/ storing contacts to SIM card. The only clear reply is reading from the SIM.

Is it possible to add phonebook entry to SIM card?
Do you know a tutorial?


texts: ESP32 playing wav sounds distorted or too fast (but not all wav's)

texts:
I am building a sound project on an ESP 32 via I2S  using an example from:
https://github.com/nhatuan84/esp32-i2s-sdcard-wav-player

It works fine with the example wav file t.wav posted in the repository.

But when I try to use a custom wav which I exported from audacity it sounds distorted  and/or too slow/fast (it sounds fine when I play it within audacity).

This is an example that is totaly distorted when playing from the esp with I2S:
badly sounding wav
While it sounds fine when playing from audacity.

I tried different settings in audacity exporting 16 bit, 32 bit. 44100 Hz, 11025.

Any hints or tips what I could try or am doing wrong?

Thx!

Jeroen


texts: Dynamic SSID + Password from ESP8266WiFi

texts:
I'm using the ESP8266WiFi library on a NodeMCU, running the arduino bootloader in the arduino software (Windows 10 app version).

I'm trying to load the SSID and password from SD-card (this part is successfull).

My problem this far is when i use the Wifi library it looks like this:

 Wifi.begin(const char*, const char*);

Since it takes 2 const parameters i cannot change it later. Is there anyway i can add SSID and PASSWORD to my sketch without having to recompile it. (I have to send it to people who does not know how to compile and flash an arduino)

I'm not attached to the ESP8266WiFi library, i'm not attached to SD-card, other solutions are welcome.

SD-reader works as planned, WiFi works as planned with a static password and SSID.


texts:
Please somebody who had the same issue help me.
The question is how to connect this Mini Ethernet shield to an Arduino.
The main problem is the pins that my shield have or haven't; my current connections to the Arduino Mega 2560 are:

5v to 5v
GND to GND
LNT to NULL
CLK to NULL
SO  to pin50
WOL to NULL
SLK to PIN52
ST  to ????
RST to RST
CS to PIN53
Q3 to NULL
GND to NULL

But in all cases when I search the connection diagram every picture has SI, but I don't have it (I tried to connect ST to PIN51 without luck).

What kind of Ethernet shield is that? Or how to connect those pins?

I hope someone can help me; thank you in advance.

/*
  DHCP-based IP printer

  This sketch uses the DHCP extensions to the Ethernet library
  to get an IP address via DHCP and print the address obtained.
  using an Arduino Wiznet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13

  created 12 April 2011
  modified 9 Apr 2012
  by Tom Igoe
  modified 02 Sept 2015
  by Arturo Guadalupi

 */

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
   // Ethernet.init(53);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

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

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
}

And result is :

16:41:14.242 -> Initialize Ethernet with DHCP:
16:41:14.804 ->    Failed to configure Ethernet using DHCP
16:41:14.848 -> Ethernet    shield was not found.  Sorry, can't run
without hardware. :(


texts:
I have a project where I have to control a DC motor.
In this code the purpose is that every time you press a button the direction of the motor changes.

I only get the error that L1 (and L2,R1 and R2) are not declared in this scope. the place in the loop.
How do I define the variables so that the code works?

int Motorforward = 10;   // MotorDirectionPin set to pin10
int Motorbackward = 11;   // MotorDirectionPin set to pin11
const int button1Pin = 2; //button control set to pin 2

int state = L1;
int state = L2;
int state = R1;
int state = R2;

int button1State;  // current reading from the input pin
int previous = LOW; //the previous reading from the input pin

char input;

void setup(){
pinMode(button1Pin, INPUT); //set pin as input
Serial.begin(9600);

pinMode(Motorforward, OUTPUT); // sets the pin as output
pinMode(Motorbackward, OUTPUT);
 }

  void loop(){
button1State = digitalRead(button1Pin);
input = button1State;

switch(state){
  case L1:
    if (state == L1){
    if (button1State == HIGH){
        state == L2;
    }
  }
  break;

case L2:
  if (state == L2){
    if (button1State == LOW){
      state == R1;
    }
  }
  break;

case R1:
  if (state == R1){
    if (button1State == HIGH){
      state == R2;
    }
   }
  break;

case R2:
  if (state == R2){
    if (button1State == LOW){
      state == L1;
    }
  }
  break;
}


texts:
I am trying to build a quadcopter using an arduino. I Bought 4 30A ESC's from Ebay the link is http://www.ebay.co.uk/itm/4pcs-Brushless-speed-controller-ESC-MultiCopter-KK-Quad-rotor-X-copter-30A-S-/310950293677?pt=LH_DefaultDomain_3&hash=item486614f0ad and a A2212 2200KV motor, im also using a sparkfun arduino uno. I have connected the white (data) servo wire of the ESC to pin 9 of my arduino and the black (ground) servo wire of the ESC to gnd of the arduino. When i connect the battery to the esc i get the 3 beeps because of my 3 cell battery regardless of what code is on the arduino even if the arduino is not present. the code that is on the arduino is.

#include <Servo.h>

Servo motor;

void setup()
{
  Serial.begin(9600);
  motor.attach(0);
}
void loop()
{
  motor.write(100);
}

I'm not sure what is wrong. Can someone please help me.


texts:
I'm trying to calculate de rotation speed of a dc motor.

I'm using the sensor shown in the picture and a slotted disk attached to the motor. The results I was getting made no sense and after several tests I realised the following:

Most of the times I manually blocked or unblocked the sensor, two pulses were counted. That would mean that for each tooth of the slotted disk, up to four pulses were counted instead of one.

Bellow is a test code. I count pulses on the interrupt handler and reset the counter when calculating the motor speed.

Am I doing something wrong or is the sensor suffering from bouncing signals?

int encoderCounter = 0;
int encoderDiscSlots = 21;

int encoderPin = 19;

void encoderIncrementISR()
{
  encoderCounter++;
}

double calculateMotorSpeed(int interval)
{
  Serial.print("enc ");
  Serial.println(encoderCounter);
  double rpm = (encoderCounter*1.0/encoderDiscSlots)*60000/interval;

  encoderCounter = 0;
  return rpm;
}

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

  pinMode(encoderPin, INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(encoderPin), encoderIncrementISR, RISING);
}

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

  delay(1000);
  double rpm = calculateMotorSpeed(1000);
  Serial.print("rpm ");
  Serial.println(rpm);
}

The sensor uses the LM393 IC from TI, a spec sheet can be found here


texts:
I am creating a server node that I want to be able to save the wifi SSID and the password into persistent memory so that when it starts ups it can connect to the network. I have looked for several hours and found just a few bits of information. One bit I found here http://playground.arduino.cc/Code/EEPROMWriteAnything

#include <EEPROM.h>
#include <Arduino.h>  // for type definitions

template <class T> int EEPROM_writeAnything(int ee, const T& value) {
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value) {
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          *p++ = EEPROM.read(ee++);
    return i;
}

This code will not store String values to the EEPROM. So as I thought I would ask for advice from the Stack Exchange geniuses.

Thanks!


texts: Trying to use Nano Every as a sort of USB logic analyzer, but can't isolate it from "device under observation"

texts:
Here's the scenario: I have a radio that displays information on a 1602A LCD. The 1602A is plugged into a header so I can easily pull it out and instead plug in logic analyzer leads. The logic analyzer decodes the HD44780 protocol and shows me the data that would have gone to the 1602A. The logic analyzer, not surprisingly, doesn't have any noticeable effect on the radio.
Now I want to replace the logic analyzer with a Nano Every. I wired it up so that the signals to be observed are connected to digital input pins on the Every. The Every is powered through USB and doesn't intentionally draw any power from the radio. Everything runs as expected and the Every shuffles readings to the PC via serial. HOWEVER, in this combination, the radio draws at least twice as much current from the power supply and the radio's voltage regulators begin to heat up substantially!
I would have thought that the digital input pins of the Every are high enough impedance that it would have no significant effect on the radio, just like the logic analyzer didn't. I can only assume that "significant" current is flowing from the radio's LCD header into the Nano Self's input pins, since they are the only connection between the radio and the Nano.
So, I guess my question is this: How can I make the Nano Self work more like a logic analyzer? Do I need additional circuitry between the signals being tested and the Self's input pins, perhaps logic buffers? Or might something else be going on here?


texts:
In my project I need three arrays to store data inside.

I define a maximal number of elements as a macro variable. However, at a certain point in the setup function, the program could determine, that the arrays would actually store a smaller number of elements. In other words, it is possible (and even likely) that there is more memory reserved for the arrays than actually necessary.

As I think that memory might be a critical factor on a micro controller like the Arduino, I would like to set the excess memory free.

Is there a way to dynamically resize and shrink the arrays at runtime?

Something like this (pseudocode)

#define maxSize 50
int theArray[maxSize];

int actualSize = getActualArraySize();
// sets actualSize to a value <= 50, let's assume actualSize = 20
shrinkArray(theArray, actualSize);
// shrinkArray doesn't exist :) I need something like that.


texts:
I'm having trouble with using parallel shift registers, I've studied example codes and I've come up with this function to set the pins to on or off. The problem is the first time the function runs all the output pins are set to HIGH regardless of the values in the array.

    void updateRegister(int ClockPin,int DataPin,int LatchPin){
      int pinState;//Holds the state of the data pin
      pinMode(ClockPin, OUTPUT);//Sets the pinmode of the pins
      pinMode(DataPin, OUTPUT);//Sets the pinmode of the pins
      pinMode(LatchPin, OUTPUT);
      digitalWrite(LatchPin, 0);//Turns latch off to prevent bleedover while shifting

      digitalWrite(DataPin, 0);//clear everything
      digitalWrite(ClockPin, 0);//clear everything

      for (int i=1; i<=16; i++){//Repeats 16 times with i increment from 1 to 16
          if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH
          else{pinState= 1;}//If it equals false set it to 0, LOW

          digitalWrite(DataPin, pinState);//Sets the data pin depening on the pinstate
          digitalWrite(ClockPin, 1);
          digitalWrite(DataPin, 0);
          digitalWrite(ClockPin, 0);
        }
      digitalWrite(LatchPin, 1);//Turns latch pin back on
    }

I'm storing the boolean values of the each pin in an array called Qout which is defined and all set to false like this

    boolean Qout [17];//Holds the state for each pin
    for (int i = 1; i < 17; i++ ) {Qout[i]=false;}//Sets all output to off

I know I should start at Qout[0] but it just makes it way more confusing.

Can someone help me fix my function so that it actually works.

This is what I based it on ShftOut23


texts: What sensor do I use to measure the intensity of direct sunlight?

texts:
I'm trying to measure how bright the day is on a particular day to see how it affects plant growth. The brightest sun can be 120,000 lux. It possible to measure such a large brightness? What sensor do I use?

The best options I've found is the BH1750FVI since its sheet says, "[i]t is possible to detect min. 0.11 lx, max. 100000 lx"

However, it still doesn't go high enough.

Note: I live "only" 3,494 km (2171 miles) from the equator, and it can get fairly bright here.


texts: Is the used clock for the Baudrate generator adjustable on an arduino due?

texts:
I hope to find some answers or pointers to a boggling task of mine:

Having an Arduino DUE that I want to push to its serial limits, I came up with the idea of hooking it up to my rPi via serial at least at 921600 baud.

Technically both seem capable of that. A loopback test with the rPi was successful up to 921600 and I've managed to get a "good" quality transmission up to 576000 bps already (error-rate should be around 1,3%), but anything higher gets problematic.

Problems:

DebugConsole, CuteCom and minicom don't have support for any speeds in-between, so either 921600 works or it doesn't
minicom supports 1.000.000 baud, but this would still mean a ~5% error-rate, which is according to my calculations and tests, but they are in question here as well ...

From the Atmel Doc I've got

BaudRate = MCK ⁄ CD × 16

From that I've derived that with the 84MHz Due a baudrate of 1.050.000 would be the actual rate I should aim for, as CD must(?) be an INT.

1050000 = 84000000 / 5 * 16

Questions:

Is my assumption of an optimal 1.050.000 baudrate right?
Is it possible to use a different clock for the baudrate generator than the 84MHz?

Remarks:

A Clock of 14,7456MHz should be optimal as it is equal to 921600 * 16.

I am using TXD/RXD1 on the Due.

The Due is transmitting on 921600 but the data is scrambled due to the errors.

In case somebody is wondering, my hope is that it is easier to adjust the arduino to 921600 baud than it is to setup a tool and configure the rPi to support 1050000 baud - but I am working both ways, only that with the rPi I know what to do ..


texts:
I've been using a pair of arduino uno and nrf24l01 and found it wasn't really suitable due to low range when it comes to obstacles.

Essentially I'd like to use it in country areas where it would ideally transmit through dense trees and over hills at around 500 meters.

I've spotted the SI4432 and the sx1272 (which seems ideal but it doesn't seem popular despite it's high NLOS range capabilities?)

I was just wondering if anyone had any recommendations on which would be the best radio module to try? Any help would be really appreciated. Many thanks in advance.


texts: Arduino Ethernet and Uno R3 as a firewall

texts:
Is there a way to program the Ethernet Shield and Uno R3 to act as a firewall without using a huge chunk of the allowed bytes on the R3?  I plan on using a DC adapter to plug the R3 into a wall, and use the mini-SD card to keep logs while having the ethernet shield plugged into my router.

I know that it is possible to program it to do this but I want to know if there is a simple modification I can make to the web-client library or if I should use the web-server library and modify that?


texts: Arduino not adding decimals correctly on double variable


texts: Newbie interfacing MLX90614 with arduino Due (Atmel3X8E)

texts:
I am a newbie trying to interface the infrared temperature sensor MLX90614 with the arduino Due. But it keeps sending out junk values in the serial monitor. I've tried it out on the Arduino Mega and it works perfectly. What might be the problem and how do I rectify it?
Thanks in advance.

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test");
  mlx.begin();
}
void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
  Serial.println();
  delay(500);
}


texts: A knob that can be turned by hand, have the position read, and turned by software to another position?

texts:
I'd like to be able to change variables on the Arduino by adjusting a set of knobs.  When I get to a desirable setting I'd like to be able to save those settings on the Arduino... and then I'd like to be able to load those settings back, and have the knobs turn themselves back to the correct positions.  Specifically I'm thinking of using this with a synthesizer.

I understand how to do all of this, except, I don't know if there are knobs that allow this type of behavior.


texts: Multiple Wire.write() not working for Arduino Nano I2C

texts:
Code for Master
#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
}

void loop()
{
    Wire.beginTransmission(9);

    Wire.write('c');
    Serial.println('c');
    Wire.write('a');
    Serial.println('a');
    Wire.endTransmission();
}

In my case Wire.write('c') is performing the task which is assigned to 'c' in slave board.
Then its printing 'c' in serial monitor as intended.
But, Wire.write('a') line is being neglected and nothing happens on slave board.  But again, it's printing 'a' in serial monitor as per code.
Why is that Wire.write('a'); is neglected? Both boards are Arduino Nano.
Code for Slave
#include <Wire.h>
#define RED 8
#define GREEN 10
int x = 0;

void setup() {
  pinMode (RED, OUTPUT);
  pinMode (GREEN, OUTPUT);
  Wire.begin(9);
  Wire.onReceive(receiveEvent);
}

void receiveEvent(int bytes) {
  x = Wire.read();    // read one character from the I2C
}

void loop() {
    if (x == 'a') {
        digitalWrite(RED, HIGH);
        digitalWrite(GREEN, LOW);
    }
    if (x == 'b') {
        digitalWrite(RED, LOW);
        digitalWrite(GREEN, HIGH);
    }
    if (x == 'c') {
        digitalWrite(RED, HIGH);
        digitalWrite(GREEN, HIGH);
    }
    if (x == 'd') {
        digitalWrite(RED, LOW);
        digitalWrite(GREEN, LOW);
    }
}


texts: Long story short, I'm trying to build some form of device that you can wear and it will detect when something moves behind you. I wanted to use PIR sensors for the motion detection, but I have no idea if they can detect objects if you're moving. Any ideas?


texts: Input a signal from a sensor to an Arduino Due

texts:
I'm working with Arduino Due and I have a sensor that outputs a square signal with voltages in the range of 0-5V.

In the Due specs there is a warning that says:

"Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Providing higher voltages, like 5V to an I/O pin could damage the board."

Is it possible to connect it to the board?

Thanks.


texts: Extract arduino collected data periodically

texts:
I'd like to extract data collected by a battery powered arduino for example once a day without stopping it and not using SD card.

It's posible, when I want to extract the collected data, to connect a laptop through the USB and then get data because Arduino is, at regulat time intervals, calling 'Serial.println(...)'?


texts:
I am trying to get an RFID tag number using a WinForms application. But whenever I click the Button the application stops responding. Please help regarding this.

Arduino code

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.init();
}

void loop() {
  if(rfid.isCard()) {
    if(rfid.readCardSerial()) {
      Serial.print(rfid.serNum[0], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[1], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[2], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[3], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[4], HEX);
      Serial.println("");
      delay(1000);
    }
  }
  rfid.halt();
}

C# code

private void button1_Click(object sender, EventArgs e) {
  try {
    serialPort1.Open();
    serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
    textBox2.Text = "connected";
    serialPort1.Close();
  }
  catch(Exception ex) {
    textBox2.Text = "Com port disconnected";
  }
}

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) {
  SerialPort sp = (SerialPort)sender;
  string indata = sp.ReadExisting();
  textBox1.Text = indata;
}


texts: How do I use ultrasound to track a moving object?

texts:
I'm trying to create a small scale, dumb-downed version of the pitch tracking systems used to detect the speed and direction of baseballs.

I'm currently working with an HC-SRO4 sensor and an Arduino, but I'm unsure how to expand because a single sensor can't track an object that's not moving linearly (ie rising or falling as it moves). My team's idea was to make a grid of multiple HC-SRO4's connected to one Arduino, but we're worried that the delay will be too large if we try to turn them on sequentially to avoid interference.

How can we use ultrasound to track a moving ball?


texts: Problem communicating Using Nrf24l01+pa+lna, I am receiving 00 Hex

texts:
I am trying to build a wireless switch. At one end, I have Arduino Uno connected to Nrf24l01+pa+lna module. While at the other end there is Arduino Nano connected to Nrf24l01+pa+lna and a relay. I send char '1' or '0' through Nrf24l01 attached to Arduino Uno. Nrf24l01 attached to  Arduino Nano  receives this char and turns on or off the relay connected to Pin D3 of Arduino Nano. The my Arduino Nano replies back as '1' or '0'. Uno receives it and displays it on serial monitor.
At start the communication sometimes worked and sometimes didn't. Then I connected a 10uF capacitor to the both Nrf24l01 modules. Now I am receiving 00 Hex and relay is also not responding. Can any one help. Code is attached.
// Arduino Uno Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};

char serialChar;
char motorChar;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_MIN);
}

void loop() {
    radio.stopListening();
    if (Serial.available() > 0) {
      serialChar = Serial.read();
      radio.write(&serialChar, sizeof(serialChar));

      delay(5);
      radio.startListening();
      while (!radio.available());
      radio.read(&motorChar, sizeof(motorChar));
      Serial.print(motorChar);
    }
}

//Arduino Nano Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
char command;
int relayPin = 3;

void setup() {
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_LOW);

  pinMode(relayPin,OUTPUT);
  digitalWrite(relayPin, HIGH); // Relay is Now Off
}

void loop() {
    delay(5);
    char state = '0'; // switch is off
    radio.startListening();

    if (radio.available()) {
      radio.read(&command, sizeof(command));
      if(command == '1'){
        digitalWrite(relayPin,LOW); // Relay is Now On
        state = command;
        delay(5);
        radio.stopListening();
        radio.write(&state, sizeof(state));
      }
      else if (command == '0'){
        digitalWrite(relayPin, HIGH); // Relay is Now Off
        state = command;
        delay(5);
        radio.stopListening();
        radio.write(&state, sizeof(state));
      }
      else{
        delay(5);
        radio.stopListening();
        radio.write(&state, sizeof(state));
      }

    }
}


texts: I cant seem to form a code to read both DHT11 and pulse sensor

texts:
I combined both the heart pulse sensor code and the DHT11 code. I can get a decent reading from the pulse sensor however an error is given from the DHT11 sensor. I am able to get them to function normally when i set them up individually however when i combine the 2 setups, I am unable to get a reading from the DHT11 although i can get one from the pulse sensor.

I am using ArduinoUNO, DHT11 humidity and temp sensor, and the Pulse Sensor.

THE CODE:

#include <SimpleDHT.h>
#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.

//  Variables
const int PulseWire = A0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
const int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);                               // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
                  // Otherwise leave the default "550" value.

PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"

void setup() {

  Serial.begin(115200);          // For Serial Monitor
  // Configure the PulseSensor object, by assigning our variables to it.
  pinMode(2,INPUT);
pinMode(A0,INPUT);

  pulseSensor.analogInput(PulseWire);
  pulseSensor.blinkOnPulse(LED13);       //auto-magically blink Arduino's LED with heartbeat.
  pulseSensor.setThreshold(Threshold);

  // Double-check the "pulseSensor" object was created and "began" seeing a signal.
   if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.
  }
}

void loop() {

 int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".
                                               // "myBPM" hold this BPM value now.

if (pulseSensor.sawStartOfBeat()) {            // Constantly test to see if "a beat happened".
 Serial.println("♥  A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
 Serial.print("BPM: ");                        // Print phrase "BPM: "
 Serial.println(myBPM);                        // Print the value inside of myBPM.

  delay(20);                    // considered best practice in a simple sketch.
}
 Serial.println("Sample DHT11...");

  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
  Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);
  return;

  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" H");

  // DHT11 sampling rate is 1HZ.
  delay(1500);
  }
}


texts: Constants within array of structs causes strange compiler errors?

texts:
In my sketch I have the following:

#define HU_ADDR                 0x190;
#define ALL_AUDIO_ADDR          0x1FF;
#define MY_ADDR                 0x360;
#define UNKNOWN_ADDR            0xFFF;

typedef byte MessageID;
enum {
  ACT_UNKNOWN,
  ACT_POWERON,
  ACT_POWEROFF,
  ACT_PASSIVEOFF_0,
  ACT_PASSIVEOFFRARE_0,
  ACT_PASSIVEON_0,
  ACT_KEYTURN,
  ACT_PRESSDISC
};

struct MessageDef {
  MessageID ID;
  word MasterAddr;
  word SlaveAddr;
  byte PayloadLength;
  byte Payload[20];
  char Description[20];
};

MessageDef MessageTable[] = {
  {ACT_POWERON,           HU_ADDR, UNKNOWN_ADDR, 13,  {0x00, 0x60, 0x31, 0xF1, 0x01, 0x01, 0x81, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00},                   "On call"},
  {ACT_POWEROFF,          HU_ADDR, UNKNOWN_ADDR, 13,  {0x00, 0x60, 0x31, 0xF1, 0x00, 0x00, 0x81, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00},                   "off?"},
  {ACT_PASSIVEOFF_0,      HU_ADDR, UNKNOWN_ADDR, 3,   {0x00, 0x11, 0x01},                                                                               "Passive: Weak"},
  {ACT_PASSIVEOFFRARE_0,  HU_ADDR, UNKNOWN_ADDR, 4,   {0x00, 0x11, 0x01, 0x20},                                                                         "Passive: Strong"},
  {ACT_PASSIVEON_0,       HU_ADDR, UNKNOWN_ADDR, 16,  {0x00, 0x74, 0x31, 0xF1, 0x80, 0x13, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x03, 0x03}, "On response"},
  {ACT_KEYTURN,           HU_ADDR, UNKNOWN_ADDR, 11,  {0x31, 0x62, 0x31, 0xF1, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},                               "Key turned"},
  {ACT_PRESSDISC,         HU_ADDR, UNKNOWN_ADDR, 4,   {0x00, 0x62, 0x31, 0x9F},                                                                         "DISC pressed"}
};

When I compile this, for some reason the Arduino IDE points at the first line and says "expected '}' before ';' token". If I replace the text like so:

#define HU_ADDR                 0x190;
#define ALL_AUDIO_ADDR          0x1FF;
#define MY_ADDR                 0x360;
#define UNKNOWN_ADDR            0xFFF;

typedef byte MessageID;
enum {
  ACT_UNKNOWN,
  ACT_POWERON,
  ACT_POWEROFF,
  ACT_PASSIVEOFF_0,
  ACT_PASSIVEOFFRARE_0,
  ACT_PASSIVEON_0,
  ACT_KEYTURN,
  ACT_PRESSDISC
};

struct MessageDef {
  MessageID ID;
  word MasterAddr;
  word SlaveAddr;
  byte PayloadLength;
  byte Payload[20];
  char Description[20];
};

MessageDef MessageTable[] = {
  {ACT_POWERON,           0x190, 0xFFF, 13,  {0x00, 0x60, 0x31, 0xF1, 0x01, 0x01, 0x81, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00},                   "On call"},
  {ACT_POWEROFF,          0x190, 0xFFF, 13,  {0x00, 0x60, 0x31, 0xF1, 0x00, 0x00, 0x81, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00},                   "off?"},
  {ACT_PASSIVEOFF_0,      0x190, 0xFFF, 3,   {0x00, 0x11, 0x01},                                                                               "Passive: Weak"},
  {ACT_PASSIVEOFFRARE_0,  0x190, 0xFFF, 4,   {0x00, 0x11, 0x01, 0x20},                                                                         "Passive: Strong"},
  {ACT_PASSIVEON_0,       0x190, 0xFFF, 16,  {0x00, 0x74, 0x31, 0xF1, 0x80, 0x13, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x03, 0x03}, "On response"},
  {ACT_KEYTURN,           0x190, 0xFFF, 11,  {0x31, 0x62, 0x31, 0xF1, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},                               "Key turned"},
  {ACT_PRESSDISC,         0x190, 0xFFF, 4,   {0x00, 0x62, 0x31, 0x9F},                                                                         "DISC pressed"}
};

Then it compiles with no complaints.
....what? Why? Aren't these functionally identical? Why does the compiler care if I use HU_ADDR instead of 0x190?


texts:
Recently i bought an "Serial 128X64 OLED LCD Display SSD1306".

I searched for available libraries and tried to find the best one to use before actually experimenting with this device.

I came across a hackaday article mentioning a "HIGH SPEED SSD1306 LIBRARY"

So that drew my attention and got on with it. This is the link to the afforementioned library for the Arduino DUE.

DayOLED_SSD1306

Right from the beginning i had some trouble with the wiring.
I wired 3.3 volts to input, GND, RES, DC, CS pins are wired according to the library example..
But the library contains no info on how to wire D0 and D1 pins. Since this OLED works both I2C and SPI, i thought maybe these two pins are ommited.

So i hooked it up, load up the example code and got compilation errors.

Here are the errors:

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp: In member function 'virtual void DayOLED_SSD1306::drawPixel(int16_t, int16_t, uint16_t)':

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp:114:14: error: 'swap' was not declared in this scope

     swap(x, y);

              ^

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp: In member function 'virtual void DayOLED_SSD1306::drawFastHLine(int16_t, int16_t, int16_t, uint16_t)':

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp:598:16: error: 'swap' was not declared in this scope

       swap(x, y);

                ^

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp: In member function 'virtual void DayOLED_SSD1306::drawFastVLine(int16_t, int16_t, int16_t, uint16_t)':

C:\Users\User1\Documents\Arduino\libraries\DayOLED_SSD1306-master\DayOLED_SSD1306.cpp:666:16: error: 'swap' was not declared in this scope

       swap(x, y);

Anybody got a clue what is going on with the swap() function?
Maybe it's deprecated?

Anyone has managed to get this library working?
Or maybe has managed to get this Display working even with another library?


texts:
I have a short program which should receive data, use this data to turn on/off an LED, and send data when a button is pressed. It is deployed on a Digispark board. The button is connected to INT0 port (PB2). The interrupt works, but data is not send. Receiving data works fine.

What am I missing here?

#include <SoftSerial.h>

#define RxD 1
#define TxD 0
#define out 3
#define btn 2
#define testled 4

SoftSerial blueToothSerial(RxD, TxD); //RX, TX
volatile int buttonState = 0;

void setup() {
  pinMode(out, OUTPUT);
  pinMode(btn, INPUT);
  pinMode(testled, OUTPUT);
  setupBlueToothConnection();
  digitalWrite(out, HIGH);
  digitalWrite(testled, HIGH);
  attachInterrupt(0, intrpt, CHANGE);
}

void loop() {
  char newVal;
  if(blueToothSerial.available()){
    newVal = blueToothSerial.read();
    if (newVal == '1') {
      digitalWrite(out, HIGH);
    } else {
      digitalWrite(out, LOW);
    }
  }
}

void intrpt() {
  buttonState = digitalRead(btn);
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(testled, HIGH);
  } else {
    // turn LED off:
    digitalWrite(testled, LOW);
    blueToothSerial.println("0");
  }
}

void setupBlueToothConnection() {
  blueToothSerial.begin(9600);
  blueToothSerial.print("\r\n+STWMOD=0\r\n");
  blueToothSerial.print("\r\n+STNA=HC-05\r\n");
  blueToothSerial.print("\r\n+STOAUT=1\r\n");
  blueToothSerial.print("\r\n+STAUTO=0\r\n");
  delay(2000);
  blueToothSerial.print("bluetooth connected!\n");
  delay(2000);
  blueToothSerial.flush();
}

EDIT

Serial data is sent fine. The above code works. On Windows I can see the data are coming, but not on OS X.


texts:
Arduino Uno is connected with PC. In 100 ms intervals PC sends command and then Arduino changes outputs (they control relays through transoptors) and sends an answer (sensors data). After some time (eg. after 100 cycles or after 1000 cycles) Arduino restarts and then I lose connection with it.
Code:

//#define DEBUG

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

const byte OUTPUT_ARRAY_SIZE = 8;
const byte INPUT_ANALOG_ARRAY_SIZE = 4;

//pins
const byte pinPresse[INPUT_ANALOG_ARRAY_SIZE] = {A0, A1, A2, A3}; //sensors 0-5V
const byte pinTemp[1] = {13}; //temperature sensor/ 1-Wire
const byte pinOut[OUTPUT_ARRAY_SIZE] = {3, 4, 5, 6, 7, 8, 9, 10}; //8 outputs
const byte pinLevel[1] = {12}; //sensor 0-1
const byte pinSecu = 11; //security pin, turns a motor off

//sensors data
unsigned int inputPresse[4] = {0, 0, 0, 0}; //0...1023: 0...400bar
unsigned int inputTemp[1] = {0}; //oC
unsigned int inputLevel[1] = {0}; //LOW/HIGH

//data from pc
bool output[8] =       {1, 1, 1, 1, 1, 1, 1, 1};
bool outputPrev[8] =   {1, 1, 1, 1, 1, 1, 1, 1};

unsigned long currentMillis=0;
bool flag1 = false;

//temperature sensor/ 1 Wire DS
OneWire oneWire(pinTemp[0]);
DallasTemperature tempSensor(&oneWire);

void setup() {
  //pull-up
  for (int i = 0; i < OUTPUT_ARRAY_SIZE; i++) {
    digitalWrite(pinOut[i], HIGH);
  }
  digitalWrite(pinSecu, HIGH);
  Serial.begin(115200);
  for (int i = 0; i < OUTPUT_ARRAY_SIZE; i++) {
    pinMode(pinOut[i], OUTPUT);
    digitalWrite(pinOut[i], HIGH);
  }
  pinMode(pinSecu, OUTPUT);
  digitalWrite(pinSecu, LOW);
  for (int i = 0; i < INPUT_ANALOG_ARRAY_SIZE; i++) {
    pinMode(pinPresse[i], INPUT);
  }
  pinMode(pinLevel[0], INPUT);
  tempSensor.begin();
  delay(500);
  digitalWrite(pinSecu, HIGH);
  while(!Serial){
    ;
  }
  Serial.print("READY@");
}

void loop() {
  if( flag1 && millis() - currentMillis > 3000 ) {
      error("0RESET@");
  }

  if (Serial.available()) {
    currentMillis = millis();
    readSerial();
    readSensors();
    printResults();
    setOutputs();
    flag1 = true;
#ifdef DEBUG
    Serial.print("Elapsed [ms]: "); Serial.println(millis()-currentMillis);
#endif
  }
}

void readSerial() {
  String inputString = "";
  byte i = 0;
  char inChar;
  while (i < OUTPUT_ARRAY_SIZE) {
    while (!Serial.available()) {
        if( flag1 && millis() - currentMillis > 3000 ) {
          error("1RESET@");
         }
    }
    inChar = (char)Serial.read();
    if (inChar == 'Q'){
      error((char*)"2RESET@");
    }
    else if (inChar == ';') {
      setValue(&i, &inputString);
      inputString = "";
      i++;
    }
    else inputString += inChar;
  }
}

void setValue(const byte *i, const String *inputString) {
  output[*i] = inputString->toInt();
}

void readSensors() {
    //0-1 sensor
    inputLevel[0] = digitalRead(pinLevel[0]);
    //0-5v sensors
    for (int i = 0; i < INPUT_ANALOG_ARRAY_SIZE; i++) {
      pinMode(pinPresse[i], INPUT);
      inputPresse[i] = analogRead(pinPresse[i]);
    }
    //temperature/ 1-Wire
    if(flag1) {
      inputTemp[0] = tempSensor.getTempCByIndex(0);
    }
    tempSensor.requestTemperatures();
}

void printResults() {
    for (int i = 0; i < INPUT_ANALOG_ARRAY_SIZE; i++) {
      Serial.print(inputPresse[i]);
      Serial.print(';');
    }
    Serial.print(inputTemp[0]);
    Serial.print(';');
    Serial.print(inputLevel[0]);
    Serial.print(';');
    Serial.print("@");
}

void setOutputs() {
  if (output[0] == LOW || outputPrev[0] == LOW) {
    digitalWrite(pinSecu, LOW);
  }
  else {
    digitalWrite(pinSecu, HIGH);
  }
  for (int i = 0; i < OUTPUT_ARRAY_SIZE; i++) {
    if (output[i] != outputPrev[i]) {
      digitalWrite(pinOut[i], output[i]);
    }
    outputPrev[i] = output[i];
  }
}

void error(char *code) {
  Serial.print(code);
  Serial.flush();
  softwareReset();
}

void softwareReset() {
  asm volatile ("jmp 0");
}

I suspect memory leakage. But where?


texts: char to String conversion in Arduino program

texts:
I have started learning about Arduino and am well versed in Java and Python. In an Arduino program, I need a character input via Serial to be stored in a String variable. From my previous programming experience, I knew that a code like the one below would give an error as char can't be converted into String like this.

void loop() {
  if(Serial.available()) {
     String s=(char)Serial.read();
  }
}

As expected, the above code gives an error on compiling. But when I first defined s and then assigned its value in a separate step in void loop(), I got no error.

void loop() {
  if(Serial.available()) {
     String s;
     s=(char)Serial.read();
  }
}

The above code yields no error despite the fact that it is almost similar to the first code. What I suspect is that it has something to do with String being a class. Can one tell what is going on?


texts: High power consumption of ATmega32u4 when connected to iOS device

texts:
Just wondering if I can get some help here.

I have a simple scheme of MIDI controller based on ATmega32u4:
ATmega32U4 with TXLED and RXLED as output pins and USB functionality

And my team wants me to make this device Android/iOS compatible (because our Arduino prototypes worked fine with iPads and even iPhones).

I am experiencing a high power consumption of ATmega32u4 when connected to iOS devices. When we connect our device to iOS we get the following message:

Meanwhile, when I make almost the same scheme and run the identical sketch on ATmega328 chip it works just fine!

I tried running all the stuff on Arduino boards, and the result is stable:

works on Arduino Uno and Arduino Mega (based on ATmega328 chip);
doesn't work on Arduino Micro and some of its Chinese clones like Arduino Micro Pro (based on ATmega32u4).

We've found a small trick/workaround: connect even two our ATmega32u4 devices through an active USB hub with additional power supply to one iPad, and they both work perfectly, then we switch off the additional power on the hub, and devices continue to work fine using the power from this single iPad without any messages about high power consumption.
This case leads me to the thought that high consumption of ATmega32u4 chip appears only on the device initialisation stage.

Is there a way to solve this?

Thanks in advance.


texts:
I have following code:

MyApp.ino:

#include "DfRobotLcdShield.h"

void setup() {
}

void loop() {
}

DfRobotLcdShield.h:

#include <LiquidCrystal.h>

When I try to compile, I'm getting the error:

In file included from MyApp.ino:1:0:
c:\temp\build5856181074637812172.tmp\DfRobotLcdShield.h:4:27: fatal error: LiquidCrystal.h: No such file or directory
 #include <LiquidCrystal.h>
                           ^
compilation terminated.
Error compiling.

When I add

#include <LiquidCrystal.h>

directly to the .ino file, it works. I'm using the latest Arduino-IDE 1.6.3.