texts: WS2812B Led Digital Panel Matrix Flexible Screen 8*8. Some LEDs that are not supposed to, switch on

texts:
My project is composed of an ESP32, a level converter and two WS2812B Led Digital Panel Matrix Flexible Screen 8*8 (from Aliexpress) interconnected with the provided cable. My objective is to show a score, no scrolling or any other animation.
The main functionality works ok, I can display any decimal number between 00 to 99 (one digit in each 8x8 panel).
My problem is that apart from the digits printed, some not so aleatory LEDs switch on, not necessarily on the same color as the intended number, nor on the selected luminosity. Changing the number changes this undesirable pattern that seems to repeat for the same number on the same 8x8 matrix. Problem patters does not follow a specific 8x8 matrix, the problem does not seem to be in the hardware.
The level converter converts the ESP32 3.3v to 5v required by the Matrix but even before I connected the level converter the problem was the same.
The code I am using is as below:
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            14

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      128

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

int delayval = 10; // delay for half a second

void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  pixels.clear();
  pixels.setBrightness(1);

  boolean N0[8][8] PROGMEM = {{0,0,1,1,1,1,0,0},{0,1,1,1,1,1,1,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,1,1,1,1,1,1,0},{0,0,1,1,1,1,0,0}};
  boolean N1[8][8] PROGMEM = {{0,0,0,1,1,0,0,0},{0,0,1,1,1,0,0,0},{0,0,0,1,1,0,0,0},{0,0,0,1,1,0,0,0},{0,0,0,1,1,0,0,0},{0,0,0,1,1,0,0,0},{0,1,1,1,1,1,1,0},{0,1,1,1,1,1,1,0}};
  boolean N2[8][8] PROGMEM = {{0,0,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,0,0,0},{0,0,1,1,1,1,0,0},{0,0,0,0,0,1,1,0},{0,1,1,0,0,0,1,0},{0,1,1,1,1,1,1,0},{0,1,1,1,1,1,1,0}};
  boolean N3[8][8] PROGMEM = {{0,0,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,0,0,0},{0,0,1,1,1,1,0,0},{0,0,1,1,1,1,0,0},{0,0,0,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,0,0}};
  boolean N4[8][8] PROGMEM = {{0,0,1,1,1,0,0,0},{0,0,1,1,1,1,0,0},{0,0,1,1,0,1,1,0},{1,1,0,0,1,1,0,0},{0,1,1,1,1,1,1,1},{0,0,0,0,1,1,0,0},{0,1,1,1,1,0,0,0},{0,0,0,1,1,1,1,0}};
  boolean N5[8][8] PROGMEM = {{0,0,1,1,1,1,1,0},{0,1,1,1,1,1,1,0},{0,0,0,0,0,1,1,0},{0,1,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,0,0,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,0,0}};
  boolean N6[8][8] PROGMEM = {{0,0,1,1,1,0,0,0},{0,0,1,1,0,0,1,0},{0,0,0,0,0,1,1,0},{0,1,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,0,0},{0,0,0,1,1,0,0,0}};
  boolean N7[8][8] PROGMEM = {{0,1,1,1,1,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,0,0,0,0},{0,0,0,1,1,0,0,0},{0,0,0,0,1,1,0,0},{0,0,1,1,0,0,0,0},{0,0,0,0,1,1,0,0},{0,0,1,1,0,0,0,0}};
  boolean N8[8][8] PROGMEM = {{0,0,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,0,0}};
  boolean N9[8][8] PROGMEM = {{0,0,1,1,1,1,0,0},{0,1,1,0,0,1,1,0},{0,1,1,0,0,1,1,0},{0,0,1,1,1,1,1,0},{0,1,1,0,0,0,0,0},{0,0,0,0,0,1,1,0},{0,1,1,1,0,0,1,0},{0,0,1,1,1,1,0,0}};

  int counter = 0;
  for(int line=0;line<8;line++){
    for(int column=0;column<8;column++){
      if(N2[line][column]==1){
        pixels.setPixelColor(counter, pixels.Color(0,255,0));
        pixels.show();
        delay(delayval);
      }

      if(N1[line][column]==1){
        pixels.setPixelColor(counter+64, pixels.Color(255,33,255));
        pixels.show();
        delay(delayval);
      }

      counter++;
    }
  }
  while(1){};
}

This is a non optimized code for testing purposes only.
What am I doing wrong?


texts:
I'm new here and to the aurdino.
I'm building a 3D printed robotic arm controlled by a EMG sensor. I purchased a V3 EMG board and leads on Aliexpress. Here's a list of the things I've purchase for this project

Arduino Uno

EMG sensor

2 MG996R servos 7.2 max voltage I know not to power these through the
board.

X4 AA battery pack with male barrel input lead to power the arduino.
Wiring, header pins and cables.

I don't have any breadboards BTW.
The functionality is basic, servos on pulleys and strings, I'm looking for one servo to control the open close hand function, and the other is to open and close the index and thumb for a pinch function to pick up smaller objects.
I need to know the following,
Option to power servo, EMG sensor and arduino from single power source or two batteries and how to wire these a simple picture or schematic would be great.
What code can I quickly copy and paste to perform the functions I mentioned.
I do have some very basic DC electronic experience.
I just don't want to damage my components by just experimenting as it takes weeks to replace them otherwise.  Thanks.


texts: Micro + restricted user Win XP = avrdude: butterfly_recv(): programmer is not responding

texts:
I have a Micro (original) and I am (trying to) using it under windows XP.
I was successful in installing its drivers (by swithching to ad Admin account) and uploading sketches to it, no problem. Even when I switched to my limited account, I was able to upload new sketches without error.

But...

Everytime I reboot my computer, as soon as I connect the Micro to the usb port, I get a "New hardware found" popup window from Windows. If I ignore the window I do not see the board in Arduino's IDE. If I choose to install the drivers (by loggin in that window as an admin and then fetching them from the Arduino folder) I end up seeing the board, selecting the COM port and then when compiling, getting the dreadful

avrdude: butterfly_recv(): programmer is not responding

If I press the reset button I get the "Found new hardware window" again and the cycle repeats.

To make it work again I have to log off, log in in an admin user account, and install the friggin drivers from there. After that, if I log off and enter into my limited account, I can see board, port and I can finally upload my sketches (or at least that was the case the last two times).

Is it supposed to work this way?
Can I make it work like a Nano: install drivers only once and then just use the board?

PS
I have to mention that I happen to have 5 compatible Nanos with a ch340G chipset that work like a charm (and cost one tenth of the Micro). I installed the drivers ONCE and forgot about that.
I also happen to have a keyboard and a mouse, and they do not require me to install their drivers every time I plug the USB connector off.
Why is the Micro misbehaving this way?


texts: Debugging a RadioShack Arduino motor/sensor shield

texts:
I bought a cheap "Make" kit at RadioShack, which includes some sort of proprietary Arduino Uno compatible motor/sensor shield. Naturally, the documentation is pretty bad. The documentation and Arduino code for the kit is here:

https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit

It includes a circuit schematic (2770168-CorePCB_schematic.pdf), but I'm still having trouble mapping the pins to the Arduino's pins. Can anyone help me make sense of this?

What I've made out so far is the shield's screw terminals appear to be connected to quadruple h-bridges. However, there are several other pin headers that I can't quite make out. I think it also directly exposes 4 of the Uno's ADC pins and 4 DIO pins. There are four pins for dual IR line sensors, but there's a lot of circuitry between these and any Arduino pins. Almost everything feeds into a DC6688F2SCN chip, but I can't find a datasheet anywhere, so I have no idea what it does.

The manual says jumpers on J16 need to be removed in order to connect to the Uno over USB, so it looks like I can't use the shield with the board and debug via USB at the same time. Is this board worth investigating or should I trash it?


texts:
I am using the SW6106 powerbank IC as an I2C but no matter what I have tried I couldn't read something other than "FF".

Datasheet for the IC.

Timing diagram for reading data:

Timing diagram for writing data:

The code I use:

#include <Wire.h>

byte ADDRESS_SLAVE = 0x3C;
byte REGISTER_XY = 0xB0;
byte READ_LENGTH = 1;

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

  Wire.begin();
  Wire.setClock(400000); // set I2C 'full-speed'

  Wire.beginTransmission(ADDRESS_SLAVE);
  Wire.write(REGISTER_XY);  // set register for read
  Wire.endTransmission();
}

void loop() {
   Wire.requestFrom(ADDRESS_SLAVE,READ_LENGTH);
   byte buff[READ_LENGTH];
   Wire.readBytes(buff, READ_LENGTH);
   for (int i = 0; i < READ_LENGTH; i++) {
     Serial.println(buff[i], HEX);
   }
   Serial.println();
   delay(1000);
}

Serial monitor output:

I really couldn't understand anything from that timing diagram and couldn't read anything from the IC. I'd appreciate any help.

Edit:
I edited the code a little bit to see what Wire.endTransmission(); returns.

#include <Wire.h>

byte ADDRESS_SLAVE = 0x3C;
byte REGISTER_XY = 0xB0;
byte READ_LENGTH = 1;

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

  Wire.begin();
  Wire.setClock(400000); // set I2C 'full-speed'
}

void loop() {
  Wire.beginTransmission(ADDRESS_SLAVE);
  Wire.write(REGISTER_XY);  // set register for read
  int x = Wire.endTransmission();
  Serial.println(x, DEC);
  delay(200);
}

And it retruns the following:

I really don't know where I am doing wrong.


texts: RN-52 - Bluetooth Audio Module two way communication with Android

texts:
Im planning a project that involves sending data from a door phone to an android phone and vice versa using the RN-52 chip from sparkfun. Because of the nature of the project it is necessary to be able to send and receive audio simultaneously, is this possible? I've done some googling and it seems to me impossible because of sink/source, since you cant have both at the same time (using A2DP).

Can this be done with another profile I don't know of?

Even if that were to work, can the chip handle two way communication?

Is this project feasible with BT, or should I be looking at WIFI-communication instead?
Ultimately it would be nice to be able to use BT because of costs.

Edit: Can I use bluetooth hands free profile? This profile is (AFAIK) intended to send audio to and from a phone (amongst other functionality). The chip does support HFP/HSP, can this work?


texts: All the differences between Arduinos: Pro Mini & Pro Micro

texts:
I'd like to know the differences between these two boards: Arduino Pro Mini and Arduino Pro Micro.

Even if I've read this and this related post, it is not clear enough. I've always used the Arduino Uno or Leonardo and I'm a little bit scared of using these compact miniaturised boards.

I have seen so far those differences:

The Micro doesn’t need the separate FTDI, while the Mini does
The Micro takes more time to boot up due to USB device (keyboard/mouse) emulation (is more like a Leonardo than an Uno)
They both have 5 V and 3.3 V versions
The Mini has 2 more digital IO and 2 more analog Inputs (1 more PWM)
The pinout is the same (a shield designed for the Pro Mini is OK also with Pro Micro)
Micro is more expensive (IF you don't have already an FTDI cable).

So, what I care about most is the boot up time (because it could make debug harder) but other than that.. if I don't need the 2 more Digital IO and the 2 more Analog Inputs.. why buy one over the other?

And some more question: can I use the Mini boot loader inside the Micro to avoid the boot up time (if I do not need the keyboard/mouse emulation)?

Is the power consumption the same? Can I use the same battery?

Sorry if this is a silly question but I'm little bit confused.


texts: Sketch with multiple classes (.h and .cpp) - how to interconnect classes

texts:
I wanted to move most functionality of my sketch into different classes, to keep things better organized. One class worked just fine, but when I had to use multiple classes and pass information between then things stopped working.

I have two classes, my main Remote class, and my RemoteDisplay class. The main class takes care of fx, measuring battery voltage and I want to display this through the RemoteDisplay class. To do so I initiate the Display class with a pointer to the Remote class, so I can access the voltage function. This, however, doesn't work, even though I forward declare the Remote class in the Display class.

Remote.ino

#include "Remote.h"

Remote Remote;

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

void loop() {
  Remote.display.showBattery();
}

Remote.h

#include "RemoteDisplay.h"
class Remote
{

public:

  RemoteDisplay display;

  Remote( void );

  float voltage;

};

Remote.cpp

#include "Remote.h"

Remote::Remote(void)
{
  display.initiate(this);
}

RemoteDisplay.h

class Remote;

class RemoteDisplay
{

public:

  RemoteDisplay(void);

  void initiate( Remote * _pointer );

  void showBattery( void );

private:

  /* Reference to the remote class */
  Remote * pointer;
};

RemoteDisplay.cpp

#include "RemoteDisplay.h"

void RemoteDisplay::initiate( Remote * _pointer )
{
  pointer = _pointer;
}

void RemoteDisplay::showBattery( void )
{
  Serial.println( pointer->voltage );
}

I get the errors:

error: invalid use of incomplete type 'class Remote'
showBattery( pointer->voltage() );

note: forward declaration of 'class Remote'
class Remote;

Why is it so? Any help is much appreciated.


texts: How can I stop SoftwareSerial from receiving data and re-enable it at some other point?

texts:
My project involves and RFID reader connected to an Arduino Pro Mini (5V, 16MHz) and an Adafruit CC3000 breakout WiFi chip. The device reads RFID tags and sends them to my web service. I am using Software Serial to read the RFID device data.

After I scan something, the Arduino tries to send the value that was read to the web service. This obviously causes a delay and the program only continues execution (i.e. next iteration of the loop() function) after the data has been sent.

My problem is simple. While the value is being sent, the serial buffer is can still accept scans from the RFID reader and on subsequent iterations, because there is data in the buffer the device attempts to send data again.

My question is how can I stop the software serial port from receiving data while I am trying to send data to the web service? Then when the data is sent successfully, how can I re-enable the software serial port from accepting data?


texts: Why does Arduino Due Native Port change serial ports after every reset? (Linux)

texts:
Previously I had my Due connected via Programming Port for weeks, and it never changed serial ports after pressing the reset button. Recently I switched to having it connected via the Native Port instead, and was surprised to see that it changes port numbers every time I press the reset button.

For example if it was on ttyATM1 beforehand, after pressing reset it'll be on ttyATM2 instead. It changes numbers like this after every reset. Is this normal behavior?

I have a python script sending serial data to the Due, and I have to change the port number in the python code every time the Due changes ports.


texts: My arduino won't show up in Device Manager in any way, neither in unknown devices nor in COM port.

texts: I have a brand new arduino(original), and it is not showing up in Device manager or anywhere else. Even the computer doesn't Prompt anything. I am using Windows 7 32 bit.


texts: Possibilities and limitations for onboard data acquisition

texts:
I could define myself as a "nerdy cyclist", so while my interest in Arduino is steadily growing (have not bought or used yet), my first idea for a project would be:

Instrument a bicycle with some sensors (accelerometer, reed switch, etc) and an Arduino;
Ride long distances (that is, four hours or more, sometimes non-stop);
When at home, download some sort of "data file" (from SD card, I think);
Analyze results with Python/Matlab/whatever.

So my questions:

Is any model of Arduino suitable for this purpose?
What is the expected sample rate vs number of channels? 100Hz per channel would be excellent for my purposes, for example.
Can I keep incrementally saving to SD "forever" (that is, while battery and card space are available)?


texts: Is it possible to obtain %0.05 duty cycle at 1hz in arduino?(a 500us square pulse at 1 sec period)

texts: I have a system which requires me to obtain different duty cycles at different frequencies. But using the analogWrite() does not allow me to obtain a value lower than 1/255 duty cycle. I need to obtain lower duty cycle values for 1Hz


texts: So at my school we are preapering for a competition. They asked me to do the technical side of it. And I accepted... I was thinking of using an arduino as a usb device for the buttons. I am going to use the serial port for this. But I can't think of a way to do it in the way I want. I want to recieve the button presses fair and well. But I also want to control the lights for the buttons, from my computer. I am using Serial.printLn() to send the serial data to the computer. But how can I send serial data to the arduino without delaying other things (What happens when someone presses a button while I am sending a command?)? Thanks in advance!


texts: WiFiEsp not working on Software Serial, working fine on Hardware Serial

texts:
What I want to achieve

I want to connect to my wifi network using Arduino UNO and ESP8266 using WiFiEsp.h library over `SofwareSerial, since UNO doesn't have additional H/W serial.

What I am able to do already

I have a Mega, which I am able to connect to my wifi network(using ESP8266) using its hardware serial (RX1 and TX1), I've been following up this code example. Though it has code to deal with both cases( when H/W serial is present and when it's not) It doesn't seems to work on Software Serial on UNO, works perfectly on MEGA's H/W serial. I have made a little change in code as to set the Serial1 baudrate to 115200 as this seems to be supported by my ESP's firmware (1.54)

ERROR

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module

What I've tried

Tried running Software Serial on MEGA on pins 10,11 and 6,7 (Rx,Tx) (Same Error).
Swapping Rx,Tx :P
Changing pins to 10,11 instead of 6,7 on UNO
Switching Baudrate to 9600 on UNO (no help)

Yeah, Not much, but it seems so straight forward I can't figure out what could go wrong. It seems like it can't communicate to ESP, but why?


texts: [SOLVED]how to send command to Gsm module from Arduino via serial port

texts:
Am using SIM7600X 4G HAT module (GSM) and Arduino Uno
after I start the module and Arduino, I receive data from Gsm module but I can't send any command to it.
On my Arduino board when I get data RX led flashing, and when I send command TX led flashing.
#include <SoftwareSerial.h>
SoftwareSerial myserial(3, 4); // gsm_TX, gsm_RX

void setup(){
  myserial.begin(9600); //Initialize GSM serial port
  Serial.begin(9600); //Initialize Arduino default serial port
}

void loop(){
  while(1){
    while (myserial.available()) {
      //Serial received data, output via mySerial.
      Serial.write(myserial.read());
    }
    while(Serial.available()) {
      //myserial received data, output it via Serial.
      myserial.write(Serial.read());
    }
  }
}

As the picture I send "AT" command or any command it no response.
it show only module start up command.

My circuit


texts: I am working on pcb design with nrf24l01 smd. I have read somewhere that nrf24l01 module has problem while communication when it is placed with its antenna within the pcb. I want my module to be within the pcb as much as possible to save some space. I will be making the pcb at home and will be placing atmega 328p smd on the opposite layer. Should I fill the opposite layer with ground pad?


texts: How can I loop my code? For example after 30 minutes?

texts:
So I have this code which records the temperature and humidity using a DHT22 sensor. After it get's the values it then sends it to a webpage using PHP $_GET method, where that gets imported into a DB and emails (using PHP). But this only happens when I upload the code to my ESP8266; how can I know build in a loop function that it sends it every 30 mins or given time?

#include <ESP8266WiFi.h>
#include "DHT.h"

const char* ssid     = "bbox2";      // SSID of local network
const char* password = "azerty";   // Password on network

WiFiClient client;
char servername[]="lucasdebelder.be";  // remote server we will connect to
String result;

float temperature;
float humidity;

#define DHTPIN 14

#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  dht.begin();
  delay(2000);
  Serial.begin(115200);
  Serial.println("Connecting");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
  }
  Serial.println("Connected");
  delay(1000);
  readSensor();
  String temperatureString = String(temperature,1);
  String humidityString = String(humidity,1);
  sendDataToServer(temperatureString,humidityString);
}

void loop() {

}

void sendDataToServer(String temperature, String humidity)
{
  if (client.connect(servername, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /send_temperature.php?temperature="+temperature+"&humidity="+humidity+" HTTP/1.1"); //Send data
    client.println("Host: lucasdebelder.be");
    client.println("Connection: close");  //close 1.1 persistent connection
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

 while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
      result = result+c;
    }

  client.stop(); //stop client
  Serial.println(result);

}

void readSensor()
{

  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  Serial.println("Temperature:");
  Serial.println(temperature);
  Serial.println("Humidity:");
  Serial.println(humidity);

}


texts:
I'm reading a text file saved on my ESP8266 device (using LittleFS).
while (myFile.available()) {
        Serial.write(myFile.read());
    }

My goal is to save file content ( each line ) to a String / char array.
myFile.read() returns a binary - and I'm looking for a quick and elegant way to do so ( as in Serial.write which converts it to text ).
Guy


texts: What do you do when you finish a project?

texts:
I have just about completed my first Arduino project using an Arduino Uno board, but is that what I use inside the finished device? I figured I’d keep the Uno for future projects and have something else controlling the finished product. Are you supposed to just keep purchasing the Uno board every project?
I just got it a couple of days ago so I’m not very familiar with any of it. If that is the case do you use the batter for power since I can’t have it connected to my laptop once it’s done.


texts: SRF-02 UART, transmitting from one address to another

texts:
So I just starting playing around with UART and SoftwareSerial while playing with these SRF-02 Sensors - http://www.robot-electronics.co.uk/htm/srf02techSer.htm

I need help getting one to read to the other, I have been using this, makes sense logically, but doesn't work. I was thinking I'm missing something important for the synchronization of both sensors to one another.

Code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX

void SendCmd(unsigned char address,unsigned char cmd)
{
  mySerial.write(address);//set the address of SRF02(factory default is 0)
  delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit
  mySerial.write(cmd);//send the command to SRF02
  delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit
}
void setup(void)
{
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("SRF02 TEST!");
}
void loop(void)
{
  unsigned int reading;
  SendCmd(0x00,0x5C);//Transmit 8 cycle 40khz pulse from adress 0x00
  delay(70);//time for SRF02 to measure the range
  SendCmd(0x02,0x5E);//Get Range, returns two bytes (high byte first) from the most recent ranging to adress 0x02
   delay(10);//wait for some time,let the Arduino receive 2 bytes data from the TX pin of SRF02
  if(mySerial.available()>=2)//if two bytes were received
  {
    reading = mySerial.read()<<8;//receive high byte (overwrites previous reading) and shift high byte to be high 8 bits
    reading |= mySerial.read(); // receive low byte as lower 8 bits
    Serial.print(reading); // print the reading
    Serial.println("cm");
  }
  delay(250); // wait a bit since people have to read the output :)
}


texts:
I received the error bellow when I tried to upload any sketch on my MKR100. I uninstall/reinstall de COM drivers and the arduino IDE and nothing solve the problem. I bought another MKR1000 thinking the ahrdare was the problem , but I got the same errors.
Also If I try to open the serial monitor I got :
Error opening serial port 'ÇOM12'(Port not found)
Can someone help me?
Sketch uses 47444 bytes (18%) of program storage space. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port COM12
processing.app.debug.RunnerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:152)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
at processing.app.SketchController.upload(SketchController.java:732)
at processing.app.SketchController.exportApplet(SketchController.java:703)
at processing.app.Editor$UploadHandler.run(Editor.java:2055)
at java.lang.Thread.run(Thread.java:748)
Caused by: processing.app.SerialException: Error touching serial port 'COM12'.
at processing.app.Serial.touchForCDCReset(Serial.java:107)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:136)
... 5 more
Caused by: jssc.SerialPortException: Port name - COM12; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.touchForCDCReset(Serial.java:101)
... 6 more


texts:
I'm trying to control the speed of a DC motor using PWM. Here is my code so far:

int motor = 9;
int fadeValue = 5;

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

void loop() {
  for (int fadeValue = 5 ; fadeValue <= 245; fadeValue += 10) {
    analogWrite(motor, fadeValue);
    delay(100);
  if (fadeValue==245) {
    fadeValue=255;
    break;
  }
}

I want the motor to slowly increase it speed then stay high. However, the loop keep repeating.

Thanks in advance guys.


texts:
I got an Arduino kit from my dad.
But inside this box is a thing, maybe a sensor. But I can't find what it is.
Anyone recognize this 'thing' on the picture?


texts: I'm trying to get audio data from an ADC connected to an Arduino into a host PC.  I've done some digging and found LUFA, which I think Arduino uses under the hood. Is it possible to use the Arduino as a USB device, and if so, are there any examples?  Thanks!


texts:
I am trying to read the humidity and temperature using a DHT11 temperature sensor for an Arduino UNO using the DHT.h library. I have my code below:

#include <DHT.h>
#define dataPin 4
dht DHT;

void setup() {
  Serial.begin(9600)

}

void loop() {
  int readData = DHT.read11(dataPin);
  float t = DHT.temperature;
  float h = DHT.humidity;
  Serial.println("Temperature: ")
  Serial.print(t)
  Serial.print(" ºC")
  Serial.println("Humidity: ")
  Serial.print(h)
  Serial.print(" % ")
  delay(2000)
}

When compiling the program, it gives me an error:

fatal error: DHT.h: No such file or directory

I have also tried with lower case letters, but it will not work. Is there any reason why? Do I have to install it? I have tried to search for the library in the Arduino app Sketch - Include Library - Manage Libraries, but the library is not there.


texts: Programming an Arduino using Python, rather than C/C++

texts: I am not very skilled with the C Language and I was wondering if there is a way in which python could be used to program an Arduino. This would most likely require a different IDE in order to be able to debug the scripts them self.


texts:
I have  written a trivial code in Arduino IDE but while verifying its returning a error displaying "i was not declared in scope 12'

  int pinMatrix[i][j]= {{2,3,4},{5,6,7},{7,8,9}};
void setup() {
for (i=0;i<3;i++){
  for(j=0;j<3;j++){
    pinMode(pinMatrix[i][j],OUTPUT);
  }
}

}

void loop() {
for(i=0;i<3;i++){
  for(j=0;j<3;j++){
      digitalWrite(pinMatrix[i][j],HIGH);
      delay(1000);
      digitalWrite(pinMatrix[i][j],LOW);
  }

  }

}


texts: Is it possible to program Arduino in transpiled JavaScript?

texts:
Coming from JS, I find it very difficult to program Arduino in C++ (not even knowing which version or what features are supported), being bound to the loop and delay, not being able to (easily) use anonymous functions in parameters or async code.

I know JS isn't natively supported by Arduino, but I know languages can be transpiled.

I have seen many solutions, so just to pick few:
JohnnyFive J5, which runs via cable on a host PC,
NectarJS with their arduino-uno target,
or andrei-markeev/ts2c which converts ES3 to C89.

Each of them come with their own limitations and it's very difficult to find the right without prior experience with IoT. Did anyone walk this path already and found a viable solution?


texts: How can I calculate approximate cycles per second from pulsed pin on Arduino MKR Zero?

texts:
The relevant tech specs for a MKR Zero are:
    32.768 kHz (RTC*), 48 MHz

*Real-Time Clock

What I'm curious about is how I might do an approximate calculation of cycles per second from operations.

I'm running the following (extremely simplified) code :

int pin3 = 3;
void setup() {
  //set digital pin pin3 as output

  pinMode(pin3,OUTPUT);
}

void loop(){
  digitalWrite(pin3,HIGH);//set pin pin3 to +5V
  delay(100);//wait 100ms
  digitalWrite(pin3,LOW);//set pin pin3 to 0V
  delay(100);//wait 100ms
}

Now I'm curious how many cycles per second (approximately) that might account for.

The Equation?

What would the equation be to calculate that?

Not Processor Op Codes

Is this even possible to approximate?  I understand it will be difficult because those lines of code do not equal the actual op codes and don't exactly break down to specific cpu cycles or whatever.

Would it be something like:

48,000,000 (48MHz) / 200 (millisecond pause) = 240KHz?

Or would I use the real-time clock speed?

32768 / 200 = @163Hz

Or something completely different?
I'm trying to better understand how I might create a very simple frequency generator and I know that depending upon the chip speed the code will vary.


texts: Removing and using programmed Atmega 328 of Arduino UNO on customised PCB

texts: I am a newbie. I would like to kno whether the original Atmega328 on Arduino Uno, programmed with my own sketch, can be removed from an Arduino Uno board and used  on my customised PCB?


texts:
That seems to be a bit stupid to myself but I can't figure out to get to know when my button is pushed (closed) or released (open).

You must know that this not just a simple push button. Actually it is more of a complex button with multiples output (Y, G, 0V, COM, NO, NC, HORM, 12V).
With a multimeter i've been able to locale witch output are closed when the button is pressed. These are HORM (that is the name for two outputs -?!-) and on the other side COM and NO.

I've tried to plug that to my arduino Mega, on PIN 7, and getting the value with Digital.Read. Tho when i try to display it on the Serial, it doesn't work and return an error. (It did the same for HORM and COM/NO)

I also noticed something strange. When the button is pressed, Arduino seems to notice it because my "ON" led turns off and then turns back on. Like if the arduino was crashing. The 13th pin LED stay HIGH after the arduino goes back on.

Please, have a look at my code.

int ledPin = 13; // choose the pin for the LED
int inPin = 7;   // choose the input pin (for a pushbutton)
int val = 0;     // variable for reading the pin status

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);    // declare pushbutton as input
}

void loop(){
  val = digitalRead(inPin);  // read input value
  Serial.write(val);
  if (val == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH);  // turn LED ON
  }

  delay(1000);
}

Do you guys have any advice ?

Thank you very much in advance.

Also please have a look at the circuit. The only difference is that instead of having this kind of simple pushbutton, i've got my NO and COM plugged the same way.


texts: Increasing range of a DC-offset signal (software)

texts:
I am trying to read a signal with a DC offset of 511 (as seen by the ADC). The signal's tiny with regards to the offset, and I'm feeding it to a library that does a Fourier transform on it. It comes from a 3.5mm audio jack with AC coupling and the offset so I can see the full signal.

How may I increase the range of the signal? I am thinking something like the input signal is (490-530) and I want an output of (400-630) or something (numbers solely for example). The issue is that I still need the resulting signal to be centered around 511 AND I don't know the exact amplitude of the input (since it varies based on volume and particular audio going in at the moment).

I can assume that the volume of the audio input is relatively fixed (I need to be able to adjust this gain later, but I'm assuming the volume will be constant at some value per time I'm running the project), so I don't need envelope-following or something, but I'm not sure how to do this even so.


texts: How to compile an official VS1003 / VS1053 example for Arduino / ESP8266?

texts: Have anyone ever successfully run any of the official playback and recording examples for VS1003 or VS1053 on Arduino / ESP8266? I mean, I was able to play sound with VS1003, but I just can't make the official example compile on Arduino IDE... It looks like it should be no problem (just provide a few methods and copy the main method code from the PDF file to the setup() in sketch) but I'm just getting a bunch of stupid compiler or linker errors, like "undefined reference to 'VSTestInitHardware()' " while the player.h header file (containing it) is included. I'm not a C / C++ expert so it's either something stupid I do or it's just not possible on Arduino. Can anyone provide a compilable example? I'm trying it with ESP8266 currently (and it is my desired target CPU), but an Arduino Uno version could help too (it throws different errors but doesn't compile neither). Thank you.


texts:
I'm working on a project where I could have up to six devices connected to an arduino, it might be the case that not all of them will be attached at the same time, and all of them need to be able to receive PWM signals but without using delay().

There are a number of different PWM patterns already programmed into the code, what I'd like to do is be able to assign more than one device to a single pattern, and start/stop the patterns at different times to different devices.

I have a python script (and soon an Android app) that sends a message in the following format to the device:

<int(pin_number), string(pattern_name), int(highest_pwm_value 0 - 255), int(delay_between_pulses_in_seconds)>

Is there some way of coding something like the following, and if so, how would I go about it?

array timings[];

void fade(unsigned long thisMillis, int fadeInterval, int maxPWM, int motor_pin) {
  if (thisMillis - timings[motor_pin] >= fadeInterval) {
    // yup, it's time!
    if (fadeDirection == 1) {
      fadeValue = fadeValue + fadeIncrement;
      if (fadeValue >= maxPWM) {
        // At max, limit and change direction
        fadeValue = maxPWM;
        fadeDirection = 0;
      }
    } else {
      //if we aren't going up, we're going down
      fadeValue = fadeValue - fadeIncrement;
      if (fadeValue <= minPWM) {
        // At min, limit and change direction
        fadeValue = minPWM;
        fadeDirection = 1;
      }
    }
    // Only need to update when it changes
    analogWrite(motor_pin, fadeValue);

    // reset millis for the next iteration (fade timer only)
    timings[motor_pin] = thisMillis;
  }
}

The bit that I'm unsure about is how the array should be defined etc, as I'm primarily a python developer so it's rare I have to explicitly set the type of an item in an array!


texts: Can't burn bootloader through Arduino Nano clone ISP to atmega328p

texts:
I'm trying to use a Nano v3 as ISP to program an atmega328p on a board with ISP headers:

I followed the instructions under
https://www.arduino.cc/en/Tutorial/ArduinoISP which I think have been recently updated. I'm simply connecting ISP headers together except for D10 from programmer to reset on the target AVR.

The ISP sketch seems to be working fine as far as I can see the heartbeat pulsing a led. But when trying to burn bootloader with settings:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x01
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0x10
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): unknown response=0x12
Error while burning bootloader.

I noticed something weird though, the 5V and GND on the ISP header on the programmer nano only has around 0.4V. This even without anything external but the usb connected. Is my nano broken or is the usb connection not able to deliver enough power?


texts: How will I solve my problem : expected primary-expression before '>' token

texts:
// defines pins numbers
const int trigPin = A0;
const int echoPin = A1;
// defines variables
long duration;
int distance;

#include <moving.h>
#include <Servo.h>

Servo servo;

moving car(6, 2, 3, 5, 4, 7, 11, 8, 9, 10, 12, 13); // setting up a new RC car with pins EN1, IN1, IN2, EN2, IN3, IN4, EN3, IN5, IN6, EN4, IN7, IN8

void setup() {
{
  for (int i=2; i<14; i++)
  {
    pinMode(i, OUTPUT);
  }
  servo.attach(10);
  servo.write(90);
}
{
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
}

void loop() {
  if (distance) > 10; // this is the problem
  car.set_speed(127);
  car.forward();
  delay(3000);
  if (distance) < 10; // and this
  car.set_speed(0);
  car.forward();
  delay(600);
  car.set_speed(127);
  car.right();
  delay(700);
  car.set_speed(127);
  car.forward();
  delay(700);
}


texts:
What would be the best way to send the following information from one MCU to another?

Now I'm just sending the sentence over as is eg. Serial.print(sentence in here)

Example sentence: 1306,60.123456,50.123456,23.765382,40.897558,245,85,20.3,5,65,1500,0.9

Many thanks.


texts: Dimming this ~30V led with PWM, what do I need?

texts:
I have a street lamp with a led and simple driver in it, I don't know the exact led voltage but the driver (image attached) says 27-36V DC output, MODEL: 50W.
Is there a part I could place between this driver and the led, so I can control dimming by Arduino via PWM ?
The led driver specs (large image below) says: INPUT; AC 85-285V and OUTPUT: DC 27-36V 1500mA, MODEL: 50W
I thought it would work to put this "PWM power module" between the driver output and the led, but (I tested months ago) I remember it started to blink, I think only when decreasing power but not on full power (controlled by PWM with arduino).

Should it work with this module or I am trying something very wrong ?
Are there any other parts that should work for sure in this situation ?

The specs on the PWM module are these:
Voltage: 5 V - 36 V DC;
Power: 400 W;
Current: 30 A;
PWM Voltage: 3.3-20V;
PWM frequency: 0-20kHz ;


texts: Options for communicating between Arduinos

texts:
I'm looking to communicate between ~5-10 Arduinos to send commands and data between them. By "Arduino" I mean the ATmega328 programmed using the Arduino programming framework.

Each of the devices would be on the same PCB.

I know I2C and SPI can communicate to some degree, but that they're really meant for peripherals devices connected to a micro controller rather than connecting multiple micro controllers to each other, and that they usually only send a few bytes of data at a time. On the other hand I know LCD displays can be driven using them, and I'd imagine there's a lot of data being transferred in those cases.

Is there a something like I2C (multi-master, multi-slave, single-ended, serial computer bus) for communicating between micro controllers? Allowing each device to send data to each other device unsolicited. For example, if a switch was pressed on device A, it would tell device B, without having device B ask A all the time if a switch was pressed. and vice versa.

Edit: I found some libraries that may do what I want with RS-485. Is this the only viable option for ~1k bps transmission between 5-10 devices? I would imagine TCP/IP over Ethernet would work as well, but that seems like too much. Are there any I2C libraries that allow sending that amount of data between only master devices?

https://github.com/MichaelJonker/HardwareSerialRS485
https://github.com/MajenkoLibraries/ICSC


texts: Could I Connect many Arduino Nano boards together?

texts: I want to know if I could connect many Arduino Nano  boards together (Example : 10 boards ) , Also i want to know  if there is any problem in Communication between them  using I2C , could this affects processing speed on every board ,  and  if there's going to be any kind of delay when communicating?


texts: Is code in a class repeated for each instance?

texts:
I haven't needed classes before in programming for Arduino, but I now have a good use case. I'm not sure I grasp how this will affect code space, though.

Currently I have a struct that holds the properties of an object, and common code that iterates over an array of 12 of that struct. It's fairly compact.

It would be cleaner to wrap the operations on the struct in a class and act on an array of 12 of that class. Essentially the current struct would become private data of the class.

Will all the code in the class be repeated in each instance, or is the compiler clever enough to avoid such repetition?

Any clarifications welcome. C++ is not my main language.


texts: `.readFileCounts()` not working on DFPlayer mini module

texts:
I just played around using a MP3-TF-16P module, aka DFPlayer mini. The library and the examples I used as a basis can be found here.

My current setup contains a button (NC, normally closed), which is connected to Pin D2 and has an interrupted attached to it. The button input is debounced by using a time difference inside the ISR. The code (based on getStarted example) can be found below.

Using the button to play the next song works as expected. However, when trying to get the total number of tracks located on the SD card by calling Serial.println(player.readFileCounts()) as shown in the FullFunction example the board does neither print anything nor respond to any further commands. Even using the FullFunction example does not print anything.

Could someone please double-check this behaviour? Is this a module-related ore a library-related problem, since I am using a MP3-FT-16P module which might be a cheap clone of the original DFPlayer mini module? Does this work with other MP3-FT-16P modules out there meaning that mine is faulty?

#include "stdint.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

#define interruptPin 2
#define softSerialRx 10
#define softSerialTx 11
#define debounceDelayMillis 1000

volatile uint32_t lastInterruptTime = 0;
volatile bool interruptOccured = false;

SoftwareSerial softSerial(softSerialRx, softSerialTx);
DFRobotDFPlayerMini player;

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

  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), interruptHandler, FALLING);

  Serial.println(F("Initing player ..."));
  // `player.begin(stream)` returns true when module is initialized
  if (!player.begin(softSerial)) {
    Serial.println(F("... failed"));
    while(true) {
      // never leave this loop since initialization went wrong
    }
  }
  Serial.println(F("... ready."));

  // volume: 0 ... 30
  player.volume(30);

  // when using `player.readFileCounts()` player module does not respond to further commands
  // Serial.println(player.readFileCounts());
}

void loop() {
  // read status messages from DFPlayerMini on its software serial port when available
  if (player.available()) {
    printPlayerStatus(player.readType(), player.read());
  }

  if (interruptOccured) {
    Serial.println("Button pressed");
    player.next();
    interruptOccured = false;
  }
}

void interruptHandler() {
 uint32_t interruptTime = millis();
 if (interruptTime - lastInterruptTime > debounceDelayMillis) {
   interruptOccured = true;
 }
 lastInterruptTime = interruptTime;
}

void printPlayerStatus(uint8_t type, uint16_t value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number: "));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError: "));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}


texts: Just got aurdino uno what should I do. Are there any cool projects or are there any good websites to learn how to code it any links would be appreciated as I really need how to program it. It seems really cool:-).


texts: Would a 100KΩ resistor connected to ground pull an open analog line down to 0

texts:
I have a project that has a photoresistor wired into a voltage divider and connected through a 3.5mm “stereo mini plug”. When nothing is in the mini plug, the analog line is an open circuit, and floats, creating jittery spurious readings.

I’d like to wire a pull-down resistor into the project box to tie it to ground so I get a zero reading when the light sensor is not connected, but want to alter the voltage reading from my photo sensor voltage divider circuit as little as possible.

If I connect a 100KΩ resistor between my analog input and ground, that would give me zero readings on the analog pin when the photo sensor is not plugged in, wouldn’t it? I can’t see how < 20 CM of 26 gauge wire would pick up enough interference to pull my analog pin up from 0 through a 100kΩ resistor.

What is the effective range of an analog pin on an Arduino? (A Mega 2560, if that matters) What’s the lowest voltage that will register above 0?

(The project box is getting crowded, so experimenting is getting tricky. I’d like to make a single change rather than trying different resistor values.)


texts: The analog read is not giving the correct waveform as that of an oscilloscope

texts:
I have this code that fetches analog input values from terminals A0, A1 and A2 of Arduino mega 2560. But, when I plot the data, it does not give the desired waveform. The desired waveform is parallel measured in the digital storage oscilloscope. I was thinking to make use of Arduino mega 2560 as an oscilloscope that can have 16 channels. Because the DSO has only 4 and for a project, I urgently need 16 channels. Would be great if the community people suggest something. Thanks.

Below is the desired data from the oscilloscope that is measured parallel to avoid any confusion about the circuit.

%This is a script that will plot Arduino analogRead values in real time
%Modified from http://billwaa.wordpress.com/2013/07/10/matlab-real-time-serial-data-logger/
%The code from that site takes data from Serial

clear all
close all
clc

%User Defined Properties
a = arduino('Com5')             % define the Arduino Communication port
arduino=serial('COM5','BaudRate',9600);
s1 = serial('COM5');                                                       % Define here YOUR serial port
s1.BaudRate=9600;

plotTitle = 'Arduino Data Log';  % plot title
xLabel = 'Time (s)';     % x-axis label
yLabel = 'Voltage (V)';      % y-axis label
legend1 = 'Voltage 1'
legend2 = 'Voltage 2'
legend3 = 'Voltage 3'
yMax  = 5                           %y Maximum Value
yMin  = 0                       %y minimum Value
plotGrid = 'on';                 % 'off' to turn off grid
min = 0;                         % set y-min
max = 5;                        % set y-max
delay = .01;                     % make sure sample faster than resolution

%Define Function Variables
time = 0;
data = 0;
data1 = 0;
data2 = 0;
count = 0;

%Set up Plot
plotGraph = plot(time,data,'-r' )  % every AnalogRead needs to be on its own Plotgraph
hold on                            %hold on makes sure all of the channels are plotted
plotGraph1 = plot(time,data1,'-b')
plotGraph2 = plot(time, data2,'-g' )
title(plotTitle,'FontSize',15);
xlabel(xLabel,'FontSize',15);
ylabel(yLabel,'FontSize',15);
legend(legend1,legend2,legend3)
axis([yMin yMax min max]);
grid(plotGrid);

tic

while ishandle(plotGraph) %Loop when Plot is Active will run until plot is closed

%          dat = readVoltage(a,'A0')* 0.48875855327; %Data from the arduino
%          dat1 = readVoltage(a,'A1')* 0.48875855327;
%          dat2 = readVoltage(a,'A2')* 0.48875855327;

         dat = readVoltage(a,'A0')* 1; %Data from the arduino
         dat1 = readVoltage(a,'A1')* 1;
         dat2 = readVoltage(a,'A2')*1;

         count = count + 1;
         time(count) = toc;

         data(count) = dat(1);
         data1(count) = dat1(1)
         data2(count) = dat2(1)

         %This is the magic code
         %Using plot will slow down the sampling time.. At times to over 20
         %seconds per sample!
         set(plotGraph,'XData',time,'YData',data);
         set(plotGraph1,'XData',time,'YData',data1);
         set(plotGraph2,'XData',time,'YData',data2);

          axis([0 time(count) min max]);

          %Update the graph
          %pause(delay);
  end

delete(a);

disp('Plot Closed and arduino object has been deleted');`


texts: Switching time of a multiple input switch

texts:
I basically have two switches
Both switches will be pressed simultaneously in different order
I want to know which switch was pressed first


texts: How to extend my Sketch for Multiple Inputs and Outputs

texts:
I am using  4 Push Buttons and 4 leds in my project. Here the sketch is only for one push button and one Led. I want extend my sketch upto 4 push buttons and 4 leds .Please tell what changes I make in my sketch. Please any body can make changes in my sketch.
here is sketch:

const int buttonPin =2;    // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, ledState);
}

void loop() {
  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
      }
    }
  }

  // set the LED:
  digitalWrite(ledPin, ledState);
  lastButtonState = reading;
}


texts: Why is my passive buzzer clicking instead of buzzing when set to HIGH?

texts:
everyone. I am working on learning Arduino from scratch and I am on the buzzer lesson. The tutorial I am following consists on writing a code to get an input from the user in the form of an integer number, and, if it is greater than 10 (or whatever threshold you set it to) it will buzz.
I wrote the code exactly as the tutorial said but the buzzer would not buzz, it would do a weird clicking sound instead. I searched for a reason everywhere and could not find an explanation. Most questions in forums were solved by changing the positive wire from the 5V to a regular pin on the board, and those problems were due to the fact that the people asking the questions were not aware that the buzzer was a passive one.
Anyway, I managed to get a buzz by switching from digital to analogWrite and typing a value less than 255. It seemed weird that 255 and HIGH would produce the click, but values less than 255 would buzz, so I tried several analogWrite values:

At 255 the buzzer does the weird clicking.
At 254 the buzzer does a very faint buzz.

The buzzing got louder as I wrote lower numbers until it got stable at around 250, and then got less loud as I decreased the number.
Does anyone know why that is? Is the voltage too much for the buzzer at 255/HIGH? I tried a resistor but still got nothing but clicking with the program set to 255/HIGH.
This is mostly out of curiosity, but I'd still appreciate it if you could answer it.
Here is the code ("Numero" means "number" and "Dame un número" means "Give me a number":
int Numero;

int buzz=10;

int DLY=2000;

String msg="Dame un numero.";

void setup() {

Serial.begin(9600);
pinMode(buzz,OUTPUT);

}

void loop() {

Serial.println(msg);
while (Serial.available()==0){

}

Numero=Serial.parseInt();

if (Numero>25){

  Serial.println(Numero);

  analogWrite(buzz,10);

  delay(DLY);

  digitalWrite(buzz,LOW);

}

}


texts: fatal error: avr\wdt.h: No such file or directory in arduino due

texts:
I am using Arduino DUE for vehicle tracking gps/gprs device. Before using Arduino DUE I used Arduino UNO. When I am trying to load my code in Arduino DUE It shows me "fatal error: avr\wdt.h: No such file or directory". I can't delete watchdog from my code as it is so important for my device.
Now how can I solve this problem ?


texts: Wiring a potentiometer to control a 9V battery powering 2 LEDs in series

texts:
I am trying to build an array of LEDs where their brightness is controlled by a potentiometer.  The LCD will display the percentage of brightness based on the potentiometer.  I am able to successfully control the brightness of a circuit with only one LED.  However, I am having trouble with 2 two LEDs in series (which are in parallel with other sets of 2 LEDs in series).  And I believe the problem is that the Arduino is only supplying enough voltage to power one LED (maybe < 5V).  How can I properly wire a 9V battery to this circuit in which the potentiometer can control the amount voltage coming from this battery?  Are Arduinos only capable of controlling <5V with a potentiometer?

Here is my code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int potPin = A0;
int ledPin = 6;
int potValue = 0;

void setup() {
  pinMode(potPin, INPUT);
  pinMode(ledPin, OUTPUT);
  lcd.begin(16, 2);
  lcd.print("Potentiometer");
}

void loop() {
  potValue = (analogRead(potPin)/10.02);
  analogWrite(ledPin, potValue);
  lcd.setCursor(0,1);
  lcd.print(potValue);
  lcd.print("%");
  delay(100);
  lcd.print(" ");
  delay(1);
}

And here is a picture of my circuit setup:


texts: PWM output while using I2C with the ATTiny library

texts:
I've noticed that when using the USI interface on the ATTiny to send I2C via the methods from "Wire.h" with the ATTiny Arduino implementation included from the library manager (ATTinyCore), while analogWrite PWM on PB4 (Arduino pin 4, physical pin 3) works OK, it seems attempting to use it on PB1 (Arduino pin 1, physical pin 6) behaves erratically or hangs the processor.

Is this expected behavior, and is there a workaround? With the SDA line on PWM pin 0, physical pin 5 if that's the case it means when using the hardware USI to do I2C communications, I'm down to a single hardware PWM output, which is kind of a bummer.


texts: Can anyone identify why this incrementer is losing count?

texts:
I am working on a project where the end result is to count the number of cycles of a moving piece of metal using an inductive sensor.

For now I am using an Arduino Uno and have created a breadboard version for testing. The sensor has been replaced by a momentary push button. To check the count data I am viewing the number using Serial Monitor

All the elements of this set-up are working, apart from one major issue. When pressing the button the incrementer (++) occasionally adds 2 instead of 1 from only one button press. As a rough guide to the error frequency, it seems to count 11 for every 10 button presses. The error has never presented as not counting enough.

I am new to software, as such I cannot seem to see the error

Any help and guidance would be greatly appreciated

Here is the code I have written so far:

//Libraries
#include <EEPROM.h>

//Constants
const int counterPin = 2;   //Input from counter (looking for HIGH as external pulldown resistor is used)
const int EEPROMadress = 3; //holds the EEPROM address

//Variables
int counterState = 0;       //current button state
int counterStatePrv = 0;    //previous button state
int storedValue;
int presetCount = 100;

unsigned long countNumber;      //unsigned 32bit variable

void setup() {

    for (int i = 0; i < 255; i++) {
        // this performs as EEPROM.write(i, i)
        EEPROM.update(i, i);
    }
    for (int i = 0; i < 255; i++) {
        // write "presetCount" value to cell "EEPROMaddress" only the first time
        // will not write the cell the remaining 254 times
        EEPROM.update(EEPROMadress, presetCount);
    }

    pinMode(counterState, INPUT);
    Serial.begin(9600);

    countNumber = EEPROM.read(3);   //Start the counter at the presetCount value
}

void loop() {

    counterState = digitalRead(counterPin);   //Read the status of the counter input
    storedValue = EEPROM.read(EEPROMadress);

    if (counterState != counterStatePrv) {      //check that pulse went off
        if (counterState == HIGH) {             //check for pulse
            countNumber++;                      //increment (add 1) to the stored count value
            delay(10);
            Serial.print("Count  Value: ");
            Serial.println(countNumber);

            Serial.print("Stored Value: ");
            Serial.println(storedValue);
            Serial.println();

        }
    }
    counterStatePrv = counterState;

}


texts: Looking for a game application oriented display for Arduino Mega

texts:
I was using displays with serial communication (SPI), but sending bytes to draw a tile-based picture was way too slow so I'd like find one with a parallel port, enough fast bandwidth to receive fast pictures at a speed at least 10FPS (but I'd like 50FPS or 60FPS) from Arduino Mega (ATMEGA2560) and which has a library compatible with the Arduino's C++ compiler.

I think I've seen somewhere how to connect a display onto the XMEM pins of the Mega and send bytes like this:

*(0x12)=0x34 // Sends 0x1234

However, I couldn't find where to buy that specific one.

I was searching on eBay, but only found displays of unsupported drivers or drivers with broken links that I couldn't download, and displays that are ridiculously large like a shovel!

The resolution it needs to have is minimum 128x64, aspect ratio must be X:Y where X is greater than Y (unless it's possible to send bytes sideways while the screen is physically placed in a different orientation on the PCB).

It must be a touch display sensitive on anything (like Nintendo DSi when drawing Flipnotes).

It should be either:

Monochrome
Color display with MS Paint colors if it has equal to or less than 256 colors
Color display with 16-bit color input mode if it has a lot of colors

It should be no bigger than 2.5" because this is for a little handheld console.

If anyone knows where to buy it, please comment.
Thank you for your time.


texts: If an I2C connection is lost for a short period of time will it work if the connection is live again?

texts:
I'm using an ESP8266 with the Arduino library to read from a sensor(MPU9250 specifically). The readings are done via I2C but I'm using a library that abstracts these methods.

The wires are not soldered together so temporary disconnections are possible and after these disconnects the sensor readings freeze. I'm new to the world of I2C so my questions are:

Do I have to re-init the connection after it disconnects or is there a way to continue on re-connection immediately?
Is there a way to prevent this to happen (for example to stop reading when there's no connection) or should I just solder together the pins?


texts:
I’m trying to make an art sculpture, with an Arduino-uno, a servomotor and a seeduino musicshield v2.0.
I’m making the servo motor moving a stick with the attached fans of the servo, and I want to  synchronize the servo motor with the music shield  and when the motor is stopped(about one minute), the music(about one minute of music) will play and when de motor is moving the music will be stopped.

I'm super noobie with the code. I tried something like this
but, is not moving at all, neither my servo or my musicshield  when I write this:

#include <SD.h>
#include <SPI.h>
#include <arduino.h>
#include <MusicPlayer.h>

#include <Servo.h>
Servo myservo;

int val;//for the servo

void setup() {
  //setup for the music shield
  Serial.begin(9600);
  player.begin();  //will initialize the hardware and set default mode to be normal.
  player.addToPlaylist("a.mp3");
  //setup for the servo
   myservo.attach( 9 );
}
void loop() {
  mover();
  if ( val == 90) {
    music();
  }
}

void mover () {
  val = 0;// start point
  myservo.write(val);
  delay(800);

  val = 90;
  myservo.write(val);
  delay(60000);//wait for 1 min
}

void music () {

  player.play();
}

when I write this my servo moves, but obviously my music wouldn't play

#include <SD.h>
#include <SPI.h>
#include <arduino.h>
#include <MusicPlayer.h>

#include <Servo.h>
Servo myservo;

int val;//for the servo

void setup() {
  //setup for the music shield
 Serial.begin(9600);
  player.begin();  //will initialize the hardware and set default mode to be normal.
  player.addToPlaylist("a.mp3");
  //setup for the servo
   myservo.attach( 9 );
 }

void loop() {
mover();

 }

 void mover () {
val = 0;// start point
myservo.write(val);
delay(800);

val = 90;//
myservo.write(val);
delay(60000);//wait for 1 min
}

void music () {

  player.play();  //do some leisurely job
}

And the music will play when I write this, obviously the servomotor don't move, so I'm  think I have a problem mixing my servomotor and the musicshield(seeeduino music shield v2.0, and I want the music start when my servo motor is in this point of val=90 delay(60000)

 #include <SD.h>
    #include <SPI.h>
    #include <arduino.h>
    #include <MusicPlayer.h>

    #include <Servo.h>
    Servo myservo;

    int val;//for the servo

    void setup() {
      //setup for the music shield
     Serial.begin(9600);
      player.begin();  //will initialize the hardware and set default mode to be normal.
      player.addToPlaylist("a.mp3");
      //setup for the servo
       myservo.attach( 9 );
      }

    void loop() {

   player.play();
     }

    void mover () {
    val = 0;// start point
    myservo.write(val);
    delay(800);

    val = 90;//
    myservo.write(val);
    delay(60000);//wait for 1 min
    }


texts:
I bought my Robotics kit yesterday. And, I am not able to set up my Arduino port.
I have tried every method I could find on the internet. I am attaching images of my device manager and error I am getting while trying to update my ports. Any help would be highly appreciated.


texts: Should I use a loop instead of an If statement?

texts:
I have a simple sketch that tests input from 2 touch sensors and outputs to 2 relays (if a sensor is touched, trigger the respective momentary relay).  It has been a bit quirky to say the least.  perhaps I need to adjust delays or adjust sensitivity of the touch sensors, but I feel that maybe the coding could be more efficient.  Would using a WHILE or DOWHILE loop work better than an IF statement for this?  It seems like there is a timing issue between the relay and the sensor.  When I hit the sensor, the relay triggers immediately, but then it doesn't shut off right away.  Also if both sensors are made at the same time, I am seeing only 1 relay trigger or neither.  I am trying to eliminate the code as my failure point. I have the code printing to the serial monitor to show "Sensor 1 touched" or "Sensor 2 touched", and sometimes that triggers once and sometimes it will print multiple times.

int touchPin1 = 2; //Touch sensor 1
int touchPin2 = 4; //Touch sensor 2
int val_1 = 0;
int val_2 = 0;
int relayPin1 = 8; //Relay 1
int relayPin2 = 9; //Relay 2

void setup()
{
  Serial.begin(9600);
  pinMode(touchPin1, INPUT);
  pinMode(touchPin2, INPUT);
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);

}

void loop() {
  digitalWrite(relayPin1, LOW);
  digitalWrite(relayPin2, LOW);
  val_1 = digitalRead(touchPin1);
  val_2 = digitalRead(touchPin2);
  if(val_1 ==1)
  {
  Serial.println("Pad 1 Touched");
  digitalWrite(relayPin1, HIGH);
  }
  if(val_2 ==1)
  {
  Serial.println("Pad 2 Touched");
  digitalWrite(relayPin2, HIGH);
  }
  delay(100);
  //Serial.println();
}

Basically I am asking if there is a more efficient way to code this.

Touch Sensors: Adafruit Standalone Momentary Capacitive Touch Sensor Breakout Adafruit Part Number: 1374

Relays: SunFounder Relay Module for Arduino and Raspberry Pi 5V DC Trigger by HIGHLO (HIGH Trigger)


texts: How to get more than the 16 Analog INs on a Arduino Mega for using like 24 piezo sensors

texts:
i bought an Arduino Mega2560 and flashed it with usbmidi. So now it comes up as a midi device.

I need more than those 16 analog ins to be able to put all my 24 piezo sensors into it to receive midi signals from it. I still have no idea how i have to put the piezo pieces into the arduino but also no clue as how to get more than those 16 analog slots. Any way to use the digital inputs as well or do i need some extension shield or so? I'm a total beginner with arduino...


texts:
I want to make a vocab program for an arduino. The vocabs are saved in a char array seperated with an '/'. Now I want to split a random picked char and split it at the '/' so I can save it into two variables. But if I do it with strtok the original string gets sacrificed. If now the same vocab comes again...

I hope you can help me, but if you think a other way to do it would be better I'm open for suggestions.
Here's my code

long random1, random2, random3, random4;
int lengtharray = 5;
char* vocab1;
char* vocab2;
char* vocab3;
char* vocab4;
char* german1;
char* english1;
char vocabs[5][16] = {"Apfel/apple","er/he","Zoo/zoo","sie/she","Hallo/hello"};

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

void loop() {
randomSeed(analogRead(0));
random1 = random(0,lengtharray);
randomSeed(analogRead(0));
random2 = random(0,lengtharray);
while(random2 == random1){
    randomSeed(analogRead(0));
    random2 = random(0,lengtharray);
}
randomSeed(analogRead(0));
random3 = random(0,lengtharray);
while(random3 == random1 || random3 == random2){
    randomSeed(analogRead(0));
    random3 = random(0,lengtharray);
}
randomSeed(analogRead(0));
random4 = random(0,lengtharray);
while(random4 == random1 || random4 == random2 || random4 == random3){
    randomSeed(analogRead(0));
    random4 = random(0,lengtharray);
}

vocab1 = vocabs[random1];
vocab2 = vocabs[random2];
vocab3 = vocabs[random3];
vocab4 = vocabs[random4];

Serial.println(vocab1);
Serial.println(vocab2);
Serial.println(vocab3);
Serial.println(vocab4);
Serial.println("//");
delay(1000);

german1 = strtok(vocab1,"/");
english1 = strtok(NULL,"/");
Serial.println(german1);
Serial.println(english1);
}


texts: Arduino RF24 library Delay after write function causes no byte availability

texts:
It's about the RF24 library you can find here. http://maniacbug.github.io/RF24/index.html

I transmit data from one Arduino to another using NRF24L01 radios.
When I use the write-function on the transmitter arduino (joystick is an array) and after that I put in a delay higher then 10, the available function returns false.

Transmitter

radio.write( joystick, sizeof(joystick) );
delay(20);

Receiver

if(!available())
  print('No data'); // delay > 10 --> No data will be printed

Why is it working with a delay of 10 but not above? Has it something to do with timeouts which is mentioned in the docs of the library?: http://maniacbug.github.io/RF24/classRF24.html#a4cd4c198a47704db20b6b5cf0731cd58

Thank you for your answers.


texts: Why am I receiving this error: “expected unqualified-id before numeric constant”?

texts:
#include <LiquidCrystal.h>
LiquidCrystal 1cd(12, 11, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
void setup() {
 1cd.begin(16, 2);
 pinMode(switchPin, INPUT);
 1cd.print("Interroga");
 1cd.setCursor(0, 1);
 1cd.print("la sfera!");
 // put your setup code here, to run once:

}

void loop() {
  switchState = digitalRead(switchPin);
  if (switchState != prevSwitchState){
    if (switchState == LOW){
      reply = random(8);
      1cd.clear();
      1cd.setCursor(0, 0);
      1cd.print("La sfera dice");
      1cd.setCursor(0, 1);
      switch(reply){
        case 0:
        1cd.print("si");
        break;
        case 1:
        1cd.print("probabilmente");
        break;
        case 2:
        1cd.print("certo");
        break;
        case 3:
        1cd.print("bene");
        break;
        case 4:
        1cd.print("forse");
        break;
        case 5:
        1cd.print("chiedi ancora");
        break;
        case 6:
        1cd.print("improbabile");
        break;
        case 7:
        1cd.print("no");
        break;// put your main code here, to run repeatedly:
      }
    }
  }
 prevSwitchState = switchState;
}


texts:
I am trying to create a project in my free time just for a bit of fun -
it consists of two MKR1000 (one acting as a web server connected to one laptop, and the other acting as a web client connected to a different laptop - so I can view the Serial Monitor).

One MKR1000 has a potentiometer attached to it (therefore I can change the value of it), and sends the potentiometer value to the serial monitor every 4 seconds.

THE AIM: Once the web server sets up the wifi network, and the web client connects to that wifi network, I want to send the potentiometer value across to the web client every time it gets updated. However I am clueless on how to achieve this.

This is my web server void loop code (the rest is similar to the https://www.arduino.cc/en/Tutorial/Wifi101WiFiWebServer):

void loop() {
  WiFiClient client = server.available();
  // listen for incoming clients
  if (client) {
    // if you get a client,
    Serial.println("new client");
    // print a message out the serial port
    String currentLine = "";
    // make a String to hold incoming data from the client
    while (client.connected()) {
      // loop while the client's connected
      if (client.available()) {
        // if there's bytes to read from the client,
        char c = client.read();
        // read a byte, then
        Serial.write(c);
        // print it out the serial monitor
        if (c == '\n') {
          if (currentLine.length() == 0) {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();
            // the content of the HTTP response follows the header:
            client.print("Click here showValue of the potentiometer
");
            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
            break;
          } else {
            // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {
          currentLine += c;
          // add it to the end of the currentLine
        }
        if (currentLine.endsWith("GET /showValue")) {
          Serial.println(sensorValue);
          delay(2000);
        }
      }
    }
    client.stop();
  }
}

And this is my web client code I use this https://www.arduino.cc/en/Tutorial/Wifi101WiFiWebClient  - I am not sure how I should modify this in order to receive the potentiometer value across from the web server MKR1000. Any tips or hints would be hugely appreciated!

I am sorry if this is a simple question, however I am just starting with the Arduino idea, and I'm new to coding!

Thanks.


texts:
I'm experimenting with the "2 pin capacitance meter" and trying to make it more accurate. Currently I've made the Arduino read 62.5 ns intervals but this means the time for the ADC to read is taking up a bigger part of the interval. I'm currently using a prescaler value of 8 on the ADC. Unfortunately reading continuously isn't really an option so I am limited to around 8us of read time instead of 6.5us. This isn't that much of a problem since I know that the read will take near 8us from experiments, however I do not know when during that 8us interval the actual reading takes place.

So that is my question, does the adc take the average value during those 8us, does it "lock" the bits at the beginning or when exactly does the reading occur?

Link to capacitance meter, specifically the third one: http://www.circuitbasics.com/how-to-make-an-arduino-capacitance-meter/#comment-363733)


texts:
For an application I use Arduino DUE and VNH2SP30 as the motor driver.I think this motor drive is only compatible with 5V logic but DUE provide 3.3V logic.Will my problem be solved if I use logic level shifter to convert 3.3V logic level to 5V?In the meantime, I control the speed and direction of the motor with the following code:

analogWrite(PWM_kare,head_analog);
digitalWrite(INB_kare, HIGH);
digitalWrite(INA_kare, LOW);


texts: ESP8266, I am trying to establish a SoftAP and I cant seem to get the WiFilocalIP function to give me my IP

texts:
I am just trying to establish a server and it seems that I can't get the serial monitor to read the local IP of my device and my Client can't establish a connection to update the sensor value. when I run the monitor I get this:

IP Address: (IP unset)

here is my code:

    #include <ESP8266WiFi.h>
    #include <ESP8266WebServer.h>

    /// Config parameters for Access Point
    char * ssid_ap = "This Little Buddy";
    char * password_ap = "guessing";
    IPAddress local_ip(192,168,4,4);
    IPAddress gateway(192,168,4,1);
    IPAddress subnet(255,255,255,0);

    //Setup Server Object
    ESP8266WebServer server;

    //Sensors and what not here
    float sensor_value = 0.0;

    void setup() {
        //identify and start WiFi
      WiFi.mode(WIFI_AP);
      WiFi.softAPConfig(local_ip, gateway, subnet);
      WiFi.softAP(ssid_ap, password_ap);
      //sanity check
      Serial.begin(115200);
      Serial.println();
      Serial.print("IP Address: "); Serial.println(WiFi.localIP());
      //Configure the server's routes
      server.on("/", handleIndex); //using top root path for last sensor value
      server.on("/update", handleUpdate); //use this to update sensor value
      server.begin();
    }

    void loop() {
      // put your main code here, to run repeatedly:
    server.handleClient();
    }

    void handleIndex(){
      server.send(200, "text/plain", String(sensor_value));//need to refresh page to get information
    }

    void handleUpdate(){
      //value is passed by an URL argument
      sensor_value = server.arg("value").toFloat();
      Serial.println(sensor_value);
      server.send(200,"text/plain", "Updated");
    }


texts: Motor for a winch (with controller and external power supply)

texts:
I'm in need of a motor or continuous servo to power a winch. The motor must be continuous* and reversible, but it does not need to be fast, precise, nor bear a load when powered off. It just needs to overcome ~50 Newton of friction force (to winch open my bedroom curtains laterally).

(* it needs to, given a discrete drum (maybe max 4cm diamater), winch about 1m)

I am using a MEGA2560 R3 which has a 5V port. I've tried using a 12V DC stepper motor (24BYJ48) with a standard ULN2003 controller, with a winch drum of ~2cm diameter, but it could not overcome the friction. I didn't spare much thought for the parameters of the arduino Stepper instance though; I just used a configuration which worked for winching lighter loads.

I'm a rookie, but I'm assuming my board cannot sufficiently power the motor(s) (I have 3), and possibly that they themselves are too weak. Hence I'm looking for a stronger motor and controller, controllable by my arduino, but which has a direct power supply (from mains). So:

have I got this all wrong? Is it possible to arrange my 12V stepper motors to exert 50 Newton of tension, using the 5V supply from MEGA?
is there a shield for my MEGA which can enable these motors to function in parallel?
otherwise, is there a strong continuous servo with an external power supply that would work here?


texts:
I'm pretty clueless about electronics so everything has to be explained in simple terms to me.

I have an Arduino with a program which provides a value via the Analog output, so that is anything from 0-5V.

On the other side I have a VFD with an IO card which allows to connect to a (4-20mA) current loop, to vary the speed accordingly.

How do I convert from lets say 1-5V to the 4-20mA in a somewhat cheap and safe way (I don't want to destroy the PLC [and possibly the Arduino])?

Of course the Arduino and the PLC have separate power sources.


texts:
I am writing a utility program to test relay boards. I'd like to be able to accept a user input of the number of relays on the board. Is this doable via the serial monitor since when I'm testing boards I'm generally doing it at my desk with my testing Arduino attached to my laptop? I'd prefer not to go the LCD and keypad route.

Is there an accepted practice for doing this?


texts:
Because I have no pins available on my Wemos D1 mini, I want to drive my Neopixel ring from a MCP23008 I/O expander.

I'm trying to run the 'simple' example from the Adafruit_neopixel library. How do I declare the Neopixel pin number when using say pin 0 on the MCP23008 - or is this impossible?


texts: Using Blynk to control stepper motor is jerky

texts:
I am using Blynk to try and control a 28byj-48 stepper motor using the ULN2003 driver and an Arduino UNO from my iphone via USB withe the iOS Blynk App.

Without using Blynk, my stepper is smooth and works fine:

  #include <Servo.h>
  #include <Stepper.h>

  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,
  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
  const int motorpin1 = 8;                    //Assign motor  pins to Arduino pins
  const int motorpin2 = 9;                    //
  const int motorpin3 = 10;                   //
  const int motorpin4 = 11;                   //

  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4
  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);

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

  void setup() {
    myStepper.setSpeed(600);
  }

  void loop(){
     myStepper.step(-500);
  }

But when I use Blynk, the stepper is so jerky and stutters terribly:

  #include <SoftwareSerial.h>
  SoftwareSerial SwSerial(10, 11);
  #define BLYNK_PRINT SwSerial
  #include <BlynkSimpleSerial.h>
  #include <Stepper.h>

  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,4-step mode
  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft
  const int motorpin1 = 8;                    //Assign motor pins to board pins
  const int motorpin2 = 9;                    //
  const int motorpin3 = 10;                   //
  const int motorpin4 = 11;                   //

  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4 blah blah
  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);
  char auth[] = "my auth key here";

  void setup(){
    SwSerial.begin(9600);
    Blynk.begin(auth);
    myStepper.setSpeed(600);
  }

  BLYNK_WRITE(1){
    myStepper.step(param.asInt());
  }

  void loop(){
    Blynk.run();
  }

I am using a slider on the app to control the stepper by the way. I am not sure what I am doing wrong, any suggestions?


texts: INPUT_PULLUP not work for D8 in my NodeMCU v3

texts:
I changed my arduino NodeMCU application pin mode to use INPUT_PULLUP mode instead of INPUT. D8 input pin is not working as expected, I is always in LOW even the button is pressed or not.

I have 3 input pins (D2, D7, D8), when I changed to internal pull up resistor, I removed each external resistors from input and changed the circuit accourding to this: https://www.arduino.cc/en/Tutorial/InputPullupSerial

D2 and D7 works well, but D8 is not. I checked with a volage between GND and pins:

when button on D2, D7 is not pressed: 2.95 - 3 V
when button on D8 is not pressed: 0.8 V
when button on D2, D7, D8 is pressed: 0V (as expected)

You can see my code in github:
https://github.com/kisdaniel/HomeDashboardGarageDoorOpener


texts:
I'm planning to make a handbrake for my racing simulator (Assetto Corsa) and I wanted to know how can I transform arduino into a joystick so the game can read the analog input?

Thanks in advance, and sorry for my bad english.


texts: Controlling motors via accelerometer not working

texts:
I want to control the 2 servos(pan tilt) using accelerometer data value from android app. Im using nodeMCU v3, 2 servos(pan tilt) and smartphone.

Connection:

servos(pan tilt) is connected to 5 v battery charger and in pin GPIO12 and GPIO14.

nodeMCU is connected to laptop port.

My problem is, my servos (pan tilt) can't read my accelerometer data value.

Here my code:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <Servo.h>
#define DEBUG 1

const char* ssid = "Connect";
const char* password = "ececonnect";

WiFiUDP Udp;
unsigned int port = 5514;
char packet[255];

// Create servo objects
Servo panServo;
Servo tiltServo;

// Center servos
int tiltVal = 90;
int panVal =90;

String inText;
float value0, value1, value2;

void setup()
{
panServo.attach(14);
tiltServo.attach(12);

Serial.begin(115200);
Serial.println();

Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("Connection Successful");
Udp.begin(port);
Serial.printf("Listener started at IP %s, at port %d\n",
WiFi.localIP().toString().c_str(), port);

Serial.println("Android Sensor Type No: ");
Serial.println("1- ACCELEROMETER  (m/s^2 - X,Y,Z)");
Serial.println("2- GYROSCOPE (rad/s - X,Y,Z)");
Serial.flush();
}

void loop()
{
Serial.flush();
int packetSize = Udp.parsePacket();
if (packetSize)
{
//Serial.printf("Received %d bytes from %s, port %d\n", packetSize,
Udp.remoteIP().toString().c_str(), Udp.remotePort());
int len = Udp.read(packet, 255);
if (len > 0)
{
packet[len] = 0;
}
Serial.printf("UDP packet contents: %s\n", packet);

int sensorType = 0;
unsigned long logCount  = 0L;

char getChar = ' ';  //read serial
getChar = Serial.read();

sensorType = Serial.parseInt(); // read sensor typr
logCount  = Serial.parseInt();  // read total logged sensor readings
value0 = Serial.parseFloat();  // 1st sensor value
value1 = Serial.parseFloat();  // 2rd sensor value if exists

if (DEBUG) {
Serial.print("Sensor type: ");
Serial.println(sensorType);
Serial.print("Sensor log#: ");
Serial.println(logCount );
Serial.print("Val[0]: ");
Serial.println(value0);
Serial.print("Val[1]: ");
Serial.println(value1);
Serial.print("Val[2]: ");
Serial.println(value2);
Serial.println("-----------------------");
delay(10);
}

if (sensorType !=1) return;

panVal = value0; // value0 = X sensor reading
tiltVal = value1;  // value1 = Y sensor reading

tiltVal = map(tiltVal, 10, -10, 0, 179);   // Map Accelerometer Y value to
tilt servo angle.
tiltServo.write(tiltVal);
delay(10);

panVal = map(panVal, -10, 10, 0, 179);  // Map Accelerometer X value to pan
servo angle.
panServo.write(panVal);
delay(10);
}

}


texts: Problem receiving data from RPi to Arduino via serial

texts:
Our team has been trying to send data over from RPi to Arduino but there are some weird things happening:

If we open the serial monitor of arduino on RPi itself, the serial data is sent by RPi and received by Arduino successfully.

However, if we do not open the serial monitor of arduino on RPi, the serial data is sent by RPi but not received by Arduino.

The communication between them is via USB cable.

Below are the codes implemented on RPi (using RS232 Linux library in C):

void *rs232t_connect(void *arg)
{
 struct RS232Connection *connect = (struct RS232Connection*)arg;

 // connect to USB port ttyACM0
 fprintf(output, "Waiting for connection on Comport ttyACM0 (24)...\n");
 while(RS232_OpenComport(connect->cport_nr, connect->bdrate, connect->mode) == 1)
     sleep(1);

 // set connected flag to signal completion of connection to main()
 connect->connected = true;
 fprintf(output, "Connection accepted.");

 return 0;
}

void *rs232t_send(void *arg)
{
 struct RS232Connection *connect = (struct RS232Connection*)arg;
 unsigned char buf[4];
 int32_t g;
 bool reconnect = false, resend = false;

 while(1)
 {
   // sample
   g = 10;

   // convert from LSB->MSB to MSB->LSB
   memset(buf, 0, sizeof buf); // clear buffer
   buf[0] = (g >> 24) & 0xFF;
   buf[1] = (g >> 16) & 0xFF;
   buf[2] = (g >> 8) & 0xFF;
   buf[3] = g & 0xFF;

   if(RS232_SendBuf(connect->cport_nr, buf, sizeof(int)) == -1)
   {
     // Print error msg if sending failed
     fprintf(output, "Disconnected\n");
   }
   else
   {
     fprintf(output, "Outgoing Message: %d\n", g); // DEBUG
     g = 0;
   }
 }
 return 0;
}

Arduino Code:

long readSerialInt() {
  long result = 0;
  long temp[4];
  if (Serial.available() >= 4) {
    digitalWrite(13, 1);
    for (int i = 0; i < 4; i++) {
      temp[i] = Serial.read();
    }
    result += temp[0] << 24;
    result += temp[1] << 16;
    result += temp[2] << 8;
    result += temp[3];
    return result;
  }
  else {
     return 0;
  }
}

Any idea why this is happening? Its weird that we need to open the serial monitor of Arduino IDE on RPi before the message gets sent out.

We are sending data over to Arduino. However Arduino does not detect the messages we are sending to it (it didnt perform any action/light up any LED).

Thank you


texts:
I'm looking to toggle a pin on and off in a fast and timing-sensitive manner, and I'm wondering if the Arduino Uno has any built in "buffers" that would be able to hold a set of values and send them sequentially to the output pin at high speed, separately from the rest of the loop. I could then refill the buffer with the next set to be outputted, and so on.
Is this even possible? If anyone has any documentation on what's involved, I'd really appreciate some links (or tips!) :) thanks


texts: Arduino Uno sometimes cannot connect to the computer

texts:
Last month, I bought an Arduino Uno R3 board (believed to be a clone). In the first few week, it seem to be working fine. However, in this week, it became very strange. What it basically does, it sometimes can be connected and detected by the computer and serial connection can be opened. However, after a specific amount of time, it started to be hidden and cannot be detected by the computer. The device is not even in device manager with [show hidden devices] turned on. It is extremely weird because after a specific amount of time again (~12-24 hours), it started to work normal again and can be detected and programmed by my computer. It is extremely weird and this combination of incidents continues to loop in the past couple days. I really need some personal help since the information and methods in the internet never helps me.

My specs: Windows 7 Professional 64 bit, Arduino IDE and driver 1.6.7

What i had tried:

[WHEN IT CAN BE DETECTED]

Nothing. Since it was working fine, I didn't attempt to perform any action because I afraid it will worsen the situation
Tried to re-flash the Mega16u2 Chip using the application Flip, but it cannot be turned into DFU mode apparently

[WHEN IT CANNOT BE DETECTED]

Unplug and plug it again
Tried to use a different cable
Tried to use a different PC (Windows 10)
Tried to update the driver, however when I check the device manager, it didn't show any COM ports or whatever, also there's no unrecognized device. I have checked 'show hidden devices'.
Installed Arduino UNO driver (not able to start, error code 10)
Installed FTDI drivers (also not able to start, error code 10)
Reinstalled the whole Arduino IDE and drivers

Any answers are appreciated.


texts: Is the C++ STL fully supported on Arduino?

texts:
I don't yet own an Arduino board to run code on, and as the title says, I'm curious if the C++ STL is fully supported on Arduino and already part of the Arduino IDE. The STL is probably the most efficient, fully tested, and resource-minimal (which is a slightly redundant phrase, as I already mentioned efficiency) publicly available C++ code out there, and would make life much easier to code for Arduino.

If the STL is not a part of Arduino IDE, then how to include specific libraries such as <algorithm> and <utility>? (I'm very tempted to ask "why isn't it included?" but that seems too broad.)


texts: How to reset ATmega328P fuses using USBasp programmer?

texts:
I think I bricked two ATmega328Ps when I was trying to burn new bootloaders using Arduino Pro Mini, the USBasp programmer and the Extreme Burner AVR software. I had two ATMega328p with bad booloaders and I intended burn the correct bootloader to the chips.

First I connected the USBasp programmer to my Arduino Pro Mini equipped with an ATmega328P. I verified that communication was good as I could read and write to EEPROM. All was excellent.

I was using the following fuses:

LOW Fuse Byte=0x62
High Fuse Byte=0xD9
Extended=0xFF
Lock = 0xFF
Calibration = 0xFFFF FF8A
Then the following happened:

I killed the 1st chip when I only pressed button ERASE CHIP on the programmer.

I killed the 2nd chip when I wrote the following fuses to it:

LOW Fuse Byte=0xFF
High Fuse Byte=0xDA
Extended=0xFD
Lock Fuse = 0xCF
In both cases I had the following error message:

Cannot Communication with chip
Power On failed
avrdude output similar messages:

RC=-1. No answer...
(avrdude -c usbasp -p m328p -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m )
How can I solve this problem?

How can I reset all the fuses to factory default to make the chips respond again?


texts: Trying to flash ATTiny85 bootloader using FT232R in the Arduino IDE

texts: I have a FT232R that I want to use to flash my ATTiny85 bootloader in the Arduino IDE, can someone help me out on this? I don't want to get a AVR programmer.


texts: Nano can't get reply from ENC28J60 Ethernet Shield

texts:
My Arduino Nano can't get a reply from my new ENC28J60 Ethernet Shield - I can't get any library examples to work. Using the UIPEthernet lib, and running the EchoServer example with logging turned up, I get:

ENC28J60::init DEBUG:csPin = 10
ENC28J60::init DEBUG:miso = 12
ENC28J60::init DEBUG:mosi = 11
ENC28J60::init DEBUG:sck = 13
ENC28J60::init DEBUG:Use Native hardware SPI
Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) DEBUG_V3:Function started
ENC28J60::init DEBUG_V3:Before readOp(ENC28J60_READ_CTRL_REG, ESTAT)
Enc28J60Network::readOp(uint8_t op, uint8_t address) DEBUG_V3:Function started
...

so it gets nicely into the Enc28J60Network::init function. But shortly after, it does a phyWrite, tries to read a response, and then times out.

ENC28J60::init DEBUG_V3:Before phyWrite(PHCON2, PHCON2_HDLDIS)
Enc28J60Network::phyWrite(uint8_t address, uint16_t data) DEBUG_V3:Function started
... lots of attempts to read
Enc28J60Network::phyWrite ERROR:TIMEOUT !!

And then it all starts to fail, and it never gets better. I tried the EtherCard lib, too, and it fails in a similar way.

I put the scope on the SPI pins, and I see reasonable stuff: activity on SCK and MOSI, nothing on MISO, and the SS (pin 10) switching ok - and the shield claims to use pin 10 (I briefly tried pin 8 as I flailed in confusion, but no luck there either).

So at this point, either I'm misunderstanding something, or the shield is DOA.

Update: Earlier, I strongly suspected the SCK line because it showed a very poor signal on my scope. But it turned out to be poor grounding on the scope probe, and the signal  was actually fine, a red herring. Thanks to @Majenko for drawing my attention to it.

Update 2: After getting no SPI response from the shield under any circumstances, my working hypothesis is that it was DOA. I've gone back to my UNO with W5100: all working fine. I have ordered more Nano ethernet shields, to arrive in a week or two, so I'll try with those, and provide updates/answers then.


texts: Renault car (2003) remote control signal is not received by rc receiver (rcswitch)

texts:
I have an arduino uno, I have set up a rf receiver as well known library rcswitch suggests I do, but I can never see something on the serial monitor in the IDE environment. I am using the example provided by the library, and did the pin set-up as described.
The key (car card) is that of an old Renault Laguna 2. I have browsed the web and am pretty sure that it sends an rf 433mhz signal, and my receiver is also listening to that frequency, so I am quite surprised that nothing pops up.
I also have a transmitter but only 1 dev board so can't really think of any way to test the receiver. Any suggestions ? In case the receiver might be broken how can it be tested? Am quite new to this.
Any help appreciated


texts: How can I use a BlueSMIRF Silver (RN-42) as a HID Keyboard (on IOS)?

texts:
I've got a BlueSMIRF Silver (RN-42) Bluetooth module.
I am trying to create a basic keyboard I can play with on an iPad Air.

At the moment barely manage to get the module to pair with OSX
but only through using Bluetooth Setup Assistant and using "Passcode Options...use a specific code".

With this option, the module pairs, but the connection resets about every 5 seconds.

On iPad it tries to use a generate number really fast and fails straight away, being unable to connect.

I noticed there is a BlueSMIRF HID version, but from what I can tell, the hardware is the same,
just the firmware is different. I've gone through the whole Bluetooth Data Module Command Reference & Advanced Information User’s Guide(pdf link) manual and from what I can gather,
even though I have Silver firmware burned onto my module, I should be able to set and use the HID profile
(from the default SPP):

  Roving Networks modules shipped with firmware version 6.11 and higher
  support the HID profile. You do not need special firmware if your
  module is running firmware 6.11 or higher.

and my module reports version as:

Ver 6.15 04/26/2013
(c) Roving Networks

I've also gone through the Bluetooth HID Profile(pdf link) guide from Roving Networks, but the same information is present in Chapter 5 of the advanced user's guide mentioned above.

I've setup the following settings (with commands used):

HID Profile (S~,6)
Device discovery and pairing is set to automatic, without using GPIO6(SM,6)
HID Flag is set to Keyboard (SH,0000)
Authentication is set to open (SA,0)

I've also tried the inquiry scan(SI,0800)  and page scan(SJ,0800)  windows to maximum
in the hope it would increase the odds of successful pairing and made sure I rebooted the module and checked the settings again.

I have used the same module with the SPP profile just fine, but I'm still fairly new to Bluetooth
and this is the first time I try to use the HID profile.

How can I use the BlueSMIRF Silver as a basic Bluetooth Keyboard for an iPad Air ?


texts: Problem with a DHT11 Temperature & Humidity sensor

texts:
I'm new in the Arduino world and today i was trying to make a simple program to show the temparature an humidity with this sensor. I made a circuit following one tutorial and nothing happend, the result was Temperature: 0 Humidity: 0.
My question is, what is wrong? Probably the sensor is broken or the code is wrong.
I also need to say that i use a 5K1 resistor in exchange of the 4.7K resistor and accidentally I connected the sensor without the resistance for a few seconds.

This is the code:

#include <DHT.h>
#include <DHT_U.h>

int SENSOR = 2;
int TEMPERATURE;
int HUMIDITY;

DHT dht(SENSOR, DHT11);

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

void loop() {
TEMPERATURE = dht.readTemperature();
HUMIDITY = dht.readHumidity();
Serial.print("Temperature: ");
Serial.print(TEMPERATURE);
Serial.print(" Humidity: ");
Serial.println(HUMIDITY);
delay(1000);
}

This is the circuit scheme:

This is a photo of the circuit and the sensor (probably damaged):

Thanks for your time and sorry for my bad english.