texts:
I'm using an Arduino to control an experimental setup and read analogue signals from some sensors. But there are other sensors for which I need a DAQ for. I have a National Instrument USB-6259. On my PC I use LabView or NI SignalExpress to read data from DAQ connected via USB. Considering that I want the read data from different sensors to be synced, I was wondering if I could somehow read the DAQ directly on the Arduino?

Some other points:

I also have Arduino Ethernet Shield, if required.
The final goal is to have logged data synced so out of the box solutions are also acceptable for me.
If I'm not mistaken there are some versions of Arduino which you can install Linux on, just like a Rasppbery pi. There are even OSes for normal Arduino boards. There is a Low Cost USB DAQ Driver for use with Raspberry Pi for NI USB-6008/6009 devices. Is it possible to install this driver on Arduino?
I prefer not use a Raspberry pi because analogue/PWM read and write there is not as straight forward. So if there are other boards which are as easy as an Arduino with an OS compatible with current driver please suggest.


texts:
My objective is to light a led on a strip corresponding to a keyboard note.
I have Arduino Uno with MIDI in module hooked up to a serial port. Piano is hooked with a standart midi cable, Led Strip is powered using Arduino's 5v (Figured i don't need more because Max 10 leds will be active at a time).

My setup works but not accurately. All is fine when only 1 note at a time is played, but the denser the music becomes (faster or more notes are played simultaniously) more inaccuracies show - more leds don't turn off or on, or the notes I didn't play light up.

At first i used software serial and there were even more mistakes, when i switched to hardware it became better.
Could it be that Arduino UNO is just not powerfull enough and cannot keep up with incoming midi input or is there another problem?

Here is the code:

#include <MIDI.h>
#include <Adafruit_NeoPixel.h>

MIDI_CREATE_DEFAULT_INSTANCE();

#define STRIP_PIN 11
#define STRIP_NUM_PIXELS 88

Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_NUM_PIXELS, STRIP_PIN, NEO_GRB + NEO_KHZ800);

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
  strip.setPixelColor(pitch - 21, strip.Color(50, 50, 50));
  strip.show();
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{
  strip.setPixelColor(pitch - 21, strip.Color(0, 0, 0));
  strip.show();
}

// -----------------------------------------------------------------------------

void setup()
{
    MIDI.setHandleNoteOn(handleNoteOn);
    MIDI.setHandleNoteOff(handleNoteOff);
    MIDI.begin(MIDI_CHANNEL_OMNI);
    strip.begin();
}

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


texts:
I have seen commercial Xbee / Zigbee clones using HC-05 integrated inside.
Are they any different than regular HC-05 bluetooth modules?

What is differences in usage between a HC-05 bluetooth module and a Zigbee HC-05 module?


texts: someVariable = { somethingThatLooksLikeAFunction }; possible?

texts:
Wasn't sure how to title this question...

I was curious whether the title example is possible somehow, and are there any good tricks to using it?

I have been using something similar quite a lot:

newBool = (someTest) ? true:false;
newInt  = (x + (y / z));
[...]

However, I was curious if it was possible to add far more conditions, almost like a function?

For some simple(*) examples:

someThing = {
    int _x = aFunction(_x);
    if(_x) {
        something = somethingElse;
        for(...){ ... }; // etc
    } else {
        /* otherStuff */
    }
};

Or

someThing = {
    for(_x=0;_x<y;_x++){
        z++;
    }
    someThing = (z>y) ? a:b;
};

I understand it's worth just separating it off into functions most of the time, although I'm trying to get away from a function/library-fest as much as possible...  It's getting annoying crawling through everything when I could just have the useful stuff right there, where I need it, instead of 1000 lines away, or in another library.  It also allows the text editor to fold the code out of sight, starting from one variable, instead of on each clause.

With the few tests I have tried, I've not been successful in achieving what I'm experimenting with, so, is this kind of thing possible in any way? and if so, what are the rules/possibilities/different ways you could implement this?

* Emphasis on simple! And a semi-pointless/completely useless "function" alert too!  I'm just curious about the "proof of concept" in the examples...


texts:
I'm trying to create a function that takes two colours and creates a smooth gradient between them one colour at the beginning and one at the end

I just can't figure the math of mixing them evenly

I'm using neopixel library


texts: Diorama Controller Part 2 - Need More Outputs

texts:
For background see my original post.  I've decided to not to use batteries and have it wired up with wall power.

I wish to use the Arduino Pro Mini 5V as the controller for my diorama project.  I have five completed buildings which will all have LEDs (with only two wired up so far).  The two currently wired buildings have multiple "zones/rooms" that can have its LEDs activated separately.

Building 1 is a saloon with rooms above.  It has a total of 7 zones/rooms.

Building 2 is a store with a doctor's office above and rooms in the back of each.  It has 4 rooms.

With this setup, I am able to use the software to simulate people coming and going within the rooms.  It's pretty neat.

However, I'm currently at 11 outputs out of the Mini.  I'm running out of pins.  How can I have more outputs?


texts:
I have a arduino clone that is not being assigned a /dev/tty by Debian Stretch (Stable).  It does have the ch340g chip.  I have tried the driver from the manufactures site with no joy.  Would the lack of a bootloader cause this problem?

Thanks.


texts: Having problems registering my SIM800 with the network

texts:
I have a SIM808, connected via hardware serial to an Arduino Mega. Communication between the Arduino and the SIM808 is fine. However, the quality of the signal is listed as 0 all the time. (AT+CSQ)

I've checked, and there is definitely 2G (and 3G) signal. Power is fine. SIM is unlocked, and works in other M2M equipment.

The network status lights blink rapidly (ie searching for a network) for about 5 seconds. Then it takes one long blink, then goes back to blinking rapidly.

The module is picking up the names of the available networks, yet does not seem to be able to register.

I'm using a prepaid data SIM card from Vodacom (South Africa).


texts: How to use the analog comparator to determine when an analog pin has reached a certain voltage?

texts:
I am trying to find some information on how to use the analog comparator on an Atmega328 to detect when an analog pin has reached a certain voltage (3.16 volts).

I cannot find any example code that says how to do this, although I have read that the analog comparator can compare the voltage on an analog pin with the voltage output by a PWM pin. I do not understand how this would work as the PWM pins do not output an analog voltage, but a pulse width modulated square wave. Is it possible to use the comparator to compare with a certain voltage this way?

I have tried polling with analogRead(), but it is too slow for my application.


texts: How to prevent interference between dc motor and arduino?

texts:
It may be already asked question in somewhere but I am struggling!

I have a four wheel robot which I want to drive it to perform 90-degree left/right turn, I am using the MPU6050 3dof to get angles, however everything is ok when the DC motors are off and the readings from the MPU6050 are pretty good.

But when the DC motors are on, the readings start to be increase randomly. I tried to use a different power supply to the DC motors and the Arduino, but with no solution. At the end when I reset the Arduino everything was back to be normal even if the DC motors are on!

Any help will be appreciated and I am open for any suggestion.


texts: How to combine button's coding into this servo's coding?

texts:
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

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

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

void loop() {
  for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 90; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
  }
}


texts:
I'm new to Arduinos and programming. I'm getting into a project and one of my tasks was to learn how to incorporate servos into Arduino and learn about sensors. I wanted to combine both, but I'm having some problems in my syntax. Can I get some help?

This is my code:

// servo test
#include <Servo.h>
#include <IRremote.h>
#define START_BUTTON //place code for button // code recieved from start
button
#define STOP_BUTTON //place code for button // code recieved from stop
button

int servopin1 = 13; // first servo
int servopin2 = 12; // second servo

int pos = 0;

int receiver_pin = 4; // output pin
int vcc = 5; // vcc ir sensor
int gnd = 6; // gnd for ir sensor
IRrecv receiver(receiver_pin);
decode_results output;
Servo Servo1;
Servo Servo2;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  receiver.enableIRIn();
  pinMode(vcc, OUTPUT);
  pinMode(gnd, OUTPUT);
  digitalWrite(vcc, HIGH);

  Servo1.attach(servopin1);
  Servo2.attach(servopin2);
}

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

    if (receiver.decode(&output)) {
    unsigned int value = output.value;
    switch(value) {
      case START_BUTTON:
        if (pos <= 180){
           Servo1.write(pos);
           delay(500);
           pos = pos + 30;}
        else {
           pos=0;
             }
        if (pos <= 180){
          Servo2.write(pos);
          delay(500);
          pos = pos + 30;}
        else {
            pos=0;}
      break;
      case STOP_BUTTON:
           Servo1.write(0);
           delay(200);
           Servo2.write(0);
           delay(200);
           break;
            }
     }
  }

  //^servo 2 positions and delays
}

I'm trying to figure out why I'm getting a the following error:

C:\Users\Alex\Documents\Arduino\Servo_test2Library\Servo_test2Library.ino:
In function 'void loop()':

Servo_test2Library:38: error: expected primary-expression before ':' token

       case START_BUTTON:

                        ^

Servo_test2Library:53: error: expected primary-expression before ':' token

       case STOP_BUTTON:

                       ^

C:\Users\Alex\Documents\Arduino\Servo_test2Library\Servo_test2Library.ino:
At global scope:

Servo_test2Library:64: error: expected declaration before '}' token

 }

 ^

Multiple libraries were found for "IRremote.h"
 Used: C:\Users\Alex\Documents\Arduino\libraries\IRremote-2.2.3
 Not used: C:\Users\Alex\Documents\Arduino\libraries\Arduino-IRremote-master
Using library Servo at version 1.1.2 in folder: C:\Program Files
(x86)\Arduino\libraries\Servo
Using library IRremote-2.2.3 at version 2.2.3 in folder:
C:\Users\Alex\Documents\Arduino\libraries\IRremote-2.2.3
exit status 1
expected primary-expression before ':' token


texts: How many times can I upload a program or sketch to my Arduino Uno Clone Board?

texts: I'm about to work on my very first project using arduino (I'm just about to buy one next week), and one of our professor says that we can only upload a program or sketch in an Arduino Uno Board for approximately 8 times. He also added that if we're using a clone version, it'll can only last for 2 sketch uploads. Is this true or is he bluffing? Thank you in advance.


texts: Arduino voltage drop while communicating with another Arduino

texts:
I have an Arduino Uno rev 3 and an Arduino Nano in my Setup. I want to create a proof of concept, where one Arduino triggers the other via the Digital IOs.
Arduino 1 sets a blinking signal on a digital pin (500ms delay between high/low), which is received by arduino 2. If the signal is high, Arduino 2 triggers a LED (digital pin to LED+; LED- over 330 Ohm resistor to ground), so the signal gets looped through somehow. The grounds of the two Arduinos are connected, too.

Code Arduino #1:

void setup() {
  DDRD |=_BV(PD7); //Sets Digital Pin 7 as Output
}

void loop() {
 PORTD |=_BV(PD7); // equivalent with digitalWrite(7, HIGH);
 delay(500);
 PORTD &=~_BV(PD7); // equivalent with digitalWrite(7, LOW);
 delay(500);
}

Code Arduino #2:

void setup() {
  DDRD &=~_BV(PD7); //Sets Digital Pin 7 as Input
  DDRD |=_BV(PB0); //Set Digital Pin 8 as Output
}

bool set = false;

void loop() {
  if((PIND&_BV(PD7))==_BV(PD7)) { //true if digital pin 7 is set
    if(!set) {
      //PORTB |= _BV(PB0);
      digitalWrite(8, HIGH);
      set = true;
    }
  } else {
    //PORTB &=~_BV(PB0);
      digitalWrite(8, LOW);
    set = false;
  }

}

But instead of emitting a bright light, which can be seen if connecting the blinking signal directly to the LED, it emits a faint light. The voltmeter also shows an significant Voltage drop. Whilst the digital pin should have a voltage of ~5V when set to HIGH (never reached because of inner resitance inside the arduino), it measures about 1.6-1.8V.
I also switched the both Arduinos which showed the same result, so it shouldn't be a hardware defect.

Thanks in Advance!


texts: MPU6050 accelerometer giving output as -1 -1. Can anyone tell the issue in the code?

texts:
// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include<Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0); // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

Serial Monitor output:

AcX = -1 | AcY = -1 | AcZ = -1 | Tmp = 36.53 | GyX = -1 | GyY = -1 | GyZ = -1
AcX = -1 | AcY = -1 | AcZ = -1 | Tmp = 36.53 | GyX = -1 | GyY = -1 | GyZ = -1
[…]


texts: Calling functions from an array of pointers in a library causes 'undefined reference to' error

texts:
I am trying to create a library, where I have an array of pointers to functions in it. This array is used by other functions in the library. This is the code of the header file:

class Lib {
  public:
    static void call();
    static void (*caller[])();
  private:
};

This is the code of the .cpp-file:

#include "Lib.h"

void (*caller[2])();

void Lib::call() {
  caller[0]();
}

The sketch executing this is

#include <Lib.h>

void setup() {
  Lib::call();
}

void loop() {}

When I try to compile this, I get the following error:

  undefined reference to `Lib::caller'
  collect2: error: ld returned 1 exit status
  Mehrere Bibliotheken wurden für "Lib.h" gefunden

Another weird thing is that the error about the multiple found libraries goes away if I take away the line

Lib::call();

However, if I put the same code directly into the sketch like so:

void (*caller[2])();

void call() {
  caller[0]();
}

void setup() {
  call();
}

void loop() {}

I get no error. What's the problem here?


texts: Load Adafruit GFX bitmap fonts on desktop for pixel-level design

texts:
I am designing UI for 160x128 ST7735-based TFT display which will be displayed using Adafruit's GFX library (and the driver in Adafruit_ST7735.h). I am using the default bitmap font (custom fonts don't provide the white-out functionality, causing flicker) and would like to load it in some desktop pixel editor (like Gimp or some pixel-art editor) so that I can work the design out on desktop.

There are many posts about converting regular (TFT, OTF) fonts to the c-style array, I need to do the opposite. If possible, including the scaled variants, so that I have 1:1 corespondence :)

Any tips on this?


texts: What type of power supply is the Arduino Due’s 5v pin and what is its current?

texts:
I’m looking to use a Futaba Servo with my arduino Due and was told it requires a “high current 5 volt supply” and I don’t know much about current so excuse my arrogance.
I know the arduino Due has a 5 volt pin. But what type of power supply is it? (Linear power supply, switching power supply, etc.) and how much current does it provide? If I get this information to my instructor he can tell me if it will suffice.

Thank you!


texts: How to wait outside the loop without delay()?

texts:
Is it possible to delay a task inside a function that is called only once (meaning, it's not inside the loop) without using delay()?

This library I'm using, for reading sensor measurements via serial has a delay() in it. I want to get rid of it, but I don't how to do it, because the library's function is not looped.

I guess the simple solution would be to move the library functions inside the loop, so I can do a simple check with millis() and run the delayed part as soon as 250 ms have passed. I would like to improve this library though and do a simple, single call for sensor data that doesn't not hold up the entire program.

This is the function with the delay:

uint16_t COZIR::Request(char* s)
{
  Command(s);
  // empty buffer
  buffer[0] = '\0';
  // read answer; there may be a 100ms delay!
  // TODO: PROPER TIMEOUT CODE.
  delay(250);
  int idx = 0;
  while(CZR_Serial.available())
  {
    buffer[idx++] = CZR_Serial.read();
  }
  buffer[idx] = '\0';
  uint16_t rv = 0;

  switch(buffer[1])
  {
    case 'T' :
            rv = atoi(&buffer[5]);
            if (buffer[4] == 1) rv += 1000;
            break;
    default :
            rv = atoi(&buffer[2]);
            break;
  }
  return rv;
}

I've had a look at the SoftTimer library, but it requires sketches to be written very differently (without a loop). I'm also not sure if I can even pass arguments to delayed tasks with that library.


texts: Change Arduino Uno clock from 16MHz external to 1MHz internal

texts:
I've got a project where I need to program an ATmega328P on an Arduino Uno board, then transplant it into a custom PCB - however, this board does not have an oscillator installed, and so I need to run the microcontroller off its internal clock.

My goal here is to be able to code my software with the Arduino IDE, insert a factory-fresh ATmega328P straight from the tube into the socket on the Arduino Uno board, then move the device from the board to the PCB without any changes along the way. What's the best way to go about this?


texts:
Using the Ticker library for the ESP32, how can I use a lambda as an argument to the attach method?
tickerSystemManager.attach(1000, [&](){
  systemManager->sync();
});

Attempting to use the above, I get the following error:
Matrx.cpp:11:4: error: no matching function for call to 'Ticker::attach(int, Matrx::setup()::<lambda()>)'
...
Ticker.h:40:8: note: candidate: void Ticker::attach(float, Ticker::callback_t)

How can I capp a lambda into this method?


texts: Volatile variable not updating from timer ISR

texts:
I know this is a problem that has come up many times but I can't seem to get this code fragment to update the count variable on an ATMEGA328P. I am using an Arduino Uno as a development board, with the LED on pin 13 set to flash for debugging. I have confirmed the timer and LED part work by toggling port B pin 5 in the ISR routine.

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

volatile uint8_t count;

void init_100us_tick(void) {
    TCCR0A = _BV(WGM01) | _BV(WGM00);       // WGM mode 7 with OCRA as top
    TCCR0B = _BV(WGM02) | _BV(CS01);        // CLK / 8 prescaler
    TIMSK0 = _BV(OCIE0B) | _BV(TOIE0);      // Interrupt enabled on OCR0A
    OCR0A = 200;                            // 16 MHz / 8 / 200 = 100 us
    sei();                                  // Enable interrupts
}

ISR(TIMER0_COMPB_vect) {
    count++;
}

int main(void) {
    DDRB |= _BV(DDB5);                      // PB5 output
    init_100us_tick();                      // Initialise 100 us tick
    count = 0;                              // In case of micro reset

    for (;;) {
        if (count >= 100) {                 // Every 10 ms
            count = 0;
            PORTB ^= _BV(DDB5);             // Toggle PB5
        }
   }
   return 0;
}

This is being compiled and burned to an Arduino Uno with the following:

avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o test.o test.c
avr-gcc -mmcu=atmega328p test.o -o test
avr-objcopy -O ihex -R .eeprom test test.hex
avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyUSB0 -b 115200 -U flash:w:test.hex

I have tried disabling the optimisation with no effect. AVR-GCC is version 4.9.2


texts: Using Arduino based OpenCR with USB Host Shield 2.0 to connect to PS4 controller

texts:
I am trying to use a PS4 controller with my dynamixel setup using the OpenCR 1.0 board. The USB Host Shield 2.0 library is used to talk to the controller, but the current library does not support Open CR 1.0, but it does support other ARM boards. Is it easy to modify the library to talk to Open CR? My guess is that it is just the SPI pins (and other pins) that need to be redefined, but any guidance regarding the same would be great.

https://github.com/felis/USB_Host_Shield_2.0

https://github.com/ROBOTIS-GIT/OpenCR


texts: How to read bytearray from arduino pin in arduino sketch

texts:
I'm using the DYP-ME007TX sensor with arduino uno.
The output from this sensor comes in packets of 4-bytes:

Data[0]= 0xFF: Packet Header
Data[1]= 0x0-0xFF: Data Most Significant Byte (MSB)
Data[2]= 0x0-0xFF: Data Least Significant Byte (LSB)
Data[3]= 0x0-0xFF: Data Checksum: = (0XFF + MSB + LSB) &amp; 0xFF

Data is in MILLIMETERS

16 bit value in mm = Data[1] << 8 | Data[2]

How can exctract this packet in arduino sketch and extract millimeter number?


texts: My PIR sensor output changes but digitalread high all the time

texts:
This is my final project, I have to communicate with two wemos d1 mini by LAN. The problem is that when I read the state of the PIR sensor it is "HIGH" all the time, but when I connect the led light, it blinks as I move my hand - so the sensor is not broken.
I have tried with D7,D2,D3 and its the same... code is in the loop body
PIR output is directly connected to the D0.

#include <SPI.h>
#include <ESP8266WiFi.h>

int pirPin = 0;
int val=0;
/*int led1 = 1;
int  led2 = 3;
int led3 = 4;
int senzor2 = 5;
int led4 = 6;
int led5 = 7;
//int led6 = ;
*/
int ledPin = 2;
String ID = "001";

boolean uspostavljenostVezeSaServerom=false;
char ssid[] = "arduinoserver";           // SSID od mreže na koju se spaja
char pass[] = "arduinoserver";            // lozinka mreže na koju se spaja

unsigned long askTimer = 0;

IPAddress server(192,168,1,80);       // fiksna adresa servera na koji se spaja arduino(klijent)
IPAddress ip(192, 168, 1, 79);
IPAddress gateway(192,168,1,1);           // gateway mreže (nije obavezno)
IPAddress subnet(255,255,255,0);          // subnet mreže (nije obavezno)

WiFiClient client;

void setup() {
  pinMode(pirPin,INPUT_PULLUP);

  Serial.begin(115200);               // podešavanje bauda za komunikaciju
  spajanjeNaMrezu();                  // spajanje na mrežu
}

void loop () {

  if(uspostavljenostVezeSaServerom==false)spajanjeSaServerom();  // arduino uspostavlja komunikaciju sa serverom
  if(WiFi.status() != WL_CONNECTED) spajanjeNaMrezu();

val = digitalRead(pirPin);
  Serial.println(val);
delay(300);

  //Serial.println(digitalRead(val));

 /* client.connect(server, 80);   // Spajanje na server
  client.flush();
  client.println(ID);
  String answer = client.readStringUntil('\r');   // čekanje povratne poruke dok ne dođe do znaka "/r"
  */
}

void spajanjeSaServerom(){

  String answer;
  while(answer != "OK")
    {
      Serial.println("Uspotavljanje veze s serverom...");
      client.connect(server, 80);   // Spajanje na server
      client.flush();
      client.println(ID); // slanje koda klijenta serveru
      Serial.println("Šaljem ID: " + ID);
      answer = client.readStringUntil('\r');
      Serial.println("Odgovor servera: " + answer);
    }

  Serial.print("Veza uspostavljena!");
  uspostavljenostVezeSaServerom=true;
}

void spajanjeNaMrezu(){
  WiFi.config(ip, gateway, subnet);
  WiFi.begin(ssid, pass);             // spajanje s ruterom
  while (WiFi.status() != WL_CONNECTED) {
      Serial.println("Spajanje na mrežu...");
      delay(500);
  }
  Serial.println("Uspjesno spajanje na WiFi");
  Serial.print("Status: "); Serial.println(WiFi.status());
  Serial.print("IP: ");     Serial.println(WiFi.localIP());
  Serial.print("Subnet: "); Serial.println(WiFi.subnetMask());
  Serial.print("Gateway: "); Serial.println(WiFi.gatewayIP());
  Serial.print("SSID: "); Serial.println(WiFi.SSID());
  Serial.print("Signal: "); Serial.println(WiFi.RSSI());

}


texts:
i have 30Amp ESC which i can move motor by providing values ,

but i am unable to know what is the minimum and maximum throttle speed of the motor....

how to achieve that level of info through arduino,

although when i calibrate through Open pilot software ,it is able to calibrate and the minimum value is 1500ms ..

Also after calibrating it once , do i need to arm everytime before using ESC in the arduino program through serial input ?


texts: How to create qr code based on 30 digit number and send the generated qr code to wireless printer.


texts: ESP8266 NodeMCU 3v3 current for fingerprint sensor

texts: From what i see that 3.3Vpin provide 3.3V and 400mA. The fingerprint module i use is AS608. Connecting the fingerprint module power pin to 3.3V of the nodemcu. From the datasheet it only can handle 3.3VDC, operating current<60mA and peak current at <70mA. Do i need to add a resistor to take the current away. Since last time i use another fingerprint module which is R307 connecting to Vin of the nodemcu and now it not working anymore?


texts: How to keep track of millis during sleep mode

texts:
In my application, I need to keep track of the time the application has been running as well as use sleep modes. However, when using the sleep modes, Timer0 is disabled, and therefore millis stop counting.

Is there a way to measure/count how long the Arduino was in sleep mode for?

To give you some more background info, this is what I'm trying to achieve:
I am using a pressure sensor which sends an interrupt to the Arduino every 80ms and wakes it up.
The program does various routines to process the data which can take anywhere from 2ms to 60ms.
It then goes into sleep mode until another external interrupt occurs, approx 20-78ms later.
The application has many processes based on time, such as a stopwatch, timer and alarm, so I need to be able to keep track of this, preferably using millis().
The device is running on a single cell 250mah LiPo battery which at present only lasts about 4 hours.
I'm using an ATMega1284.

In most of the sleep modes Timer0 is disabled. Which means that millis() stops counting. Is there a way, without using an RTC (Both Space and weight are at a premium), to keep millis counting whilst in sleep mode?

I notice that SLEEP_MODE_IDLE keeps Timer0 running, but that means that for every millisecond an interrupt wakes up the device. Please correct me if I'm wrong, but given that my loop can take about 60ms to execute, I don't see much advantage to sleeping for 1ms.

Possible solutions:

Use Timer2 for the millis function?
Use the Watchdog Timer to count how much time has passed whilst in
sleep mode and add this to millis() when waking up?
If there was a VERY small SMD RTC which didn't need any external
components such as oscilators etc then this might be feasible.


texts:
I am attempting to build mocoLUFA under OS X el Capitan 10.11.6.

[Editor: mocoLUFA (MIDI firmware for Arduino Uno)]

I am using the specified LUFA version (LUFA101122) and I have tried building with both brew avr-gcc and also Crosspack-AVR.

The problem I am facing isn't with the build or the install. It's just that as soon as I install the hex file, I get no midi messages at all.

What does work - the OSX machine recognises the MIDI device and the MIDI device appears in DAW's, however MIDI Monitor registers no messages at all.

I have tried downloading a custom-built mocoLUFA and I am able to install this and it works fine. I see midi messages coming across from my sketch.

Crosspack-AVR installs avr-gcc 4.8.1.

My question is - what is the correct build environment in order to achieve a working mocoLUFA under OSX? I have tried both mocoLUFA and dualMoco and I get the same result with each.

My purpose for this is to modify mocoLUFA so that it can support sending MTC over USB. At present, it appears that mocoLUFA does not support System Common messages.

UPDATE: Built fresh Ubuntu VM. Installed avr-gcc, avr-libc, LUFA-100807 and mocoulfa. Same result. hex builds fine, no response from the atmega16u2. TX light flashing, sketch on the 2560 running, but no midi messages down the usb cable.


texts:
How to get Current date, month and year. I have used RTC, NTPClient, but it didn't work. This gives default output of 1970. What can I do for fixing it.

time_t now = time(nullptr);
struct tm* newtime = localtime(&now);
String tmpNow = "";
tmpNow += String(newtime->tm_year + 1900);
tmpNow += "-";
tmpNow += String(newtime->tm_mon + 1);
tmpNow += "-";
tmpNow += String(newtime->tm_mday);
tmpNow += " ";


texts: NodeMCU serial port - use with computer and device at the same time

texts:
I'm trying to understand how serial communication for ESP8266 in NodeMCU actually works. I found a quote saying that normal Serial is mapped to ports GPIO 1 (TX) and GPIO 3 (RX). They are even labeled on the board like this, so I believe this is true.

However I'd like to understand the relationship between those pins and serial communication over USB. Does this work the same way as in normal Arduino where you can use either communication over USB or hardware serial on pins 0 & 1?

I did some tests and if I run simple program like:

Serial.begin();
//.......
Serial.println("Hello world");

I can see that in serial monitor on my PC. How does that impact serial communication on GPIO 1 & 3 ?


texts: How to send unmodulated IR-Signal via cable?

texts:
I need to generate en (extended) NEC signal. I have connected an Arduino with a display-device via an IR cable.

Arduino --> IR-cable --> IR-input of display device

IR-cable:

One plug is cutted and the 3 wires are connected with the arduino.

The arduino should generate NEC Signals, and the display shall react to it. Basically the arduino acts like a wired remote control.

The problem is: There are many tutorials around, that show how to do this with a sensor (e.g by using this library). But none of the tutorials says how to do it with a cable.

I found out, my previous attempts all failed, because I tried to generate a modulated NEC-signal to the display. The display however does not understand it, because there is no device that demodulates the signal. The IR sensor normally does this, which is missing in this case.

e.g.
This is, what an modulated NEC signal looks like:

00 4e ff 61

The library generates the moduled signal (pulse bursts) and this is how it works for IR sensors.

But how do I have to send my IR-command, that the display understands it? How do I send a not-modulated IR signal?

The following graphic demonstrates the issue:

I do not have IR-LED Transmitter, Amplifier, Limiter, Band Pass Filter, Demodulator, Integrator, Comparator....
I just want to create the green Output-signal directly from my Arduino


texts: How to convert my Arduino setup to a PIC setup?

texts:
I have an arduino setup with LCD, RTC, EEPROM, Reed Switch, AC/DC Buck Converter, 4X4 Keypad.
What PIC IC will let me connect with all these(40 Pins), and yet accept Arduino Code.
I don't want to rewrite the code. I learn Arduino only recently, So shifting to another coding language is near impossible, since am not a coder.


texts:
I am using a Uno as a data logger with a DS1307 RTC and the following libraries Time.h DS1307RTC.h

The DS1307 does not have any support for DST and neither library includes Time Zone.

Are there any libraries which adjust for DST?

I used the Timezone module to correct my times for DST.
It took a little time to sort it out, so I though I would post the steps I followed.

Customise WriteRules for my Timezone.
I copied rule from WorldClock.
NOTE also need to modify Timezone in setup(void)
Run WriteRules.pde to write rules to EEPROM address 100

Run TimeRTCSet.pde to set RTC time to UTC.
Start Serial Monitor.
In Terminal send time to Arduino

date -u +T%s > /dev/tty.usbmodemFA131

Run HardwareRTC.pde to demonstrate time display in UTC & local

I modified my sketch by including the following code:-

#include <Timezone.h>    //https://github.com/JChristensen/Timezone
⋯
Timezone myTZ(100);       //assumes rules stored at EEPROM address 100
TimeChangeRule *tcr;        //pointer to the time change rule, use to get TZ abbrev
time_t utc, local;
⋯
utc = now();
local = myTZ.toLocal(utc, &tcr);


texts: Using Arduino UNO as FTDI programmer for 9DOF Razor IMU

texts:
I am trying to upload some code to the ATmega328 on Sparkfun's 9DOF Razor IMU. Because I don't have an FTDI board at hand I was trying to use my UNO by "grounding" the RESET pin. Communicating with the 9DOF works well (it has some sample firmware loaded):

So here's the problem:

When I try to program the ATmega328, the Arduino IDE gives e the following error:

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

What am I doing wrong?


texts: Is it possible to press a button from Arduino and my computer will get a key event?

texts:
My idea seems easy:

I connect a button with arduino, then write some code and upload it to arduino. Then I open the notepad(or any other editor) on my computer. When I press the button, there will be a character "A" displayed in the notepad.

I have tried with my Arduino uno, and use Serial.write/print function to send an A to serial port 9600, but it seems the character A only shows in the serial monitor GUI.

My question is:

Is "Arduino uno" is OK to implement this?
If not, what other board should I use?
Is Serial.write/print the correct function?
Or shall I use the Keyboard.??? function?
Do I have to write an application which runs on the computer and listens the serial port, and emit a real key event? (that's sad)


texts: Using an IR sensor from another manufacturer

texts:
I am currently trying to create a line tracing robot with my Arduino Uno.

I have an IR Sensor (http://support.robotis.com/en/product/auxdevice/sensor/irsensor_manual.htm) but I am not sure if I can use this for my Arduino.

Can someone please tell me if I can? Thanks in advance.


texts: How does the speed work in VirtualWire Library

texts:
I'm analyzing the VirtualWire library and in it, the send messages are being sent with digitalWrite in the "send" method. However, there is a setup speed function. I'm reading that function and I see a lot of prescalers and TCCR variables. However, I'm not quite sure what these things do. Because, if it uses digitalWrite anyway to send the bits, then really is no intrabit delay, etc. Can someone please clarify this?

Sorry if question is convoluted. Happy to do any clarification. Thank you for all guidance!

EDIT: Also, how do I transmit a block of message. Something greater than a byte? I'm trying to calculate BLER of messages and software serial only transmits 1 byte at a time. While virtualWire uses low-level error detection (and i want to avoid the use of any error detection/correction).


texts:
I'm trying to  run an Arduino code that simultaneously:
1) blinks an led on-off every 3 seconds
2) gets a voltage input from an EMG sensor and positions a servo motor accordingly

While I run this program, I'd like to plot the following on the same graph
1) LED status on/off printed as 600 if on and 0 if off
2) EMG value being fed to the arduino
3) The angle the Arduino is sending to the servo motor

I wrote the following code which works to an extent but the problem I'm facing is, I only get two graphs on the plotter instead of 3, I think the EMG value and the angle have combined into a single line as seen in this picture:

However, if I remove the angle print statement, I get a proper graph for the other 2 as this:

How do I change my code so I can plot all three separately?
Thanks in advance.

#include <Servo.h>
Servo myservo;
const int ledPin =  LED_BUILTIN;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 3000;
int led=0;
int servovalue=0;
void setup() {
  Serial.begin(9600);
  myservo.attach(9);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int sensorValue = analogRead(A0);
int angle = map(sensorValue, 0, 1023, 0, 180);
myservo.write(angle);
Serial.print(sensorValue);
Serial.print(“ ”)
Serial.println(angle);
delay(15);
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (ledState == LOW) {
      ledState = HIGH;
      led = 600;
    } else {
      ledState = LOW;
      led = 0;
    }
    digitalWrite(ledPin, ledState);
  }
  Serial.print(" ");
    Serial.println(led);
}


texts:
I got a breadboard with 10 LEDs, 4 of them fade, to be specific:
3, 5, 6 and 9 are working. 0, 1, 2, 4, 7, 8 are not working.

I'm using LEDs and resistors on all spots, they're all the same. Tried changing things around but the problem doesn't seem to be the resistors or the LEDs.

I'm using the following code (I'll highlight the parts for the fading, by marking it between //** comments).

Does anyone know a way to fix this? Or see any problem?

const int inButton = 13;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
int delayTime = 100;
int brightness = 0;
int fadeAmount = 5;

void setup() {
  //**
  pinMode(inButton, INPUT);
  for (int out = 0; out < 10; out++){
    pinMode(out, OUTPUT);
  }
  //**

  pinMode(testLed, OUTPUT);
}

void loop() {
  buttonState = digitalRead(inButton);
  if (buttonState != lastButtonState){
    if (buttonState == 1){
      buttonPushCounter++;
    }
  }

  lastButtonState = buttonState;

  if (buttonPushCounter % 5 == 0){
    for (int i = 0; i < 10; i++){
      digitalWrite(i, 1);
      delay(delayTime / 2);
      digitalWrite(i, 0);
    }
  }
  else if (buttonPushCounter % 5 == 1){
    for (int i = 0, j = 9; i < 10, j >= 0; i++, j--){
      digitalWrite (i, 1);
      digitalWrite (j, 1);
      delay(delayTime / 2);
      digitalWrite (i, 0);
      digitalWrite (j, 0);
    }
  }
  else if (buttonPushCounter % 5 == 2){
    for (int i = 0; i < 10; i+=2){
      digitalWrite(i, 1);
    }
    delay(delayTime);
    for (int i = 0; i < 10; i+=2){
      digitalWrite(i, 0);
    }
    delay(delayTime);
    for (int i = 1; i < 10; i+=2){
      digitalWrite(i, 1);
    }
    delay(delayTime);
    for (int i = 1; i < 10; i+=2){
      digitalWrite(i, 0);
    }
  }
  else if (buttonPushCounter % 5 == 3){
    for (int i = 0 ; i < 10 ; i++){
      analogWrite(i, brightness);
    }
    brightness = brightness + fadeAmount;
    if (brightness == 0 || brightness == 255){
      fadeAmount = -fadeAmount;
    }
    delay(25);
  }
  else {
    int R1 = random(10);
    int R2 = random(10);
    int R3 = random(10);
    int R4 = random(10);
    digitalWrite(R1, 1);
    digitalWrite(R2, 1);
    digitalWrite(R3, 1);
    digitalWrite(R4, 1);
    delay(delayTime);
    digitalWrite(R1, 0);
    digitalWrite(R2, 0);
    digitalWrite(R3, 0);
    digitalWrite(R4, 0);
  }
}


texts:
I want to make a piezo buffer beeping with assembly code, but i haven't managed to yet. I have an Arduino UNO board (ATMega328p) and using avra and avrdude to build and load. The buzzer just stay silent. Here's my code:

.nolist
.include "m328pdef.inc"
.list

.equ _a = 141 ;(16000000 / 256) / 440(frequency of A) - 1

.cseg
  ;wgm02..0 = 7 (fast pwm, top = ocr0a)
  ;cs02..0 = 4 (N=256)
  ;com0b1..0 = 2 (clear on compare match, set at bottom)
  ldi r16, 0b00100011
  sts tccr0a, r16 ;need out!
  ldi r16, 0b00001100
  sts tccr0b, r16 ;need out!
  ;ocr0a = _a to obtain 440Hz
  ldi r16, 141
  out ocr0a, r16
  ;ocr0b = ocr0a/2 to obtain a duty cycle of 50%
  ldi r16, 71
  out ocr0b, r16
  ;enable output at D5 aka oc0b aka Arduino pin 5
  sbi ddrd, 5
  loop:
  rjmp loop

Wiring is good and the buzzer too, since it works with a C sketch

EDIT: I found my answer by myself (with the help of answerers). I was accessing IO ports (tccr0a and tccr0b) with sts, while i had to use out. (tccr0a and tccr0b are IO ports defined in "m328pdef.inc" as IO addresses, not as memory addresses)


texts:
This is my first post. I hope that I am posting in the right section of the forum. Otherwise, could an admin move this topic to the appropriate section please?

Board : Arduino Pro Mini 3.3V 8MHz

Arduino IDE : 1.6.12
Arduino is powered by a FTDI Board and USB Mini-B cable from the computer USB port in the following order :

Arduino        FTDI

BLK              GND

GND             CTS

VCC             VCC

RXi              TX

TXo             RX

DTR             DTR

Also, I have connected a HC-06 bluetooth module in the following order :

Arduino    HC-06

GND         GND

VCC         VCC

D10         TXD

D11         RXD

The Serial Monitor is open on COM4, Newline, 9600 baud.

The code that I'm trying to run is :

#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11);
void setup()
{
  pinMode(13, OUTPUT);
  BT.begin(9600);
  // Send test message to other device
  BT.println("Hello from BTSerial");

  Serial.begin(9600);
  Serial.println("Hello from Serial");
}

char a; // stores incoming character from other device
void loop()
{

  if (BT.available())
  // if text arrived in from BT serial...
  {
    a=(BT.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
      BT.println("LED on");
    }
    if (a=='2')
    {
      digitalWrite(13, LOW);
      BT.println("LED off");
    }
    if (a=='?')
    {
      BT.println("Send '1' to turn LED on");
      BT.println("Send '2' to turn LED on");
    }
    Serial.println(a);
  }
}

I am trying to communicate with the HC-06 from an Android phone.
I am posting in this section of the forum because when I send a message from the phone to Arduino the following is printed in the Serial Monitor :

à„…€ƒ¦¤„„‡…§¤¦„‡Å„EóAãbBãbHãb

When I am trying to send a message from Arduino to the phone, nothing is received on the phone.

Could someone please explain why I get garbage output on the Serial Monitor even though the baud rate is the same in the code as it is in Serial Monitor window?
Is there a problem with the Arduino IDE?

Edit 12.11.2016

This is what I get when I open the Serial Monitor in the Arduino IDE with this code :
Newline, Baud rate 9600

‚Æ‡¥Ç$¤†Fó

If I change the Serial Monitor properties to Newline, Baud rate 19200 this is what I receive :

Hello from Serial

On the Android phone application I do not get anything printed.

Also, please note that this question is also addressed on the Arduino forum at the following link :
http://forum.arduino.cc/index.php?topic=434623.0
I will try and answer in both places as I am not sure that everybody has an account on the forum


texts: What are examples of large Arduino code bases and how are they organized?

texts:
I'd like to find out:

how big can an Arduino project get, is there some limit?
are there examples of large open source code bases? I did some research but find only example projects with single .ino file. Are there projects with multiple files e.g. functions, constants in separate files say to avoid a 10K+ .ino file?


texts: Attiny13 analogread() not working on all pins

texts:
I am new here and perhaps you could help me. I am trying to program Attiny13 with the following short sketch which uses ADC (analogread()) function, that is supposed to work like this:

reads voltage from voltage divider using photoresistor - analogread() from A1 (ADC1)
turns LED on/off whenever there is low light (covering photoresistor) - digitalwrite() LED at 3 (PB3)

however it does not work on each of the ADCs:
- works when I use A3 (ADC3) as analogread
- does not work when I use A1 (ADC1) or A2 (ADC2) as analogread

Do you know what might be the reason? Same code, but works on 1 of the ADCs only.

I program uC with USBASP programmer, but I don't think this matters since with 1 of the ADCs all works fine. Also it works on Arduino Mega 2560 and uC Atmega88, so something wrong with Attiny13.

Sketch that does not work:

int state = 0;

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

void loop()
{
    int reading = analogRead(A1);

    if (reading < 100) // ONCE I COVER PHOTORES. IT GOES INTO THIS LOOP AND TURNS ON/OFF THE LED
    {
        state = !state;
        digitalWrite(3, state);
        delay(200);
    }

    delay(100);
}


texts: MQTT broker and Arduino + Sensors NRF24L01

texts:
I am newbie, I have never used MQTT before, so I have some questions.
Here is my topology.

I have several sensors (Arduino Pro Mini + NRF24L01) and main server/handler(Arduino Mega + Ethernet Shield or ESP module) to receive/send messages to/from sensor nodes, so all network is build on NRF24L01 (NRF24 Mesh library). But I need to be able to communicate with all these sensors from outside over the internet. Previously I implemented simple socket communication.
I have recently discovered MQTT protocol and it is awesome. I want to implement communication between main server and outside world using it.

What part of my topology should implement broker in? I think it should be on the main server (Arduino Mega) but again communication between main server/master server is implemented via NRF24L01 modules and custom protocol.
Or in my case is better to use HTTP communication with master server?

Please explain this topic and suggest how to implement this correctly in my case.


texts: Will Arduino Pro Mini 3.3V run at half the speed of 5V version?

texts:
Provided a very simple sketch like this:

void loop() {
  digitalWrite(1, !digitalRead(1));
}

... should I expect 5V Arduino to run twice as fast as 3.3V, or are there some internal adjustments in place?

Specifically, I'm wondering about Pro Mini and/or Nano boards. The "speed" here is simply the frequency measured on pin 1.

edit:

To clarify, I'm wondering if there might be some behind-the-scenes frequency divider that makes sure Arduino code always run at the same physical speed, even if the actual MCUs run on different clocks.

Possibly the simplest way of forming this same question: Can the sketch above be used to identify 3.3V Pro Mini boards from 5V versions, with the help of a frequency meter?


texts: Start LED blink at certain millis() value

texts:
I was looking at the blink without delay sketch and I was trying to modify it so the LED would start blinking after 1000 ms. I changed the previousMillis variable to 1000, but the program didn't change. In fact, it doesn't seem to change for any value of previousMillis. I thought that this would change the if statement:

if (currentMillis - previousMillis >= interval)

because 2000ms would have to pass for currentMillis - previousMillis to be equal to 1000ms (interval). What am I missing?


texts: TinyGPS++ isn't being updated or SoftwareSerial isn't reading

texts:
I'm trying to read the GPS data on an Arduino Uno from a Neo-6M module and print it on a LCD display. However, no variable is being changed by the read function. This could either be because of an incorrect reading of the gps variable or a wrong use of the SoftwareSerial library.

Here's the code:

#include <TinyGPS++.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <splash.h>

#include <SoftwareSerial.h>

Adafruit_SSD1306 display;  // Create display
SoftwareSerial gpsSerial(4,3);//rx,tx
float lati=0,longi=0;
float sat=0;
TinyGPSPlus gps; // create gps object

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gpsSerial.begin(9600); // connect gps sensor
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize display with the I2C address of 0x3C
  display.clearDisplay();
  display.setTextColor(WHITE);
}

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

    gps.encode(gpsSerial.read());
    display.setCursor(80,3);
    display.print("R");

  //if(gps.location.isUpdated())
  {
    lati = gps.location.lat();
    longi = gps.location.lng();
    sat = gps.satellites.value();
    display.setCursor(100,3);
    display.print("U");
  }

  display.setCursor(20,20);
  display.print(lati);
  display.setCursor(20,40);
  display.print(longi);
  display.setCursor(100,40);
  display.print(sat);
  display.drawRect(0,0,127,63,WHITE);
  display.display();
}

EDIT: The data coming from gpsSerial is a series of -1
EDIT 2: Swapping SoftwareSerial gpsSerial(4,3); to SoftwareSerial gpsSerial(4,3); makes it output a series of ints. However, encoding it with gps.encode(gpsSerial.read()) still doesn't update the data.


texts: Why are there two sets of tools and bootloaders in the Arduino IDE?

texts:
After digging around on a separate problem, I found that avrdude, avr-gcc and some more tools can be found in two different locations:

(1): C:\Program Files\Arduino\hardware

(2): C:\Users\<user>\AppData\Local\Arduino15\packages\arduino

These two folders also both contain similar copies of the hardware directory where all the bootloader hex-files and source code is stored:

(3): C:\Program Files\Arduino\hardware\arduino\avr

(4): C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17

I say similar because the bootloaders\caterina folder in (4) contains quite a few hex-files that are missing in (3).

When burning a bootloader, looking at verbose output from the Arduino IDE reveals that hex-file and executable of avrdude from (2) are used, not (1).

What is the reason for this? My guess would be that location (1) is deprecated, but why choose to put stuff like this into Appdata in the first place?


texts: How can i send one char from arduino to android(bluetooth)

texts:
I am trying send one char from arduino to android through module HC-05, i can send from android to arduino, but now i want to do it from arduino to android, Someone have any example about how can i do it?

Help me


texts: Arduino due erase button and power switching

texts:
Last days I have been investigatin schematics of arduino due board. The purpose of proper understanding of schematics in crucial for me, beacuse I indend to build myself my own board with some minor modifications.

I would really want to learn something from it and not just blindly copy stuff that are already done. In schematics there are two things that I do not understand. First is the working principle of erase button (see: erase button). I have my own idea how does it work, but would like to clarify the working principle from someone that know exactly what is the purpose of all the elements that are connected to erase button. Also, why is ERASE_CMD  line connected to Atmega processor?
 Second thing is switching of power supply between external power and both usbs (see: usb switch). Again, would someone please just brifly describe working principle? Here I really do not undertand why is there op amp added?

Thank you in advance.

Erase button:

USB switch:

PLEASE NOTE: Both pictures are taken from original arduino webpage: https://store.arduino.cc/due  (see: documentation -> schematics)


texts:
I have a raspberryPi and Arduino connected via i2C. On the RPi I have a python script that takes int values and simply sends them to the RPi, which in turn echoes them back. I am trying to debug this, since I am unable to send ints larger than 255.

One thought was that I might be able to connect the arduino slave directly to my Mac, and then use the Arduino serial monitor to help with debugging.

Unfortunately the python script will not run, because I assume i2C can only be run on a Linux kernel.

Am I mistaken?

This is an edited portion of my python code

import smbus
import time
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)

# This is the address we setup in the Arduino Program
address = 0x04

def writeNumber(value):
    bus.write_byte(address, value)
    return -1

def readNumber():
    number = bus.read_byte(address)
    return number


texts: Arduino Uno + Wifi Shield + PS2 Keyboard + LCD Display

texts:
I'm new in the Arduino Community and I'm facing a problem when I try to use a PS2 Keyboard and an LCD Display (16x2) on an Arduino Uno with a Wifi shield.

I would like to write something with the keyboard and display it in the LCD before sending it to a webservice.

Here is my problem:

When I use the keyboard and the display on my Arduino WITHOUT the wifi shield --> All is OK. I can write on the display the key that has been pressed.
When I use the keyboard and the display on my Arduino WITH the wifi shield --> All is OK until I write something on the display. As soon as I write on the display with the function lcd.print(), the keyboard does not work anymore (it detect the character '2' every time I press a key).

It's very surprisingly because if I dont use lcd.print(), the keybord works without any problem.

Here is a part of my code:

#include <LiquidCrystal.h>
#include <PS2Keyboard.h>

LiquidCrystal lcd(12, 11, 2, 5, 6, 8);
PS2Keyboard keyboard;

const int DataPin = 9;
const int IRQpin = 3;

void setup(){
  keyboard.begin(DataPin, IRQpin);
  lcd.begin(16, 2);
}

void loop(){
  checkKeyboard();
}

void checkKeyboard(){
  if (keyboard.available()) {

    char c = keyboard.read();

    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
      Serial.print(c);
      displayText(c);
    }
  }
}

void displayText(char c){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Pressed key:");
  lcd.setCursor(0,1);
  lcd.print(c);
}

Does somebody know how to solve this problem?

Thank you very much in advance :)

Edit: Here are the pins that I use on the board :

Arduino pin 2 -> LCD pin 11
Arduino pin 5 -> LCD pin 12
Arduino pin 6 -> LCD pin 13
Arduino pin 8 -> LCD pin 14
Arduino pin 11 -> LCD pin 6
Arduino pin 12 -> LCD pin 4
Arduino pin 3 -> Keyboard IRQ
Arduino pin 9 -> Keyboard Data


texts: I2C LCD Serial Interface Board not displaying text (wrong pins?)

texts:
I have a 1602 LCD screen that works fine on its own. However I wanted to free some pins by using an I2C / IIC LCD controller I purchased separately.

While the controller seems to be communicating with my Arduino UNO on the right address, I cannot get text to display. By default (no code) it seems the LCD will have 1 line of 16 solid "squares". When using address 27 in my code, the LCD will change to 2 lines of 16 squares (see photo below). The code also calls for the backlight to flash 3 times, which works. However I cannot get anything but 2 lines of squares. (Full code is at the bottom of this question).

I'm using the LiquidCrystal_I2C library by F Malpartida, which seems to be commonly used.
Is there a better library I should be using?

I'm wondering whether it's just the wrong pins being used in the code. All sketches I see online use the following pins:

//                    addr,en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Set the LCD I2C address

But all of the 1602 LCDs I see online have the same pins as mine, as you can see in my photo below:

These pins seem to be standard:

To further confuse me, the pins on the LCD board start with 1 on the left, yet the default code's pins seem to start with 0! So I tried changing the code's pins to the numbers on the LCD board. The LCD no longer changes to 2 lines of squares and no longer blinks the backlight. I then tried subtracting 1 from each pin (to start from 0), same result. I then tried used the default pins minus 1, same result. Thus the default pins are somehow more correct?! What am I doing wrong?

Has anyone else gotten one of these I2C controllers to work for them, and if so, how?

Full code:

/* YourDuino.com Example Software Sketch
 16 character 2 line I2C Display
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
#include <LiquidCrystal_I2C.h>

/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 2 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);  // Used to type in characters
  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++) {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("HI!YourDuino.com");
  delay(8000);

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Use Serial Mon");
  lcd.setCursor(0,1);
  lcd.print("Type to display");

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

}/* --(end main loop )-- */


texts: printing data from gps on Serial1 and sensors into Serial

texts:
I am having some trouble using my gps (on Serial1) with my other sensors.
They both work great independently but when I use them in the same code, it's either the gps or the sensors that get to write on the Serial monitor.
For my gps I am using TinyGPS++, but I have a feeling that's not what's causing this problem here.
To simplify the code I'll be replacing what the sensors are supposed to write with this:
Serial.println("Hello there");

Here is the code
  if (Serial1.available() > 0) {
    gps.encode(Serial1.read());
    if (gps.location.isUpdated()){
      Serial.println("Satellite Count:");
      Serial.println(gps.satellites.value());
      Serial.println("Latitude:");
      Serial.println(gps.location.lat(), 6);
      Serial.println("Longitude:");
      Serial.println(gps.location.lng(), 6);
      Serial.println("Speed KT:");
      Serial.println(gps.speed.knots());
      Serial.println("Altitude Feet:");
      Serial.println(gps.altitude.feet());
      Serial.println("");
    }
  }
  Serial.println("Hello there");

I get this
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there
Hello there

If the line is removed, I get this
Satellite Count:
5
Latitude:
xx.xxxxx
Longitude:
-xx.xxxxxx
Speed KT:
0.19
Altitude Feet:
331.69

Thank you


texts: Can't figure out how to distribute the power

texts: so I'm making a project, kind of BB-8 droid replica, and I stumbled upon a problem. Since I am using two RC brushless motors, ESC's and batteries, I want to make my Uno board fed up from those batteries. Also, I want to use inductive charging set that would charge both batteries. Can anyone tell me or give some kind of scheme how should I distribute the power from batteries and what additional boards should I buy?


texts:
I'm trying to make my Arduino's LED blink for the first time, but when I try to upload the code I get the following error in the Serial Monitor:

  Error opening serial port '/dev/ttyACM0'.
  Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission

BTW, I have serial.debug_rate=9600, so I don't think that's the problem. Can anyone help me with this please?


texts: Connect GPS module (WeeBee) to Arduino Uno

texts:
This is my very first Arduino project. I want to learn about GPS navigation by exploring the NMEA protocol!

Therefore, I bought a WeeBee GPS module. After reading the datasheet, I have two questions:

The official Arduino website states

  Note: if you are using an Arduino Uno, keep in mind that you can't use the GPS module at the same time as your computer is connected on the USB port.

But I you go to the end of his tutorial, you will see he can transmit the GPS data to his computer. I don't understand why it would not be possible...
The GPS module datasheet (download link here) states that the maximum voltage is 5V. But it also states

  serial connections are 3.3V CMOS Logic Levels

and

  Suitable decoupling must be provided by external decoupling circuitry.

So, does it mean I need a logic level converter to prevent damage to the GPS module?


texts: CS5211AGP wireless RF transmitter (433MHZ) address decoding problem

texts:
I am using CS5211AGP wireless RF transmitter to transmit some data and another side receive this data through nRf905 as receiver. But now problem is how can I decode RF transmitter address (because transmitter and receiver address must be same).

if any one working on this module then please suggest me how can I decode address.

Please show below image where you can see the connection of address and zone.

Now please say about what address should I set at receiver side for communication.

Thanks in advance.

Regards,
rajneesh


texts: Splitting a Serial.readString into string array

texts:
I am working on a project where I need to split incoming data from serial (time to be exact, so aa:bb:cc) and need to split it into aa then bb and cc, ideally into  an array. I know I could use readStringUntil and make 3 separate variables, but I would prefer it is in arrays. Here is the code that supposed to do this. It works with predefined string (eg. 00:00:00), but with reading serial it says that the initializer fails to determine size of "input".
Thank you in advance for helpful suggestions.

Here is the code:

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  Serial.begin(9600);
  while(!Serial.available()){} //wait until Serial data received
  String vst = Serial.readString();
  char buf[vst.length()+1];
  vst.toCharArray(buf, vst.length());
  char input[] = vst;
  char delic[] = ":";
  char* sub = strtok(input, delic);
  while(sub != NULL){
   Serial.println(ptr);
    sub = strtok(NULL, delic);
  }

}


texts:
On Arduino Due, I set-up DMA transfers using direct control of memory mapped hardware registers.

There is a 16-bit BTSIZE field in CTRLA which indicates the number of (width sized) transfers.  If I specify larger than 8191, the value of btcount is trimmed to 13 bits after the DMA channel is enabled.  I set chunk size src/dest to 1.

The ATMEL data sheet for the sam3x (linked from the due page) does not mention this 'limitation' (section 22.7.16), or possibly I'm using it wrong.

What reference is canonical and correct for the DMAC (dma controller)?

As noted in the links in the comments, multi-buffer transfer can work around this, but since I don't know why it works or fails, it's hard to decide if that solution will work in all cases.


texts: How can I made my Arduino follow the time exactly?

texts:
I am making an Arduino clock. You can set time to it, and then it keeps on going. The problem is that it is always within a minute off. It is not a major issue, but one that I would like to fix. I use the millis function. The program checks if millis is evenly divisible by 60,000(1 minute). After I set the time, millis is NOT at 0, meaning that is ahead of what I set by a number of seconds. How can I fix this? Code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int hours=0;
int minutes=0;
const int modePin=6; //button
int prevModeState=HIGH; //prev state of button
unsigned long timer;
int modeState;//current state
int mode=0;//mode of alarm
int buttonCounter=0;
const int incrementPin=9;
const int switchPin=7;
int incrementState;
int switchState;
int prevIncrementState=HIGH;
int prevSwitchState=HIGH;
int switching=0;

void setup() {
lcd.begin(16, 2);
lcd.setCursor(6, 0);
lcd.print("Time:");
lcd.setCursor(6, 1);
lcd.print("00:00");
pinMode(modePin, INPUT_PULLUP);
pinMode(incrementPin, INPUT_PULLUP);
pinMode(switchPin, INPUT_PULLUP);
}

void loop() {
modeState=digitalRead(modePin);
if(prevModeState!=modeState){
      prevModeState=modeState;
   if(modeState==LOW){
    buttonCounter++;
  if(buttonCounter%2==0){
    mode=0;
    lcd.clear();
    lcd.setCursor(6, 0);
    lcd.print("Time:");
    writeTime();
}
  else{
    mode=1;
    switching=0;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Set Time:");
}

   }
  }
if(mode==0){
  timer=millis();
  if(timer%60000==0){
     minutes++;
    writeTime();
    }
}
else if(mode==1){
 incrementState=digitalRead(incrementPin);
  switchState=digitalRead(switchPin);
  if(prevSwitchState!=switchState){
    prevSwitchState=switchState;
    if(switchState==LOW){
    switching++;
    }
    if(switching==4){
      switching=0;
    }

    }

  if(prevIncrementState!=incrementState){
    prevIncrementState=incrementState;
    if(incrementState==LOW){
      if(switching==0){
        if(hours<14){
        hours+=10;
        }
        else if((hours>=14)&&(hours<20)){
        hours-=10;
        }
        else{
          hours-=20;
        }
        }

        else if(switching==1){
          if((hours==9)||(hours==19)){
            hours-=9;
          }
          else if(hours==23){
            hours-=3;
          }
          else{
          hours++;
          }
        }

        else if(switching==2){
          if(minutes<50){
             minutes+=10;
          }
          else{
            minutes-=50;
          }

        }
        else if(switching==3){
          if(minutes%10==9){
            minutes-=9;
          }
          else{
          minutes++;
          }
        }

    }

  }

  writeTime();
}
}

void writeTime(){
  lcd.setCursor(6, 1);
   if(minutes>=60){
        minutes=0;
        hours++;
        }
     if(hours>=24){
        hours=0;
     }
if(minutes<10){

      if(hours<10){
        lcd.print(String("0")+hours+":"+"0"+minutes);
      }
      else{
        lcd.print(hours+String(":")+"0"+minutes);
      }
    }
    else{
      if(hours<10){
         lcd.print(String("0")+hours+":"+minutes);
      }
      else{
         lcd.print(hours+String(":")+minutes);//possibly split if problems arise
      }

    }
}


texts:
I have a NRF24L01 radio module. The description indicates that it can work in the ISM frequency range of 2.400 ... 2.525 GHz. The channel step is 1 MHz, and there are 125 channels in total.

The channel number can be set using
radio.setChannel (0x125);
The maximum number is supposedly 125. However, I examined the signal spectrum in Sdrsharp using a radio tuner and it turned out that the frequency at the maximum channel is very low.

I started increasing the number and got to 180 radio.setChannel (125); the frequency was 2525 MHz as stated. It turns out that the number of channels of the radio module is not 125, but 180? I determined the 180 number experimentally. The literature says that it has 125 channels 1 MHz wide.
The most interesting thing is that the Arduino IDE does not give errors when entering a large number of channels. Tell me how you can speed up the process of switching channels in order to understand how they switch. To manually reflash it for a long time when changing each channel.
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9, 10); // use 9 и 10 pin arduino uno
byte address[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"};
byte counter = 1;

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

  radio.begin(); //activate module
  radio.setAutoAck(0); //confirmation mode, 1 on 0 off
  radio.setRetries(0, 15); //(time between attempts to reach out, number of attempts)

  radio.setPayloadSize(32); //packet size, in bytes

  radio.openWritingPipe(address[0]); //we are pipe 0, we open a data channel
  radio.setChannel(125); //select a channel (in which there is no noise!) 0 ... 125

  radio.setPALevel (RF24_PA_MIN); //transmitter power level. To choose RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
  radio.setDataRate (RF24_2MBPS); //exchange rate. To choose RF24_2MBPS, RF24_1MBPS, RF24_250KBPS
  radio.powerUp(); //get started
  radio.stopListening(); //do not listen to radio broadcasts, we are a transmitter
}

void loop(void) {
  while (1)
  {
    radio.write(&counter, 1);
    //Serial.println(counter);
  }
}

Is it possible to toggle the channel number radio.setChannel (0x180) sequentially in a void loop?
thanks!
I tried to do this:
void loop (void) {
     for (int n = 0; n <126; n ++)
     {
       radio.setChannel (n); // select a channel (in which there is no noise!) 0 ... 125
       radio.write (& counter, 1);
       delay (1000);
     }
}

However, radio.write (& counter, 1) should work separately from any loops to avoid delays. Otherwise, it doesn't work correctly.


texts:
When I upload my sketch I get this error message:

  avrdude: ser_open(): can't open device "\.\com3": the system cannot
  find the file specified

I tried reinstalling the IDE and the drivers. I tried looking into the preferences txt file and the COM was alright.

Also, I uploaded it successfully from another computer.

What is wrong about my PC trying to upload Arduino? And the most curious thing of all is that yesterday it was fine and it was working.


texts: When a pushbutton and sensor are in a certain state, do something for a certain period of time (15 seconds)

texts:
I have a sketch that contains code for an analog input (FSR sensor), a pushbutton, and 6 blinking LEDs.

Currently, the sketch is written to allow the LEDs to blink only when the button is pressed and there is sensor input.

Can someone help me write code to make the LEDs blink for a certain period of time once there is input from the analog sensor and while the button is pressed?  I am trying to make the LED blink for 15 seconds and then turnoff.

thank you!

/*
 6 Flashing LED Lights With A Pushbutton and FSR Sensor
*/

const int buttonPin = 8;
const int LedPin1 = 7;
const int LedPin2 = 6;
const int LedPin3 = 5;
const int LedPin4 = 4;
const int LedPin5 = 3;
const int LedPin6 = 2;

int buttonState = 0;
int SensorPin = A0;
int SensorPinReading;

void setup() {
  Serial.begin(9600);
  pinMode(LedPin1, OUTPUT);
  pinMode(LedPin2, OUTPUT);
  pinMode(LedPin3, OUTPUT);
  pinMode(LedPin4, OUTPUT);
  pinMode(LedPin5, OUTPUT);
  pinMode(LedPin6, OUTPUT);
  pinMode(buttonPin,INPUT);
  pinMode(SensorPin, INPUT);
}

void loop() {
  SensorPinReading = analogRead(SensorPin);
  Serial.print("Analog reading = ");
  Serial.print(SensorPinReading);

if (SensorPinReading < 10) {
  Serial.println(" - No Pressure");
} else if (SensorPinReading < 200) {
  Serial.println(" - Light Touch");
} else if (SensorPinReading < 500) {
  Serial.println(" - Light Squeeze");
} else if (SensorPinReading < 800) {
  Serial.println(" - Medium Squeeze");
} else {
  Serial.println(" - Big Squeeze");
}

  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH && SensorPinReading > 10)  {
  digitalWrite(LedPin1, HIGH);
  digitalWrite(LedPin2, HIGH);
  digitalWrite(LedPin3, HIGH);
  digitalWrite(LedPin4, HIGH);
  digitalWrite(LedPin5, HIGH);
  digitalWrite(LedPin6, HIGH);
  delay(600);
  digitalWrite(LedPin1, LOW);
  digitalWrite(LedPin2, LOW);
  digitalWrite(LedPin3, LOW);
  digitalWrite(LedPin4, LOW);
  digitalWrite(LedPin5, LOW);
  digitalWrite(LedPin6, LOW);
  delay(200);
  }
  else {
    digitalWrite(LedPin1, LOW);
    digitalWrite(LedPin2, LOW);
    digitalWrite(LedPin3, LOW);
    digitalWrite(LedPin4, LOW);
    digitalWrite(LedPin5, LOW);
    digitalWrite(LedPin6, LOW);
  }

}


texts: Using special Arduino "boolean" Data Type instead of standard "bool" data type

texts:
There is a special, non-standard Arduino data type called "boolean".
How does it compare with the standard C++ data type "bool", and what are the reasons to use one or the other?
If they are identical in usage, why do both exist, and which one is preferred in Arduino code?


texts: Can someone interpret the code in the Title line for me?  Specifically the function of the "%" sign?  It is a line having to do with a 100 element circular buffer.


texts: Can a cheap RF module be used for two way communication

texts: Can a cheap RF(transmitter and receiver) module be used for two way communication, not at the same time of course but for example arduino A sends string to be printed on lcd the arduino B receives it and prints it on lcd, then after some time arduino B sends a temperature data back to arduino A, then arduino prints the temperature data on the serial monitor. All of this while arduino A is connected to a transmitter and arduino B is connected a receiver.


texts: What is the advantage of using a motor shield if I want to use a stepper motor?

texts:
I know that it is possible to connect a stepper motor directly to an arduino (as displayed here). I know that another option is to use a motor shield (for example the Arduino Motor Shield or the Adafruit Motor Shield).

What I would like to know: What are the actual advantages of using a motor shield?

Is it just a question of convenience? Or does a motor shield do something that could not easily performed without a shield? Does it allow me to connect more motors than I could connect directly without a shield (power supply comes to mind)?


texts:
Can I compile c/c++ code on the linux part of the Arduino Yun?

How complete is the linux part of the Arduino Yun?
Can I scp some c/c++ code onto the Atheros AR9331 chip compile it?

Or must I first crosscompile all software and then put them onto the Atheros?


texts:
Some ideas please?
I'm stuck and also don't judge me for how i wrote the code. I'm new into coding and still learn. So, the idea is that i want to display data and clock on lcd but when the lamp is on i want a message to be printed for 5 sec then the clock and date will be printed again... and so on.
Data from serial is comming from an esp which trigger some event wireless.Arduino receive feedback that the job has been done and then display a message on lcd. More exactly.. Using mqtt - from browser i push a button to turn on a lamp. Once the lamp is on, a message arrives at esp from the mqtt broker that lamp is on now. esp then send data to arduino using serial. and arduino should display the text " Lamp on "

    #include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>

LiquidCrystal_I2C lcd(0x3F,20,4);
DS3231 rtc (SDA, SCL);

int verificare_stare_releu = A13;
char a;

void setup(){
  Serial.begin(115200);
  rtc.begin();
  lcd.init();
  lcd.backlight();
  pinMode(A13,INPUT);
}

void loop(){

  int b = analogRead(verificare_stare_releu);
    if(!Serial.available()){
    display_clock();
    }
    if(!Serial.available()){
    if(b >= 900){
      lcd.print("Lamp ON ");
    }

    if( b < 900 ){
      lcd.print("Lamp OFF");
    }

    }

  if(Serial.available()>0){
    a = Serial.read();
    if(a == 102){
    lcd.setCursor(0,0);
    lcd.print("Lamp ON ");
    }
  if(a == 110){
    lcd.setCursor(0,0);
    lcd.print("Lamp OFF");
  }
  }

}

  //a = digitalRead(verificare_stare_releu);

void display_clock (){
   lcd.setCursor(0,0);
  lcd.print("Ora: "+(String)rtc.getTimeStr());
  lcd.setCursor(0,1);
  lcd.print((String)rtc.getDOWStr()+(String) rtc.getDateStr());
}


texts: Arduino ds3231to TM1638 problems,alarm clock project

texts:
Good morning,
I am coding an alarm clock on arduino by using a DS3231 and a TM1638.
The code works and the time updates in the serial monitor,although the time doesn't update on the tm1638.
I'll attach the code here:

#include <DS3231.h>
#include <TM1638.h>
#include <Streaming.h>
#include <SPI.h>
#include <Wire.h>
#include <InvertedTM1638.h>
#include <TM1638.h>
#include <TM1638QYF.h>
#include <TM1640.h>
#include <TM16XX.h>
#include <TM16XXFonts.h>
byte buttons;
#define TM1638_STB D5
#define TM1638_CLK D6
#define TM1638_DIO D7

TM1638 module(TM1638_DIO, TM1638_CLK, TM1638_STB);
// DS3231 uses I2C - device ID 0x68
// on Wemos mini pins SDA -> D1 and SCL -> D2
DS3231 rtc;
int hours;
int minutes;
int seconds;
bool h12;
bool PM;
int data;
RifTime t;
char buffer[24];

void setup()
{
  // set up the 7-segment display
  module.clearDisplay();
  module.setupDisplay(true, 2);
  Wire.begin();
  Serial.begin(115200);

  Serial.println(F("\nDS3231 Hi Precision Real Time Clock"));

  // Fill these variables with the date and time.
  int seconds, minutes, hours, dayofweek, dayofmonth, month, year;

  // Example for april 15, 2013, 10:08, monday is 2nd day of Week.
  // Set your own time and date in these variables.
  // dayofweek = 4; // Day of week, any day can be first, counts 1...7
  hours = 14;
  minutes = 30;
  seconds = 0;
  year = 2019;
  month = 8; // month 1...12
  dayofmonth = 28; // Day of month, 1...31

  data=( hours * 10000 + minutes * 100 + seconds * 1 );

  rtc.setClock(year,month,dayofmonth,hours,minutes,seconds);
}

void loop()
{
  rtc.getTime(t);
  Serial << rtc.toString(buffer) << endl;

  delay(1000); // do nothing

  module.setDisplayToDecNumber(data,4,false);

  if(seconds==60)
  {
    seconds=00;
    minutes++;
  }
  if(minutes==60)
  {
    minutes=0;
    hours++;
  }

  if(hours==24)
  {
    data=00000000;
  }

  if((data)==143000)
  {
    module.setLEDs(0x0001);
  }
  else
  {
    module.setLEDs(0x0000);
  }

}


texts: Arduino Pro Mini (3.3V version) input voltage range / tolerance

texts:
I have a few Arduino Pro Mini clones (cheap Chinese stuff) and would like to power them with 12V power supply (same as fan voltage). According to the Arduino Pro Mini spec the RAW pin can take 3.35-12V (3.3V model). In practice this means a 12V PSU cannot be used as they are almost always over 12V with low load. I read that the voltage regulator in this board is capable up to 16V input. I tried plugging in a cheap 12V power adapter that read 15.1V with no load but a component on the arduino clone board actually exploded instantly. The board seems to work still when powered from usb programmer. Component that burned out is just above VCC, RST and GND pins.

Why did this happen? What did I just damage and most importantly what is a safe voltage level to use? I already have a few 12V switching power supplies it would be a shame if I could not use them.

Solution:

In the end it seems to have been a faulty arduino clone, faulty or poor quality power adapter or the fact that I powered the power supply before plugging it to the board's RAW input pin. The cheap 12V switching power supplies work just fine even though my multimeter registers a voltage spike as high as 30V during power up.


texts: Opening .h and .cpp files from folders other than the sketch folder

texts:
My team has a C++ program from another microcontroller that we are moving to Arduino, which is currently divided into two main folders, the sketch and libraries. We want to be able to open some of the library files in the Arduino IDE along with the sketch, something it will do automatically if they are in the same folder, but not allow otherwise. The files in question are referenced from the other libraries though, which means moving just a few of them results in compilation errors. We don't want to move them all to the sketch folder, since that defeats the purpose, but a few of my teammates are vehemently opposed to having to edit them using another IDE.

So is there a way to have these files open in the Arduino IDE with the sketch? Or do I have to tell my teammates to suck it up and use a second editor if they want to make changes?

Alternatively, a way to get the libraries able to reference files in the sketch folder would also work.


texts:
I am trying the RFID RC522 reader kit with an Arduino UNO to built a controlled access system for a door.

Using the code below, I am able to read the UID of my card and light up an LED when the reader detects the card or the badge, however it will light up whatever card is presented to it even if the UID of this card is not entered as a String in my program.

My question is how can I enter hundreds of cards (depending on memory) that will unlock the door and have all the others set as unknown if not in my program.

Thank you very much for your help

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_PIN          10         //(or SDA) Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance
// ===========================================================================
String read_rfid;
String ok_rfid_1 = "C5 12 E3 52"; // for the badge
String ok_rfid_2 = "9A 48 3A D5"; // for the card
// ==========================================================================
int led = 3;
// ===========================================================================
void setup() {
 Serial.begin(9600); // Initialize serial communications with the PC
 //while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
 SPI.begin(); // Init SPI bus
 mfrc522.PCD_Init(); // Init MFRC522
 mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
 Serial.println(F("Scan PICC to see UID, SAK, type, and data bleds..."));
  pinMode(led, OUTPUT);
}
// ===========================================================================
 void dump_byte_array(byte *buffer, byte bufferSize) {
  read_rfid="";
  for (byte i = 0; i < bufferSize; i++) {
    read_rfid = read_rfid + String(buffer[i], HEX);
  }
 }
// ==========================================================================
void unlock() {
  digitalWrite(led, HIGH);
  delay(2000);
  digitalWrite(led, LOW);
}
// ======================================================================
void loop() {
 // Look for new cards
 if (! mfrc522.PICC_IsNewCardPresent())
 return;
 // Select one of the cards
 if (! mfrc522.PICC_ReadCardSerial())
 return;

  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  Serial.println(read_rfid);

  if (read_rfid == ok_rfid_1 || ok_rfid_2) {
    Serial.println("Open");
    unlock(); // turns LED on
  }

  else {
    Serial.println("Stay Closed");
  }
}


texts: How to prevent the garbage data when the serial port is initialised?

texts:
I use Arduino Uno. I get garbage in Serial Monitor or HyperTerminal right after I connect to the port. Here is an example code:

void setup() {
  // initialize serial:
  Serial.begin(57600);

}

void loop() {

    Serial.println("Test");
}

An example screenshot of the output. When port is re-connected the first received data is not Test:

So my problem is when the port is initialised the first data received is garbage. Is there a way to prevent this happening? Is that something to do with bootloader baud rate? I tried other baud rates and get same issue and I really want to use 57600 or 115200 baud rate.


texts: Digital Comparator with ATTiny85 doesn't behave as expected

texts:
Here is my schematic:

I've removed the resistors from the LEDs to make it smaller.
The 1 and 2 on the left are outputs from the arduino (which supplies the VCC and ground).

These 1 and 2 are HIGH or LOW and I want the leds to turn on according to this table:

┌───────┬────────────────────┐
│ INPUT │ OUTPUT             │
├───┬───┼──────┬──────┬──────┤
│ A │ B │ Led1 │ Led2 │ Led3 │
├───┼───┼──────┼──────┼──────┤
│ 0 │ 0 │ 1    │ 0    │ 0    │
│ 1 │ 0 │ 0    │ 1    │ 0    │
│ 0 │ 1 │ 0    │ 0    │ 1    │
│ 1 │ 1 │ 1    │ 0    │ 0    │
└───┴───┴──────┴──────┴──────┘

And this is the code I am using with the ATTiny85

const int pinA = PB3;
const int pinB = PB4;
const int pinOut1 = PB2;
const int pinOut2 = PB1;
const int pinOut3 = PB0;

void setup() {
    pinMode(pinA, INPUT);
    pinMode(pinB, INPUT);
    pinMode(pinOut1, OUTPUT);
    pinMode(pinOut2, OUTPUT);
    pinMode(pinOut3, OUTPUT);

    int a = digitalRead(pinA);
    int b = digitalRead(pinB);

    if (a == b) {
        digitalWrite(pinOut3, HIGH);
    }
    else if (a == HIGH) {
        digitalWrite(pinOut1, HIGH);
    }
    else {
        digitalWrite(pinOut2, HIGH);
    }
}

With this set up, I get this output:

┌───────┬────────────────────┐
│ INPUT │ OUTPUT             │
├───┬───┼──────┬──────┬──────┤
│ A │ B │ Led1 │ Led2 │ Led3 │
├───┼───┼──────┼──────┼──────┤
│ 0 │ 0 │ 1    │ 0    │ 0    │
│ 1 │ 0 │ 0    │ 1    │ 0    │
│ 0 │ 1 │ 1    │ 0    │ 0    │ <- See the difference
│ 1 │ 1 │ 1    │ 0    │ 0    │
└───┴───┴──────┴──────┴──────┘

I think it has something to do with the fact that the ATTiny gets powered on if you supply 5v to one of the input pins too and not to VCC.

And yes, I keep restarting the board (by pulling out the VCC pin and seeing the led turn off).

I've also tried connecting A and B to VCC and ground both in all possible positions. Here I noticed that connecting A (or B) to 5v (of the arduino) while VCC is not connected, the board will turn on.

I hope this is enough info.


texts:
I would like to control my stepper via serial monitor and unfortunatley the code below did not work. Serial monitor works (Serial.println()), but it does not execute the stepperOne() part. Any ideas why would be awesome.
Thank you.

#include <AccelStepper.h>

const int stepPin = 5;
const int dirPin = 4;
const int enPin = 12;

String msg;

unsigned int DEST = 800;
unsigned int SPD = 1600;
unsigned int ACCEL = 1600;
const int TEST = 3;

void setup() {

  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode(enPin,OUTPUT);
  digitalWrite(enPin,HIGH);
  Serial.begin(9600);  // Start Serial

}

void loop() {

if (Serial.available()>0) {
    msg = "";
    while (Serial.available()) {
      delay(10);
      char tmp = Serial.read();
      // msg += tmp;
     if( tmp!='\r' && tmp!='\n' ) msg+=tmp; // Does not work either
    }
    msg.replace(" ","");
    if (msg=="G") {
      stepperOne();
      Serial.println("Stepper turned.");
    }
    Serial.flush();
  }
}

void stepperOne() {

  AccelStepper stepper(1,stepPin,dirPin);
  digitalWrite(enPin,LOW);
  stepper.setMaxSpeed(SPD);
  stepper.setAcceleration(ACCEL);
  stepper.move(DEST);
  if (DEST > 0) {
    while ( stepper.distanceToGo() > 0 ) {
      stepper.run();
      }
  digitalWrite(enPin,HIGH);
  }
 }


texts: How does Arduino distinguish between SPI programming data and regular data?

texts: The Arduino can be programmed using SPI without a boot loader. Without a boot loader, the Arduino starts running its sketch right away. So, how does the Arduino know that it is being programmed via SPI vs regular SPI traffic already present on the SPI bus? Was is the pin-level, electrical signal that let's the Arduino know the difference?


texts:
So, I recently bought an Arduino Mini (5V, 16MHz), and a USB to Serial Converter.
Provided are the links to both the products:
Arduino Mini,
USB to Serial Converter

Now, I tried programming the mini by connecting the pins in this order:
Rx -> tx, tx-> rx, VCC -> 5V, GND -> GND, DTR -> DTR

The computer detected the USB to Serial converter after I installed the drivers manually. However, the Arduino IDE failed to program the Arduino Mini every single time, even after I swapped the TX, RX pins.

I tried to program the Arduino Mini using an Arduino Uno (I removed the onboard Atmel Atmega microcontroller on the Uno before programming). I connected the pins in this order: TX->TX, RX->RX, 5V-> VCC, GND-> GND, RST -> DTR. From the IDE, I chose Arduino Pro Mini (5V, 16Mhz).

The Mini was programmed successfully this time.

My question: What was wrong with the USB to Serial converter? Why couldn't it program the Arduino Mini with the USB to Serial Converter?


texts: Is it possible to test a SPI connection by wiring the MISO directly to the MOSI pin?  I'm working on a low-level SPI implementation, and I want to check that the library is basically working.  It would be nice to be able to test the connection itself without additional hardware.


texts: Arduino with Ultrasonic sensor integrated but vibration motor not working according to the code

texts:
Here's my code after editing the measurement had error. Now the ultrasonic measurement is working but the vibration motor is not vibrating.

#define trigPin1 8
#define echoPin1 7
#define motorPin1 13

long duration, distance, UltraSensor;

void setup()
{
  Serial.begin(9600); // to use the serial monitor.
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  //pinMode(motorPin1, OUTPUT);

}

void SonarSensor(int trigPin, int echoPin)
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;
  delay(100);
}

void loop()
{
  SonarSensor(trigPin1, echoPin1);
  UltraSensor = distance;
  Serial.print(distance); // print out the distance on Serial Monitor
  Serial.println("cm");
//
  if (distance <= 60 && distance >= 45) // Checking the distance, you can change the value
  {
    digitalWrite(motorPin1, HIGH); // motor on
    delay(200);
    digitalWrite(motorPin1, LOW); // motor off
    delay(200);
  }
  else if(distance < 45 && distance >=30)
  {
    digitalWrite(motorPin1, HIGH); // when greater than 100cm
    delay(100);
    digitalWrite(motorPin1, LOW);
    delay(100);
  }
  else if(distance < 30)
  {
   digitalWrite(motorPin1, HIGH);
   delay(50);
   digitalWrite(motorPin1, LOW);
   delay(50);
  }
  else
  {
    digitalWrite(motorPin1, LOW);
  }
}


texts: What are some fun things you can do using the ICSP header?

texts:
I bought 10 Arduino Nanos for a project, each with all of their headers soldered in place.  Each was going to go into a tiny space, so I found myself needing do desolder the ICSP headers.

This led to a bit of a moral conundrum.  What would I lose by removing these useful looking headers.  They cover quite a lot of space on the nano, so they must be important right?  Am I going to regret removing these things when I finally realize how useful they are (I thought to myself.)

In the end, I did remove the ICSP headers, but the event got my thoughts going.  What is this header all about?  Why is it there?  What can I do with it?  I began to search for things that I could do with the ICSP header, but engaging results were not forthcoming ( except for this project:  https://www.arduino.cc/en/Hacking/ParallelProgrammer )

Anyway, I was more interesting in things that flash, move, jump, sing, and such, so are there any interesting things that can be done with the ICSP header?


texts: Function is executing when I try to store it in an array

texts:
I am trying to store a set of functions with different parameter in an array. When the code enters the function songlearn with tune==1 I want the functions with set parameters to be stored in the array without executing. What am I doing wrong? Here's my code:

const int x=100;
int (*SongSeq[x])();
int note[x];
int playNote(int midi, int row, int col, int len, bool short_led = false);
void songlearn(int tune);
int tune;

void songlearn (int tune){
  if (tune==1){
    state=1;
   lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("Learning Song :");// Print a message to the LCD.
  lcd.setCursor(1, 1);
  lcd.print(menuP1);
// if (songpage==1){
// if (BackState==HIGH){//leaving song
//     posP=0;
//     Page=2;
//    Play(posP);
//    }
// }
  //Plays Mary Had a Little Lamb on a loop at 145 BPM
//Bar 1
SongSeq[0]= playNote(0x40, 3, 1, 414); //Quarter note: E
note[0]=0x40;
SongSeq[1]=playNote(0x3e, 2, 4, 414); //Quarter note: D
note[1]=0x3e;
SongSeq[2]=playNote(0x3c, 2, 2, 414); //Quarter note: C
note[2]=0x3c;
SongSeq[3]=playNote(0x3e, 2, 4, 414); //Quarter note: D
note[3]=0x3e;
//Bar 2
SongSeq[4]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[4]=0x40;
SongSeq[5]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[5]=0x40;
SongSeq[6]=playNote(0x40, 3, 1, 828,1); //Half note: E
note[6]=0x40;
//Bar 3
SongSeq[7]=playNote(0x3e, 2, 4, 414,1); //Quarter note: D
note[7]=0x3e;
SongSeq[8]=playNote(0x3e, 2, 4, 414,1); //Quarter note: D
note[8]=0x3e;
SongSeq[9]=playNote(0x3e, 2, 4, 828,1); //Half note: D
note[9]=0x3e;
//Bar 4
SongSeq[10]=playNote(0x40, 3, 1, 414); //Quarter note: E
note[10]=0x40;
SongSeq[11]=playNote(0x43, 3, 4, 414,1); //Quarter note: G
note[11]=0x43;
SongSeq[12]=playNote(0x43, 3, 4, 828,1); //Half note: G
note[12]=0x43;
//Bar 5
SongSeq[13]=playNote(0x40, 3, 1, 414); //Quarter note: E
note[13]=0x40;
SongSeq[14]=playNote(0x3e, 2, 4, 414); //Quarter note: D
note[14]=0x3e;
SongSeq[15]=playNote(0x3c, 2, 2, 414); //Quarter note: C
note[15]=0x3c;
SongSeq[16]=playNote(0x3e, 2, 4, 414); //Quarter note: D
note[16]=0x3e;
//Bar 6
SongSeq[17]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[17]=0x40;
SongSeq[18]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[18]=0x40;
SongSeq[19]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[19]=0x40;
SongSeq[20]=playNote(0x40, 3, 1, 414,1); //Quarter note: E
note[20]=0x40;
//Bar 7
SongSeq[21]=playNote(0x3e, 2, 4, 414,1); //Quarter note: D
note[21]=0x3e;
SongSeq[22]=playNote(0x3e, 2, 4, 414,1); //Quarter note: D
note[22]=0x3e;
SongSeq[23]=playNote(0x40, 3, 1, 414); //Quarter note: E
note[23]=0x40;
SongSeq[24]=playNote(0x3e, 2, 4, 414); //Quarter note: D
note[24]=0x3e;
//Bar 8
SongSeq[25]=playNote(0x3c, 2, 2, 1656); //Whole note: C
note[25]=0x3c;

//End song
  }
 }
 int playNote(int midi, int row, int col, int len, bool short_led = false)
{
    int len1, len2;
    if (short_led) {
        len1 = len * 3 / 4;
        len2 = len * 1 / 4;
    } else {
        len1 = len;
        len2 = 0;
    }
    noteOn(0x90, midi, 100);
    digitalWrite(LedR[row], HIGH);
    digitalWrite(LedC[col], LOW);
    delay(len1);
    digitalWrite(LedR[row], LOW);
    digitalWrite(LedC[col], HIGH);
    delay(len2);
    noteOff(0x90, midi, 0);
}


texts: SoftwareSerial returns garbage when powered externally

texts: I'm currently working on a project with the ESP8266 and Arduino Nano, and when I power the device via USB they talk to each other via SoftwareSerial just fine. I use the Arduino IDE Serial Monitor to monitor this communication. But when I power it with a 15 V wall wart to Vin it returns mostly garbage, again I can tell this with the Arduino IDE Serial Monitor (I know I shouldn't connect two power supplies at a time). When powered over 5 V USB everything is great. Why would I have a problem only when connected to an external power supply?


texts: How to remove or only show part of the data received?

texts:
I'm using the ble_client.ino example and I can't figure out how to only show some of the notifyCallback data. I'm getting three different types of data from one service UUID.

static void notifyCallback(
  BLERemoteCharacteristic* pBLERemoteCharacteristic,
  uint8_t* pData,
  size_t length,
  bool isNotify) {

  static unsigned long lastPrinted;
  const unsigned long printInterval = 100;
  if(millis() - lastPrinted >= printInterval) {
    lastPrinted = millis();
    Serial.println();
    }
    Serial.printf(" Data:%X", pData[16]);

}

This is what get in the serial monitor

  Data:A9 Data:B9 Data:F5
  Data:A9 Data:B9 Data:F5
  Data:A9 Data:B9 Data:F5
  Data:A9 Data:B9 Data:F5

I just want the

  Data:B9
  Data:B9
  Data:B9
  Data:B9
  Data:B9

to be shown. How to?


texts: NodeMCU V2 ESP8266 - Use 5VIN as power for heater of a MQ-9 Sensor

texts:
Right now I'm trying to understand how I could (easily) power the heater of my MQ-9 carbon monoxid and gas sensor.

Here is the datasheet: http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf

It needs 5V for some gases, so I thought I could maybe power the heater via the 5VIN pin (while plugged via usb), since the other output pins have a max. voltage of only 3.3 V?

And to control the power, I could then add a relay switch, which would cut the circuit between heater and VIN (if I only want to measure the gases)?

Or am I completely wrong?

P.S: And no - I don't want to add a 5V power supply additional to the normal USB plugging on VIN :)