texts: Battery charger board with status interface

texts:
There are of course a lot of different battery charging boards, which can be used with the Arduino, most being TP4056 based. There are also a few battery charged boards with an on-board display showing the charge status and there are of course also a lot of programmable battery charger controllers (ICs) with status and control interfaces.

But is there any board available, not just the 'raw' IC, using a charging controller with a status interface, which allows access to the status interface from pins on the board? I can't seem to find anything.

For a battery powered Arduino project I am planning, it could at least be very convenient if I could query the battery charging status from software.


texts: How does the Arduino send more than 6 bytes via I2C

texts:
I have been working with the wire library (I2C) to send data from one Arduino to another.  I read that the Arduino can only send 6 bytes per cycle, but I have been able to transfer much larger strings.  This code works without error:

  Wire.beginTransmission(4); // transmit to device #4

  for(int i = 0; i < 20; i ++){
    char rand = random(65, 100);
    Wire.write(rand);
  }

  Wire.endTransmission();    // stop transmitting

How is this possible?  It seams that 32 characters can be sent without trouble.

I read this here: http://arduino.cc/en/Tutorial/MasterReader

  Arduino 1, the Master, is programmed to request, and then read, 6 bytes of data sent from the uniquely addressed Slave Arduino.

Now that I look at this again (after reading the responses) I think that the limit was set in the code sample.


texts:
I am doing a prototype using ATmega8L-8PU to detect temperature and control a relay and buzzer, but the schematic seems not work, therefore I do a simple test to verify the AVR's pins are working perfectly or not.

I using the example sketch - Blink to control Digital-13 to let LED blink. It is work.

Then I do a second sketch to test all pins (Due to leak of LED, I test first 8 pins.) It failed. Second Sketch is quite simple and strict forward: blink D0-D7 LED one by one.

char i, j, pcnt = 1;

char startDigitalPin = 0;
char maxDigitalPin = 7;

void setup()
{
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    // put your setup code here, to run once:
    for(i=startDigitalPin; i<=maxDigitalPin; i++) {
        pinMode(i, OUTPUT);
        digitalWrite(i, LOW);
    }
}

void loop()
{
    // put your main code here, to run repeatedly:
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    for(i=startDigitalPin; i<=maxDigitalPin; i++) {
        for(j=i; j<=maxDigitalPin; j++) {
            digitalWrite(j, HIGH);
            delay(100 * pcnt);
            digitalWrite(j, LOW);
            delay(100 * pcnt);
        }

        digitalWrite(i, HIGH);
        delay(200 * pcnt);
    }

    pcnt++;

    if(pcnt > 10) {
        pcnt = 1;
        delay(8000);
    }
}

Question:

Why I using Blink example sketch, D13 is work fine, the LED light on with normal bright.
Why second sketch, the D13 LED super dark, but it light on.

Check it out these 2 videos in youtube.
https://www.youtube.com/watch?v=sknNPxqg5zc
https://www.youtube.com/watch?v=KWsdP3egsvY

I have burn a bootloader to ATmega8L-8PU (Summary Datasheet) using Arduino IDE 1.6.5 with MiniCore, Config: ATmega8 External 8MHz.

Parts in my bearboard using:

ATmega8L-8PU
2 x 22pf
1 x 100nf
1 x 8MHx crystal
9 x LED with 330Ohm resistor


texts: How can I have 2 differents frequency on the 2 DAC outputs on an Arduino Due?

texts:
I would like to blink, using specific waveforms, 2 LED controlled by the 2 DAC output of the Arduino Due.

I wrote this :

    #include "Waveforms.h"

    int i = 0;
    int sample;

    void setup()
{
      analogWriteResolution(12);
}

    void test(float fq, int wave1, int wave2)
{

      sample = ((1/fq)*1000000)/120;

      analogWrite(DAC0, waveformsTable[wave1][i]);
      analogWrite(DAC1, waveformsTable[wave2][i]);

      i++;

      if(i == maxSamplesNum)
          {
            i = 0;
          }

      delayMicroseconds(sample);

}

    void loop() {
    // 10 Hz, 0 is a sine wave on DAC0, 3 is a square wave on DAC1

      test(10, 0, 3);

I would like to be able to change the frequency of each output (1Hz - 100 Hz) using differents waveforms. Changing waveforms is ok and it works, but is it possible to also change the frequency so to have two differents output frequency on each DAC output ?

The goal is to have, for example, simultaneously :

1 Hz, sine wave on DAC0.
10Hz, square wave on DAC1.

Thanks a lot.


texts: Communication between ESP01 Arduino NANO and using External Interrupt in Arduino NANO for other than communication program same time

texts: I have done communication between ESP01 and Arduino NANO (ATMEGA328 based). ESP pins used are GPIO-0 and GPIO2. In NANO, used D2 and D3. This program working Ok. Now I want to add external interrupt in my Arduino NANO program while continuing communication with ESP01. But I cannot use D2 and D3 because it was used by communication program. Now Arduino NANO's limit is it has only two interrupt pins which are D2 and D3. So if I use this for external interrupt program, I lose communication with ESP01. Can anybody help me to use my both task at the same time: Task1- External interrupt in Arduino Nano, Task2- Communication with ESP01. Your reply will help me to solve this issue. Thanks in advance.


texts:
i just bought this lcd. I connected all pins as discripted on this datasheet (Page 8). However i noticed that there is no pin to control the contrast. I also didin't get the display to run yet.

Might that be a problem?

edit: here is the code...

#define RST 3
#define CE 2
#define DC 4
#define DIN 6
#define CLK 5

void LcdWriteCmd(byte cmd)
{
digitalWrite(DC, HIGH); //DC pin is low for commands
digitalWrite(CE, HIGH);
shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data
digitalWrite(CE, LOW);
}

void setup()
{
pinMode(RST, OUTPUT);
pinMode(CE, OUTPUT);
pinMode(DC, OUTPUT);
pinMode(DIN, OUTPUT);
pinMode(CLK, OUTPUT);
digitalWrite(RST, LOW);
digitalWrite(RST, HIGH);
LcdWriteCmd(0xAE); // LCD set display enabled
LcdWriteCmd(0x21); // LCD set power COntrol
LcdWriteCmd(0x14); // LCD bias mode 1:40
LcdWriteCmd(0xA2); // LCD basic commands
// LcdWriteCmd(0xA9); // LCD all segments on
}

void loop()
{
}


texts:
I have built the following to dim the brightness of the LED backlight of a display:

I am using a BS170 MOSFET (the diode is no extra part but included in the MOSFET, according to the datasheet). The BL pin is the supply of the LED backlight. (I have left out all other pins.)

Unfortunately, it does not work. Even if I set the PWM pin to 255, the backlight does not light (actually it's completely off). If I short BL and Vcc, it lights up as it should.

Also, the voltage readings confuse me: I measure 3.3 V on the gate and drain against ground, 1.5 V on source against ground (= the voltage across the backlight) but only 1 V if I measure drain against source.

So my questions are:

Shouldn't this add up to 3.3 V?
More importantly, why do I get only 1.5 V at BL?
Most importantly, what do I need to change? Different MOSFET? No MOSFET?

The primary aim of controlling the backlight is to be able to switch in off completely, thus reducing power consumption. (Being able to dim it is only a plus.)

EDIT

I should have added details about the display. It's one of those:

I haven't found a datasheet / specs for exactly this model. Most datasheets I found refer to a different version that is not 5 V compatible. A very similar model is described here.

Concerning my question I haven't found information on how much current the backlight would draw. Therefore I didn't want to drive it directly from the PWM pin. (Actually I could just measure it...)


texts:
I am trying to write code so that 18 LEDs will light up randomly except 2 of them light up together. Am I using random wrong? I initialized it to make the random number random.

Here is my code:

int timer = 1000;

int ranndom;

void setup() {
    // put your setup code here, to run once:
    pinMode(30, OUTPUT);
    pinMode(31, OUTPUT);
    pinMode(32, OUTPUT);
    pinMode(33, OUTPUT);
    pinMode(34, OUTPUT);
    pinMode(35, OUTPUT);
    pinMode(36, OUTPUT);
    pinMode(37, OUTPUT);
    pinMode(38, OUTPUT);
    pinMode(39, OUTPUT);
    pinMode(40, OUTPUT);
    pinMode(41, OUTPUT);
    pinMode(42, OUTPUT);
    pinMode(43, OUTPUT);
    pinMode(44, OUTPUT);
    pinMode(45, OUTPUT);
    pinMode(46, OUTPUT);
    pinMode(47, OUTPUT);

}

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

    ranndom = random(30, 47);

    if (ranndom == 38 || ranndom == 39) {
        digitalWrite(38, HIGH);
        digitalWrite(39, HIGH);
        delay(timer);

        digitalWrite(38, LOW);
        digitalWrite(39, LOW);
        delay(timer);
    }
    else {
        digitalWrite(ranndom, HIGH);
        delay(timer);

        digitalWrite(ranndom, LOW);
        delay(timer);
    }

}


texts: How to store values inside an empty array and get the average integer? [UPDATED QUESTION]

texts:
Goodafternoon,

I want to read values form a microphone (Adafruit MAX9814) connected to the Analog port A0 from Arduino and store the values that are incoming inside an array.

After the values are stored in the array, I want to read out the values and store the number that is repeated most time in a variable. Is this possible and how to achieve this?

I came up with the following:

const int micPin = A0;
int soundArray[10];

void setup() {

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

}

void loop() {

  int micValue = analogRead(micPin);
  Serial.println(micValue, DEC);
  //delay(400);

  for (int i = 0; i > 10; i++) {
    soundArray[i] = micValue;
    Serial.println(soundArray[i]);
  }
  delay(1000);
  Serial.println("End of for loop");

}

The problem now is that a value of the microphone will be repeated 10 times. So I will receive 10 times the number 234 for example. See image.

This is not what I want. I want to get different numbers in the array of that moment.

Hope someone can help me out.
Thanks in advance.


texts: Arduino: Reading PPM values from MQ-131 Ozone sensor

texts:
I have this sensor MQ131 by sainsmart: https://www.amazon.co.uk/gp/product/B00NL8XIQG/ref=ox_sc_act_title_1?ie=UTF8&psc=1&smid=A3DRI1TTHCTDIG

All I can read is the analog value which does not reflect the gas concentration. Any Arduino code for that to read the ppm concentration?
How long does the sensor needs to be preheated?


texts: Can the Arduino Pro (Portenta H7) communicate between threads?

texts:
I have an application that runs a stepper motor from an Arduino board. This requires use of the delayMicroseconds(int us) to control the speed at which the motor turns. For this reason, all code within the main loop() must execute extremely quickly or the stepper movement will become choppy or slow.
I am also using the Serial.readString() function to receive instructions on when the stepper should move and the Serial.println(string val) function to send the current position data back to the caller. The serial library is not particularly fast compared to the rest of the program as serial writes will take milliseconds (which is too slow for the stepper).
To solve this another thread could be used to manage the communications portion of the program and leave one thread exclusively for running the stepper motor. This will require that the threads are able to communicate with each other in a way that does not take a long time. Alternatively as the Pro supports MicroPython if there is a way to communicate between the Arduino program and a MicroPython application the python part could handle the serial communications.
The following link is the best example I could find and it does not show any communication between programs. Dual Core Processing
Example Pseudo-code
The following is an example of how I think this could work if the two cores could communicate with each other directly. As I am unsure whether this is possible I am also unsure whether any thread-locking would be required to prevent deadlocks.
Core 1
const int pinPulse = 2;
const int pinDirection = 3;

int moveTo = 0;
int currentLocation = 0;

void loop() {
    if (currentLocation != moveTo) {
        // Set direction
        if (currentLocation > moveTo)
            digitalWrite(pinDirection, HIGH);
        else
            digitalWrite(pinDirection, LOW);

        // Run movement
        executeMovement();

        // Update position
        if (currentLocation > moveTo)
            currentLocation--;
        else
            currentLocation++;
    }
}

void executeMovement() {
    digitalWrite(pinPulse, HIGH);
    delayMicroseconds(250);
    digitalWrite(pinPulse, LOW);
    delayMicroseconds(500);
}

int getCurrentLocation() {
    return currentLocation;
}

void setMoveTo(int val) {
    moveTo = val;
}

Core 2
Thread core1; // Pseudo-code

void loop() {
    // Check for and update new move to location
    while(Serial.available() > 0 ) {
        String input = Serial.readString();
        core1.setMoveTo(input.toInt()); // Assuming input can always be parsed to int
    }

    // Return position to caller
    Serial.println(core1.getCurrentLocation());
}


texts:
I am using different codes which set different values of baud rate through the Serial.begin() function.
I have an Uno using Serial.begin(9600) connected to an ESP8266 ESP-01 module
SoftwareSerial WiFiBoard(2, 3);
WiFiBoard.begin(115200)

Both of them are printing and reading from Serial, but when I use Arduino IDE Serial Monitor, I'm only able to display the content of the 9600... Am I missing a setting somewhere?
Also, when I configure both of them to use the baud rate 9600, I still only see the Uno information


texts: change variable configuration using bluetooth device in esp32?

texts: i am working on a small project in which i have to change the configuration using bluetooth device . to illustrates this if i have LED and led in high when we press "a" and low when we press "b" but we want another option is that we can also change high variable to c , f, g etc using bluetooth app.


texts: How to control a large number of devices with an Arduino

texts:
I'm doing some initial research on a project I have in mind. I am super new to all this Arduino stuff so taking it slow and gathering lots of info.

I want to control around 1000 small linear actuators to push/pull a very small load. The purpose of this question is specifically how to manage that many devices. The devices won't ever need to start their own transmissions so the Arduino can get everything done by polling them ...I hope ...and I don't think it would be a lot of data to each device but I imagine overall it may be. I want to control each device at the "same" time, all with the same cabling distance (around 2m). From what I can tell, a CANbus  is exactly what I need, where I can assign a unique ID to each device (node) and then write some code to control the network array.

In summary, is a CANbus the ideal bit of hardware here to work with an Arduino to control in real time such a high number of devices?

Thanks,
Nick.

Edit: Sorry for the vagueness, I'm very new to all this so really just looking for keywords to help scope my project out before asking more complex specific questions. It's difficult to formulate what's in my head to experienced people without sounding like a goose. I'm experienced on the software side, but the hardware i/o is all brand new.

Ultimately, I am wanting to sample a grey scale image/sequence of images and depending on the value sampled in a 0-255 range which is mapped to the extension capabilities of each actuator to extend/contract in that pixel.

Hope that is more helpful. Thanks.


texts: How to analogRead() 2 separate pins simultanously?

texts:
I am trying to create a simple piano playback using a flex sensor, a proximity sensor and a piezo buzzer.

I want to have it so that when the flex sensor is triggered, a sound is played on the piezo buzzer. The tone it makes is dependent on the values received from the proximity sensor.

Here is my code:

int psrAnalogPin = 6;
int fsrAnalogPin = 10;
int speaker = 9;
int fsrReading;
int psrReading;

void setup(void) {
  Serial.begin(9600);
  // We'll send debugging information via the Serial monitor
  pinMode(speaker, OUTPUT);
}

void loop(void) {
  psrReading = analogRead(6);
  delay(10);
  psrReading = analogRead(6);
  delay(10);
  Serial.print("\n psr reading = ");
  Serial.println(psrReading);
  fsrReading = analogRead(10);
  delay(10);
  fsrReading = analogRead(10);
  delay(10);
  Serial.print("\n fsr reading : ");
  Serial.println(fsrReading);
  if(fsrReading < 980 && psrReading > 599){
    tone(9, 400, 1000);
  } else if (fsrReading < 980 && psrReading > 500){
    tone(9, 500, 1000);
  } else if (fsrReading < 980 && psrReading < 392){
    tone(9, 600, 1000);
  }
}

When I look at the serial monitor's output, the values output seem to be only reading from my flex sensor(fsrReading) and not my proximity sensor. If I only read the proximity sensor's value it works, but not both at the same time.

How can I get it so that it reads both values instead of just one?


texts: how to detect the incoming message from sim800 GSM module

texts: I am designing an motorcycle security system and I need to receive the message  from the user.Hence i need to detect the incoming message and read the number and data from the message


texts: Controlling 16x2 LCD backlight (I2C module)

texts:
I've installed an I2C module on my 16x2 LCD so i don't have access to all those LCD pins to control the backlight LED.

BUT there is a 100 ohm smd resistor in series with anode of the backlight LED, i want to remove the resistor and use Arduino PWM to control the backlight or i can just replace that resistor with a 330 ohm or a 1K resistor.

Red box showing the resistor and blue box showing the Jumper.

Also I2C module itself have a jumper for LED backlight which also goes to that resistor...

Just wanted to ask here and make sure it is going to work before doing any modification to the LCD.

which way is better? is it going to work?

UPDATE: i used Arduino PWM and a 2n2222 transistor and was able to successfully control the backlight brightness via jumper pins of I2C module.


texts: Clock generator up to 8 MHz using pin 3 arduino nano

texts:
I would like to generate square signal up to 8 MHz using internal timer of arduino, I have done successfully in pin 11, but i want to change it in pin 3, but still stuck. Here is the code

 pinMode(11,OUTPUT);

 TCCR2A = ((1 << WGM21) | (1 << COM2A0));
 TCCR2B = (1 << CS20); // prescaler = 1
 TIMSK2 = 0;
 OCR2A = 1;

from this page here
How can i change the pin to pin 3?

Thank you


texts: USART, SPI or Bit-Bang for the continuous transfer of bytes without inserted extra bits

texts:
I have heard that

The SPI hardware introduces a 9th, HIGH bit between bytes
USART still uses start and stop bits when in synchronous mode

Are both these statements true? Can I modify the built-in SPI library to avoid #1? Or will I have to bit-bang the protocol needed?


texts:
I'm currently getting started with Arduino, so I do not have very much knowledge.
In this project I have a receiver and a transmitter with 2 buttons.
So, I'd like to switch something to on, when I press the A button. If A is pressed longer I'd like something else to happen.
Same thing goes on with the B button, but for some reasons, when I long press A, then B gets triggered and I have no clue why...

Btw. this code is not purely made by me, but copied and edited for my use.
If anyone could help me I'd be very happy :)

code:

//ButtonAEvents

long prevA = 0;
long prevB = 0;
int buttonStateA = 0; // 0 = not pressed   --- 1 = long pressed --- 2 short pressed
int buttonStateB = 0; // 0 = not pressed   --- 1 = long pressed --- 2 short pressed
int ButtonAPin = 2;
int ButtonBPin = 3;
int DURATION_A_IN_MILLIS = 1000;
int DURATION_B_IN_MILLIS = 1000;

//ONE TIME SETUP

void setup()
{
    pinMode(ButtonAPin, INPUT);
    pinMode(ButtonBPin, INPUT);
    Serial.begin(9600);
}

//LOOP BEGIN

void loop()
{

    //BUTTON A CHECK
    buttonStateA = 0;
    if (digitalRead(ButtonAPin)) {
        prevA = millis();
        buttonStateA = 1;
        while ((millis() - prevA) <= DURATION_A_IN_MILLIS) {
            if (!(digitalRead(ButtonAPin))) {
                buttonStateA = 2;
                break;
            }
        }
    }

    if (!buttonStateA) {
        // Nothin pressed
    }
    else if (buttonStateA == 1) {
        //LONG PRESS

        Serial.println("LongpressA");
        digitalWrite(A1, HIGH);
        delay(100);
    }
    else if (buttonStateA == 2) {
        //SHORT PRESS
        digitalWrite(A1, HIGH);
        Serial.println("ShortpressA");
        delay(100);
    }

    //BUTTON B CHECK
    buttonStateB = 0;
    if (digitalRead(ButtonBPin)) {
        prevB = millis();
        buttonStateB = 1;
        while ((millis() - prevB) <= DURATION_B_IN_MILLIS) {
            if (!(digitalRead(ButtonBPin))) {
                buttonStateB = 2;
                break;
            }
        }
    }

    if (!buttonStateB) {
        // Nothin pressed
    }
    else if (buttonStateB == 1) {
        //SHORT PRESS

        Serial.println("LongpressB");
        delay(100);
    }
    else if (buttonStateB == 2) {
        //LONG PRESS
        digitalWrite(A1, LOW);
        Serial.println("ShortpressB");
        delay(100);
    }
}


texts: Powering a 5V Arduino Pro Mini with 3.3V

texts:
I want to run the 5V board at 3.3V because I can get the 5V version cheaper than the 3.3V version.

I read that you can power the Arduino Pro Mini with a battery by connecting the battery to the 5V pin, bypassing the regulator.

Somewhere else I read that the only difference between a 3.3V and 5V Pro Mini is the regulator.

Are these assumptions correct? If yes, can I use a 5V Pro Mini like a 3.3V by powering it with a 3V Battery on the 5V pin?


texts: XBee Shield Arduino External Power Issue

texts:
The XBee part of the entire thing works flawlessly no matter how things are being run.

Equipment:

Laptop
Arduino Uno
Sainsmart XBee Shield
USB XBee Explorer
2 x XBee Series1 modules
Terminal software

What we are doing:

Send data through terminal software using "XBee 1" on a USB explorer, to remote "XBee 2" which is connected to Arduino Uno using the Sainsmart Shield. Arduino sends a reply which we see in the terminal software. (This is basically just using the two XBee modules to eliminate physical RX-TX connections in a simple point to point communication.)

This configuration works perfectly fine when the remote Arduino + XBee are powered by a USB port of a PC (doesn't have to be the same PC - tried with separate PCs, one powering the transmitter and other the receiver.)

The problem:

This configuration does not work if the remote Arduino + XBee are being powered by:

9V Battery (brand new)
12V, 2A adaptor
5V, 2A mobile charger directly supplying through USB

BUT it starts working after pressing RESET (sometimes, very rarely, we have to press RESET 2 or 3 times but it does start working) and keeps working while the supply is not disconnected/turned off.

Important Note 1: As mentioned earlier, the remote XBee always works perfectly fine in all of the above cases as shorting RX/TX shows that the data perfectly and flawlessly echoes back.

Important Note 2: I don't think that the Arduino isn't starting up, as to check that I am blinking pin13 LED which always starts working fine in any of the scenarios listed above.

Please help. Having to RESET every time after power up makes the whole thing pretty useless for any real world application.

When I say that does not work, I mean I don't get a reply from arduino when I send a query over terminal.

After pressing Reset, it begins working, i.e. I start getting a reply.

But I don't think that Arduino isn't startup because Pin 13 LED blinks as expected which is something I put just to check whether Arduino code starts running.

As far as circuit, it is nothing but XBee Explorer USB plugged into my laptop and arduino with ready made XBee shield plugged into another USB port (which is when it works). Powering Arduino from a USB port of a different PC also gives no issues.

Only when Arduino is powered by external power source like an adapter or phone charger or 9V battery (literally tried all 3) does it not work automatically and I have to Reset the Arduino after which it starts replying.


texts: I am new to Arduino. I want to simulate a circuit which uses an accelerometer ADXL335 and a DC motor. If any deviation observed in the accelerometer readings, I want the motor to rotate. Is there any way I can simulate its working in software without implementing it?


texts: Using Due (SAM3X8E) native USB port for programming?

texts:
I would like to make my own version of the Arduino Due.

What I can't find the answer to is;
Can I program a blank SAM3X8E using the native USB port from within the Arduino IDE, or do I first need to program some bootloader or similar?

My board will not have the Mega16U2 which is normally used for programming.


texts: Is there a variable type of half byte? Is there a workaround?

texts:
I have this long array of 64 values going from 0 to 15, values which only cost 8 bits, for a pulse width modulation.
So I made a test to see its cost in space, commenting one of the two arrays.
const byte wave[64] = {8,9,9,10,11,11,12,12,13,13,14,14,14,15,15,15,15,15,15,15,14,14,14,13,13,12,12,11,11,10,9,9,8,7,7,6,5,5,4,4,3,3,2,2,2,1,1,1,1,1,1,1,2,2,2,3,3,4,4,5,5,6,7,7};
//const byte wave[2] = {8,9};
byte i = 0;
void setup() {pinMode(1,OUTPUT);}
void loop() {            //(Don't worry about the code in here,
  analogWrite(1,wave[i]);//it's just to get the program
  i++;delay(1);          //to hold on to the data)
}

The compiler said Sketch uses 1112 and 1050 bytes (3%) of program storage space. or a difference of 62 bytes.
This tells me that one could save a lot of memory by keeping them in a 4-bit or what I'd like to call half byte, going from 0 to f rather than from 00 to ff.
How could I do so without turning the code to unreadable bit mush?


texts:
I am connecting Arduino Uno R3 with HC 08 module lie following

Arduino 5v -> HC 08 Vcc
Arduino gnd -> HC 08 gnd
Arduino Pin 5 -> HC 08 RXD
Arduino Pin 6 -> HC 08 TXD

Then I connected two LEDs to 9 and 10 pins

Then loading following sketch.

#include <SoftwareSerial.h>

int availableLEDpin = 9;
int notAvailableLEDpin = 10;
SoftwareSerial hc_08(5, 6); // RX-5, TX-6
void setup() {
  pinMode(availableLEDpin, OUTPUT);
  pinMode(notAvailableLEDpin, OUTPUT);
  Serial.begin(9600);
  hc_08.begin(9600);

}

void loop() {
  hc_08.listen();
  if (hc_08.available()) {
    Serial.println(hc_08.read());
    digitalWrite(availableLEDpin, HIGH);
    digitalWrite(notAvailableLEDpin, LOW);

  }
  else {
    digitalWrite(availableLEDpin, LOW);
    digitalWrite(notAvailableLEDpin, HIGH);
  }
  delay(100);
}

I am trying to connect to bluetooth from y iOS application. The application is searching and connecting to the HC 08 correctly. And sending data successfully - Swift code log showing sent successfully.

But back in Arduino, always led connected to pin notAvailableLEDpin is glowing and nothing is printing in serial monitor. What is wrong with my implementation?


texts: How to control two devices with Arduino?

texts:
I want to control two devices:

AC
Humidifier

I have a DHT11 sensor for temperature and humidity. I want the AC to turn on when the temperature is greater than 30°C, and off when it's less than 20°C. Same for the humidifier: on (humidity < 50 ) and off (humidity > 90 ).

It's not necessary for both to operate at the same time, i.e first check for AC then humidifier.

I want to do this task using a single Arduino Uno.


texts: How will Arduino communicate wirelessly through XBee?

texts:
I am using one XBee S2 configured as coordinator API attached to my laptop and one XBee S2 attached to an Arduino Uno that is configured as a router AT. I want to generate an alarm on LabVIEW as I have used VISA for serial communication.

#include <SoftwareSerial.h>

int buttonState1 = 0;
SoftwareSerial XBee(2,3); // RX, TX
int pin=13;
void setup() {
    XBee.begin(9600);
    Serial.begin(9600);
    pinMode(2,INPUT);

}

void loop() {
    if (Serial.available())
       buttonState1 = digitalRead(2);

    if (buttonState1 == HIGH) {
       // turn LED on:
       Serial.println(1);

    }
   /*else
    {
        Serial.println(2);

    }*/
    else {
       // turn LED off:
       Serial.println(0);
    }

    delay(100);
}

but I am getting no response at all.

What could be the root cause for this and how do I diagnose that?


texts:
I'm trying to use an ATMega328 board to control a board of a broken UPS device. I replaced all the internals of the UPS by custom components, so the only things which remain are the chassis and the front board.

On this board, there are five buttons, and three LEDs.

All those components are connected to the ground, each one through its own resistor. By connecting the different pins to the ground and to analog pins of the ATMega328 board, I can successfully detect when the buttons are pressed.

Things, however, get tricky when I want to turn the LEDs on. They have their anode connected to the ground (through a 47Ω resistor), and their cathode connected to a dedicated pin. This means that if I apply voltage to this pin, the LED remains off.

The LED, however, turns on if I connect the ground to a 5V pin on ATMega328 board and the cathode pin to the ground of the ATMega328 board. However, connecting the ground to 5V makes it impossible to read the state of the buttons (or should I wire them somehow specifically?)

Therefore, how do I feed negative current from the ATMega328 board?

There is a similar question on this subject, but while the author wants to “understand the underlying electronics of the arduino and microcontrollers in general,” I, instead, just want to know how to make it work. Reading the answers from the linked question, I have an impression that this is possible, but they don't explain how to do it.


texts: Why PIN3 stays at 1v3 in a IR emitter project?

texts:
Here is my very simple IR emitter circuit.
OSI5FU5111C-40 is an infrared LED.

I am using the IRremote library from here
in this simple sketch,

#include <IRremote.h>
unsigned int raw[100]={... *SOME RAW SIGNAL* ...};
IRsend irsend;

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

void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      Serial.print("Start sending ...");
      irsend.sendRaw(raw, 100, 38);
      delay(40);
    }
  }
}

The problem is when I send 1 to serial monitor,

it outputs triple Start sending ... and LED emits no signal.

So I test the voltage between PIN3 and GND before and after sending the 1.
The voltage stays around 1V3.

Would someone please give me some advice? Thank you!


texts: Interface a mobile phone's finger print scanner with arduino

texts: Is it possible to salvage a fingerprint scanner from an old and dead smartphone and use it with Arduino? I am not talking about writing an android program and send data to Arduino over Bluetooth or WiFi, I am talking about wiring up fingerprint scanner of a mobile phone to Arduino.


texts: FTDI Breakout with additional ISP connector

texts:
TL;DR - Can the six yellow ISP pins be used as a normal ISP?

The usual USB-TTL FTDI breakout board looks like this:

Recently, I came across a variant of the board shown below. However, what are the additional yellow header pins on this board for? They are labelled ISP.

Here is a view of the rear:

So can they really be used as a standard ISP/ICSP?

However, according to the diagram below, which labels the 6 pins in question, I am not sure that there is a valid correlation of signal lines.

That is to say, would CTS to MISO, RI to RST, DSR to SCK and DCD to MOSI work? Or is that why a special version of avrdude is required, as alluded to in FT232RL: USB to Serial 232 TTL Adapter –?and ISP? - post #6:

As a new feature there is a 6-pin ISP header available. With it, avrdude and avrftdi you can program Atmels and Arduino bootloaders. A special version of avrdude with compiled FTDI driver is neccessary.

However the provided link to that version of avrdude, with the compiled FTDI driver, is dead.
It is also said, in post #7, that these pins are actually equivalent to an X3 connector, as found on the older Arduino Dicimila/NG/Duemilanove boards.

and those can (evidently) be used like so, as a bit banged SPI,

It should be noted that the RI, CTS, DCD and DSR (labelled RSD) pins are available, along the sides of the original FTDI breakout board. So, does the breakout board with the ISP header just provide access to these same signals using a different header?
I am a little confused - have I just over thought this, and this breakout board is simply an ISP/ICSP header and an FTDI connector rolled into one board (when used with the appropriate version of avrdude)? Or is it not a usual ISP header? I can not find any specific documentation relating to this type of breakout board, as stated in post #4.
Can anyone say, definitively, what these six pins are for? If they are not a normal ISP header, could you provide a detailed way of using it? A schematic would be helpful.


texts:
I am trying to build a frequency meter using Interrupts and Timer1, which works as if the system receives an Interrupt it would get the timer's data and would calculate

  Signal's Frequency = 1 / (Counter * Timer's Period) => F_s = F_t/TCNT

but the result is way off, and it does not even make sense. I have had altered my code to look that if the timer's data is not valid or sth, but the number that the timer counter has counted is sth that I expect.

Here is my code:

int f=0;
char msg[50];

void setup()
{
  Serial.begin(115200);
  noInterrupts();           // disable all interrupts
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  TCCR1A = 0;
  TCCR1B = 0;
  OCR1A = 0;
  OCR1B = 0;
  TCCR1B |= (0<<CS12)|(1<<CS11)|(0<<CS10);    // Clock 2MHZ
  TCNT1  = 0;
  TIMSK1 = 0; // disable timer overflow interrupt
  interrupts();
  attachInterrupt(1,pin_ISR,RISING);
}

void pin_ISR(){
  //digitalWrite(13,!digitalRead(13));
  f = 2000000/TCNT1;
  TCNT1=0;
}

void loop()
{
  sprintf(msg,"Humidity:%d \n",f);
  Serial.print(msg);
}


texts: How would I go about powering addressable RGB LED light strip? [Arduino Nano]

texts:
The addressable RGB LED I have is WS2812B. I plan on controlling the LEDs via an Arduino nano. I have a total of 188 LEDs to supply power to.

Would I require anything between the addressable RGB LED strip and the 12v power supply?

Would I require a 1000uF capacitor?


texts: Can an L293D motor driver shield do microstepping?

texts:
I bought a L293D motor driver shield and have used it with a pre-made sketch for driving a pair of stepper motors, but I'm not familiar with its capabilities.

The sketch I've used so far doesn't use microstepping when it's set up for this shield (though it does use it with the Adafruit shield).

I've done some searching, and it's not clear if the L293D chips on the shield can do microstepping, and if so, how.

Are L293D chips (and thus the motor driver shield that uses them) capable of microstepping? If so, how can I add this capability into my sketch?


texts: Scanned RFID data is not appearing in the serial monitor

texts:
I am attempting to use this code to receive data from 2 ports, alternating between them:

/*
  Software serial multple serial test

  Receives from the two software serial ports,
  sends to the hardware serial port.

  In order to listen on a software port, you call port.listen().
  When using two software serial ports, you have to switch ports
  by listen()ing on each one in turn. Pick a logical time to switch
  ports, like the end of an expected transmission, or when the
  buffer is empty. This example switches ports when there is nothing
  more to read from a port

  The circuit:
  Two devices which communicate serially are needed.
   First serial device's TX attached to digital pin 10(RX), RX to pin 11(TX)
   Second serial device's TX attached to digital pin 8(RX), RX to pin 9(TX)

  Note:
  Not all pins on the Mega and Mega 2560 support change interrupts,
  so only the following can be used for RX:
  10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

  Not all pins on the Leonardo support change interrupts,
  so only the following can be used for RX:
  8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

  created 18 Apr. 2011
  modified 19 March 2016
  by Tom Igoe
  based on Mikal Hart's twoPortRXExample

  This example code is in the public domain.

*/

#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(10, 11);

// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(50, 51);

int RFIDResetPin = 13;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  pinMode(RFIDResetPin, OUTPUT);
  digitalWrite(RFIDResetPin, HIGH);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Start each software serial port
  portOne.begin(9600);
  portTwo.begin(9600);
}

void loop() {
  // By default, the last intialized port is listening.
  // when you want to listen on a port, explicitly select it:
  portOne.listen();
  Serial.println("Data from port one:");
  // while there is data coming in, read it
  // and send to the hardware serial port:
  while (portOne.available() > 0) {
    char inByte = portOne.read();
    Serial.write(inByte);
  }

  // blank line to separate data from the two ports:
  Serial.println();

  // Now listen on the second port
  portTwo.listen();
  // while there is data coming in, read it
  // and send to the hardware serial port:
  Serial.println("Data from port two:");
  while (portTwo.available() > 0) {
    char inByte = portTwo.read();
    Serial.write(inByte);
  }

  // blank line to separate data from the two ports:
  Serial.println();
}

I am using a mega2560, and have the pins placed in the 10 and 51 port. any help is appreciated.


texts: Arduino Due and BNO055 address in i2c mode

texts:
I have a project where I need to have several IMUs, the BNO055 shuttle board (I explained my project here), I manage to get the Euler angles from one BNO055 sensor, which have the address 0x29, because I linked the I2C_MODE_ADR_SEL to a HIGH level.

I would like to have another sensor with the address 0x28. As the datasheet says, I must link the I2C_MODE_ADR_SEL to a LOW level (to the GND) the i2c Scanner from the Arduino Playground does not recognize any i2c device.

I don't know how to change my sensor address, can anyone help me with this issue ?


texts: client.connect() fails except the first time

texts:
I am communicating with the Web server's database via Arduino GSM shield + GPRS connectivity

void loop()
    {
     if (client.connect(server, port))
      {
         .......
      }
     else
     {
      Serial.println("Server not found");
     }
    delay(1000);
    }

The first time when the loop() runs in the serial port, the code works perfectly and stores in my server's db. The second time when the loop() runs after some delay, It is unable to connect to the server and results "server not found" . I don't know what is the problem.

Please let me know if there is a way to connect continuously.
Thank you


texts: FTDI to HM-10(CC2541) serial command no response

texts:
I'm trying to communicate with my HM-10 module though a FTDI converter on my mac. I have installed the FTDI driver and disabled the mac's default FTDI driver. This is my arduino IDE setup:
board: I tried Arduino Uno/ Arduino Pro mini(ATmega328 3.3V)
Port: /dev/cu.usbserial-50285BI
programmer: AVRISP MKII

I connect rx on MH-10 to txd on converter and tx on HM-10 to rxd on converter. 3.3Vcc and GND respectively. The HM-10 module is powered up but I can not find the beacon signal. When I send command from arduino IDE's serial monitor there was no response from the chip at all. The RX and TX leds on converter never lighted up either. My goal is just to setup a BLE beacon and change the UUID(may do more advanced programming in future) and have been struggled on this for couple of hours. please help me.

Thanks!


texts: USB power on arduino digitalRead is normal, but, gives error when using buck(step down) converter

texts: I am using arduino for digitalRead(). i've been using INPUT_PULLUP, and when using USB power, all seems normal. but, when i switched to  power supply and buck converter(12v to 5v), the digitalRead() randomly change. why is that?


texts:
I'm a little new to circuitry, and the Arduino in itself!

From what I know, I think that it might be possible to actually build one (the processor itself, of course) from transistors. This isn't a practical question, of course, but it would be an excellent learning opportunity.

Would it be actually possible to go through with such a project (Even without EEPROM)?

If so, how would it be completed?

Thank you!


texts:
I'm trying to read 5 analog inputs, but all the pins are reading the same as pin A0, plus or minus a couple points. I tried using pulldown resistors on all 5 pins and it made no difference. The board is a Leonardo. Thanks for any ideas/help!

void setup() {
    Serial.begin(115200);
    analogReference(EXTERNAL);
}

void loop() {
    int A0, A1,A2,A3,A4;
    delay(200);
    A0= analogRead(A0);
    A1= analogRead(A1);
    A2= analogRead(A2);
    A3= analogRead(A3);
    A4= analogRead(A4);

    Serial.print(A0);
    Serial.print(" ");
    Serial.print(A1);
    Serial.print(" ");
    Serial.print(A2);
    Serial.print(" ");
    Serial.print(A3);
    Serial.print(" ");
    Serial.print(A4);
    Serial.print("\n");
}


texts: Rotate a brush less motor using arduino only

texts:
I connected a brushless motor to 5V and GND pin of Arduino Uno connected to my laptop via USB. I ran the servo motor code in the examples list but the motor did not work. Is it possible to rotate motor using Arduino only without ESC or h-bridge and how?
Thanks in advance..


texts: Arduino program to scan two different rfid cards in same program ? Im using nodemcu- esp8266 , rc522 reader and Firebase

texts:
/*My project is a Library management system using rfid cards. Im trying to generate a code wherein User first scan a book and then the record will be pushed in Issued_Books table in Firebase . Then the user scans his id to ensure that the book will be issued on his/her id.
But in my program is scanning only books id. It fails to scan users Id after that. Im a beginner so can anyone guide me? */

//My loop code is as following:

void loop() {

  if ( !mfrc522.PICC_IsNewCardPresent() ) {
    delay(50);
    return;
  }

  if ( !mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }
String book;

  for ( byte i = 0; i< mfrc522.uid.size; i++ ) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    book.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    book.concat(String(mfrc522.uid.uidByte[i], HEX));}
    book.toUpperCase();

    Firebase.pushString("Issued_Books/Book_rfid",book);

      Serial.println();

  if ( !mfrc522.PICC_IsNewCardPresent() ) {
    delay(50);
    return;
  }

  if ( !mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }
  String user;

  //Serial.print("Scan your id: ");
    for ( byte i = 0; i< mfrc522.uid.size; i++ ) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    user.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    user.concat(String(mfrc522.uid.uidByte[i], HEX));}
    user.toUpperCase();
    //Serial.print(F("Card UID: "));
    Firebase.setString("Issued_Books/Book_rfid/user_rfid",user);

    delay(3000);
}


texts: I am involved in a project that is going to measure PH and chlorine in a swimming pool.  The plan is to use a Arduino Yun. The sensors we are going to use are connected using serial.  Since we may be using multiple sensors, is there any difference in reliability, latency, known issues (bugs) of using software serial versus pin0 and pin1? Is it any way to avoid software serial pitfalls (if there are any)?


texts: Upload already compiled code on Linux CLI without arduino-cli

texts:
I have a sketch for an Arduino Nano. I'm compiling it on my build server and get these 3 files:

project.bin.elf
project.bin.hex
project.bin.with_bootloader.hex

Now I need to be able to upload/flash them onto the board (connected via a serial interface) without arduino-cli. Mainly because I can't install it via apt-get which means I'd have to start jumping through loops to be able to use it (stuff like keeping it up to date, installing, etc. on hundreds of devices).
So I was wondering if there are any tools in the debian repositories I can use to upload the compiled sketch and if so how.

I've been looking for a solution and came across several answers and topic but strangely enough all either use arduino-cli, other specialized tools or link to dead pages or pages that no longer contain the answer.

Examples:

How to compile, upload and monitor via the Linux command line?
Compiling sketch vi command line


texts: Do I need an Microchip ATSAM3X8E Evaluation Kit?

texts:
I am intending to use the Arduino Due processors into my own designs. We have a very extensive (dozen of thousands of lines in .c code) sets of Arduino Due functional codes, and now I intend to move into a more solid form shape.
I have the following questions. What i need is some sort of feedback in order to answer those by myself and realize how to proceed.

I understand some of the Fast Speed Serial options in the Microchip IC cannot be tried in the Arduino Due (such as USBOTG?)?. What I actually need is some Serial Speed close to 2Mbps and a USB Programming Port.

Which are the main differences between the Microchip ATSAM3X8E and the Atmel ATSAM3X8E? R: No, they are the same.

I notice there are some functionalities in the Microchip ATSAM3X8E or even in the Atmel ATSAM3X8E not able to be reproduced in the Arduino Due Board?

Do The Microchip ATSAM3X8E IC have its own functionalities not present in the Atmel ATSAM3X8E? R: No, they are the same.

As note, there is a Keil ARM SAM3X-EK Evaluation Kit (also also here with its brochure), with a ATSAM3X8H, which is not the same IC series, but somehow exposes my concern (if real).

If my concern about High Speed Serial is real, how should I evaluate it?


texts: Read one value from continuous data stream at a lower frequency

texts:
I am working on a university final project and have run into a problem with programming Arduino, after a 3 year hiatus. I have a pressure transducer that is sending pressure data at 10Hz. I have successfully programmed my Arduino Pro Micro to read the data as it is coming in. I'm using the SoftwareSerial library to set digital pins 8 and 9 to RX and TX, respectively. As the pressure transducer is continuously streaming data values, I read each character, store them in an array, and print them to the Serial Monitor. I'm using a start and end-marker to recognize each incoming character and put them into the array. The raw data output from the transducer is in the form:

*000114.2927
*000114.2926
*000114.2927

And this is the code I am using.

#include <SoftwareSerial.h>
#define paroRX 8
#define paroTX 9

SoftwareSerial paroSerial(paroRX, paroTX);

const byte numChars = 16;
char paroChars[numChars];     //array to store received data
char paroToSend[numChars];      //array to transmit
boolean newParoData = false;

void setup(){
  Serial.begin(9600);     //with transmitter radio
  paroSerial.begin(9600);
}

void loop(){
  paroSerial.listen();
  readParo();      //read from Paro and store values in paroChars
  if(newParoData == true){
    for(int i=0; i<16; i++){
      paroToSend[i] = paroChars[i];
    }
    Serial.print(paroToSend); Serial.print('\n');     //transmit Paro data with a new line for each value
    newParoData = false;
  }
}

void readParo(){
  static boolean receiveInProgress = false;
  static byte index = 0;
  char startMarker = '*';
  char endMarker = '\n';
  char pd;
  while(paroSerial.available() && newParoData == false){
    pd = paroSerial.read();
    if(receiveInProgress == true){
      if(pd != endMarker){
        paroChars[index] = pd;
        index++;
        if(index >= numChars){
          index = numChars - 1;
        }
      }else{
        paroChars[index] = '\0';      //terminate string
        receiveInProgress = false;
        index = 0;
        newParoData = true;
      }
    }else if(pd == startMarker){
      receiveInProgress = true;
    }
  }
}

And this is the output that I get, which is correct. I don't really want that * in front anyways.

000114.2927
000114.2928
000114.2927
000114.2929

But all of this happens at 10Hz, which means I get a constant stream of readings on the Serial Monitor. I want to slow this down to 1Hz, or just one reading per second. The obvious solution that occurred to me was to put a delay in the loop. So I tried to implement this with delay(1000) and using the millis() function as well, but I get strange readings like:

000114.2927
***000114
**2928
***.000114
000114.2928

How can I read at 1Hz from the 10Hz data stream? I want to just store one data value from the stream per second in the form of 000114.2927, then ignore the rest while the Arduino does something else.

Thanks!


texts:
I'm currently working on a project that requires that I simultanously check the state of two buttons. Each button HIGH state is assigned to one if loop. Here's the basic concept:

void loop() {
  S1_State = digitalRead(S1_Pin);
  S2_State = digitalRead(S2_Pin);
  ButtonPRESSED = false;

  P1_Time = random(2000, 5000);
  delay(P1_Time);
  digitalWrite(P1_Pin, HIGH);

  while(ButtonPRESSED == false) {
    if (S1_State == HIGH) {
       Serial.print("Player 1 wins");
       Serial.print("");
       digitalWrite(P1_Pin, LOW);
       ButtonPRESSED = true;
       delay(5000); }
    if (S2_State == HIGH) {
       Serial.print("Player 2 wins");
       Serial.print("");
       digitalWrite(P1_Pin, LOW);
       ButtonPRESSED = true;
       delay(5000); }

The problem is that checking for the button states this way requires that the S1_State loop _has to be read before the S2_State loop_, thus giving player 1 an advantage. Although I'm not sure how pronounced this issue is in practice, it certainly was noticable when I was first trying this project out through python code on a Pi through similar means.

Is it possible check the conditions to both if loops simultanously? If not, are there other ways to circumvent this problem?


texts: How do I send data to an Arduino via light flashes

texts: I want to send a very small amount of data to an Arduino via visible light ( blinking lights on a screen ). The data is no more than settings and the rate does not have to be fast. Does anyone have a method for doing this?


texts: How to use Servo movement with RTC with Storage error

texts:
#include <Wire.h>
#include "ds3231.h"
#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
int pause = 800

#define BUFF_MAX 256

;uint8_t wake_HOUR1 = 10;
uint8_t wake_MINUTE1 = 53;
uint8_t wake_SECOND1 = 0;

uint8_t wake_HOUR2 = 4;
uint8_t wake_MINUTE2 = 30;

unsigned long prev = 5000, interval = 5000;

void set_alarm (void)
{
  uint8_t flags1 [5] = {0, 0, 0, 1, 1};
  uint8_t flags2 [4] = {0, 0, 1, 1};

  DS3231_set_a1 (wake_SECOND1, wake_MINUTE1, wake_HOUR1, 0, flags1);

  DS3231_set_a2 (wake_MINUTE2, wake_HOUR2, 0, flags2);

  DS3231_set_creg (DS3231_INTCN | DS3231_A1IE);

  DS3231_set_creg (DS3231_INTCN | DS3231_A2IE);
}

void setup ()
{
  myservo.attach (14);
  myservo.write (0);

  Serial.begin (9600);
  Wire.begin ();
  DS3231_init (DS3231_INTCN);
  DS3231_clear_a1f ();
  DS3231_clear_a2f ();
  set_alarm ();
}

void loop ()
{
  char buff [BUFF_MAX];
  unsigned long now = millis ();
  struct ts t;

  if ((now - prev> interval) && (Serial.available () <=0)) {
    DS3231_get (& t);

    snprintf (buff, BUFF_MAX, ".% d% 02d% 02d% 02d%:.% 02d", t.year,
             t.mon, t.mday, t.hour, t.min, t.sec);
    Serial.println (buff);

            DS3231_get_a1 (& buff [0], 59);
            Serial.println (buff);
            DS3231_get_a2 (& buff [0], 59);
            Serial.println (buff);

            if (DS3231_triggered_a1 ()) {

              Serial.println ( "-> Frist Service load");

              myservo.write (120);
              delay (pause);
              myservo.write (0);

              DS3231_clear_a1f ();
            }
                if (DS3231_triggered_a2 ()) {

              Serial.println ( "-> Second Service load");

              myservo.write (120);
              delay (pause);
              myservo.write (0);

              DS3231_clear_a2f ();
            }
            prev = now;
  }
}

  Sketch uses 9,178 bytes (28%) of program storage space. Maximum is 32,256 bytes.
  Global variables use 648 bytes (31%) of dynamic memory, leaving 1,400 bytes for local variables. Maximum is 2,048 bytes.

Storage Space problem


texts:
here is the code.

PROBLEM:- if I use for the loop the error comes "expected unqualified-id before for .......but if I use the void loop instead of for loop...the code is run without any error. Meanwhile, I needed for loop .

long int Distance = 0;  // Record the number of steps we've taken
//LOW LOGIC MOVEMENT BACKWARD and GEARS MOVE clocwise
// PIN 18 FOR DIRECTIRON
// PIN 19 FOR STEP  INPUT
int y= 10^-6;
long int k;
long int h= 1600;
void setup() {
Serial.begin(9600);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  digitalWrite(18,LOW);
  digitalWrite(19, LOW);
 digitalWrite(14, LOW);
 digitalWrite(15, LOW);
}
for ( k=0; k<=h; k++)
{
  //if we are at the end of our move
  digitalWrite(19, HIGH);
  delayMicroseconds(100);
  digitalWrite(19, LOW);
  delayMicroseconds(100);
  Distance = Distance + 1;   // record this step
  //k=Distance;
//   Check to see
  if (Distance ==h)
 {
   // We are! Reverse direction (invert DIR signal)
   if (digitalRead(18) == LOW)
    {
     digitalWrite(18, HIGH);
   }
   else
   {
     digitalWrite(18, LOW);
   }
//    Reset our distance back to zero since we're
 //   starting a new move
   Distance = 0;
  //   Now pause for half a second
    delay(1000);
  }
  }
}


texts:
Is here some easy way to control bipolar motor
 without using any other external devices, drivers or shields? I have small motor from CD-ROM so I expect it's low voltage. By control I mean just turning clockwise  and anti-clockwise and speed. I'm looking for easy to make circuit not just direct control from Arduino.


texts:
I want to check each cell voltage using arduino.

and how to calculate dc current using CT Sensor using Arduino?


texts:
Peter Scargill found a way to use DS18B20 temperature sensor without any library and just using OneWire library, and it's amazing how blazing fast it is! (it's an old article from 2013)

#include <OneWire.h>
int16_t dallas(int x,byte start){
    OneWire ds(x);
    byte i;
    byte data[2];
    int16_t result;
    do{
        ds.reset();
        ds.write(0xCC);
        ds.write(0xBE);
        for (int i = 0; i < 2; i++) data[i] = ds.read();
        result=(data[1]<<8) |data[0];
        result>>=4; if (data[1]&128) result |=61440;
        if (data[0]&8) ++result;
        ds.reset();
        ds.write(0xCC);
        ds.write(0x44, 1);
        if (start) delay(1000);
    } while (start--);
    return result;
}
void setup (){
  dallas(A0,1);
}
void loop (){
  float currentTemp = dallas(A0,0);
}

Problem is The accuracy, he converts float to int to get accuracy of 1 degree and it's working just fine.

How can i get accuracy of .5 (or .2?) degree using this semi library?


texts: Reading serial buffer taking newline character instead of user input

texts:
I am trying to compare whether the user input matches a user ID or not. When I read the input from serial, the program is taking the last character which is newline char '\n' and moving it into the char data value to compare against the stored user ID and I don't understand why it's taking the '\n' value instead of the actual user input.

int Gled = 7;
int Rled = 8;
int wait = 5000;
char UserID = "12345";
char data;
char incoming;

void setup() {
  Serial.begin(9600);
  pinMode(Gled,OUTPUT);
  pinMode(Rled,OUTPUT);
  Serial.println("Please Enter your username or ID:");
}

void loop() {
  if(Serial.available()>0) {
    while(1) {
      data=Serial.read(); //read user input and move to data char
      if(data !='\n')
        incoming = data; //if data doesn't equal newline data = incoming
      if (data == '\n')
        break; // newline char detected break
      if (data == -1) //continue reading all of user input
        continue;
      Serial.print(data);
      Serial.print(incoming);
    }
    Serial.println(incoming);
    if(incoming == UserID) { //if user input matches run statement
      digitalWrite(Gled, HIGH);
      Serial.println();
      Serial.println("Access Granted");
      Serial.println("Hello User Name");
      delay(wait);
      Serial.println("Login time exceeded, you are now logged out.");
      Serial.println("Reenter your UserID to log back in.");
      digitalWrite(Gled, LOW);
      Serial.end();
      Serial.begin(9600);
    } else if(incoming != UserID){
      //user input doesn't match run statement
      digitalWrite(Rled, HIGH);
      Serial.println();
      Serial.println("Access Denied");
      Serial.end();
      delay(wait);
      Serial.begin(9600);
      digitalWrite(Rled, LOW);
      Serial.println("Please Enter a Valid ID to Continue.");
    }
  }
}


texts: Arduino Nano - programmer is not responding

texts:
I cannot seem to upload the simple blink program to my Arduino Nano. I keep getting the message:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

What I have tried already with a lot of suggestions on Google. I have tried it on both a Windows 7 & 8 machine and with 2 different Nano's:

Set my Board to Arduino Nano
Set my Processor to ATmega168
Set my port to COM1
On windows 8 turned off driver signature
Installed the FTDI Driver
Checked my drivers in control panel

USB controllers says USB Serial Converter
USB Serial port says USB Serial Port (COM1)

Rebooted a Lot!

When I plugin the nano to the USB it starts blinking the L led 180 times a minute. When I start uploading, L blinks at about 80-100 times a minute, blinks the rx and then start blinking the L led fast again.


texts: arduino yun sysupgrade 'platform_check_image' failed

texts:
https://www.arduino.cc/en/Tutorial/YunSysupgrade
when i run the following command. i get this error.

run-sysupgrade /mnt/sda1/openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade.bin
Image metadata not found
Invalid image type.
Image check 'platform_check_image' failed.

via webinterface its the same problem

i have a freshly unboxed arduino yun rev2

i really don't want to use the go updater since i still have 2 years of warranty.
https://www.arduino.cc/en/Guide/YunUpdater


texts:
I saw the one of your Answer that dated the 13th May 2015, i want to cross- correlate the vibration signal (with Predefined Signal) to remove the unwanted signals.But i want to do that real time so can we use the Arduino or have to use the Another platform. please advise .

Kaveendra Sampath


texts: Can I use arduino pro micro rx tx as digital pins

texts:
I'm using arduino pro micro Atmega32u4 5v 16Mhz
I want to use it to make a HID Keyboard and Mouse but I ran out of pins so I was wondering if I can use the RX and TX pins as digital input pins. Will it work? Will it affect the communication of the arduino  to the computer?


texts: Help understanding Print::write()--it calls write()--where is write() defined? Help reading code

texts:
I'm writing a new serial library (eRCaGuy_Peer2Peer) to allow any 2 pins on an Arduino to be used for peer-to-peer type communication between Arduinos, withOUT interrupts or timers/counters.

Currently SPI, Serial, and I2C are pin-specific, and SoftwareSerial requires pin change interrupts. My implementation will solve these problems.

However, I first am trying to understand some things. As I study SoftwareSerial, I see it inherits from the Stream class, which inherits from the Print class.

I don't understand how Print's write is implemented. This is from Print.h:

virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
  if (str == NULL) return 0;
  return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
  return write((const uint8_t *)buffer, size);
}

This is from Print.cpp:

/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
  size_t n = 0;
  while (size--) {
    if (write(*buffer++)) n++; //<--where is this write defined?
    else break;
  }
  return n;
}

My Questions:

What does this mean? I've never seen anything like this before: virtual size_t write(uint8_t) = 0; Why the = 0?
What does it mean/how does it work defining functions in .h files? I've never done this before: ex:
size_t write(const char *str) {
  if (str == NULL) return 0;
  return write((const uint8_t *)str, strlen(str));
}
Where is the write command I've marked above defined? Is Print::write() calling itself recursively?
Also, why does SoftwareSerial.h call using Print::write; (shown below) when it already re-implements the virtual write function just above that?

virtual size_t write(uint8_t byte);
    virtual int read();
    virtual int available();
    virtual void flush();
    operator bool() { return true; }

using Print::write;


texts: Communicating between a computer and multiple Arduinos

texts:
I am designing a experiment of controlling 6 small wind turbines wirelessly. For each wind turbine, I need to measure power time series (or voltage or current time series) from the generator, and control blade pitch angle, yaw angle, and generator load (using variable resistance). The control input will be all PWM signal.

I am planning to put an Arduino UNO with a ZigBee wireless module to each wind turbine, making it measure the power time series and transmit to the central node, as well as receive the control input from the central node and command the control input to servo motors. The central node will be additional Arduino UNO.

Here are my questions:

Is it possible for each Arduino to send time series signal to central node wirelessly without interference with other Arduino? (6 wind turbines transmitting time series to a central server). If it is possible, How can I implement such network ? recommending a source for learning would be also greatly helpful.
Interface between the central node and the computer software: The algorithm in the computer need to process the received power time series and determine the optimum control input for 6 wind turbines. Then these control input should be transmitted to wirelessly to 6 wind turbines. In such case, what is the good option to interface the algorithm and the Arduino connected to the computer? Currently the algorithm is written in Matlab. I heard there is the sketch interfacing Arduino and Matlab, is it efficient enough for such project?


texts: Can someone help me decipher the code for the arduino? I am totally lost

texts:
The code is as follows:

void loop(){

    light = analogRead(5);
    Serial.println(light);
    analogWrite(3,light/4);

}


texts: Can you activate the whole pixel on LCD?

texts: I'm working on a project where I'm trying to display the level of a filled tank through ultrasonic, then displaying it on a 16x2 LCD. I'm trying to do it through the whole LCD Pixels, such that when the tank level is full, the first 5 pixels are activated (as what happens when you connect the LCD initially without having any code for it, the whole pixels are turned on, giving 16x2 white rectangles, as shown in the picture below). Is there a way to activate an entire pixel on the LCD?


texts: Arduino IDE, Underlying Code and Libraries

texts:
I'm trying to better understand what is going on behind the Arduino IDE. First off I am no expert in C or writing firmware to boards but do have experience in real development.

I see currently the Arduino IDE is one big vast library we first select our board.
What I don't understand is where are our header files? The source files for the board you select?

Not only that we use a number of functions already detected within the IDE where are these located also is any of this code editable?

I had a look through the Arduino directory and most of this stuff looks like its Java I was hoping for C files. Thanks for any links, help or info anyone can give.


texts:
I use Ethernet Shield and Arduino to GET data from the server in JSON format. Request looks like this:

client.println("GET http://ramp.local/api/actions?");

The response I get is:

[{"action_id":1,"action_type":"up","action_status":"new","ramp_id":31,"user_id":17},
{"action_id":2,"action_type":"down","action_status":"new","ramp_id":32,"user_id":20},
{"action_id":3,"action_type":"up","action_status":"completed","ramp_id":32,"user_id":17},
{"action_id":4,"action_type":"up","action_status":"failed","ramp_id":31,"user_id":17}]

How to collect a data in a string variable and parse it to get action_status?


texts: None of the programs in Arduino example is compiling

texts:
I am new  to Arduino. I have connected the Arduino to the computer and I have installed the necessary drivers. But when I am compiling the Blink.ino program and other programs, which is present in the example, I am getting an compilation error. I have the IDE folder in D:\ drive

exec: "D:\\Arduino\\arduino-nightly\\tools-builder\\ctags\\5.8-arduino5/ctags": file does not exist
    Error compiling.

I don't know what to do. Please help me


texts:
Please take a look at following example (I have Java background):

const char* BT_ADDRESS = "abcd,ef,ghijkl";

void bar(const char* string) {
  ...
}

void foo() {
   bar("AT+BIND=" + BT_ADDRESS);
   bar("AT+LINK=" + BT_ADDRESS);
}

How to achieve this with "Arduino-C++" so BT_ADDRESS only has to be entered at one location?


texts: 5v to 4.3v Regulator - For SIM800 module

texts:
I want to build a simple voltage regulator  3.8-4.2V with atleast 2A Peak Current Capability for my GSM Shield (It doesn't have regulated power supply), I don't want variation or it may burn the board.

Using voltage divider won't help here as there can be variations.
Somewhere i read LDO are for for this task but i am able to get only 3.3v regulator with 800mA supply.

Can i use 3.3v to power the same ?


texts: Dataflash SPI Flash chip shared programming SPI pins

texts: I have an ATTINY841 that is utilizing a Dataflash SPI flash chip (AT45DB011D).  The SPI pins are connected to the same pins used for programming the ATTINY841.  When I program the ATTINY841, I find that the Dataflash chip is being erased, and I have to reprogram it also.  This happens even though the Write Protect pin on the Dataflash is asserted (connected to Ground).  To prevent this I currently need to remove the Dataflash from the circuit when programming the ATTINY841 and replacing it when finished, however I won't be able to do that when the circuit is transferred to PCB.  Has anyone experienced this or know how to deal with it?  Do I have a bad chip?


texts: Microcontroller software shutdown with transistor 2N4401

texts:
I am trying to understand why connecting, say, an Arduino digital pin 4 to a 2N4401 pin 2 as well as 5V PSU to 2N4401 pin 1 and Arduino VCC  to 2N4401 pin 3, won't keep power.

When shorting pin 1 and pin 3 on the 2N4401 the MCU is powered on and in-software pin 4 is set to pinMode OUTPUT and HIGHwhich should allow the 2N4401 to let power flow to the MCU for as long as power is available even when the short circuit between 2N4401 pin 1 and 3 is cut.

Instead what happens when the short between pin 1 and 3 is cut, the MCU is turned off instantly.

It's as if the transistor isn't reacting to the pin 4 MCU signal at all.

Could anyone explain why this is happening?

I'm sure I lack a lot of knowledge here and I want to know how I could utilize a 2N4401 to make a SW shutdown system.

Why 2N4401? Why not a MOSFET?
MOSFET's circuits that do SW shutdown are available, but no transistor base SW shutdown circuits are to be found anywhere, and the 2N4401 is all that I have right now.

Update

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

void loop(){
  digitalWrite(4, HIGH);

  delay(3000);

  digitalWrite(4, LOW);
}


texts: Why isn't the stack pointer changing in this simple sketch?

texts:
I'm playing around with context switching, and my first idea is to play with SP and see how it changes.  However, Sp doesn't do what I expect.  The sketch is below. I'm using an Uno R3.  What I expect to see is that SP should first print out some value, then it should be 4 integers further along (4x2 bytes?) when printed the second time.  But that doesn't happen, and both times I see the exact same value for SP.  What could the problem be?

    void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  Serial.print("X = ");
  Serial.println(SP,HEX);
}
void loop() {
  // put your main code here, to run repeatedly:
Serial.print("BEFORE: ");
Serial.println(SP,HEX);
int y = 15;
int z = y;
int g = z + y;
int dsf = z-y;
  Serial.println(dsf+g); //this should make these variables DO something...
  Serial.print(" After = ");
  Serial.println(SP,HEX);
  delay(1000);
}


texts: Integrating an analog signal using Arduino Due

texts:
I have an 2 analog signal, and I want to calculate the difference between 2 signals (A0 and A1), then integrate an analog, but it doesn't work (I just started studying Arduino).

Please could you show me how to deal with this problem?

Thanks a lot

float analogInPin = A0;
float analogInPin1 = A1;
float analogOutPin = DAC1;
float FeqIn, FeqIn1, FeqIn2, FeqIn3, FeqOut, w, Triarea, Recarea, area, n, y, t;

void setup() {
  Serial.begin(9600); // use the serial port
}

void loop() {
  FeqIn1 = analogRead(analogInPin);
  FeqIn2 = analogRead(analogInPin1);
  FeqIn3 = FeqIn1 - FeqIn2
  // integration
  area(1) = 0;
  y(1) = 0;
  for (n = 1; n = t; t++) {
    Triarea(n+1) = (0.5*t(2))*(FeqIn3(n+1) - FeqIn3(n));
    Recarea(n+1) = t(2)*(FeqIn3(n));
    area(n+1) = (Triarea(n+1) + Recarea(n+1)) + area(n);
  }
}

The error message is:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

_02.ino:3: error: 'DAC1' was not declared in this scope
_02.ino.ino: In function 'void loop()':
_02.ino:20: error: expected ';' before 'area'
_02.ino:21: error: 'y' cannot be used as a function
_02.ino:24: error: 'Triarea' cannot be used as a function
_02.ino:24: error: 't' cannot be used as a function
_02.ino:24: error: 'FeqIn3' cannot be used as a function
_02.ino:24: error: 'FeqIn3' cannot be used as a function
_02.ino:25: error: 'Recarea' cannot be used as a function
_02.ino:25: error: 't' cannot be used as a function
_02.ino:25: error: 'FeqIn3' cannot be used as a function
_02.ino:26: error: 'area' cannot be used as a function
_02.ino:26: error: 'Triarea' cannot be used as a function
_02.ino:26: error: 'Recarea' cannot be used as a function
_02.ino:26: error: 'area' cannot be used as a function
'DAC1' was not declared in this scope


texts:
Is there a way to clean up this code...or do some smart coding?

In this example I use 6 relays, in the final code it will be 10.

Also I now use 5 switches and that will be 8, each with an own led. Now I only stated 1 led.

The code reads a button, and a few relays will get a signal. Also the buttonled will go on.
I will add more cases later. But I was wondering, is it possible/easier/just another way of writing the high/low to the relays and leds.

Can I somehow combine the LOWs or HIGHs within a case?

int relay1 = A5;
int relay2 = A4;
int relay3 = A3;
int relay4 = A2;
int relay5 = A1;
int relay6 = A0;

int led1 = 3;

int sw1 = 5;
int sw2 = 6;
int sw3 = 7;
int sw4 = 8;
int sw5 = 9;

int sw1Status, sw2Status, sw3Status, sw4Status, sw5Status;
int order = 1; // default is to set all relays off.

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

  pinMode(led1, OUTPUT);

  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  // input pull-up, so default state of buttons is HIGH.
  pinMode(sw1, INPUT_PULLUP);
  pinMode(sw2, INPUT_PULLUP);
  pinMode(sw3, INPUT_PULLUP);
  pinMode(sw4, INPUT_PULLUP);
  pinMode(sw5, INPUT_PULLUP);

}

void loop() {

  // read the buttons status
  sw1Status = digitalRead(sw1);
  sw2Status = digitalRead(sw2);
  sw3Status = digitalRead(sw3);
  sw4Status = digitalRead(sw4);
  sw5Status = digitalRead(sw5);

  if (sw1Status == LOW) { // if button 1 pressed
    order = 2; // go to case 2
  }
  if (sw2Status == LOW) {
    order = 3;
  }
  if (sw3Status == LOW) {
    order = 4;
  }
  if (sw4Status == LOW) {
    order = 5;
  }
  if (sw5Status == LOW) { // button 4 toggle
    if (order != 7) { // if order is not equal 5 turn on relay 1 & 4
      order = 6;
    }
    else { // else go to case 1, which will turns off all relays
      order = 1;
    }
  }

  switch (order) {
    case 1: // if order equals 1
      digitalWrite(relay1, LOW);
      digitalWrite(relay2, LOW);
      digitalWrite(relay3, LOW);
      digitalWrite(relay4, LOW);
      digitalWrite(relay5, LOW);
      digitalWrite(relay6, LOW);
      digitalWrite(led1, LOW);
      break;

    case 2: // if order equals 2
      digitalWrite(relay1, HIGH);
      digitalWrite(relay2, LOW);
      digitalWrite(relay3, HIGH);
      digitalWrite(relay4, LOW);
      digitalWrite(relay5, HIGH);
      digitalWrite(relay6, LOW);
      digitalWrite(led1, HIGH);
      break;

    case 3: // if order equals 3
      digitalWrite(relay1, LOW);
      digitalWrite(relay2, HIGH);
      digitalWrite(relay3, LOW);
      digitalWrite(relay4, HIGH);
      digitalWrite(relay5, LOW);
      digitalWrite(relay6, HIGH);
      digitalWrite(led1, LOW);
      break;

    case 4: // if order equals 4
      digitalWrite(relay1, HIGH);
      digitalWrite(relay2, HIGH);
      digitalWrite(relay3, HIGH);
      digitalWrite(relay4, LOW);
      digitalWrite(relay5, LOW);
      digitalWrite(relay6, LOW);
      digitalWrite(led1, LOW);
      break;

    case 5: // if order equals 5
      digitalWrite(relay1, LOW);
      digitalWrite(relay2, LOW);
      digitalWrite(relay3, LOW);
      digitalWrite(relay4, HIGH);
      digitalWrite(relay5, HIGH);
      digitalWrite(relay6, HIGH);
      digitalWrite(led1, LOW);
      break;

    case 6: // if order equals 5
      digitalWrite(relay1, LOW);
      digitalWrite(relay2, LOW);
      digitalWrite(relay3, HIGH);
      digitalWrite(relay4, HIGH);
      digitalWrite(relay5, LOW);
      digitalWrite(relay6, LOW);
      digitalWrite(led1, LOW);
      break;

    default: // if none of above cases is valid go to case 1
      order = 1;
      break;
  }
}


texts: Arduino Uno R3 not recognized by computer, TX and RX not blinking, neither are lit. Is it dead?

texts:
I was trying to make my arduino uno r3 to work on my Linux machine (including the IDE), but it wouldn't. At first I thought it was a software problem. Added myself to different groups and did everything, people discussed on the forums. It didn't work. It wasn't recognized by the computer at all. I reinstalled. Nothing again. Thought it was a hardware problem of my computer. Tried with dad's (Windows 7 machine). Didn't work. Then I saw that the two leds (TX and RX) are not blinking, neither are lit. I started doing a research on the internet but everybody suggests doing the loopback test from the IDE. My Arduino Uno R3 is not recognized by the computer, therefore the IDE. Is there any way to check if it's dead or if it's a minor problem?

Edit: I read a lot on the case last night and I reach to the conclusion that my ATmega16u2 (the usb-serial chip, I'm sure it is 16u2 and not 8u2, it's written on the chip itself) might be dead. Tried to reflash the firmware but cannot get it in DFU mode (as it says in this article click here). dfu-programmer (the Linux application) throws the following error: dfu-programmer: no device present. What to do?


texts: Can we detect a magnet using Arduino? If so how?

texts: If so, please tell me and also tell me if any interfacing of other microcontroller needed?


texts:
I have a DHT11 that outputs temperature and humidity values to my serial monitor. I'm trying to serial the COLOUR of the light based on the temperature conditions. So far I only get 1's and 0's. How can I change these integer values to output string say RED, GREEN or BLUE?

Code

#include <dht.h>

dht DHT;
#define DHT11_PIN A5
int redPin = 10; // Red LED,  connected to digital pin 10
int grnPin = 9; // Green LED, connected to digital pin 9
int bluPin = 8;  // Blue LED, connected to digital pin 8

void setup() {
  Serial.begin(9600);
  // Sets the pins as output for RGB LED
  pinMode(redPin, OUTPUT);
  pinMode(grnPin, OUTPUT);
  pinMode(bluPin, OUTPUT);
}

void loop() {
  int chk = DHT.read11(DHT11_PIN);
  int t = DHT.temperature;
  int h = DHT.humidity;
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print( "," );
  Serial.print("Humidity = ");
  Serial.print(h);
  Serial.print("\n");
  delay(60000);
  if((DHT.temperature < 26) && (DHT.temperature >= 23.2)) {
    // Writing the LED colour pins HIGH or LOW to set colours
    digitalWrite(redPin, HIGH); // yellow
    digitalWrite(grnPin, HIGH);
    delay(100);
    digitalWrite(bluPin, LOW);
  }
  if((DHT.temperature < 23) && (DHT.temperature > 20.2)) {
    digitalWrite(grnPin, HIGH); // green
    delay(100);
    digitalWrite(redPin, LOW);
    digitalWrite(bluPin, LOW);
  }
  if((DHT.temperature < 20) && (DHT.temperature > 17.2)) {
    digitalWrite(grnPin, HIGH); // aqua
    digitalWrite(bluPin, HIGH);
    delay(100);
    digitalWrite(redPin, LOW);
  }
  if(DHT.temperature <= 17) {
    digitalWrite(bluPin, HIGH); // blue
    delay(100);
    digitalWrite(grnPin, LOW);
    digitalWrite(redPin, LOW);
  }
  delay(1000);
  // Sensor shouldn't be read too frequently so delay of 1s
}

I will be grateful if I can get some help. Thanks!


texts: Workflow when using Emacs, Arduino-makefile and Serial monitor?

texts:
I'm trying to develop code, compile, upload and use the Serial monitor for debugging of a script for an Arduino Pro Mini. I'm using Emacs as my IDE. I'm having trouble determining the exact sequence of commands to do this most efficiently. What I'd like to do is:

Edit my code, compile and upload from Emacs (able to do this now)
Switch to a window running minicom (or putty, etc.) and observe the debug output.
rinse and repeat

My problem is that now, I have to stop and start minicom each iteration, after I upload the code. Sometimes, restarting minicom causes my Arduino to reboot, and that then displays the debugging output correctly. Sometimes, it takes two minicom restarts to accomplish this. Also, if I don't kill minicom before uploading, it just prints garbage to the screen, and seems to hang. I'm hoping for something like the Arduino IDE Serial monitor, that just runs continuously, and that correctly displays the debugging output.
Ideally, I'd like help coming up with the exact commands to run a Serial monitor that wouldn't require stopping and starting it. Is this possible?
Thanks for all your suggestions and advice.
-Kevin


texts: What's the 2nd ICSP header for in Arduino Uno R3?

texts:
Looking at my Arduino Uno R3 board and its reference design schematic I noticed that there's a second ICSP 6-pin header. In the schematic, the connector I'm referring to is named ICSP1.

What's that for?
What useful things can an average Arduino user like me do with it?

The relevant part of the schematic is below (marked in red).


texts:
I am fairly new(having less hands on experience) to Arduino and electronics in general. I have a project for which I know the features and required electromechanical parts. I need some advice in choosing the right Arduino. Here's my requirement :-
I need the board to handle the following Hardware/Software parts -

3 Geared motors,
1 BLDC 1000 kva
2 cameras ( one is also ok)
TinyML for object detection
Mic to receive audio commands
Speaker to talk back.
Wifi shield to send/receive information to internet or a laptop.
3 small servo motors.
2 Proximity sensor.
1 dc motor (6-9v)

Please advice which Arduino board will be perfect for the above requirements. I was thinking of Arduino Mega 2560, but after looking into various projects I couldn't decide if it was sufficient as I have many hardware parts.


texts: How to address +HTTPACTION:0,600,0 Not HTTP PDU response

texts:
I am using the SIM900A gsm module and trying to connect with my site using a GET request. My issue is that when submitting AT+HTTPACTION=0, I receive a status the response as +HTTPACTION:0,600,0. In this case, the GET request is raised successfully but the response size is 0. In this case, I am not able to fetch a response from the server. The datasheet says the 600 code means "Not HTTP PDU" but I am not aware of how I need to address this. I also sometimes receive code 200, but it is very rare.
following is the response of the AT commands:
AT

OK
AT+COPS?

+COPS: 0,0,"Vi India"

OK
AT+CGDCONT=1,"IP","internet"

OK
AT+CGDCONT=?

+CGDCONT: (1-3),"IP",,,(0),(0)

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","internet"

OK
AT+SAPBR=1,1

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"100.103.109.188"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","mysite.co.in/newlist.php?K=THS&a=35.97&b=18.84"

OK
AT+HTTPACTION=0

OK

+HTTPACTION:0,600,0
AT+HTTPTERM

OK

Thanks in advance for the support.
Edit I have tried further, I have observed that still, the status code still remains the same 0,600,0 status code. However, when I changed the URL to www.google.com, it returns the expected +HTTPACTION:0,200, xxx status code. Please provide some guidance to get the issue resolve.


texts: Clear Timer on Compare or CTC in ATmega328P, Toggle OC0A on Compare Match

texts:
I want to use the CTC on the ATmega328P to play same notes with a speaker, a project that I find in this book.

In the data sheet I read:

  For generating a waveform output in CTC mode, the OC0A output can be set to toggle its logical level on each compare match by setting the Compare Output mode bits to toggle mode (COM0A1:0 = 1). The OC0A value will not be visible on the port pin unless the data direction for the pin is set to output.

So I suppose that after I initialize the CTC and set as output the PIN PD5 (where I connected the speaker) the TCNT0 will change as a sawtooth wave (during time) and the PIN PD5 will be or 0V or 5V depending on the TCNT0 value. Is it correct?

So I change a little bit the code that is in the book:

#include <avr/io.h>
#include <util/delay.h>
#include "scale8.h" //Use to convert C2,C3 ... in numbers, for instance C2 = 100

static inline void initTimer(void) {         //Inializzazione del timer
    TCCR0A |= (1 << WGM01);                  /* CTC mode */
    TCCR0A |= (1 << COM0A0);                 /* Toggles pin each cycle through */
    TCCR0B |= (1 << CS00) | (1 << CS01);     /* CPU clock / 64 */
}

static inline void playNote(uint8_t period, uint16_t duration) {

    TCNT0 = 0;                                 /* reset the counter */
    OCR0A = period;                            /* set pitch */
    DDRD |= (1 << PD5);                        /* enable output on speaker */

    for(int i=0; i<duration; i++){             /* Variable delay */
        _delay_ms(1);
    }

    DDRD &= ~(1 << PD5);                        /* turn speaker off */
}

int main(void) {
    // -------- Inits --------- //
    initTimer();

    // ------ Event loop ------ //
    while (1) {
                                                    /* Play some notes */
        playNote(C2, 200);
        playNote(E2, 200);
        playNote(G2, 200);
        playNote(C3, 400);

        _delay_ms(1000);
        _delay_ms(1000);
        _delay_ms(1000);

    }
    return 0;
}

The problem is that the voltage of the PIN PD5 doesn't change! I try to print the voltage using serial but it's always 0V.


texts: How can I build a simple "Smartwatch" with Arduino Pro Mini and Display?

texts:
I want to know how I can build a simple "Smartwatch" with an Arduino Pro Mini and a Display with a size from maybe 1,5" what Display should I use for Touch and color?

I only want simple things like synchonising the time with my Smartphone trough a HC-06 Bluetooth Module.


texts: Joy-IT RS232 Shield and RS232 voltage levels

texts:
First of all, sorry if this is a dumb question, but I'm pretty new to the whole Serial RS232 concepts.
I do have an Arduino Board that, from what I read about, is not able to communicate via RS232 because of different levels.
My question now is: If the Joy-IT RS232 Shield will make up for that. So is this shield handling the RS232 level shift? I don't really know what to look for so I am asking here.
Thanks!


texts: How to use Infra Red (IR) to reset arduino board

texts:
I am a big noob I know that

but can this code be used to reset arduino board (instead of pressing the usual reset button on the board)

I want to reset the board as If am pressing the reset button using IR

int receiverpin = 2; // pin 1 of IR receiver to Arduino digital pin 2
#include <IRremote.h>
IRrecv irrecv(receiverpin); // create instance of irrecv
decode_results results;
void setup()
{
irrecv.enableIRIn(); // start the receiver
}
void(* resetFunc) (void) = 0; //declare reset function @ address 0

void loop()
{
 if (irrecv.decode(&results)) // have we received an IR signal?
{
if(results.value == 0x2FD847B) //if the button press equals the hex
{
  resetFunc();
}
{
irrecv.resume(); // receive the next value
}
}
}


texts:
I have a brushless motor what is hooked up to a external power supply and I'm using an arduino with a potentiometer to control it. I know that the motor has power but whenever I turn the potentiometer nothing happens. I'm wondering if my wiring is wrong. Here's the wires is connected:

First pin of the potentometer to arduino GND
Second pin of the potentometer to arduino A0
Third pin of the potentiometer to arduino 5V

Black wire of the ESC to arduino GND
Red wire of the ESC to VIN
White wire of the ESC to D8

I'm also using a switch to give both the arduino and motor power and they both seem to turn on fine.

Motor has external power and does twitch very slightly when powered on with this circuit but I can't get is to actually move substantially using the potentiometer.

Here's my code:

#include <Servo.h>//Using servo library to control ESC
Servo esc; //Creating a servo class with name as esc
void setup()
{
esc.attach(8); //Specify the esc signal pin,Here as D8
esc.writeMicroseconds(1000); //initialize the signal to 1000
Serial.begin(9600);
}
void loop()
{
int val; //Creating a variable val
val= analogRead(A0); //Read input from analog pin a0 and store in val
val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)
esc.writeMicroseconds(val); //using val as the signal to esc
}


texts:
I've made a code to make a stepper work together with a HCSR04 sensor. The problem here is that the sensor has to use a delay in order to work. This delay messes with the smootness of the stepper.

If I remove the code for the sensor the stepper runs verry smooth, adding the sensor code causes the stepper to run 'shaky'.

The code:

int trigPin = 11;
int echoPin = 10;

void setup()
{
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor
pinMode(6,OUTPUT); // Enable
pinMode(13,OUTPUT); // Step
pinMode(12,OUTPUT); // Dir
digitalWrite(6,LOW); // Set Enable low
digitalWrite(5,LOW); // Set Step low
Serial.begin(9600);
}

void loop()
{
//rotateleft();
//Serial.println("ik draai nu exact een rotatie linksom");
//delay(1000);
//rotateright();
//Serial.println("ik draai nu exact een rotatie rechtsom");
//delay(1000);
//velocity();

 //sensor
 long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2); //**problem**
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(5); //**problem**
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 Serial.print ("cm:");
 Serial.print (distance);

//eigen creatie
if (distance > 20 && distance < 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(1000); // Wait
}

if (distance > 10 && distance < 20)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(3000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(3000); // Wait
}

if (distance > 1 && distance < 10)
{
  //digitalWrite(13,HIGH); // Output high
  //delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
}

else
{
 velocity();
}

}

void velocity()
{
 digitalWrite(13,HIGH); // Output high
 delayMicroseconds(500); // Wait
 digitalWrite(13,LOW); // Output low
 delayMicroseconds(500); // Wait
}
 }


texts:
My sketch looks somehow like this:

ClassA classA;

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

    classA = ClassA();
    Serial.println("Bar")

    ...
}

void loop() {
    classA.functionFoo();
}

The constructor of ClassA however calls some internal methods that perform a Serial.println().

My problem is, that the first (implicit) call of the constructor of ClassA comes in the first line of the sketch with

ClassA classA;

This is before the Serial interface has been initialized (with Serial.begin(9600)). Therefore the Serial.monitor cannot interpret the first messages coming from the serial interface.

How can I either suppress any Serial.writes before the setup function or otherwise make sure that the Serial interface is initialized before the setup function?


texts:
Hello guys (and gals)!

I'm trying to figure out how to program thresholds using my arduino board.

Essentially, to make this as simple as possible, this is what I have going on.

I am sampling a value every one second, I am taking the value and trying to make certain actions occur based on when this value crosses certain thresholds.

The value read every second will be a value between 0-150.

The thresholds will work something like this:

If value crosses over 20 and becomes 20 or higher, do an action.

If value crosses over 20 and becomes 19.9 or less, do a different action.

And then do the same for a threshold at 30, 40, 50, and 65.

I would need to have it so that if it reads a value of 15, and then a second later, reads a value of 23, it does an action. But if it reads 23, and then reads 24 a next, it needs to not do anything because it hasn't crossed over from one threshold to another. I only want an action to perform if a threshold is crossed either by increasing or decreasing past it.

So again, to reiterate;

If first value read is 34, and second is 42, do an action.

If first value is read at 57, and second at 44, do an action.

If first value is 24, and second value is 26, do nothing. (no threshold was crossed)

The next part would be figured out if a threshold was crossed twice, or more, to do that action twice or more times.

Any advice on how to code this?

Thanks in advance.


texts:
I just recently installed the ESP8266 libraries on the arduino IDE using the boards manager, the code compiles fine with the ESP, but when the board is changed to UNO, i get this error,

opt/arduino-1.6.7/hardware/tools/avr/bin/avrdude: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory

Any solution to this?


texts: One of the LEDs on my Arduino is very dim

texts:
I made a vibration sensor using an Arduino. It is connected to an Android app. When the start button is pressed on the app, a red light LED turns on (stand by), and after 2 - 5 seconds, the red LED turns off and a green LED turns on (meaning the system is ready). The green LED turns off if the sensor detects a vibration. The green LED works perfectly. However, the red LED is always dim. I've tried testing the red LED separately, it works fine. I've tried changing the pin it's connected to, it's still dim. I've included my code below if it helps.

Thanks in advance.

int ledPin = 13;
int ledPin2 = 9;
int EP = 7;
int cal = 500;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(EP, INPUT); //set EP input for measurement
  Serial.begin(9600); //init serial 9600
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '1') {
      cal = 100;
    }
    if (c == '2') {
      cal = 200;
    }
    if (c == '3') {
      cal = 300;
    }
    if (c == '4') {
      cal = 400;
    }
    if (c == '5') {
      cal = 500;
    }
    if (c == '6') {
      cal = 600;
    }
    if (c == '7') {
      cal = 700;
    }
    if (c == '8') {
      cal = 800;
    }
    if (c == '9') {
      cal = 900;
    }
    if (c == '0') {
      int randm = random(2, 6);
      int x = randm * 1000;
      digitalWrite(ledPin2, HIGH);
      delay(x);
      unsigned int tm = millis();
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin2, LOW);
      while (1) {
        long measurement = TP_init();
        char br = Serial.read();
        if (br == 'x') {
          break;
        }
        if (measurement > cal) {
          digitalWrite(ledPin, LOW);
          unsigned int out = millis() - tm;
          unsigned char i = out;
          Serial.print(out);
          break;
        }
      }
    }
  }
}

long TP_init() {
  delay(0);
  long measurement = pulseIn (EP, HIGH);
  //wait for the pin to get HIGH and returns measurement
  return measurement;
}


texts: The Arduino robot tutorials describe a cord comming with the official robot, now I'm confused

texts:
I recently got the Arduino Robot and have been looking at the examples for the RobotLibrary. As I looked, I found something quite confusing (for me at least), a few of them describe connecting a sensor (like an IR sensor or Ultrasonic sensor) to a port with a cable that was provided with the robot. But I never received a cable. Which got me to question, what type of cable is this, because it is not the same cable you would use on an UNO, at least not according to the pictures. So does anyone know what type of cables these are and/or where I can get them? Thanks :smiley-mr-green:

Here are the pictures btw:

And the next one:


texts: To what extent is Javascript used in robots?

texts: I originally discouraged my friend against the use of Javascript in his robot project because I didn't know any use for Javascript outside of web developement but then I saw this book on amazon. Since I wouldn't want to mislead him could someone help me develop a better understanding of how often Javascript is used when making robots with an Arduino?


texts: Adafruit Huzzah Feather not resetting and serial monitor garbage

texts:
Hi there,

I have an Adafruit Huzzah Feather project laid out as you can see in the diagram above.

Currently I am having trouble getting it to reliably reset and start the sketch. More often than not I receive garbage in the serial monitor and the sketch doesn't begin.

The baud rate is set to 115200 and when the sketch occasionally I begin to see the expected behaviour and serial messages.

I have done some tests to see if the serial connection is causing a problem. I uploaded a sketch with and without Serial.begin(115200);. Without this the sketch behaves as expected (I'm flashing an LED sequence to know when the loop has begun). When I add serial communication back I get about 50/50 success rate when resetting.

Here are some thoughts about what could be the problem:

A problem with circuitry. Not sure if something is causing the board to occasionally activate the bootloader? After reading some of the FAQs I'm wondering if I'm accidentally pulling a GPIO pin low. However time has been spent making sure the problematic GPIO pins (0, 2 15) aren't being used.
Possible problem with the board itself - but this is unlikely because there are two of them with exactly the same problem.
Problem with the code. (https://pastebin.com/VAEreu6b)

Any thoughts and suggestions are very welcome at this stage.

Best,
Gareth

EDIT: Forgot to add code. Now here: https://pastebin.com/VAEreu6b


texts: Serial does not work when LiquidCrystal library is used

texts:
I have been struggling with a LCD for 6 hours straight - I've had many problems including random characters showing up, and this time (not quite sure what changed, I tried so many things) as soon as I instantiate a LiquidCrystal object the Arduino stops sending on the Serial port. On the following code, commenting the instantiation of lcd makes "Starting" and "Printing" appear in the serial terminal - otherwise nothing is displayed. Either way, the LCD is desperately blank (black spaces on the entire first line, and I tuned the contrast when random characters were displayed).

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
//RS EN D4 D5 D6 D7
//LiquidCrystal lcd(2, 3, 4, 5, 9, A5);
//RW to GND, VSS to GND, VCC to 5V, V0 to wiper of 5V-to-GND 10k potentiometer

void setup() {
  Serial.begin(9600);
  Serial.println("Starting");
  //lcd.begin(16, 2);
}

void loop() {
  //lcd.setCursor(0, 1);
  //lcd.print(millis() / 1000);
  Serial.println("Printing");
}

I'm using this Arduino Pro Mini, and this LCD. Note that on the Arduino, pins 10 11 12 and 13 are used for a SD (which works), and 6 7 8 are used for a RS232 driver (which is disabled).

Honestly I'm sending a message in a bottle, I'm out of ideas...

The wiring is as explained in the code, I checked it 5 times and it is matching. There is a 10k pot on GND-VO-5V of the LCD, and I haven't wired the backlight.

Edit1: With the LCD active (all lines uncommented) I probed all LCD pins with a 'scope and when it is triggered in Normal, I can see that they all have a pulse every time the LCD is updated (I added a delay in the loop to make it more obvious). HOWEVER pins 9 and A5 take much longer than the others to get back to a high state, around 3 microseconds. Why? It might explain why the LCD doesn't work, but I don't see how it can explain the apparent freeze.

Edit2: Okay, I desoldered pins 9 and A5 and placed the wires on pins A2 A3 instead. The square waves are all square now, and the Serial works - no idea why. And back to square 1, as the LCD prints random characters now...