texts:
In my code, I have  float Hz = 0.00; I want to display values to my user in RPM as

Serial.print("Speed = ");
Serial.print(round(Hz*60);
Serial.println(" RPM);

The only hangup is that this displays as Speed = XX.00 RPM is there an easy way to get the Arduino to only print out Speed = XX RPM?


texts: Memory usage: #define vs. static const for uint8_t

texts:
I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory.

Using #defines:

#define REGISTER_MOTOR_1_MODE 0x44
#define REGISTER_MOTOR_2_MODE 0x47

Or using static const:

static const uint8_t REGISTER_MOTOR_1_MODE = 0x44;
static const uint8_t REGISTER_MOTOR_2_MODE = 0x47;

(Obviously I have more than just two registers I need to declare, but I thought two would illustrate the point just fine)


texts: Need help with my codes? for my Project: Filling and Capping using Arduino uno

texts:
HERE'S MY CODE
I have a problem for my codes. Please help
#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define IRS1 7

#define IRS2 8

#define relay1 2

#define relay2 3

int Cb = 13;

int Motor1pin = 9;

void setup() {

  pinMode(Cb, OUTPUT);

  pinMode(Motor1pin, OUTPUT);

  pinMode(relay1, OUTPUT);

  pinMode(relay2, OUTPUT);

  pinMode(IRS1, INPUT_PULLUP);// input setup

  pinMode(IRS2, INPUT_PULLUP);// input setup

  lcd.init();

  lcd.backlight();

  lcd.setCursor(16,2);

  Serial.begin(9600);

}

void loop() {

    int I1 = digitalRead (IRS1); // input for IRS1

    int I2 = digitalRead (IRS2); // input for IRS2

   if (I1 == HIGH) {

    digitalWrite(Cb, LOW); // Conveyor Belt stop

    lcd.setCursor(4,0);

    lcd.print("START");

    lcd.setCursor (4,1);

    lcd.print("FILLING...");// project in LCD 3 secs

    digitalWrite(Motor1pin, HIGH); // filling the bottle (motor on)

    delay(5000); // 3 secs fill the bottle
    lcd.setCursor(4,0);
    lcd.print("FINISH");
    lcd.setCursor (4,1);
    lcd.print("FILLED");
    delay(500); // project in LCD 0.5 secs
  }
  else if (I1 == LOW & I2 == HIGH) {
    digitalWrite(Cb, LOW);
    lcd.setCursor(5,0);
    lcd.print("START");
    lcd.setCursor (4,1);
    lcd.print("CAPPING..CW/CCW");

    digitalWrite(relay1, LOW);
    digitalWrite(relay2, HIGH);
    delay(3000); // cap for 3 secs counter

    digitalWrite(relay1, HIGH);
    digitalWrite(relay2, HIGH);
    delay(2000); // cap for 3 secs counter

    digitalWrite(relay1, HIGH);
    digitalWrite(relay2, LOW);
    delay(3000); // cap for 3 secs counter

    lcd.setCursor(4,0);
    lcd.print("FINISH");
    lcd.setCursor (4,1);
    lcd.print("CAPPED");
    delay(500);
  }
  else {
    digitalWrite(Cb, LOW);// Conveyor Belt Start
    digitalWrite(Motor1pin, HIGH);
    digitalWrite(relay1, HIGH);
    digitalWrite(relay2, HIGH);
    lcd.setCursor (5,0);
    lcd.print("START");
    lcd.setCursor (4,1);
    lcd.print("CONVEYOR...");
    delay(500);// project in LCD 0.5 secs
  }
}


texts: How do I handle multiple interrupts and outputs simultaneously?

texts:
I'd like to make a musical harp that utilizes break beam sensors.

I'd really appreciate guidance on these two questions:

How should I go about listening for multiple beam breaks at the same time? I'd like the box to be able to play cords, so I'd need to listen for the break beams while simultaneously taking the action do to other previous break beams. Are there any links to similar projects for guidance on handling multiple inputs (possibly multiple interrupts) at the same time, as well is multiple outputs?
Where is a good place to start to understand how to output non-buzzer sound with an Arduino? I bought a Adafruit Wave Shield to do the trick, but I'd appreciate advice on using this, or possibly taking an easier route.

My major concern is the first question however, and it makes me think I may need a Pi possibly? But I've never worked with those, so I'd like to avoid it if possible.

Thanks!  :)


texts: Fast PWM with Arduino, the inputs outputs don't work

texts:
Hello to the community!
I am using ATTINY85 and I am programming it through the AVRISP using an Arduino UNO.
This is the code I am using :
#include <avr/io.h>
#include <avr/interrupt.h>

void setup() {
    PORTB = 0;        //Reset values on port B

    // After setting up the timer counter,
    // set the direction of the ports to output
    DDRB |= (1<<PB1) | (1<<PB0) | (1<<PB3); // PB0, PB1 and PB3

    // PLLCSR - PLL control and status register:
    // PLL is a clock multiplier
    //      - multiplies system 8 MHz by 8 to 64 MHz
    // PLL is enabled when:PLLE bit is enabled,
    // CKSEL fuse is programmed to 0001.  This clock is
    //   switched off in sleep modes!
    PLLCSR |= (1<<PLLE);    // PLL enable

    // Wait until the PLOCK bit is enabled
    // before allowing the PCK to be enabled
    //WaitForPLOCK();
    //unsigned int i = 0;

    while ((PLLCSR & (1<<PLOCK)) == 0x00)
    {
        // Do nothing until plock bit is set
    }

    // Enable asynchronous mode, sets PWM clock source
    PLLCSR |= (1<<PCKE);

    TCCR1 = (1<<CTC1)    | // Enable PWM
            (1<<PWM1A)   | // Set source to pck
            (0<<(CS13))  |
            (0<<(CS12))  |
            (1<<(CS11))  |
            (1<<(CS10))  | // Clear the pin when match with ocr1x
            (1<<COM1A1);
    GTCCR = (1<<PWM1B) | (1<<COM1B1);

    // Set PWM TOP value - counter will count and reset
    //  after reaching this value
    //           OCR1C
    // 100 kHz   159
    // 80 kHz    199
    OCR1C = 199;

    // Enable Timer1 OVF interrupt
    TIMSK = (1<<OCIE1A) | (1<<TOIE1);

    sei();

    OCR1A = 190;  //chaning th FR
}

void loop() {
    PORTB |= (1 << PB3);
    delay(500);
    PORTB &= ~(1 << PB3);
    delay(500);
}

the problem is that when I use the PWM my rest of the outputs do not work . Any idea why is this happening?
I am using the ATTINY CORE library from Spence Konde.


texts:
I don't know if it's a stupid question but I need some help.
I am trying to follow this tutorial and I want to connect my arduino to PubNub. In the tutorial it says that I have to 'open PubNub.h and switch the comments for the Ethernet and WiFi lines' with some code provided there. But, when I open the file PubNub.h the only thing in there is this:

/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
#include "PubNubDefs.h"

class PubNub PubNub;

I'm quite new to this so I don't know much. I hope someone can help. Thank you in advance!


texts: Arduino nano clone problem with interrupt on falling edge on pin 2

texts:
I've s 1Hz square wave coming from a DS1307 SQW/OUT pin going into pin2 on the Nano that is set up as input with internal pullup enabled.
I've set up the interrupt on falling edge but I can't get the ISR to execute every second (it's not executing at all). If I wire up a button normally open to ground pin2 and I press and hold it down I can get the ISR to execute.
Where's the problem:

Is the DS1307 not grounding fast enough for the falling edge logic to
pick it up ?
Is the internal pullup resistance on pin2 too high for the square
wave to be picked up (tension on pin2 is never high enough to trigger
a falling/rising edge event) ?
Is 1Hz too fast for the internal falling/rising edge logic to trigger the
event ?
Have I done something else wrong ?
Is it a problem on the clone only ?

This is a snippet of the code to get an idea of what I'm trying to do:

    void rtc_setCG(byte val);
    const byte rtc_id = 0x68; //DS1307 i2c id: 0x68h, 104 dec, 150 octal, 1101000b
    pinMode(2, INPUT_PULLUP);
    attachInterrupt (digitalPinToInterrupt(2), rtcout_int, FALLING);

void rtcout_int ()
{ char buf[5] = "    ";
  time_t now;
  struct tm *ts;

  wdt_reset();
  noInterrupts();
  epoque++; //this is a global volatile unsigned long variable that holds the number of seconds since the arduino epoque
  interrupts();
}
void rtc_setCG(byte val)
{ Wire.beginTransmission(rtc_id);
  Wire.write((byte)0x07);
  Wire.write(val);
  Wire.endTransmission();
}
ISR (TIMER1_COMPA_vect)
{ byte nsecond;
  nsecond=(byte)((millis()/1000) % 60);
  if ( nsecond != second )
  { second=nsecond;
    epoque++;
    minute=(byte)((epoque / 60) % 60);
    hour=(byte)(((epoque / 3600) + timezone) % 24);
  }
}
rtc_setCG(0x10); //this is how I set up the ds1307 to do 1hz on the SQW/OUT

I've put a speaker on the SQW/OUT and I can hear it click so the DS1307 is set up right for what I'm trying to do but I can't get the ISR to execute on the falling edge. I tried plying with rising edge or change but made no difference.


texts: How to connect Arduino Mega2560/DUE to a perfboard?

texts: The pin position of Arduino mege2560 / due is not standard. I need to use the perfboard in the project and connect the DUE to it. This project is mainly to do a sampling circuit, the running speed of the whole circuit is between 10-20mhz, and the target signal to be collected is not less than 1MHz. A lot of underlying code is used in the programming process, and the whole circuit is similar to FPGA in operation, so the interference and delay become unacceptable. It seems that jumpers and DuPont wires are not the best choice. Besides being weak, they also introduce additional parasitic parameters and unexpected interference. I am not familiar with the use of drawing software and need to learn again, so it will cost a lot of time and money to draw PCB by myself. The hole spacing of the plate is 2.54mm. What should I do?


texts: nRF24L01 - leaves out end characters during transmission

texts:
This is my Master's code.

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

RF24 radio(7, 8);

const byte address[6] = "00001";
char text[20] = "";
int flag;
char *p;
int i;

void print();
void read();
void rfwrite();
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_1MBPS);
  radio.setChannel(1);
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();

  flag = 0;
  p = text;
}

void loop() {

  if (Serial.available()) {
    read();

  }
  if (flag) {
    print();
    rfwrite();

  }

}

void print() {
  Serial.println(text);
  flag = 0;
}

void read() {
  p = &text[0];
  for (i = 0; Serial.available(); p++, i++) {
    *p = Serial.read();
  }
  text[i + 1] = '\0';
  flag = 1;
}

void rfwrite() {

  radio.startWrite(text, strlen(text)+1);

}

Slave code:

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

RF24 radio(7, 8); //ce,csn

const byte address[6] = "00001";
char text[20] = "";
int  i;

void write_to_array();
void print();
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_1MBPS);
  radio.setChannel(1);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  while (radio.available()) {

    write_to_array();
    print();

  }

}

void write_to_array() {
  radio.read(text, strlen(text)+1);

}

void print() {
  Serial.println(text);

}

I edited the code and made it with an array like @Kwasmich said. But now some end characters are not getting printed. When I type 1234567890-= into the transmitter, only 1234567890- gets printed. When I type a new set of characters following that, the missing = gets printed. Also, this happens only on the second transmission after I upload the code to the Arduino. The first set of characters are received and printed correctly. How do I fix this? Will flushing the buffer help(I doubt this because the first transmission is received correctly)?


texts: legality of streaming data on 868 or 915 Mhz in EU/US

texts:
From what I read about duty cycles in the EU there is a 10% limitation (even less in some sub bands).
The modules I found have a max. rate of 300 kbps. Even if you max out the duty cycle that would only be 30kbps.
How do consumer devices like a digital walkie talkie operate here legally in the EU?
What am I missing?
Is there a frequency where I can legally stream constantly at more than 70kbps (not Wifi) ?


texts: SoftwareSerial receives beginning of data mangled

texts:
I'm using SoftwareSerial to communicate with a Sigfox module. Documentation for the read function assigns its value to a char. However using it I get mangled characters and also have read in other question that I should assign it to int as it can return -1 for no data and [0;255] for received character.
This is my basic troubleshooting example:
#include <SoftwareSerial.h>
SoftwareSerial Sigfox(11,10);

void setup() {
  Serial.begin(9600); // HW serial
  Sigfox.begin(9600); // SW serial --> sigfox
}

void loop() {
  if(Sigfox.available()) {
    int c = Sigfox.read();
    Serial.write(c);
  }
  if(Serial.available()) Sigfox.write(Serial.read());
}

When c is char, I get -5 instead of OK. Also other output is mangled. When c is int, it receives the data OK.
My question is - why they use char in the example in documentation? Why is char signed in Arduino?
I want to read the entire line of text from serial port and store it into array. How to define that array? I have found an example on web that uses char buffer[32], but then again I get mangled data when I assign to it. If I use array of byte/int/unsigned char, I can't print it as Serial.write(SF_buffer); won't compile because of no matching function for call to 'write(unsigned char [32])'.
So what variable types should I use to receive and store the text from SoftwareSerial correctly?
Here is my function for reading the whole line:
unsigned char SF_buffer [32]; // max length of line to read from serial
bool SigfoxReadine() { // return true when whole line was received and is in buffer
  static int SF_cnt=0;
  while (Sigfox.available()) {
    int c = Sigfox.read();
    SF_buffer[SF_cnt++] = c;
    if ((c == '\n') || (SF_cnt == sizeof(SF_buffer)-1)) {
       SF_buffer[SF_cnt] = '\0';
       SF_cnt = 0;
       return(true);
    }
  }
  return(false);
}

UPDATE:
Trying readBytesUntil - the same result, but I have found that issue is only when I send data to module using println as in this example:
#include <SoftwareSerial.h>
SoftwareSerial Sigfox(11,10);

void setup() {
  Serial.begin(9600); // HW serial
  Sigfox.begin(9600); // SW serial --> sigfox
  Sigfox.println("AT$I=11");
}

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

void SF_read() {
  if (Sigfox.available()) {
    char buff[32];
    int l = Sigfox.readBytesUntil('\n', buff, sizeof(buff));
    if (l > 0 && buff[l - 1] == '\r') {
      l--; // to remove \r if it is there
    }
    buff[l] = 0; // terminate the string
    Serial.println(buff);
  }
}

The response to first command (in setup) is mangled. The response to the same AT command manually written into serial monitor (and sent to module via Sigfox.write in loop) is OK.

ӂ*⸮FBB1E27EE7
3430E2FBB1E27EE7

Also maybe I'm little lost in when to use print and when write... Example says to use write() to send back the char that was read(). Juraj's response uses println() to print the null-terminated buffer. What is the difference when I write/println this buffer?


texts: How to prevent file overwriting in processing?

texts: i am working on this arduino project using processing. There are some sensor values which should be logged, but unfortunately my processing code rewrites the file after each cycle so that i get the last sensor value only. How do i prevent this from happening? I am using the ordinary method by the way. PrintWriter command followed by createWriter


texts: MKR ZERO is not detected in IDE / MKR ZERO not showing up in windows 8.1/

texts: I m connect it with my IDE software and its work perfectly yesterday, but today morning I'm connected it to software to upload another sketch but its didn't detect the port and the charge led is not on yesterday but today is on. I tried every resolution which is given on website but its didn't work. please help me through this I'm new to this board.


texts: How to control Keyboard inputs using arduino(serial monitor) and python keyboard libraries?

texts:
I am able to control my monitor and most other applications by giving serial input to python through arduino.
Arduino code:

void setup()
 {

  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  Serial.begin(9600);

}

void loop()
{
  if(digitalRead(2) == HIGH)
  {
    delay(5);
  }
  else
  {
    Serial.println("up");
  }
  if(digitalRead(3) == HIGH)
  {
    delay(5);
  }
  else
  {
    Serial.println("down");
  }
  if(digitalRead(4) == HIGH)
  {
    delay(5);
  }
  else
  {
    Serial.println("left");
  }
  if(digitalRead(5) == HIGH)
  {
    delay(5);
  }
  else
  {
    Serial.println("right");
  }
  if(digitalRead(6)== HIGH)
  {
    delay(5);
  }
  else
  {
    Serial.println("space");//orange
  }
  if(digitalRead(7)==HIGH)
  {
     delay(5);
  }
  else
  {
    Serial.println("nitro");//brown
  }
 }

Python code:

import serial
from pymouse import PyMouse
from pykeyboard import PyKeyboard

k = PyKeyboard()

ser = serial.Serial('COM7', 9600)

#sp.write("AT\r\n".encode('ascii'))

while True:
    p=ser.readline()
    print p
    if ('up' in p):
        k = PyKeyboard()

        k.tap_key(k.up_key)

    if ('down' in p):
        k = PyKeyboard()

        k.tap_key(k.down_key)

    if ('right' in p):
        k = PyKeyboard()

        k.tap_key(k.right_key)

    if ('left' in p):
        k = PyKeyboard()

        k.tap_key(k.left_key)

    if ('space' in p):
        k = PyKeyboard()

        k.tap_key(k.space_key)

    if ('nitro' in p):
        k = PyKeyboard()

        k.tap_key(k.enter_key)

My problem is that..I am not able to play games such as NFS and other similar games using these controls..
What should i do??


texts: I'm using ESP with USB to serial converter (D-SUN) is it possible to use the 3.3 volts of the USB instead of the Arduino Uno?


texts: Getting an error while uploading a code to the Arduino when ethernet shield is attached

texts:
I bought ethernet Shield today and connected it to Arduino Uno, now when I try to upldoad I get the following error, however if I remove the shield from the UNO it works fine.

Sketch uses 10,486 bytes (32%) of program storage space. Maximum is 32,256 bytes.
Global variables use 661 bytes (32%) of dynamic memory, leaving 1,387 bytes for local variables. Maximum is 2,048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

Is it something wrong with he ethernet shield ?
Ethernet is not plugged in but even when i plug in the ethernet wire the indicators at Jack does not lit up


texts: Is an Arduino Board Manager available in Visual Studio 2013 Community Edition?

texts:
I want to try different hardware but it is tedious switching to the Arduino ide to install hardware. Surely I can do this from Visual Studio?

If so then how? I can't find the options.


texts:
I need to know if there is a sensor that mesure pH and ORP, I have already googled about this type of sensor but i found only AtlasScientific that commercialise this kind of sensor

thanks


texts: Reading an MCP23S17 I/O expander port with the Arduino SPI library

texts:
I am trying to read an MCP23S17 I/O expander port B with the Arduino SPI library.
The following example is simple as possible, and I still can not get it to work.

The setup is an MCP23S17 I/O expander on a Teensy LC controller.
MCP23S17 port B pins are alternately grounded and energized.
I confirmed the pin voltages with a multi-meter.
Variable portBState is a bitwise reading of port B, and printed.

Expected output is:

10101010

Actual output is:

11111111

Sketch:

#include <SPI.h>

const uint8_t ADDR = 0x20;      //MCP23S17 address, all 3 ADDR pins are grounded
const uint8_t OPCODE_READ  = (ADDR << 1 | 0x01); //MCP23S17 read command

const uint8_t IODIRB = 0x01;
const uint8_t GPIOB  = 0x13;

uint8_t portBState = 0;                 //bit wise

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

    pinMode(SS, OUTPUT);                //configure controller's Slave Select pin to output
    digitalWrite(SS, HIGH);             //disable Slave Select
    SPI.begin();

    //IODIRB register is already configured to input by default

    SPI.beginTransaction(SPISettings (SPI_CLOCK_DIV8, MSBFIRST, SPI_MODE0));
    digitalWrite(SS, LOW);              //enable Slave Select
      SPI.transfer(OPCODE_READ);        //read command
      SPI.transfer(GPIOB);              //register address to read data from
      portBState = SPI.transfer(0);     //save the data (0 is dummy data to send)
    digitalWrite(SS, HIGH);             //disable Slave Select
    SPI.endTransaction();               //release the SPI bus

    Serial.println(portBState, BIN);    //should print 10101010
}

void loop() { }

Why is the output not "10101010"?

The controller is Teensy LC (3.3 volts) on Arduino 1.6.7.
SPI library: https://www.arduino.cc/en/Reference/SPI
More links in the comments below (I don't have enough reputation points to post more links in the question).


texts:
I have a very big problem by writing a list of strings to an eeprom (24LC1025) Your help with my problem highly appericiated.

I have a data matrix, PageData[111][96] and I want to write all them at once, line by line to the eeprom. I am using arduino for coding.

the code is :

{

#include <Wire.h>

#define EEPROM_ADDR 0xA0;

void setup()
{

  Wire.begin();

  Serial.begin(9600);
int PageData[111][96]={ my data is here ... }

 for (t=0; t<111; t++){
  for (unsigned long i=0; i<96; i++){
    m=i*2;
    value[m] = highByte(PageData[t][i]);
    value[m+1] = lowByte(PageData[t][i]);   }

  at=((t*192));

 for (unsigned long i=0; i< 192; i++) {
    i2c_eeprom_write_byte(EEPROM_ADDR,(at+i),value[i]);
    delay(5);                             }
      }

void i2c_eeprom_write_byte( int deviceaddress, unsigned long eeaddress, byte data )
{
if( eeaddress > 65535 )
    deviceaddress = deviceaddress | B00001000;

    deviceaddress = deviceaddress >> 1;

  byte rdata = data;
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));    // Address High Byte
  Wire.write((int)(eeaddress & 0xFF));  // Address Low Byte
  Wire.write(rdata);
  Wire.endTransmission();
}

My problem in this code: when I want to read the eeprom for the checking the strings, I realize, it does not write the eeprom the whole 111 line. It just writes randomly sometimes half of this sometimes less than this amount.

I tried several ways to solve the problem. but now I am desperate , please check this and tell me where i miss a point. Please let me know, if any information you need for the answer.


texts: Help adding 3 more on/off switches so that I can control 4 LEDs

texts:
This code is working fine to switch on/off one LED. Can anyone help me add 3 more on/off buttons so that I can control 4 LEDs?

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

byte mac[] = {
  0xDE , 0xAD , 0xBE , 0xEF , 0xFE , 0xED
};
byte ip[] = {
  192 , 168 , 2 , 20
};
byte gateway[] = {
  192 , 168 , 2 , 1
};
byte subnet[] = {
  255 , 255 , 255, 0
};
EthernetServer server(80);
String richiesta;
int pinLed = 9;

void setup() {
  Ethernet.begin(mac,ip,gateway,subnet);
  pinMode(pinLed,OUTPUT);
  Serial.begin(9600);
  richiesta = "";
}

void loop() {
  EthernetClient client = server.available();
  if(client) {
    Serial.println("Tujse na ho payega");
    while(client.connected()) {
      if(client.available()) {
        char c = client.read();
        richiesta.concat(c);
        if(c == '\n') {
          Serial.print(richiesta);
          if(richiesta.indexOf("Led=1")>0) {
            Serial.println("Pin will be high");
            digitalWrite(pinLed,HIGH);
          } else {
            Serial.println("Pin will be low");
            digitalWrite(pinLed,LOW);
          }
          client.println("HTTP/1.1 200 ok");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<title> Home Automation</title>");
          client.print(" ButtonOn  Buttonoff ");
          client.stop();
          richiesta = "";
        }
      }
    }
  }
}


texts: How do you convert a formatted print statement into a string variable?

texts:
I'm using the following routine to print the current time on the com port. I would like to capture this as a string so I can display it using ePaper.

void printLocalTime()
{
  time_t rawtime;
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo))
  {
    Serial.println("Failed to obtain time");
   return;
  }
 Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}

produces - Saturday, May 12 2018 12:18:27


texts:
Could I have some help getting the following code work?

My purpose is to turn on 4(or N) LEDs in a binary sequence with 4 (or N) bits, A,B,C,D. When bit=1, LED on, otherwise LED off,...

I will have 16 combinations, 2^4=16, so:

0000 => All leds off
0001 => All leds off except the one on the right
...

Here's the code I came up with:

int LEDblu=4;
int LEDgiallo=2;
int LEDrosso=5;
int LEDverde=7;
int num_led;
String numeri="";
String output;
int i=0;
int p;

void setup() {
    // put your setup code here, to run once:
    pinMode(LEDblu,OUTPUT);
    pinMode(LEDgiallo,OUTPUT);
    pinMode(LEDrosso,OUTPUT);
    pinMode(LEDverde,OUTPUT);

    Serial.begin(9600);

    if(Serial.available())                //Dimmi numero LED
    {
        num_led=Serial.readString().toInt();
        Serial.print(num_led);
    }
}

void loop() {
    // put your main code here, to run repeatedly:
    int vect[num_led];
    for(int i=num_led-1, c=0; i>=0; i--, c++)
    {
        int num=2^i;
        vect[c]=num;
    }

    output="";

    if(i<2^num_led)
    {
        p=i;

        for(int c=0; c<num_led; c++)     //Convert binary to decimal
        {
            if(p>=vect[c])
            {
                output+="1";
                int d=vect[c];
                p-=d;
            }
            else
                output+="0";
        }

        Serial.println(output);

        if(output[0]=="1")
            digitalWrite(LEDrosso,HIGH);
        else
            digitalWrite(LEDrosso,LOW);

        if(output[1]=="1")
            digitalWrite(LEDverde,HIGH);
        else
            digitalWrite(LEDverde,LOW);

        if(output[2]=="1")
            digitalWrite(LEDgiallo,HIGH);
        else
            digitalWrite(LEDgiallo,LOW);

        if(output[3]=="1")
            digitalWrite(LEDblu,HIGH);
        else
            digitalWrite(LEDblu,LOW);
    }

    delay(1000);
    i++;
}


texts: Mac OS X Catalina Serial Monitor Problem

texts:
I have some problems on MacBook Pro running with Catalina. I bought new nodemcu LoLin board. Its clone. It has ch340 adapter to communicate. And writing on bottom side wemos.cc and use ch340g driver.

I succesfully installed drivers and I can see my lolin boards on port list

I upload a code that doing only print hello to serial port. I tried with 9600 and 115200 baud rates. My serial monitor show garbage data. I am using platform io with VSCode to upload code and upload time is too much.When I am uploading code I got this warning :

"Detected crystal freq 156.04MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?"

I am using cheap thundeIrbolt usb converter too. But I connect with this converter to Windows pc, everything looks fine. I can see hello world on serial monitor. But on my Mac, I can see garbage only. I tried some serial monitors, Arduino IDE and platform io ide but still same.

Are there any solution about this problem?

EDIT :

I fixed issue last night. Catalina has ch340 drivers already and I setup oem driver from GitHub. Apples driver and oem drivers conflicting. If you use Mojave and higher os, you dont need any driver for ch340. So if you installed ch340 oem  driver you should delete it.

I am adding the post:
Platformio post


texts: Noise from the I2C - digital potentiometer

texts: I have a digital potentiometer controlled by Arduino, connected via the I2C bus (it controls volume). For some reason it beeps just by itself, even when no audio is playing. I have checked that it is def. I2C, as when I unplug the SDA&SCL then there is no noise (and I have many more connected to Arduino. Is there anything special about "de-noising" the I2C bus?


texts: Arduino Micro serial communication is not working after wake from power down

texts:
I'm trying to use the power down state for a battery application, but I'm having issues with the serial communication.

I'm using the lowpower.h library to put the Arduino Micro into power down mode.

When it wakes I flash an LED, which is working, so I know it's is waking up. And I also re-establish serial communication and send a message. This is not working. I receive nothing on the serial monitor, however the TX LED does flash.

I think the Arduino may be working correctly, but for some reason the serial monitor can't handle it. Perhaps there is a better serial monitor application?

#include "LowPower.h"

void setup()
{
    //20sec delay added to make uploading easier (cant upload in power down state)
    Serial.begin(115200);
    Serial.println("20");
    delay(5000);
    Serial.println("15");
    delay(5000);
    Serial.println("10");
    delay(5000);
    Serial.println("5");
    delay(5000);
    Serial.println("START");
    pinMode(LED_BUILTIN, OUTPUT);
    delay(1000);
    Serial.end();
}

void loop()
{
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

    Serial.begin(115200);
    delay(100);
    Serial.println("BLINK");
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(5000);                       // wait for a second
    Serial.println("BLINK_stop");
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(5000);                       // wait for a second

    Serial.end();

}

Serial monitor output:

20
15
10
5
START

and then nothing...


texts:
I have a PM10 sensor that I'd like to get the values from.

Here's the official documentation from the sensor:

I've looked as serial communication, but how do i process byte by byte of information if it's coming in byte at a time?

I'm looking at this example:

void setup() {
  Serial.begin(9600);
  Serial.println("<Arduino is ready>");
}

void loop() {
  recvOneChar();
  showNewData();
}

void recvOneChar() {
  if (Serial.available() > 0) {
    receivedChar = Serial.read();
    newData = true;
  }
}

void showNewData() {
  if (newData == true) {
    Serial.print("This just in ... ");
    Serial.println(receivedChar);
    newData = false;
  }
}

Ideally, i'd like to get the PM2 and PM10 values and print them out.


texts: Why does this code not respond promptly to changes in the LDR reading?

texts:
So, I wrote some simple code like this :

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Serial.begin (9600);
}

void loop() {
  LDRValue = analogRead(LDRSensor);
  Serial.println(LDRValue);
  delay(50);
}

The line will print the value of LDR sensor simultaneously, but when I add this "if" condition inside the loop :

 if (LDRValue < 100) {
   colorWipe(strip.Color(255, 0, 0), 50);
   colorWipe(strip.Color(0, 255, 0), 50);
   colorWipe(strip.Color(0, 0, 255), 50);
   colorWipe(strip.Color(0, 0, 0, 255), 50);
   theaterChase(strip.Color(127, 127, 127), 50);
   theaterChase(strip.Color(127, 0, 0), 50);
   theaterChase(strip.Color(0, 0, 127), 50);
   rainbow(20);
   rainbowCycle(20);
   theaterChaseRainbow(50);
  }

the LDR  value only printed once..

Is it a wrong "if" condition code ? I know it's kinda lame, but please give me some starting point, doesn't need to be fancy just a small lead will do, thanks!

edit : complete library


texts: Writing and Reading data from RTC module EEPROM_Arduino

texts:
i have took below code from https://lastminuteengineers.com/ds1307-rtc-arduino-tutorial/. i am not understand what these codes are doing. please help me to understand.

Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB

Thanks


texts: Serial.readString() not working becaue of outdated IDE?

texts:
I've searched google honestly but can't find an answer nor changelogs for Arduino that might be the answer.

Basically I'm trying to use Serial.readString() to input commands to the Serial Monitor but it shows an error that readString is not a member of 'HardwareSerial'.

I am using Arduino 1.0 as IDE because the device I'm using (Aceduino) seems to have a custom IDE derived from 1.0 so I'm not sure if it will work with newer IDE versions. Wondering if that was what's causing the eror


texts:
Using one of the RobotDyn boards with onboard WiFi and a Generic ESP8266 module.

I can load the sketch, but when WiFi.status() is called to see if WiFi enabled, the sketch hangs, rebooting the board after ten seconds are so.

void setup() {
  Serial.begin( 115200 );
  Serial.println( "begin - wifi status: " );
  // program hangs here - - - - - - -
  int status = WiFi.status();
  Serial.println( status );
}


texts: Not sure if logic analyzer shows an error or perhaps just a 'relay bounce'

texts:
I have an Arduino controlling a relay. I was taking a look at the timings using a logic analyzer and at the onset of the relay switching, it quickly switches again.

This seems to be occurring randomly and I thought it could be highlighting a problem with my code but I wondered if it might just be a 'relay bounce' due to the speed of the switch. I've attached an image below. Any feedback is greatly appreciated. Thanks.


texts:
This is a "water level alarm/display" sketch using and Arduino and ultrasonic sensor.
The buzzer gets on when the water level hits 100% or more.
But most of the time the water level will stay @ 100%, and I dont want the buzzer to run for long time.
How can I set the buzzer to make sound only for 15 seconds ?
It should turn off after 15 seconds, even if the water level is @ 100%

#define trigPin 8
#define echoPin 9
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int BUZZER = 10 ;

void setup(){
      int duration,distance,percentage,heightTank;
      Serial.begin (9600);
      pinMode(trigPin,OUTPUT);
      pinMode(echoPin,INPUT);
      lcd.begin(16,2);
      lcd.print("HELLO");
        pinMode(BUZZER,OUTPUT);
}

void loop(){
      int duration,distance,percentage,heightTank,deviation;
      //You'll probably want to change the next 2 lines.
      // The first one is the max. level of the water.
      // The next one is how high the sensor is above that max. level.
      heightTank=65;
      deviation=4;

      digitalWrite(trigPin,HIGH);
      delayMicroseconds(1000);
      digitalWrite(trigPin,LOW);
      duration=pulseIn(echoPin,HIGH);
      distance=(duration/2)/29.1;
      percentage=100-(((distance-deviation)*100)/heightTank);
      Serial.println(distance);
      Serial.println(percentage);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Current tank");
      //lcd.print(distance);
      //lcd.print(" cm");
      lcd.setCursor(0,1);
      lcd.print("level: ");
      lcd.print(percentage);
      lcd.print(" %");
      delay(1000);

      digitalWrite(BUZZER,HIGH);
  if (percentage > 99) {digitalWrite(BUZZER,HIGH); delay(100); digitalWrite(BUZZER,LOW); delay(100);}
  else  {digitalWrite(BUZZER,LOW);}
  }


texts: Arduino Pro Mini Avrdude stk500_getsync() not in sync

texts:
I'm new to arduino and I have a project to make a gesture sensor controller but now I'm about to test the APD9960 gesture sensor; when I program the Arduino Pro mini it keeps sending me an error  (avrdude stk500_getsync() not in sync).
This is the connection that I use. I just copied the diagram from Circuito.io:

These are my tools settings:


texts: Connect two SD cards to one Arduino board and copy from one to another

texts:
I'm trying to connect 2 SD cards to an Arduino Uno board.

My first question is: Is it possible to connect two SD cards to one Arduino simultaneously?
The second question is: If it is possible to connect 2 SD cards, How can I copy card 1 data to card 2

My project goal is to copy data from one peripheral memory to another peripheral memory when an external interrupt occurs.
Can anyone help me please ?


texts: How to access 315mhz signals from household devices, with an arduino 315mhz kit?

texts:
Background:

I am looking into automation and I have realized that many of the devices I have around my house transmit 315mhz to their specific controllers.  I know this from reading the labels on the back that say 315mhz

Question:

Is there a way I can use a 315mhz receiver with an arduino to view the signals and log the data based on what happens and mimic certain actions with the transmitter?  In other words can I program the reciever to display every bit passed through 315mhz that is in range?

I know the virtual wire library parses the data before I receive it, but I don't know to what extent?  If I just dedicate the arduino to watch that pin and print results will that tell me what is being sent?

Thanks Very Much,

Joel


texts: Arduino reading serial data non-blocking

texts:
I have an Arduino reading serial data and responding to other inputs as well, I'm trying to read incoming serial data without using the while, if at all possible. the incoming serial data will be formatted in a specific manner each time and will be CSV; It will look like such:

19,1400700083, 1-0,1-10,and other values delimited with a new line character "/n".

The first value will tell how many bytes are coming in so the serial receive function wont parse data until it gets all the bytes,second value is a Unix time-stamp, the third value (1-0) is the "get" or set" value; which will tell the Arduino to return a value or to set a value. The fourth (1-10) value will correspond to what variable to get or set. and the other values will be integers as well but are dependent on the other values.

My code is as follows:

void CheckSerialData() { // begin function

  if(Serial.available() >= 2) { // begin one, first line will be how many bytes incoming.
  int NumberOfIncomingBytes = Serial.parseInt();
    if(Serial.available() >= NumberOfIncomingBytes) { //begin two
    int IncomingTime = Serial.parseInt();
    setTime(IncomingTime); //time is always incoming with serial values
    int GetOrSetValue = Serial.parseInt(); //this value should be 1 or 0 for "getting values(1)" or "setting values(0)"
      if(GetOrSetValue == 1) { //BEGIN THREE
        int ValueToGet = Serial.parseInt();
          switch(ValueToGet) {// BEGIN SWITCH
            case 0:
              Serial.print(GetTemp());
              Serial.print("/n");
              break;
            case 1:
              //serialwrite yaw pitch roll
              break;
            case 2:
              Serial.print(GetVoltage());
              Serial.print("/n");
              break;
            case 3:
              //append all RGB final values together and serial print it
              break;
            case 4:
              //print out accel values
              break;
            case 5:
              //print alarm alarmed status
              break;
            case 6:
              //print out last time alarm set off
              break;
            case 7:
              //print out time allowed lights to turn on
              break;
            case 8:
              //print out arduino time
              break;
            case 9:
              //print out system summary, (time,voltage,temp,yaw,pitch,roll,accel
              break;

          }//END SWITCH
         }//END THREE
      else { //BEGIN TWO B //SET VALUES
      int ValueToGet = Serial.parseInt();
          switch(ValueToGet) {// BEGIN SWITCH
            case 0:
              //set global rgb value set LEFT
              break;
            case 1:
              //set global rgb value set RIGHT
              break;
            case 2:
              //set global alarm value
              break;
            case 3:
              //set global angle to start flashing emergency led's
              break;
            case 4:
              //set turn signal RGB value
              break;
            case 5:
              //set time that lights are ok to turn on
              break;
            case 6:
              //set light override value
              break;
            case 7:
              //set pattern enable
              break;

          } //END SWITCH

      }//END TWO B

          }
        }//end two
      }//end one
    }//end function
    //**********************END SERIAL FUNCTION**************************

I would like to know if this looks like it can work, or am I going about this all wrong?

(I don't have access to my Arduino currently to test the code)


texts:
I am learning UART  and the problem that i have is understanding what happens when i send serial data to my PC via USB which is built in to the Arduino uno board.

For incoming serial data i am using Terminal v1.9b and it basically lets me to set some parameters and listen to incoming data on Software serial port and or write to it.

The process:

Atmega328p's Baud rate is set to 9600
Terminal connects to it (it performs a reset) and i get my data in.

Very simple, it all works and i don't have a problem with it. What my question is: I assume that my PC doesn't talk to atmega328p directly since it has no USB interface. it talks to a bootloader chip which converts the USB to UART and then i receive that message on my atmega328p. How does that chip know which baud rate we agreed to. OR "Terminal" sends the baud rate to that bootloading chip via usb protocol and it sets its UART settings ?


texts: I have seen a lot tutorials on L298N motor driver with nodemcu and ESP 32, which are 3.3v logic boards where the motordriver is a 5v logic board, now in Arduino while doing speed control 255 means 5v or even a high means 5v but in nodemcu/ESP32 this means 3.3v, so my question is how it will work ?


texts: How does coordinator XBee receive data from router?

texts:
I have two XBees S2, one is configured as an API coordinator connected to Arduino and the other as an AT router.

The coordinator sends a frame to the router to switch on a LED. I want to switch off that LED with a button and the router send a message to the coordinator to tell him that it switch off the LED.

How can I do this?

I have one Arduino with the coordinator. I'm asking what I have to put in the script to make the coordinator receive the data.

Here is my code, how the coordinator sends the data to the router:

String inputString;
int led = 13;
void setup() {
pinMode(led, OUTPUT);
Seria.begin(9600);
}
void loop() {
while (Serial.available() ) {
// get the new byte:
delay(3);
char inChar = Serial.read();
// add it to the inputString:
inputString += inChar;
}
if (inputString.length() >0) {
Serial.println(inputString);
if (inputString == "on"){
digitalWrite(led,HIGH);
setRemoteState(5);

}
inputString="";
}
}

void setRemoteState(char value){
Serial.write(0x7E); // start byte
Serial.write((byte)0x0);
Serial.write(0x10);
Serial.write(0x17);
Serial.write((byte)0x0);
// id of recipient or use 0xFFFF for broadcast
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write(0xFF);
Serial.write(0xFF);
// 16 bit of reciepent
Serial.write(0xFF);
Serial.write(0xFE);

Serial.write(0x02);

  Serial.write('D');
  Serial.write('2');

 Serial.write(value);

long sum = 0x17 + 0xFF + 0xFF + 0xFF + 0xFE + 0x02 + 'D' + '2' + value;
Serial.write(0xFF - ( sum & 0xFF) );
Serial.print(sum,HEX);
}


texts: Powering ESP8266 module from arduino nano

texts:
I'm just starting up with arduino and i have few simple questions.

Why shouldn't i power ESP8266 WiFi module directly from arduino nano 3.3V rail? There are bunch of tutorials explicitly avoiding this or using resistors and i would like to know why?
Could i use something like a Mean Well Switching Power Supply, 5V 10A to power the Arduino Nano and therefore have stable voltage by avoiding batteries and by doing so, connect ESP8266 directly to arduino without fear of breaking something?
Could Arduino nano be powered through USB? And if yes, would it be then safe to connect ESP module to arduinos' 3.3V rail?


texts: MKR GSM 1400 Works only when connected to computer

texts: My MKR GSM 1400 works fine when connected to a computer (powered USB) and after opening a serial connection to it.  It does not when I plug it into a power supply. My power supply is a 5V 3A with a USB adapter.


texts: How to find the pin map for the LCD 1602 I2C adapter module?

texts:
I'm working with I2C to work with my LCD 1602 and the I2C adapter.
This module has 16 pins and I don't know how to communicate with it.
I2C sends 8-bit packets. What are the commands to deal with this module, because it has 16 pins?
This is my current code:
void I2C_init(void);
void I2C_start(void);
void I2C_stop(void);
void I2C_tx(uint8_t data);
void I2C_TWSR_Check(void);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  I2C_init();
  I2C_TWSR_Check();
  I2C_start();
  I2C_TWSR_Check();
  I2C_tx(0x20);
  I2C_TWSR_Check();
}

void loop() {
  uint8_t i;

  for (i = 0; i < 5; i++)
  {
    I2C_tx(0xff);
    I2C_TWSR_Check();
    _delay_ms(500);
  }
}

void I2C_init(void) {
  //set SCL to 100kHz
  TWSR = 0x00;
  TWBR = 0x48;
  //enable TWI
  TWCR = (1 << TWEN);
}

void I2C_start(void) {
  TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
  while (!(TWCR & (1 << TWINT)));
}

void I2C_stop(void) {
  TWCR = (1 << TWINT) | (1 << TWSTO) | (1 << TWEN);
}

void I2C_tx(uint8_t u8data) {
  TWDR = u8data;
  while (!(TWCR & (1 << TWINT)));
}

void I2C_TWSR_Check(void) {
  uint8_t Status;
  Status = TWSR & 0xF8;
  switch (Status)   {
    case 0x08:    // start OK
      Serial.println("Start is OK");
      break;
    case 0x10:    // Re start
      Serial.println("Re start");
      break;
    case 0x18:        // SLA+W OK ACK
      Serial.println("SLA+W OK ACK");
      break;
    case 0x20:        // SLA+W no ACK
      Serial.println("SLA+W no ACK");
      break;
    case 0x28:        // data OK ACK
      Serial.println("data OK ACK");
      break;
    case 0x30:        // data OK no ACK
      Serial.println("data OK no ACK");
      break;
    case 0x38:        // arbitration lost in SLA+W or data TX
      Serial.println("arbitration lost in SLA+W or data TX");
      break;
    default:
      Serial.println("Error");
      break;
  }
}

I don't know I get first case working all the time. I can't proceed to sending the data.
This is the most I got from google images:
PCF8574 I2C backpacks for HD44780 Compatible LCD Module Arduino Raspberry


texts: Will the L9823 work at 3.3v with Wemos boards?

texts:
Or is it 5v only?
https://www.st.com/en/automotive-analog-and-power/l9823.html
I see in the data sheet it lists under Absolute Maximum, Supply Voltage:  VDD -0.3v to 7v
Then, under Electrical Characteristics:  4.5 V < VDD < 5.5 V; unless otherwise specified.
Is the Electrical Characteristics section just listing values for an example voltage of 5v, or does the chip need 5v to work properly?


texts:
I just ran into this article: Arduino: What adapter?.

It says that the external power supply should be 9-12V. That really surprises me, since my Arduino Uno can also be powered via USB, which is 5V.

Later he talks about a 9V pin. But I can only see a 5V and 3.3V pin on mine. Is he talking about a different version of Arduino?

Judging from the picture, his Arduino looks slightly different from my Arduino Uno R3, but I can't tell which version is on the picture.


texts: Potentiometer motor system is not working

texts:
I am setting up a potentiometer system that includes a motor that is supposed to spin with the potentiometer changing the speed of the spin and a button to reverse it. I checked the coding and it is correct, the potentiometer, button, and motor are all functioning, but the system does not run. Can anyone propose any solutions to this issue?

int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int switchPin = 7;
int potPin = 0;

void setup() {
  Serial.begin(9600);
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  pinMode(switchPin, INPUT_PULLUP);
}

void loop() {
  int speed = analogRead(potPin) / 4;
  Serial.println(speed);
  boolean reverse = digitalRead(switchPin);
  setMotor(speed, reverse);

}
void setMotor(int speed, boolean reverse)
{
  analogWrite(enablePin, speed);
  digitalWrite(in1Pin, ! reverse);
  digitalWrite(in2Pin, reverse);

}


texts: Servos stop after a while in case of 8 servo motor control

texts: I recently purchased 10 units of MG996R servo motor and the 16 channel 12-bit PWM/Servo driver from Adafruit for a small project. I confirmed that all of my servos are functional and that my code is correct. My issue is that there seems to be a limit on the number of servos I can run. With 4AA batteries, I can power about 3 of the MG996R servos. Starting with the 4th one, they stop moving. I supposed that the current drawn from the servos is high, so I tried powering the servos by providing two 4AA batteries in parallel (8AA). This appeared to have increased the number of servos I can run. But after a few minutes, the servos stop responding and I have to disconnect the power for a while before the servos respond again. I read on Adafruit that I may need to add a capacitor to the PWM/servo drive if I have multiple servos. Is this my problem or I just need to provide more power? Why do the servos seem to respond initially but stop moving after a while? Thanks in advance.


texts: Print string from arduino to serial monitor

texts:
I want to send text over serial monitor to Arduino and make Arduino return that string back to me over serial monitor.

I have made this function which reads from serial input and returns a string object.

String readSerial() {
    String input;
    while(Serial.available() > 0)
        input.concat(Serial.read());
    return input;
}

In the loop() I have:

if(Serial.available()) Serial.print(readSerial());

If I just do something like Serial.print("Hello world!"); everything is fine. But, if I try to return string object I get lot's of numbers.

I guess Serial.print doesn't know how to read String object and returns ASCII codes of characters or something?

[update]
I have checked it, and it's indeed outputing ASCII codes. For Hi I get 72105.

[update]
I have updated my readSerial function to use this :

input += (char)Serial.read();

But now I'm getting carriage return and new line after every character:

[SEND] Hi
H(CR)
i(CR)

So, how can I make it return my text so that is readable?


texts: I want to control a scientific instrument with an Arduino through GPIB. I have a USB-GPIB adapter, so I would want to do it through the USB. There are tutorials on the Internet on how to connect Arduino to a GPIB instrument through pins, but I did not fid any explanation of how to do it though USB. Is there a software package I can use?


texts: 'Non-Deterministic' memory usage on Arduino

texts:
I had a problem with a memory leak in my sketch and cornered it with MemoryFree.h. This works great and I was able to fix my leak.

My sketch is not really static, but My var sizes are. I observed, that the free memory on the arduino reaches a different values and stays there.

For Example

Run 1: 1655 Bytes Free
Run 2: 1659 Bytes Free
Run 3: 1654 Bytes Free

For every run, I get a different, but over a short time, fixed memory usage. Is this normal?

P.S: The serial input to the script just repeats forever with the exact same data.


texts: Uploading arduino code to race drone flight controller

texts:
I am working on VTOL aircraft and currently I am looking for some good board as flight controller (FC). I could made it by myself, but it requests lot of time. I was thinking about one of fpv drone FC (I have avaiable this one:

https://www.banggood.com/cs/Original-Airbot-Omnibus-F4-Pro-V3-Flight-controller-SD-5V-3A-BEC-OSD-Current-Sensor-LC-Filter-p-1319177.html?gmcCountry=CZ&currency=CZK&createTmp=1&utm_source=googleshopping&utm_medium=cpc_bgs&utm_content=lijing&utm_campaign=ssc-cz-cs-all-newcustom-ncv80-1118&gclid=CjwKCAjwqJ_1BRBZEiwAv73uwEgBJQ1B3dcKvZJZy2lR5-wN-XC150Ybn0kZObpUQbgkbvKiN_fY5BoCCVEQAvD_BwE&cur_warehouse=CN

This board has very small dimensions and it has already everything I need. The problem is that it is made for softwares like betaflight etc. It uses STM32 F405 so I tried to add STM 32 support for arduino (https://github.com/stm32duino/Arduino_Core_STM32) and upload arduino code in it.

I had to install stm32 cube programmer and because this board is not one of arduino boards I have to build the code for different board with same processor (FEATHER_F405). Because of it I have to change board pinout in this file (C:\Users\\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\variants\FEATHER_F405). I checked if are those pins correct (in code I command to those pins to be High and then Low while I was measuring them with multimeter). So all the pins are correct. I was able to blik the onboard LED and beep the buzzer. The only problem I have is serial communication. I tried to send some Strings to computer via serial port, but I didnt received any data. Here is sample code that I used:

#include <SoftwareSerial.h>

#define LED 4 //PB_5   //Inverted (High => LED ON)
#define BUZZ 3 //PB_4

#define _RX1 D0 //PA_10
#define _TX1 D1 //PA_9

//#define D_P 35 //PA_11
//#define D_M 36 //PA_12

//SoftwareSerial mySerial(_RX1, _TX1); // RX, TX
HardwareSerial  hwSerial_1(_RX1, _TX1);   // RX, TX

void setup() {

  hwSerial_1.begin(9600);
 //mySerial.begin(9600);

  pinMode(LED,OUTPUT);
  pinMode(BUZZ,OUTPUT);

  //pinMode(_RX1,OUTPUT);
  //pinMode(_TX1,OUTPUT);

  //pinMode(D_P,OUTPUT);
  //pinMode(D_M,OUTPUT);
}

void loop() {

  digitalWrite(LED, HIGH);
  /*
  digitalWrite(_RX1, HIGH);
  digitalWrite(_TX1, HIGH);
  digitalWrite(D_P, HIGH);
  digitalWrite(D_M, HIGH);*/

  delay(1000);

  digitalWrite(LED, LOW);
  /*
  digitalWrite(_RX1, LOW);
  digitalWrite(_TX1, LOW);
  digitalWrite(D_P, LOW);
  digitalWrite(D_M, LOW);*/

  delay(1000);

  digitalWrite(BUZZ, HIGH);
  delay(100);
  digitalWrite(BUZZ, LOW);
  delay(1000);

  hwSerial_1.println("HelloWorld");
  //mySerial.println("HelloWorld");

}

I tried to run serial communication via USB and via UART1 (I used USB/ TTL conventer -> FT232), but non of these works. I also tried to use software serial and hardware serial library, but it didnt helped.

Do you have any advices how to make serial communication work?


texts: Electrostatic Discharge Protection on Arduinos

texts: I have been using Arduino for quite some time without providing any kind of ESD protection. Does the Arduino have on board ESD protection?


texts: Reading two sensors at different frequencies... multiple Timer3?

texts:
Originally, I had a single sensor which I was reading at 100MHz. I used Timer3 and function attached to it to do both reading and writing of the sensor data (print to com port).

Now I have added another sensor which can only be read at half the frequency. I still want to be able to write data in the same format as before for both sensor data at 100Hz, with slower sensor data just being repeated twice.

How do I handle this? Do I use multiple Timer3 attachments at different frequencies? I am planning to have three interrupts.. 1st for reading sensor A, 2nd for reading sensor B, and 3rd for writing data.


texts: Motor Shield and HC-06 Bluetooth Module competing for pins

texts:
So my problem is this, I have an Arduino Uno with an Adafruit Motor Shield (1.0) and an HC-06 Bluetooth Module and I want to use them at the same time, the problem is that the Motor Shield uses all the ports that I need for the HC-06 (TX, RX, GND and VCC). In addition to all that, my project needs to be light weight (It's a quadcopter). Is there any way that I could use both of them at the same time?

Thanks in advance!


texts: How to connect HC-06 with HC-08 with the HC-06 as master and HC-08 as slave?

texts: How do you connect HC-06 with HC-08 with the HC-06 as master and HC-08 as slave? I will try it using 2 Arduino Unos.


texts: How to work with analog readings using RPi and Firmata?

texts:
For context: I'm working on a project where I need to use sensors to figure out the current state of the environment. This process is done using an Arduino UNO and a RPi. The easiest way that I found to perform communication between both boards is by uploading Standard Firmata and reading the code from RPi using Serial communication. I'm using pyfirmata to write the code in Python on the RPI side. Also, the Arduino is powered by the RPi using the USB port.
My problem was: The ADC component in the Arduino uses as the analog reference the 5V provided by the USB. When I tested the integration, I was using my laptop. So, the computer was providing 5V to the Arduino. So far so good. When I integrated the Arduino board to the RPi, I got some problems related to the precision of the sensor. I figured out that the RPi was only giving 4.75 V to the Arduino Board. This was messing with my readings since the ADC was using 4.75V while my code had 5V to compute things. After adjusting the code, everything proceeded as planned. Both 4.75 V and 5 V were hardcoded in my code.
So, these are my questions:

Is there a way to read the Vcc using pyfirmata to figure out the correct voltage without having this hardcoded?
Is there a way to modify the analog reference to use the INTERNAL reference of 1.1V?

About the analog reference, I found this: https://github.com/firmata/arduino/issues/39 . So, pyfirmata implements send_sysex method, I just have to execute these steps, but I still don't know how.


texts: Showing chronometer on PC controlling the begining and end of time by Arduino

texts:
I'm really new on this Arduino thing, so I don't know whether what I'm gona ask is feasible or not.

I'd like to make a chronometer in the computer but the controlling button (beginning and end of count) not to be some computer key. So I was wandering if I could make a button controlled by the arduino - maybe via a piezoelectric element?

Besides the problem of not knowing what to use as a button, I don't really know if it's possible to make a graphical interface (i know how to programme in C, Python, ...) showing the numbers in the screen of the computer and the beginning and end of counting controlled by that button. Is this possible to do?

Thanks for any help to both questions!


texts: How does Arduino WiFi Shield connect to Blynk and How can I use ESP Module to connect to blynk?

texts:
I was actually quite impressed how easily Blynk gets connected to Arduino. So I had a doubt how does Arduino WiFi Shield allow Arduino Uno to connect to blynk ? And my second doubt is how can I use the ESP boards to connect to blynk using Windows10 ( for steps ) ?
Thank You.


texts: I think i worn out all of my Arduino Uno memory

texts:
Hi my Arduino Uno stacked with a motor driver shield was working perfectly however I am using the same board for a while now and suddenly my board stopped working.
When I upload a code no matter what code is the LED's on the board respond however the code is not executed it does nothing , the board doesn t even beep anymore.
Is there a way to clean the memory or something?
Please help.


texts:
I was connecting my arduino uno to a adafruif micro SD card breakout and everything worked just fine, i could read the sd, write to it and see all the info about it. To do it i just followed the tutorial in here.

My problem is that when I arrived home the exact some thing wouldn't work and I couldn't read the SD card anymore.

I was thinking it could be a bad contact problem since sometimes i get:

Initializing SD card...initialization failed. Things to check:
* is a card inserted?
* is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

And other times (almost never), i would just get:

Initializing SD card...Wiring is correct and a card is present.
Card type: SD2
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card

I would like to know if I can assume it is the breakout board failling and I would buy a new one, or if it can be any other thing.

Thank you in advance!


texts: How can I set up a watchdog interrupt vector timer on the Arduino Redboard/Uno?

texts:
I'm trying to set up a watchdog timer interrupt to execute a routine in the WDT_vec ISR at some recurring interval. I don't want the processor to reset, just to execute the code in the interrupt and return to "normal" operation. I have the following test jig appropriated from the 'net that claims to set that up:

#include <avr/wdt.h>

 void setup_WDT() {
      noInterrupts();  // disable all the interrupts
      MCUSR = 0;       // ensure that the reset vectors are off

      /* Disable and clear all Watchdog settings. */

      _WD_CONTROL_REG = (1 << WDCE) | (1 << WDE);
      _WD_CONTROL_REG = 0;

      /* Setup Watchdog for interrupt and not reset, and a approximately 500ms timeout */
      _WD_CONTROL_REG = (1 << WDIE) | (1 << WDP2) | (1 << WDP0);

      interrupts();  // re-enable interrupts
    }

void setup() {
  setup_WDT();
  Serial.begin(9600);
  Serial.println("Startup");
}

void loop() {
}

ISR(WDT_vec) {
  Serial.println("Watchdog Interrupt");
}

The output indicates that the processor is just resetting repeatedly and never reaching the ISR. Also I get the following warning on compilation from the IDE (Arduino 1.8.2):

  warning: 'WDT_vec' appears to be a misspelled signal handler, missing
  __vector prefix [-Wmisspelled-isr]  ISR(WDT_vec) {


texts: I was trying to follow this tutorial and came across >>. What exactly does this do?


texts: Best way to ask Arduino for data from Python?

texts:
I'm trying to send numerical data from inertial sensors from my Arduino to a Python script via serial (PySerial).
I found that if I continuously send the data from the Arduino without stopping, the serial buffer fills up quickly and the sensor measurements that the Python reads becomes delayed.
To fix this, I thought of having the Python script send over a transmit command to the Arduino when it needs data. I'm sending a char 't' to signify this command, but the delay between Python sending the command and the Arduino sending the data is too large.
I'm wondering if there's a 'proper' way of doing this, as I'm sure it's probably been done before?


texts: Openlog + Lilypad Simple board - not writing to SD card

texts:
I'm desperately trying to get my openlog to work and write data out to a micro SD card with no luck.

I'm using a battery-powered lilypad arduino simple board and have attached L-shaped female headers to to the openlog to plug it right in. I am also using an FTDI breakout with the lilypad to download code and that is working. I think i have matched the RX and TX properly by flipping the openlog over as it pictured in the images attached. I'm using the example code included on the sparkfun openlog page just to test:

https://github.com/sparkfun/OpenLog/blob/master/firmware/examples/OpenLog_Test_Sketch/OpenLog_Test_Sketch.ino

There are no lights lit on the openlog which might indicate a power issue - but it's super unclear.

Any ideas or help very welcome!


texts:
I am Using Arduino IDE to program NODEMCU. I am expecting LED should remain ON for 4 sec. But it turns OFF in less than 2 sec. Please can anyone explain me why this happening? Also I noticed that if serial monitor is used, led ON timming changes with baudrate. I don't know why this is happening.

#include <ESP8266WiFi.h>
#define LED D1    // external LED is connected to pin D2
uint8_t GPIO_pin = D2;
void ICACHE_RAM_ATTR IntCallback();

void setup(){
  pinMode(D1,OUTPUT);
  attachInterrupt(digitalPinToInterrupt(GPIO_pin),IntCallback,CHANGE);
}
void loop(){
  digitalWrite(LED,LOW);      // Turn off LED to indicated Interrupt routine ended
  delay(1000);               // Without this delay, LED just blinks too weakly for milliseconds
}

void ICACHE_RAM_ATTR IntCallback(){
 digitalWrite(LED,HIGH);  // Turn LED ON to indicate Interrupt Routine started
 delay(4000);             // Delay in order to keep LED ON
}


texts: How can I power up my Arduino Nano for project of Rocket Data logging?

texts: I am building a Model Rocket for which I need arduino nano to log data.But,I dont know how to power it up once it goes off the ground.Can anyone explain?


texts:
here is the code:

#define pinSom 7
#define pinRele1 2
#define pinRele2 3
#define tempoMaximoDeUmaPalma 150 //milisegundos
#define tempoMaximoEntrePalmas 500 //milisegundos

int contaPalmas = 0;
long tempoEspera = 0;
long tempoEsperaEntrePalmas = 0;

void setup() {
  // put your setup code here, to run once:
    pinMode(pinSom, INPUT);
    pinMode(pinRele1, OUTPUT);
    pinMode(pinRele2, OUTPUT);
}

void loop() {{
  // verifica o estado do sensor de som (ele fica normalmente com
  int sensorSom = digitalRead(pinSom) ;

  //se o sensor detectou palmas
  if (tempoEspera == LOW) {

      //espera um tempo para não detectar a mesma palma mais de uma vez
    tempoEspera = tempoEsperaEntrePalmas = millis();
    contaPalmas++;
  }else if ((millis() - tempoEspera) >= tempoMaximoDeUmaPalma)
     tempoEspera = 0;
  }

    //caso exceda o tempo maximo entre palmas, zera o contador de palmas

    {

    if ( (contaPalmas != 0) && ((millis() - tempoEsperaEntrePalmas)
    (i get the error here) executarAcao();
    contaPalmas = 0;
    TempoEsperaEntrePalmas = millis();

 }
}
void executarAcao()
{
   switch (contaPalmas) {
    case 2:
      digitalWrite(pinRele1, !digitalRead(pinRele1));
      break;
   }


texts: How to use output from Arduino in C++ code?

texts:
I am a complete novice in Arduino and moderately experienced with the language C++. What if I want to use the output from the serial monitor in C++ code in real time?

Also how can I write to the serial monitor. Which libraries are available for this? Also please give me links to sites where I can learn more about this topic. I am using Arduino Uno.


texts: Syntax for stopping loop until the condition has made false

texts:
I am taking reading from temperature sensor and from that data. I have to control 3 LEDs. Lets consider LED1, LED2, LED3.

If temperature range between 0-20
   I have to HIGH LED2.
   else if temperature range between 20-30
I have to HIGH LED1; HIGH LED3; LOW LED1;

my sketch is something like this:-

while(1)
{
if(temp>=0&&temp<=20)
{
digitalWrite(2,HIGH);
}
else if (temp>=20&&temp<=30)
{
digitalWrite(1,HIGH);
digitalWrite(3,HIGH);
digitalWrite(1,LOW);
}
}

The problem which I am facing is LED1 is continuously ON (which should be OFF), when temperature is between 20-30 because of continuously running loop so, how can I stop loop, once the statement under second condition has executed till the second condition has made false.


texts: Arduino Leonardo keyboard.print keeps printing equal sign

texts:
I am currently working on a DIY controller for Train Sim World. I am relatively new to the Arduino and the C programming language. My code is structured to look for button presses or PS2 joystick inputs and print a specific character for each button. I have also included a kill switch on pin 3. However when I run the code and open Notepad to see the results, the Arduino keeps printing the = character even if pin 3 is not pulled low. After I pull pin 3 low and press a button, there is a delay of about two seconds during which the = character keeps being printed over and over again, and after these 2 seconds elapse the Arduino prints the character attributed to the button several times before returning to printing = over and over again.

What can I do to fix this?

#include <Keyboard.h>

void setup() {
    pinMode(0, INPUT_PULLUP);
    pinMode(1, INPUT_PULLUP);
    pinMode(2, INPUT_PULLUP);
    pinMode(3, INPUT_PULLUP);
    pinMode(4, INPUT_PULLUP);
    pinMode(5, INPUT_PULLUP);
    pinMode(6, INPUT_PULLUP);
    pinMode(7, INPUT_PULLUP);
    pinMode(8, INPUT_PULLUP);
    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);
    pinMode(11, INPUT_PULLUP);
    pinMode(12, INPUT_PULLUP);
    pinMode(13, INPUT_PULLUP);
}
bool pantograph = 0;
void loop() {
    while (digitalRead(3) == LOW) {
        Keyboard.write("M");
        if (digitalRead(1) == LOW) {
            Keyboard.write("W");
        } else if (digitalRead(2) == LOW) {
            Keyboard.write("S");
        } else if (digitalRead(0) == LOW) {
            Keyboard.write("Q");
        } else if (digitalRead(5) == LOW) {
            Keyboard.write("Y");
        } else if (digitalRead(6) == LOW) {
            Keyboard.write("T");
        } else if (digitalRead(7) == LOW) {
            Keyboard.write("G");
        } else if (digitalRead(8) == LOW) {
            Keyboard.write("K");
        } else if (digitalRead(9) == LOW) {
            Keyboard.write("Z");
        } else if (digitalRead(10) == LOW) {
            if (pantograph == 0) {
                Keyboard.write("P");
            } else {
                Keyboard.write("O");
            }
        } else if (digitalRead(11) == LOW) {
            Keyboard.write(9);
        } else if (digitalRead(12) == LOW) {
            Keyboard.write("N");
        } else if (digitalRead(13) == LOW) {
            Keyboard.write(32);
        } else if (analogRead(A0) > 700) {
            Keyboard.write(93);
        } else if (analogRead(A0) < 200) {
            Keyboard.write(91);
        } else if (analogRead(A1) > 700) {
            Keyboard.print(39);
        } else if (analogRead(A1) < 200) {
            Keyboard.print(59);
        } else if (analogRead(A2) > 700) {
            Keyboard.print("A");
        } else if (analogRead(A2) < 200) {
            Keyboard.print("D");
        }
    }
    delay(1000);
}


texts: Outputs/inputs to Multiple Arduinos in Arduino IDE at once

texts: I apologize if this information could be easily accessed, but I'm new to Arduino and did multiple searches.  I'm currently able to write to one Arduino Trinket in Arduino IDE using digitalWrite. However, I'll have to be reading from two different Arduino Trinkets with analogRead.  An important part of this is that I must be able to access both devices at the same time.  I saw during research that other people were able to use two different Arduino IDE instances, but I don't think this will work for me.  I'll more than likely soon be purchasing 2 Arduino ItsyBitsy's or nano's for the serial USB communication.  Let me know if this would make the issue easier.  I appreciate any help!


texts: Nick Gammon "Camera shutter speed timer"

texts:
I am reading the period of pulses from a 600ppturn shaft encoder, using the FreqPeriod library, by Martin Nawrath.

This works using counter1 and the comparator on pin6 and pin7 on the Arduino Uno.

The period duration for 1-2500Hz is being used in a midi musical instrument to give a speed to volume and a note change at a fixed speed.
This has worked well on the Uno but now I want to use a Mega (which does not have both comparator pins).

So I have tried using the Nick Gammon interrupt sketch. This has produced very erratic results returning both positive and many negative numbers (shown by using "volatile long period;" in the monitor.

Can you tell me what is happening and would it be better to use a counter instead of interrupts?

Hope I have given enough information to be getting on with, many thanks.

// Camera shutter speed timer
// Author: Nick Gammon
// Date: 15th January 2012

volatile boolean started;
volatile unsigned long startTime;
volatile unsigned long endTime;
volatile unsigned long period;
volatile unsigned long lfrq;

// interrupt service routine
void isr () {
    if (started)
        endTime = micros ();
    else
        startTime = micros ();
    started = !started;
} // end of Pulse Width

void setup () {
    digitalWrite (2, HIGH); // pull-up
    Serial.begin (9600);
    Serial.println (" Pulse Width test = ");
    attachInterrupt (digitalPinToInterrupt (2), isr, CHANGE); //CHANGE RISING
} // end of setup

void loop () {
    if (endTime) {
        period = (endTime - startTime) * 32 ; // pulse width?
        Serial.print (" \n  ");
        Serial.print ( " period =  ") ;
        Serial.print (period) ;
        lfrq = 16000000.0 / period;
        Serial.print(" Hz = "); // one rev per sec = 26666 micros period
        Serial.print( lfrq );
        endTime = 0;
    }
} // end of loop


texts: Motor code for the "Pirate: 4WD Arduino Mobile Robot Kit with Bluetooth 4.0", will not work

texts:
The board is the RoMeo BLE V 1.0 and I have set the board to Arduino UNO on the board part of the arduino IDE, as I cannot find the RoMeo Board.

This is the code for the motors.

``int speedPin_M1 = 5;     //M1 Speed Control
int speedPin_M2 = 6;     //M2 Speed Control
int directionPin_M1 = 4;     //M1 Direction Control
int directionPin_M2 = 7;     //M1 Direction Control

void setup(){

}

void loop(){
    carAdvance(150,150);
    delay(1000);
    carBack(150,150);
    delay(1000);
    carTurnLeft(150,150);
    delay(1000);
    carTurnRight(150,150);
    delay(1000);
}

void carStop(){                 //  Motor Stop
  digitalWrite(speedPin_M2,0);
  digitalWrite(directionPin_M1,LOW);
  digitalWrite(speedPin_M1,0);
  digitalWrite(directionPin_M2,LOW);
}

void carTurnLeft(int leftSpeed,int rightSpeed){         //Turn Left
  analogWrite (speedPin_M2,leftSpeed);              //PWM Speed Control
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}

void carTurnRight(int leftSpeed,int rightSpeed){        //Turn Right
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}

void carBack(int leftSpeed,int rightSpeed){             //Move backward
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}
void carAdvance(int leftSpeed,int rightSpeed){          //Move forward
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}

After I upload the code, nothing happens. The boards light blinks and then after that nothing occurs. How do I get the Motors moving according to the code in the loop?


texts: Installing a different firmware on Arduino

texts: Is it possible to upgrade the firmware on an Arduino so that it can do more things such as change undervolting/ overvolting in order to provide more processing power. To do this you would have to most likely re flash the chip itself, so how would that be accomplished?


texts: How to connect RedBearLab BLE shield (Or how to find Nordic_nRF8001.h)?

texts:
I am trying to explore the possibilities of connecting an Arduino to Phonegap/Cordova. I have a RedBearLab BLE Shield, which I want to test the connection with. My MVP would be to get the value of a PIN to a Cordova app. Nevertheless, I couldn't make it even close.

The closest I got, it was using Don Coleman's Phonegap plugin.
I am trying his Simple Chat example.

With this example the sketch is attempting to include Nordic_nRF8001.h. Nevertheless, I can't seem to find this library. I downloaded it from various sources, but no matter what I do, my sketch still can't find the file.

The only way I could make it work was via CodeBender, but then the readings were a bit of a mess.

I'm not expecting anyone to do all the work for me, so if you can help me in one of the two directions, it would be awesome:

Figure out why I can't find that Nordic_nRF8001.h file.
Or help me find another method of BLE communication.

Later edit
Using the examples that come with RBL library, I figured out the name of the files I need to use. Now I'm running into another problem for which I opened a new question.

Thank you!


texts: Why is my arduino now working with my LCD 16x2 displays?

texts:
So I've tried with 3 different lcd screens and each one has given me something different (https://imgur.com/a/EVzFoVv) and here is my code

#include "LiquidCrystal.h"

// initialize the library by providing the nuber of pins to it
// LiquidCrystal lcd(8,9,4,5,6,7);
LiquidCrystal lcd(52, 50, 48, 46, 44, 42);

bool isSetup = false;

int want = 600;
int live = 615;

void setup() {
  lcd.setCursor(0,1);
  lcd.print("   Booting Up");

}
void loop()
{
  if(isSetup == false)
    Set();
}

void setupIs(){
  Clear();
  isSetup = true;
  lcd.setCursor(0,0);
  lcd.print("Want: ");
  lcd.setCursor(0,1);
  lcd.print("Live: ");
}
void Set(){
  lcd.begin(16,2);

// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print
lcd.print("WANT: 1500");
// set cusor position to start of next line
lcd.setCursor(0,1);
lcd.print("LIVE: 1800");
}

void Clear(){
  lcd.setCursor(0, 0);
  lcd.print("                ");
  lcd.setCursor(0, 1);
  lcd.print("                ");
}```


texts: Will an ATmega2560 board be faster than a Uno for hard real-time data logging?

texts:
I am designing a hard real-time data logger. The Uno is a bit marginal in processing speed.

a) Would it be faster if I changed to an ATmega2560?

b) On the datasheet, ATMEGA2560 has 135 instructions; it is 4 instructions more than the ATmega328p.

What are the extra 4 instructions for?

Are they involved in floating point maths?

c) How to select compiler option for fastest code at the expense of bigger code size, longer compilation time, etc.?

The system is:

Receive data from wireless transceiver chip via hardware SPI port.
A good portion of the time is spent on data calculation using floating point maths.
Output processed data on serial port (then to PC via the Arduino board USB to Serial chip).
Code and RAM size is not an issue, Uno has plenty space left.


texts: ESP-12e - RX/TX pins flickering on boot when used as GPIO pins

texts: I am using ESP-12e as a controller for my garden lights. I am using pins 1 (TX), 3 (RX) and 5 as an analog output (PWM signal with mosfets) for three separate light sets. ESP is powered on when wall switch is turned on (wall switch turns on power adapter). When I turn the switch on, for short period of time lights connected to pin 1 and 3 work at full power and after that they are set according to PWM signal. Lights on pin 5 works just as expected. I am not using Serial communication, just elegantOTA library for OTA updates and async web server. Is it possible to somehow disable RX/TX functionality at all/before they are set to high, or I am forced to solder lights on pins 1 and 3 to another ones? I tried some software tricks I found online, but without success.


texts: Teensy 2.0 MIDI: Number of notes in a chord limited to 6?

texts:
I am using the Teensy 2.0 with USBMidi in a project that allows musicians to use retro computers as "instruments" (https://github.com/fredlcore/midijoy). So far, all these computers had no more than four voices, so the problem I am encoutering now has not arisen so far.

When I now want to play a chord with more than six notes simultaneously, only the first six notes are received and played. However, if I release two from, let's say, eight notes, the remaining two notes are subsequently being played if these keys are still kept pressed.

Here is a script reduced to the bare minimum, when you press eight keys on the MIDI device one after another, you'll see that it stops after the sixth key, and when you then subsequently keep all keys pressed and release one after the other, you'll see that the "remaining" keys/notes will be received then:

void setup() {
  Serial.begin(38400);
  usbMIDI.setHandleNoteOn(doNote);
  usbMIDI.setHandleNoteOff(doNoteOff);
}

void loop() {
  usbMIDI.read();
}

void doNote(byte channel, byte pitch, byte velocity) {
  Serial.println(channel);
  Serial.println(pitch);
}

void doNoteOff(byte channel, byte pitch, byte velocity) {
  Serial.println(channel);
  Serial.println(pitch);
}

You have to configure the Teensy as a MIDI device so that the USBMidi libraries will be found.

Is there a hardware limit in the Teensy 2.0 that will prevent it from processing more than six notes at a time? Or is this a constraint within the library?


texts: How to wire an analog IR sensor for digital input?

texts:
How do you wire a phototransistor so that it outputs a clean digital signal in response to certain light levels?

I've wired a QRD1114 to an Arduino analog pin to detect a white or black surface. However, I want to use this sensor to detect fast movement of a black/white color strip, and since analogRead() can take up to 100µs and I'd rather use the ADC pin for other sensors, I want to rewire this so I can read the same signal with digitalRead().

In order to do this, the sensor needs to output less than 2.3V for white and more than 2.5V for black. I'm pretty close, but I'm having trouble with black. For white, the voltage drops to 0.7V, so that reads perfectly, but black still reflects a lot of IR, so it typically reads 2.3V, which still translates as a LOW value.

My sensor's circuit is a pretty basic voltage divider:

R1 is the Arduino's built-in 20k pullup. R2 is a variable resistor I've tried using to "shift" the voltage level up for the black case. Unfortunately, I've found this very difficult to calibrate. The larger I make R2, the higher the black-case voltage gets...but so does the white-case voltage. By the time I make R2 large enough so that black registers as HIGH, white also registers as high. Through trial and error, I found 25.7k ohms is the sweet spot, but the difference in voltage between the two is about 0.5V, which makes me nervous about getting false readings.

I've measured the phototransistor's resistance in each case, and for black it reads as 12.5k ohms while for white it reads as 9.7k ohms.

Given my 25.7k calibration resistance, the voltage divider should output for black:

Vout = Vin * R2/(R1 + R2)

5 * (12500+25700)/(20000 + 12500+25700) = 3.2V

and for white:

5 * (9700+25700)/(20000 + 9700+25700) = 3.1V

However, for black, my meter reads 2.3V for black and 2.0V for white.

Why do my meter measurements not match the voltage divider formula? Am I wiring this voltage divider correctly?

What can I do to get a cleaner digital output without complicating the circuit too much?


texts: Why do you need to shift bits when reading from an analog sensor?

texts:
I was playing around with some analog grove sensors and looking at examples (https://github.com/DexterInd/GrovePi/blob/master/Software/Go/grovepi/grovepi.go - this specific example is in go and for raspberry pi, but it's the same on arduino) I realised that you need to "(int(val[1]) << 8) | int(val[2])" before getting the result.

Why is that so? Why do the second 8 bits need to be left shifted by 8 and why is there then an OR with the third group of bits?


texts: How to calculate actual Baud Rate and its percent error?

texts: I am using an Arduino Uno, and I need to create a program that calculates the actual baud rate and the percent error for all standard baud rate in Arduino monitor program.


texts:
I tried to upload example code form arduino software and got error below. Two arduino attach with my computer running windows8.1. And These arduino using port 3 and port 4. The arduino using Port 3 is cordinator and arduino using port 4 is router.
I doesn't understand why error show COM1 is not available. I am not using COM1.

Arduino: 1.6.0 (Windows 8), Board: "Arduino Uno"

Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.

C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM1 -b115200 -D -Uflash:w:C:\Users\Jiya\AppData\Local\Temp\build1135139715306090793.tmp/Blink.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr  3 2014 at 23:12:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : COM1
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM1": The system cannot find the file specified.

avrdude done.  Thank you.

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

Board at COM1 is not available
Board at COM1 is not available
Board at COM1 is not available
Board at COM1 is not available
Board at COM1 is not available

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


texts: 32u4 using internal clock on custom PCB - loading sketch

texts:
I have a custom PCB with a 32u4 running fine with an 8MHz external oscillator.  I burned the bootloader and loaded my sketch with an UNO using Arduino as ISP.

I have no USB on my PCB nor do I need precise timing, so I wanted to see if I could simplify things by removing the external oscillator and caps.

Reading the 32u4 datasheet it states "The device is shipped with Low Power Crystal Oscillator (8.0 - 16MHz) enabled and with the fuse CKDIV8 programmed".

With that, can I simply hook my PCB (assuming a factory fresh 32u4) via ISP to the UNO as before and in IDE just use Sketch > Upload Using Programmer?    Basically not burning any bootloader at all.

Also, in IDE I have been choosing the Sparkfun ProMicro 3.3v, 8MHz board.  Can I still use that selection?


texts: Arduino WiFi/ESP8266 WiFi Password Changed

texts:
I am working on a project for a friend who is not very tech savvy involving an ESP8266. It will need to be connected to his WiFi network.

The issue is that he occasionally changed the password to his WiFi network. Since I will not be able to access this device at a moments notice, it needs to be able to adapt to a change in the password. Is this possible with the ESP8266, or should I switch to an Arduino WiFi board, or is something more powerful necessary?


texts: Adafruit_LEDBackpack library interfering with analog input reading

texts:
I'm trying to do something I think would be simple. I'd like to read the input of a electret microphone board and update the Adafruit 24-segment LED Bar Graph. I got each individual item working perfectly: I can read the input of the microphone on the analog pin and I can update the LED bar graph using I2C.
The issue occurs when I tried to combine the two concepts. When the bard graph gets updated, the analog input reads HIGH (1023) and never changes. I used my standard debug method and commented out code until the problem went away, so I've narrowed down the issue to a single line of code (right at the end). When the bar.writeDisplay is called the analog input perpetually reads 1023.
If I comment out that one line of code and re-upload my sketch the readings (in the Serial Monitor) are as expected (lower when its quiet and higher when its loud).
Under the hood Adafruit is using the Wire library.
I'm no good at wiring diagrams, but here's what I have:
RoboDyn Mega 2560 Pro (Embed)
5V, Gnd, SDA (20), SCL (21) to the LED Backpack
5V, Gnd, Out (A15/69)
That said, I'm relatively confident this is not a wiring problem as everything works until the software gets ahold of it.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

Adafruit_24bargraph bar = Adafruit_24bargraph();

int pin = 69;
unsigned int sampleWindow = 50; // millis
unsigned int maxScale = 24;

void setup() {
  Serial.begin(9600);
  bar.begin(0x70);  // pass in the address
}

void loop() {
  unsigned long startMillis = millis();  // Start of sample window
  unsigned int peakToPeak = 0;   // peak-to-peak level
  unsigned int sample;
  unsigned int signalMax = 0;
  unsigned int signalMin = 1024;
  while (millis() - startMillis < sampleWindow) {
    sample = analogRead(pin);
    if (sample < 1024) {  // toss out spurious readings
      if (sample > signalMax) {
        signalMax = sample;  // save just the max levels
      }
      else if (sample < signalMin) {
        signalMin = sample;  // save just the min levels
      }
    }
  }
  peakToPeak = signalMax - signalMin;
  int displayPeak = map(peakToPeak, 0, 1023, 0, maxScale); // map 1v p-p level to the max scale of the display
  Serial.print("mic: "); Serial.print(peakToPeak); Serial.print(" "); Serial.println(displayPeak);
  for (uint8_t b = 0; b < 24; b++) {
    if (b <= displayPeak) {
      int c = LED_GREEN;
      if (b >= 20) {
        c = LED_RED;
      }
      else if (b >= 16) {
        c = LED_YELLOW;
      }
      bar.setBar(23 - b, c);
    }
    else {
      bar.setBar(23 - b, LED_OFF);
    }
    //bar.writeDisplay(); // <------- THIS LINE
  }
}

UPDATE: It appears to be something with the way Adafruit uses the Wire library. I have a similar problem when I use the Adafruit 7-segment library, when I use their MCP23017 library.
But it is wiring related too. If I uncomment the commented out line above but disconnect the I2C device the analog input starts working again.
One more thing I've discovered: it depends on how many lights are lit on the I2C board. Once all the lights are lit, the analog pin reads full. When only a couple of lights are lit, the values are lower. It is like the voltage going into the mic is higher when the lights are brighter.
For curiosity sake, I tried the same thing on a different Arduino (Adafruit Feather 32u4) with the same result (so it isn't my Arduino).


texts: How to light up all LEDs of a 7x5 LED matrix?

texts: I want to light up all the LEDs of a 7x5 matrix with arduino uno. How can i do so?


texts: Using MouseX in processing to control LEDs. Error in code - LEDs remain off

texts:
I am fairly new to processing and Arduino - I have a coursework deadline for both on Monday (6th January).

I am trying to write a script that uses the mouseX values to turn LEDs on and off. I haven't got any error messages on either of the scripts but currently, nothing happens to the LEDs (they remain off) when I move my mouse. I have tested the circuit with a simpler Arduino code and it is correct so there must be an error in my code!

I would be very grateful for some help. Thanks!

Processing code:

import processing.serial.*;
Serial port;
byte lightsOn;

void setup()
{
  size(600,300);
  port=new Serial(this,"/dev/cu.usbmodem1411",9600);
}

void draw()
{
  background(32,78,95);
  rect(300,0,300,300);
  noStroke();
  fill(185,215,216);

  lightsOn=byte(mouseX);
  port.write(lightsOn);

  println(lightsOn);
}

Arduino code:

#include <Servo.h>

Servo myservo;
int ledpinA=12;
int ledpinB=13;

void setup()
{
  Serial.begin(9600);
  myservo.attach(ledpinA&&ledpinB);
  pinMode(ledpinA,OUTPUT);
  pinMode(ledpinB,OUTPUT);
}

void loop()
{
  if(0<Serial.available())
  {
    int data = Serial.read();

  if (data>300)
  {
    digitalWrite(ledpinA, HIGH);
    digitalWrite(ledpinB, LOW);
  }
  else
  {
    digitalWrite(ledpinB, HIGH);
    digitalWrite(ledpinA, LOW);
  }
  }
}


texts:
Problem: can't print to the serial monitor, it appears that the serial monitor disconnects itself after uploading a program.

I'm brand new to arduino, and I'm trying to upload a basic program to print to the serial monitor.

I use an arduino uno and my OS is Ubuntu.
I am connecting the arduino to my PC via USB.
Using Arduino Studio Release 0.0.5 experimental build 0.0.5-16058

(I am able to communicate via the digital output pins, tested by making a simple circuit to make the led light blink)

Here is the program:

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

void loop()
{
    Serial.print("test");
    delay(500);
}

Here is the result of the build, look at the last line and it says the serial monitor was disconnected? Why would this happen automatically?

[2/2/2016 8:51:26 PM] - Start Building
[2/2/2016 8:51:26 PM] - CPP File Created [/tmp/build1454471486915/test.cpp]
[2/2/2016 8:51:26 PM] - test.cpp compiled
[2/2/2016 8:51:26 PM] - CDC.cpp compiled
[2/2/2016 8:51:27 PM] - HID.cpp compiled
[2/2/2016 8:51:27 PM] - HardwareSerial.cpp compiled
[2/2/2016 8:51:27 PM] - HardwareSerial0.cpp compiled
[2/2/2016 8:51:27 PM] - HardwareSerial1.cpp compiled
[2/2/2016 8:51:27 PM] - HardwareSerial2.cpp compiled
[2/2/2016 8:51:27 PM] - HardwareSerial3.cpp compiled
[2/2/2016 8:51:27 PM] - IPAddress.cpp compiled
[2/2/2016 8:51:27 PM] - Print.cpp compiled
[2/2/2016 8:51:27 PM] - Stream.cpp compiled
[2/2/2016 8:51:27 PM] - Tone.cpp compiled
[2/2/2016 8:51:27 PM] - USBCore.cpp compiled
[2/2/2016 8:51:27 PM] - WInterrupts.c compiled
[2/2/2016 8:51:27 PM] - WMath.cpp compiled
[2/2/2016 8:51:27 PM] - WString.cpp compiled
[2/2/2016 8:51:27 PM] - abi.cpp compiled
[2/2/2016 8:51:27 PM] - hooks.c compiled
[2/2/2016 8:51:27 PM] - main.cpp compiled
[2/2/2016 8:51:27 PM] - new.cpp compiled
[2/2/2016 8:51:28 PM] - wiring.c compiled
[2/2/2016 8:51:28 PM] - wiring_analog.c compiled
[2/2/2016 8:51:28 PM] - wiring_digital.c compiled
[2/2/2016 8:51:28 PM] - wiring_pulse.c compiled
[2/2/2016 8:51:28 PM] - wiring_shift.c compiled
[2/2/2016 8:51:28 PM] - CDC.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HID.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HardwareSerial.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HardwareSerial0.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HardwareSerial1.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HardwareSerial2.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - HardwareSerial3.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - IPAddress.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - Print.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - Stream.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - Tone.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - USBCore.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - WInterrupts.c.o linked to core.a
[2/2/2016 8:51:28 PM] - WMath.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - WString.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - abi.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - hooks.c.o linked to core.a
[2/2/2016 8:51:28 PM] - main.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - new.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - test.cpp.o linked to core.a
[2/2/2016 8:51:28 PM] - test.ino linked to core.a
[2/2/2016 8:51:28 PM] - wiring.c.o linked to core.a
[2/2/2016 8:51:28 PM] - wiring_analog.c.o linked to core.a
[2/2/2016 8:51:28 PM] - wiring_digital.c.o linked to core.a
[2/2/2016 8:51:28 PM] - wiring_pulse.c.o linked to core.a
[2/2/2016 8:51:28 PM] - wiring_shift.c.o linked to core.a
[2/2/2016 8:51:28 PM] - test.cpp.elf linked to core.a
[2/2/2016 8:51:28 PM] - test EEPROM
[2/2/2016 8:51:28 PM] - test.hex builded
[2/2/2016 8:51:28 PM] - Uploading...
[2/2/2016 8:51:30 PM] - Uploaded
[2/2/2016 8:51:30 PM] - [arduino ide - serial monitor] Serial monitor connected to /dev/ttyACM0
[2/2/2016 8:51:36 PM] - [arduino ide - serial monitor] Serial monitor disconnected from /dev/ttyACM0


texts: Arduino Serial Port. COM1 does not exist

texts:
Hello everyone I'am new to this site so please bear with me.

I have an Arduino Uno that I'm using in my simple project using VS 2008. I got this error says The Port COM1 does not exist. The flow of my project is after inserting a coin into the coin slot the arduino will pass the data into my project and it will display into a Label or Textbox the value of the inserted coin.


texts:
I am new to Arduino, and I am aware that unlike Raspberry Pi you do not have a full blown OS with many custom applications running concurrently.
I plan to start an Arduino project with an Arduino NANO that will need to be portable, and include batteries. How may I get the battery status information without disrupting the rest of the functionality?


texts: I need some help getting data from a rangefinder

texts:
I have wired up my range finder (CJVL53L0XV2) to a breadboard for testing and have run the arduino example code for the rangefinder. The rangefinder works, but I do not know how to take the distance that the range finder shows on the serial monitor, example: distance measured 44mm, and turn that information into a variable that the rest of my program could use.

I am not sure how to "grab" data from the sensor and turn that data into a variable that I can then manipulate. I have tried to dissect the example code, but it seems to be taking data and using functions that do not exist anywhere but in some files in the arduino library that I can't identify or access.

Below is the code that I have been trying to reverse engineer.

[code]
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
int pbl = 9;
void setup() {
  pinMode(pbl, OUTPUT);
  digitalWrite(pbl, HIGH);
  delay(1);
  Serial.begin(115200);

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }

  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power
  Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;

  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }

  delay(100);
}
[/code]