texts:
I am trying to program an AD5930 with my Arduino Mega, and I suspect that I have a software issue or a broken Mega. I am fairly new to coding Arduino's so I am hoping someone here knows better.

Here is my code:

#include <SPI.h>

#define DATAOUT 51//MOSI
#define SPI_CLOCK  52//sck
#define SLAVESELECT_1 53//ss
#define CNTRL 36//ss

int freq1 = 0;
int BurstLength1 = 0;
int freq2 = 0;
int BurstLength2 = 0;
int PRF_RATIO = 100;

void setup(){
  Serial.begin(9600);
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);
  byte i;
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(CNTRL, OUTPUT);
  digitalWrite(CNTRL, LOW);
  pinMode(SPI_CLOCK, OUTPUT);
  pinMode(SLAVESELECT_1,OUTPUT);
  digitalWrite(SLAVESELECT_1,HIGH); //disable device
  SPI.begin();
  digitalWrite(SLAVESELECT_1,LOW); //Enable device
  SPI.transfer(0x0E);  //Send  Fstart Write Enable to Control Reg
  SPI.transfer(0x13);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0xC7);  //Send Frequency to Fstart one byte at a time
  SPI.transfer(0x4C);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0xD0);  //Send Frequency to Fstart one byte at a time
  SPI.transfer(0x93);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x06);  //Send  Fdelta Write Enable to Control Reg
  SPI.transfer(0x13);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x20);  //Send Frequency to Fdelta one byte at a time
  SPI.transfer(0x00);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x30);  //Send Frequency to Fdelta one byte at a time
  SPI.transfer(0x00);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x10);  //Send Number of Increments
  SPI.transfer(0x02);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x40);  //Send tINT Register
  SPI.transfer(0xEB);
  digitalWrite(SLAVESELECT_1,HIGH);
  digitalWrite(SLAVESELECT_1,LOW);
  SPI.transfer(0x80);  //Tburst Register
  SPI.transfer(0x0A);
  digitalWrite(SLAVESELECT_1,HIGH);
  SPI.end();
}

void loop() {
  digitalWrite(CNTRL, HIGH);
  delay(1);
  digitalWrite(CNTRL, LOW);
  delay(25);
}

I hooked up the Arduino to a logic analyzer and it looks like the code inside the setup function isn't happening. In the logic analyzer we can see that the control pin is being toggled which is the instruction in the loop method.

I know that I am getting a whole cycle as you can see the control pin toggle in the past as well when I trigger on the reset button in the logic analyzer.

This same result of nothing is happening in the ICSP header and pins 51(Data), and 52(Clk).

I hope I am just making a stupid mistake in the code.
Thanks to whomever takes pity on me.


texts:
this is my first post here because I'm a bit lost at the moment.
I currently have my ESP8266-01 hocked up to the Nano like this:

The issue I'm having is that it won't even turn on, only when I'm using the 3.3V pin the red led on the ESP8266 turns on. If connected to 3.3V and I connect the CH_PD pin to 3.3V aswell, the blue led flashes 2-3 times and then the ESP8266 turns off.

I hope someone is able to help me


texts:
I just started working with arduinos recently. I'm really interested in working with relays. I would like to turn a desk lamp on and off using an ios app or a web browser button. I have no experience working with relays but I would love to experiment with relays in order to turn a desk lamp on or off based on an external switch in like an IOS app or a browser.

I am wondering what are the risks in relays with arduino ? I would like to switch a desk lamp on or off using a relay but I don't really understand the risks with creating a desk lamp powered using a wall socket and turned on or off using a arduino relay module . What is the worst case scenario if I screw up ? What are the risks and precautions I should take while working with relays and trying to build a relay controlled desk lamp?

I live in an apartment and I am trying to make sure that my entire building does not lose electricity or I don't screw up the electricity in my unit. What are protective measures that I can take to minimize damages while working on this project?


texts: Detect button on a ground line (reverse eng)

texts:
I've found a circuit board that has a couple of circuits (buttons, IR Receiver, LED, USB). The thing is that following the line for interfacing the buttons I came across what seems to be like buttons that are connected only to the ground line of the PCB while the other end is a free pin cable.

Is there a way for the arduino to detect the ground when the button is pressed or a way to detect a short of some kind? There is a smd and a resistor on both buttons.

Circuit:

Main Ground-----Button-----SMD Capacitor-----Resistor(101)-----Free Pin

Thanks in advance!

Edit: Circuit Board


texts: Why my serial message won't show on another when I try use 2 Arduino communication

texts:
I am trying to make a simple chatting program with my 2 arduino uno and 2 PC. But when I tried write a message using PC1 serial monitor the message won't show up on PC2 serial monitor. I can't see the problem or maybe I miss something on the program.

Here is my code:
PC1:

#include <SoftwareSerial.h>

SoftwareSerial Serial1(10,11);

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

void loop()
{
    if ( Serial.available()) // Check to see if at least one character is available
    {
        char ch1 = Serial.read();
        Serial1.print(ch1);
    }

    delay(200);
}

PC2:

#include <SoftwareSerial.h>

SoftwareSerial Serial1(10,11);

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

void loop()
{
    if (Serial1.available())
    {
        char ch = Serial1.read();
        Serial.print(ch);
    }
}


texts: Bluetooth module HC05 does not react to bluetooth signal from smartphone

texts:
I try to switch off two leds with a hc05 module by sending the signal from my phone.
I know there are a lot of examples on the internet and I tried some of them, but they dont work either. I use a Elegoo Uno R3 and the "Serial Bluetooth Terminal" on my phone. When I try to send a 1 to the HC05 (slave) from my phone it just gives the 1 back, but does not seem to save it in the variable state.
I dont know if the two software serials can be a problem? But when I delete the the Software Serial it still does not work.
Here is my code:

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial Bluetooth(8,9); // RX, TX
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

void printDetail(uint8_t type, int value);
char state;
void setup()
{
  pinMode(7,OUTPUT);  //LED1
  pinMode(6,OUTPUT);  //LED2
  Bluetooth.begin(9600);
  mySoftwareSerial.begin(9600);
  Serial.begin(9600);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true){
      delay(0); // Code to compatible with ESP8266 watch dog.
    }
  }
  Serial.println(F("DFPlayer Mini online."));

  myDFPlayer.volume(30);  //Set volume value. From 0 to 30
}
void loop()
{
  digitalWrite(7,HIGH);
  digitalWrite(6,HIGH);
  static unsigned long timer = millis();
  static unsigned long zeit = 0;

mySoftwareSerial.listen();
  if (millis() - timer > 900000) {
    timer = millis();
    myDFPlayer.next();  //Play next mp3 every 10 minutes
    zeit = millis();
    while(millis()-zeit < 10000){
      digitalWrite(7, !digitalRead(7));  // toggle state
      delay(50);
      digitalWrite(6, !digitalRead(6));
      delay (100);
    }
  }
Bluetooth.listen();
state = Bluetooth.read();
if (state == '1'){
   digitalWrite(6,LOW);
   delay(5000);
  }
}

Your help would be much appreciated.

Best wishes,
CR


texts: How to insert a power button on Arduino Nano

texts:
I've an Arduino Nano to which a Micro Servo 9g is connected. The Arduino board and consequently the servo are powered by a USB powerbank connected to the board with a USB mini cable.

My question is: Is there a way to insert a power switch so I can turn on/off the board without plug/unplug the USB (that now is the way I use) ?
I was thinking to cut the USB cable and work with the positive of it but if someone has an alternative or any tips I'd really appreciate it. Thanks!

EDIT: If is needed I could make a wiring diagram.


texts: How can I program RFduinos and how can I connect them with Bluetooth?

texts: My RFduino dev kit just arrived, and for my project I have to connect a few RFduinos via Bluetooth and light up certain LEDs attached to the RFduinos. If anyone could point me in the right direction as to where I can program them/how I can connect them, it would be GREATLY appreciated.


texts: Arduino non-blocking software PWM LED fader not working

texts:
I am trying to write a simple software PWM to fade some LEDs because I don't have enough PWM I/O Ports.

The code evaluates how long you want the LED to fade, and breaks it down into a number of steps. During each step, it will evaluate the period the LED should be on.

I have the following code:

class Led{
  public:
    Led(int pin);
    void setup();
    // void updateFadeDirection();
    void updateBrightness();

  private:
    int _pin;
    unsigned long _currentTime;
    unsigned long _startTime; // Very beginning of fade period
    unsigned long _fadePeriod; // How long to fade on and off
    int _fadeStep; // current fade step i.e. 1/255
    int _fadeSteps; // How many steps to take until full brightness
    int _fadeDirection; // low to high or high to low?
    float _T_on; // Amount of time to turn LED on
    float _T_fadeStep; // Amount of time per step increment of brightness
    unsigned long _stepTime; // Start of current step period

    bool _evaluated;
};

Led::Led(int pin){
  _pin = pin;
}

void Led::setup(){
  pinMode(_pin, OUTPUT);
  _startTime = micros();
  _fadePeriod = 2*1000000; //microseconds(us)
  _fadeStep = 50; // start at 0 brightness here
  _fadeSteps = 100;
  _fadeDirection = 1;

  _T_fadeStep = _fadePeriod/_fadeSteps; // i.e. 2000000us/100steps = 20000us/step of brightness
  _T_on = (_fadeStep/_fadeSteps) * _T_fadeStep; // i.e. 20/100 * 20000us = 4000us on

  _stepTime = micros();
  delayMicroseconds(200);
}

void Led::updateBrightness(){
  _currentTime = micros();

  if(_currentTime - _startTime < _fadePeriod){
    if (_currentTime - _stepTime > _T_on){
      digitalWrite(_pin, LOW);
    } else {
      digitalWrite(_pin, HIGH);
    }

    if(_currentTime - _stepTime >= _T_fadeStep){
      // _fadeStep++;
      _stepTime = _currentTime;
      _T_on = (_fadeStep/_fadeSteps) * _T_fadeStep;
    }
  }
  else{
    digitalWrite(_pin, HIGH);
  }
}

Led LED0(0);

void setup() {
  LED0.setup();
}

void loop() {
  LED0.updateBrightness();
}

The current behaviour when powered on is the single LED will be turned off, then will turn on after 2 seconds.

In particular, it never seems to enter the else part

  if (_currentTime - _stepTime > _T_on){
    digitalWrite(_pin, LOW);
  } else {
    digitalWrite(_pin, HIGH);
  }

The problem is that the LED will never hit HIGH until the outer else is triggered.

I believe it has to do with _T_on being an int and the timestamps being unsigned long and me not casting it.

The expected behaviour is 2 seconds of dimmed (50%) light, and then a full 100% when it hits the outer else.


texts: Do I need to supply the 12V connection to an HDD

texts: I'm working on trying to control a hard drive with an Arduino Uno, but I'm having trouble with the power supply. From what I know, both the Molex Mate-n-Lok and the new SATA connectors both have 2 grounds, a 5V and a 12V power in. I'm wondering what the purpose of the 12V power supply is. I suspect it's used to drive the motor but I'm not sure.


texts:
Currently using i2C to connect a RPi with an arduino. It seems i2C is quite finicky and, drops the bus immediately if there are any IO errors. Since what i am building is meant to be semi permanent, I am worried that i2C may not be the best choice.

Has anyone done any real world testing of i2C vs GPIO for RPi to arduino communication?


texts: Arduino and MatLab with OWI Robotic Arm Edge -- Issue with I2C

texts:
I'm working on a project where I want to be able to program a robotic arm in Arduino using MatLab. I've used the Arduino Uno with an Adafruit Motor Shield V2.3 and the OWI Robotic Arm Edge kit. The arm is perfectly assembled and works just fine with the standard remote it comes with. All of the connections with the Adafruit Motor Shield are correctly placed, and the shield has been soldered onto pins that connect to the Uno.

I am absolutely positive that the physical and electronic setup is correct. However, whenever I try to move the motors attached to the shield, none of them register. Below is my code:

a = arduino('COM3', 'Uno', 'Libraries', 'Adafruit\MotorShieldV2')
shield = addon(a, 'Adafruit\MotorShieldV2')
addrs = scanI2CBus(a,0);

dcm = dcmotor(shield, 1);
dcm.Speed = 0.01;
start(dcm)

dcm2 = dcmotor(shield, 2);
dcm2.Speed = 0.2;
start(dcm2)

dcm3 = dcmotor(shield, 3);
dcm3.Speed = 0.2;
start(dcm3)

dcm4 = dcmotor(shield, 4);
dcm4.Speed = 0.2;
start(dcm4)

I believe the issue is with the third line:

addrs = scanI2CBus(a,0);

When I run the code, the shield has the following properties:

shield =

motorshieldv2 with properties:

          Pins: A4(SDA), A5(SCL)
    I2CAddress: 96 (0x60)
  PWMFrequency: 1600 (Hz)

So while the I2C address should be 0x60, the actual value of the addrs variable is a 2x1 cell instead of 0x60, as the project demands/specifies as seen in the workspace:

I'm almost certain that this is the reason behind why none of the motors are being registered, but how can I fix it?

Thanks in advance for any assistance! Please let me know if I need to supply more information.


texts:
I have an ATTiny85 connected to an NRF24L01+ module using this wiring diagram: diagram. The ATTiny85 periodically goes in and out of sleep to send some value to a receiver, an Arduino Uno. If the ATTiny is running off the Arduino power supply (3.3v), everything works correctly. When I run the ATTiny off of a separate CR2032 coin cell that delivers around 3v, the Arduino never receives any data. I have a status LED hooked up to the ATTiny to ensure that the ATTiny is waking correctly, which it is. Here's the code for both:

EDIT:
Connecting it to an external 3.3v not from the Uno makes everything work - why wouldn't the coin cell's voltage work? I think everything is rated below 2.8v, the CR2032 minimum.

ATTiny Code

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

// Routines to set and claer bits (used in the sleep code)
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

#define CE_PIN 3
#define CSN_PIN 3 //Since we are using 3 pin configuration we will use same pin for both CE and CSN

#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);

byte address[11] = "SimpleNode";
unsigned long payload = 0;

void setup() {
  radio.begin(); // Start up the radio
  radio.setAutoAck(1); // Ensure autoACK is enabled
  radio.setRetries(15,15); // Max delay between retries & number of retries
  radio.openWritingPipe(address); // Write to device address 'SimpleNode'
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
  delay(500);
  digitalWrite(4, LOW);
  delay(500);
  digitalWrite(4, HIGH);
  delay(500);
  digitalWrite(4, LOW);
  delay(500);
  digitalWrite(4, HIGH);
  delay(500);
  digitalWrite(4, LOW);
  delay(1000);
  setup_watchdog(6);
}

volatile int watchdog_counter = 0;

ISR(WDT_vect) {
  watchdog_counter++;
}

void loop()
{
  sleep_mode(); //Go to sleep!

  if(watchdog_counter >= 5)
  {
    digitalWrite(4, HIGH);
    watchdog_counter = 0;
    payload = 123456;
    radio.write( &payload, sizeof(unsigned long) ); //Send data to 'Receiver' ever second
    delay(1000);
    digitalWrite(4, LOW);
  }
}

//Sleep ATTiny85

void system_sleep() {

  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF

  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  sleep_enable();

  sleep_mode();                        // System actually sleeps here

  sleep_disable();                     // System continues execution here when watchdog timed out

  sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON

}

// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
void setup_watchdog(int ii) {

  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;

  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCR = bb;
  WDTCR |= _BV(WDIE);
}

Receiver Code

#define CE_PIN 7
#define CSN_PIN 8

#include <SPI.h>
#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);

byte address[11] = "SimpleNode";
unsigned long payload = 0;

void setup() {
  while (!Serial);
  Serial.begin(115200);
  radio.begin(); // Start up the radio
  radio.setAutoAck(1); // Ensure autoACK is enabled
  radio.setRetries(15,15); // Max delay between retries & number of retries
  radio.openReadingPipe(1, address); // Write to device address 'SimpleNode'
  radio.startListening();
  Serial.println("Did Setup");

}

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

    radio.read( &payload, sizeof(unsigned long) );
    if(payload != 0){
        Serial.print("Got Payload ");
        Serial.println(payload);
    }
  }
}

Is the problem here that the ATTiny and Uno need to be turned on at the same time to establish a connection, or is it something to do with the battery, or something else entirely? Any help would be appreciated.


texts: Can you drive a stepper motor without the L293D

texts:
Can you drive a stepper motor without L293D.

Don't awnser without giving explanations or saying it will be cheaper to buy the L293D.

Thanks


texts:
My .ino looks roughly like this

#include "command.h"

Command command;
void setup() {
}

void loop() {
}

command.h

class Command
{
    public:
        Command();
};

command.cpp

#include <Arduino.h>
#include "command.h"

Command::Command() {
  Serial.begin(9600);
}

void serialEvent() {
  while (Serial.available() > 0) {
    char inChar = (char)Serial.read();
    Serial.print(inChar);
  }
}

The serial events don't seem to be happening. It works normally if I move the code out of the class.


texts: arduino rfid with led, code is compiling but not working as expected!

texts:
code is compiling, what I want is that when rfid tag kept led should get on but instead its getting to the else loop.

int count = 0;
char input[12]; // rfid input
int led = 3; // led pin
char first[20] = {"270059204B15"}; //rfid tag no
char a[24];

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

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) // code for rfid input
  { count = 0;
    while (Serial.available() && count < 12)
    {
      input[count] = Serial.read();
      count++;
      delay(10);
    }
    Serial.print(input);
  }

  if (strcmp(input, first) == 0) /*comparing two string rfid tag no and input
   if matches led is on*/
  {
    digitalWrite(led, LOW); /* as the board which we are using is in sink
    mode low is taken as 1 or on*/
    delay(500);
    Serial.print("led is on\n");
  }

  else
  { digitalWrite(led, HIGH);
    delay(500);
    Serial.print("led is off\n");
  }
}


texts: RF433MhZ - PWM with a motor driver freezes the code

texts:
LE: I'm almost certain that the problem is noise from the DC motor. I tried with a spare motor laying around and it had no problem, even if it had no capacitor on it's leads. So I tried adding all kinds of capacitors on the present motors, no improvement. I guess I'll search for another wireless solution.
So I want to build a remote controlled car using a cheap 433MhZ receiver and transmitter. I am using this motor driver. I send the values from the joystick to the receiver and based on that I control the motor's direction. The problem is that when I use PWM (or digitalWrite) the receive data code completely freezes (my guess is receiver fault). Other code in the program works so the only problem is in the communication department. I don't think it's a software problem because when I pull out the PWM pin to the motor driver, code starts running again.
I tried with another driver (TB6612FNG), I tried another receiver, I tried another library for 433MhZ (VirtualWire), I tried using SoftPWM library, I tried using a 220 Ohm resistor in series with the PWM signal, nothing works. I put a LED on the PWM pin, no problem.
I'm using two 3.7V lithium batteries as power. The receiver gets 5V directly from arduino. I also tried using a voltage divider to power the receiver directly from the batteries.
Here's the code, it's the last version that uses RCSwitch library for comms, I send the values from the joystick as 8 byte, read the respective bits and based on them I control the motors. Now it has a workaround that if the receive code is not in use, after a period it stops the motors, gets the data, starts motors again, but this is not acceptable.

#include

RCSwitch mySwitch = RCSwitch();

bool up1, down1;
byte recData;

int AIN1 = 10;
int AIN2 = 9;
int BIN1 = 5;
int BIN2 = 6;
unsigned long resetTime;
unsigned long period = 3000;

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
    pinMode(AIN1, OUTPUT);
    pinMode(BIN1, OUTPUT);
    pinMode(AIN2, OUTPUT);
    pinMode(BIN2, OUTPUT);
}

void loop() {
      resetTime++;
  if (mySwitch.available()) {
    recData = mySwitch.getReceivedValue();
    Serial.println("Received ");
    mySwitch.resetAvailable();
    resetTime = 0;
  }
  if (resetTime > period)
      recData = 0;
   up1 = bitRead(recData, 7);
   down1 = bitRead(recData, 6);
  /*Serial.print(currentMillis);
  Serial.print("  ");
  Serial.print(recData);
  Serial.print("  ");
  Serial.print(up1);
  Serial.print("  ");
  Serial.println(down1);*/
  if (up1) {
      analogWrite(AIN1, 255);
      analogWrite(AIN2, 0);
      analogWrite(BIN1, 255);
      analogWrite(BIN2, 0);
    }
    else if (down1) {
      analogWrite(AIN1, 0);
      analogWrite(AIN2, 255);
      analogWrite(BIN1, 0);
      analogWrite(BIN2, 255);
    }
    else {
      analogWrite(AIN1, 0);
      analogWrite(AIN2, 0);
      analogWrite(BIN1, 0);
      analogWrite(BIN2, 0);
    }

}


texts: How to control relay using SIM800 and Arduino Mega through SMS?

texts: For my project I need to control relays through SMS and now I can send SMS from my SIM800 module which is connected to Arduino Mega R3. But I tried several shapes for AT commands to receive SMS and parse it to check sender number and SMS text but every time I received a 2 digits number in serial monitor of Arduino,


texts: Ideal voltage level for attachInterrupt()

texts:
Well I am working on old textile machines, it is taking motor RPM with ISR. I want to read this RPM and publish on web. but the output voltage of this old system is 0 and 22 Volt. (0 Volt when the infrared light comes into the gap in the disk, 22 volt  when the infrared light see the photocell). if I try to read this data I see 17.000 - 18.000 RPM while actual RPM was 1600. I cant read true RPM. I suspect input signal voltages which is 0 and 22 Volts. I don't think Arduino UNO works in this voltage range but I cant see any info at docs. voltage divider with 0 - 2.2 volts I have dropped but still did not work. what is the ideal voltage level for attachInterrupt() command. I am using klon arduino uno (Arduino Uno R3 SMD CH340 Chip - Klon Arduino Uno )

Also are there ane filter  to prevent interference I am using long wire (100 meter)?

this is my code

int encoder_pin = 2; // pulse output from the module
unsigned int rpm; // rpm reading
volatile byte pulses; // number of pulses
unsigned long timeold;
// number of pulses per revolution
// based on your encoder disc
unsigned int pulsesperturn = 12;
void counter()
{
   //Update count
   pulses++;
}
void setup()
{
   Serial.begin(9600);
   pinMode(encoder_pin, INPUT);
   //Interrupt 0 is digital pin 2
   //Triggers on Falling Edge (change from HIGH to LOW)
   attachInterrupt(0, counter, FALLING);
   // Initialize
   pulses = 0;
   rpm = 0;
   timeold = 0;
}
void loop()
{
   if (millis() - timeold >= 1000) {
      //Don't process interrupts during calculations
      detachInterrupt(0);
      rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
      timeold = millis();
      pulses = 0;
      Serial.print("RPM = ");
      Serial.println(rpm,DEC);
      //Restart the interrupt processing
      attachInterrupt(0, counter, FALLING);
   }
}


texts: Would an infinite loop inside loop() perform faster?

texts:
When you're writing a typical sketch, you usually rely on loop() being called repeatedly for as long as the Arduino is running. Moving in and out of the loop() function must introduce a small overhead though.

To avoid that, you could presumably create your own infinite loop, like this:

void loop()
{
    while (true)
    {
        // do stuff...
    }
}

Is that a viable way to improve performance? Will it cause other problems if loop() never returns?


texts:
I have a quirky question today.
I have an Arduino MEGA 2560 with a very simple setup. It's connected to my pc over usb, and has one device connected on its onboard TX/RX2 port group. Whenever I open the COM port on my pc I see a short spike in voltage on the TX2 pin. An analogous behavior happens on even the simplest sketches so I don't think it's the library I'm using to talk to this device.
With the sketch below instead of a short spike in voltage, the TX2 line stays high and when the pc's COM port is opened that TX2 line drops to 0v for maybe a half second.
Not super relevant info about device
It's a Noritake GU140X32F-7000 display. The mfg website doesn't list it's model directly but the
info on the 'B' variant, and it's supplied AVR code, work just fine.

MFG Website for this model>> https://noritake-vfd.com/gu140x32f-7000b.aspx
Code Library>> https://www.noritake-elec.com/codeLibrary.php#gu7000

Relevant bare-minimum code to see this effect on an oscilloscope connected
GRD <-> AVR Ground, POS <-> Pin16(TX2)
void setup() {
  Serial.begin(115200); // Connection to computer
  Serial2.begin(38400); // Connection to TX2 pin 16
  Serial2.write('akjlahsdkjahsdkjlhasdkjhaskldjhaksjhd');
}

uint8_t serialByte = 0;
void loop() {
  if (Serial.available() > 0) {
    serialByte = Serial.read();
  }
}

What happens, which I don't want happening, is after I've had the Arduino draw to the Noritake screen, and I open or reopen the COM port from my pc to the Arduino, the screen blanks itself. Doesn't matter if I use PUTTY, python's serial library with
ser = serial.Serial('COM4', 115200, R timeout=0,parity=serial.PARITY_NONE, rtscts=1)
or Serial Port Monitor's trial version from https://www.com-port-monitoring.com/ via the send dialog - it happens either way.
Especially weird is I don't see data going over this COM port in the Serial Monitor software when the COM port is opened and yet my oscilloscope (fairly crappy DSO138) catches a spike in voltage happen the moment this serial line is opened from my pc. When I use the Noritake library the TX line is normally low when there's no data, whereas the Arduino built in Serial2 line is normally high until there's data. Then when I connect it goes low for about a half second. The code Noritake uses to communicate over this serial line is a bit odd, not actually using the Serial or Stream built in classes, instead opting to write data manually to this port and only including these two external libraries.
#include <avr/pgmspace.h>
#include <util/delay_basic.h>

What causes Serial2 to go low when my PC opens the COM port to Serial on my Arduino? What can I do to prevent it from writing to Serial2?


texts: Getting RTK-precision GPS with arduino devices like NavSpark?

texts:
In trying to learn how to create a reasonably precise 3d model of my (very hilly) property, I stumbled across a product called Navspark, which appears to be a $22 arduino-compatible development board, with an RTK-capable (and RTKlib-compatible) GPS chip.

The idea with RTK is that a reference-position base-station transmits its positional error to a mobile unit, giving the mobile unit cm-level precision relative to the position of the base station. The error calculation is computationally intensive, but apparently within the capabilities of a Pi.

Is it actually possible to build an RTK-capable mobile/base pair using low-priced equipment like this?  Can you link a howto or project example?


texts:
im trying to arrange the vector in descending order but its not happening..

int fibonacci[15]={0, 1};
int a=0;

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

  for (int i=0; i<=14; i++) //loop to create the array
  {
    fibonacci[i+2]=(fibonacci[i])+(fibonacci[i+1]);
  }

  //Now arrange in descending order
  for (int i=0; i<16; i++)
  {
    for (int j=i+1; j<16; j++)
    {
      if (fibonacci[i]>fibonacci[j])
      {
        a=fibonacci[i]; //mux number
        fibonacci[i]=fibonacci[j];
        fibonacci[j]=a;
      }
    }
  }

  for (int k=0; k<16; k++)
  {
    Serial.println(fibonacci[k]);
  }
}

void loop() {
}


texts: how does a bluetooth on android works and what are the best alternative in saving data receive from bluetooth?

texts:
Can anyone confirm this for me although I have tested it myself but when I send a string of data from my android app and send it to arduino say for example data = bluetoothPort.read(); inside an if statement then when I try to use the data in another if statement for example Serial.print(data); inside another if statement it will only show a blank line which let me believe that none of the data are saved. also when a receiving a string of data for example a string of abcde and send it to arduino for example data = bluetoothport.read() and then Serial.print(data) the serial monitor shows abcde as expected but what really happens is data has the value of a then prints then replace by b then print then replace by c then print then replace by d then print then replace by e. Am I wrong or somehow right? are there any work around or parts I need that will make me store data as a whole so that I can use it for other thread or a better code to store string of data?

#include <IRremote.h>
#include <SoftwareSerial.h>

SoftwareSerial bluetoothPort(4,5);
const int RECV_PIN = 12;
const int SEND_PIN = 13;

IRsend irsend;
IRrecv irrecv(RECV_PIN);

decode_results results;
char data;

void setup()
{
   bluetoothPort.begin(9600);
   Serial.begin(9600);
   irrecv.enableIRIn();
}

void loop()
{
   if (bluetoothPort.available() > 0)
   {
       data = bluetoothPort.read(); //received bluetooth data from android
   }

   if(irrecv.decode(&results))
   {
       irreceived(); //received IR code from a remote then sends it to my android
       irsend.sendNEC(data, 32)
   }
 }

 void irreceived()
 {
     Serial.println(results.value, HEX);   //receive value of 489010
     bluetoothPort.println(results.value, HEX); //send value to android
     irrecv.resume();
 }

so the above is a simple sketch that receive data from a remote controller then send it to my android app then when I resend it back to my arduino I would like the data to be able to receive all the data instead of saving it per letter/number and also be able to store it for other statement to use.


texts:
I just got an RFID module which I want to play with.
it came with two sets of headers (pins), both straight and 90 deg.
The pins are not soldered to the shield and I need to decide which and how to solder...

As they are not designated for any specific use (that implies packacging in a specific direction or other constraints) I was wandering if there are any consideration as to which one should I solder to the circuit? and in what orientation?

straight with long pins on the top of the RFID shield? (i.e.
solder the headers as if they where another component on the
shield?)
straight with long pins below RFID shield?
90 Deg on top of the shied pointing out / in of the shield
90 Deg below the shied facing out / in of the shield

Which of these configurations I am least likely to regret :) ?


texts:
How can i send a (file) from PC to Arduino Yun at running time ?

There's a way to send some commands via Serial.
But how would a whole file goes ? Assuming the file can take place at RAM without any problems.

Thanks


texts: get request with ENC28J60 Ethernet module

texts:
I try to make a simple http get request from Arduino uno to my website (shared hosting) where i fetch the data to db.  I use the EtherCard library and ENC28J60 Ethernet module. Here is the code:

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

const char website[] PROGMEM = "xxx.com";

static byte session;
byte hisip[] = { xx,xx,xx,xx };
byte Ethernet::buffer[700];
Stash stash;

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

if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));

ether.printIp("IP:  ", ether.myip);
ether.printIp("GW:  ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);

if (!ether.dnsLookup(website))
Serial.println(F("DNS failed"));

ether.printIp("SRV: ", ether.hisip);

getReq();

}

void loop () {

ether.packetLoop(ether.packetReceive());

const char* reply = ether.tcpReply(session);
if (reply != 0) {
Serial.println(reply);
}
}

static void getReq () {
Serial.println("Sending tweet...");
byte sd = stash.create();

stash.print("unique=unique1&temp=11");
stash.save();
int stash_size = stash.size();

Stash::prepare(PSTR("GET http://$F/laravel/measures/input HTTP/1.1"
"\r\n"
"Host: $D" "\r\n"
"User-Agent: Arduino/1.0" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, website, stash_size, sd);

// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();
}

here is what i get from serial:

IP:  xx
GW:  xx
DNS: xx
SRV: xx
Sending tweet...
HTTP/1.1 200 OK
Date: Fri, 12 Jan 2018 23:40:00 GMT
Server: Apache
X-Powered-By: PHP/7.1.13
Cache-Control: no-cache
Set-Cookie: XSRF-TOKEN=eyJpdiI6IlBnT0ZVZVJwb3ROZkh4Z3ZIUDVrZGc9PSIsInZhbHVlIjoiU0NWZEQ2aSsxT3JlNlp3ek1oRTFtajBsZVVVRUxSMGFQSGpITzFTMWpScEdFZExCXC9rQ1FRT2prbVFyMVJtdnRUazBPY1RBS3JONCt1bVJFQjB1MEVnPT0iLCJtYWMiOiJiZDRjMjZmZjE5ODNlYjBjOTc3NTY4NDM2NmEyMzA2NGU1ZmM1ZGI3MzJjMGY3MjdiN2FmYTg2NDg1NmY1NTFhIn0%3D; expires=Sat, 13-Jan-2018 01:40:00 GMT; Max-Age=7200; path=/
Set-Cookie: laravel_session

and here is what i get from server log:

xx.com xx.xx.xx.xx - - [12/Jan/2018:23:18:12 +0000] "GET http://xx.com/laravel/measures/input HTTP/1.1" 200 - "-" "Arduino/1.0"

however nothing goes on db. If i try it manually from browser it works. Can anyone please give me a suggestion? Server problem, permissions, or code?

Furthermore i tested and this block of code with no result either:

if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/laravel/measures/input/"), PSTR("?unique=unique1&temp=21"), PSTR("http://xx.com"), my_callback);
  }

  ether.packetLoop(ether.packetReceive());


texts:
My SD shield works nicely on 5v supply, but does not detect SD card on 3.3v. Could someone explain the possible reason behind this? Could you also provide a solution for this?

I've worked with it on Arduino Uno. Now I want to use SD card directly with ESP-12E to read its contents using SPI by doing something like this. Since ESP8266 operates olny on 3.3v, I need SD card to work on this voltage.

I've used two separate SD card shields without any luck! Photos of the two shields and micro-SD card are attached.


texts: I am new to electronics and arduino in general. I need to split a power supply in gnd and voltage. Basically, the power supply has one single wire (with the voltage and the gnd passing through it i think), and I need them to be separated. Sorry if this is a noob question, but I am really new to this whole thing.


texts: A problem with measuring time in a for loop

texts:
I am familiar with timing using millis() function, but it seems that I have run into a problem with a for loop.
The thing is, I am comparing encoder readings with a value entered via 4x4 keypad. Since I have to enter more than one value, i placed all values from the keypad into an array. Then I created a for loop that will cycle through that array and compare each value with encoder readings, when encoder reached the entered keypad value an LED should light up for 2 seconds. This is where the problem occurs. When it reaches the set value the LED seems to light up for like a fraction of a second. My guess is that the loop is creating some trouble here. Maybe because the loop cycles so fast the LED doesn't have enough time to stay lit. What do you think?

When I tried this program without a for loop (with only one value entered from a keypad), it works fine.
The code below has two arrays with values already entered, so no need or keypad. I used it just for testing. When I solve this problem I will add a keypad.

Please ask if you need any clarification of the code , and thank you in advance

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

int led1=14;
int led2=15;
unsigned long encoder;
unsigned long prev_value;
int array1[]={100, 200, 300, 400, 500, 600};
int array2[]={150, 250, 420};
int i,j,k,l;
int brV=6;
int brM=3;
int tolerance=10;
unsigned long oldTime=0.0;
unsigned long newTime;
int dt=2000;
bool testRange=true;
bool testRange2=true;

Encoder myEnc(2,3);
LiquidCrystal_I2C lcd1(0x27, 16, 2);

void setup() {
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
lcd1.init();
lcd1.backlight();
}

void loop() {
  newTime=millis();
  lcd1.setCursor(0,0);
  encoder=myEnc.read()*446/400;
  if(encoder!=prev_value){
    lcd1.clear();
    delay(10);
    prev_value=encoder;
  }
  lcd1.print(encoder);
  digitalWrite(led1,LOW);
  digitalWrite(led2,LOW);

  k=brV+brM;

  for(l=0;l<k;l++){
     for(i=0;i<brV;i++){
        if(encoder>=array1[i] && encoder<=(array1[i]+tolerance) && testRange){
           oldTime=newTime;
           digitalWrite(led1,HIGH);
           testRange=false;
         }
         else if(oldTime-newTime >= dt){
          oldTime=newTime;
          digitalWrite(led1,LOW);
         }
         if(encoder>(array1[i]+tolerance){
          testRange=true;
         }
     }
      for(j=0;j<brM;j++){
         if(encoder>=array2[j] && encoder<=(array2[j]+tolerance) && testRange2){
           oldTime=newTime;
           digitalWrite(led2,HIGH);
           testRange2=false;
         }
         else if(newTime-oldTime >= dt){
          oldTime=newTime;
          digitalWrite(led2,LOW);
         }
         if(encoder>array2[j]+tolerance){
          testRange2=true;
         }
      }
  }

  }


texts:
I purchased this toggle switch recently because I want to use it in my project:

But I don't know what to connect up the three pins to and I can't find any information about it online. Nor can I find sample code. Can someone show me how to wire it up and provide sample code please?


texts: Manchester Library Won't Compile for Attiny85

texts:
I am creating a wireless sensor using an Attiny85.  I want to send the data to an arduino uno, so I purchased the 315mhz rf link kit from spark fun.  Since the Attiny85 does not have a TX I decided to use the Manchester library however it won't compile on the Attiny85.

I followed the steps from this blog :
http://mchr3k-arduino.blogspot.mx/2012/01/wireless-sensor-node-part-2.html?showComment=1338749638806#c853067277980266192

Here is the code I am using:

    #include <WProgram.h> //otherwise it says it can't find Arduino.h
    #include <Manchester.h> //include the library to comunicate
    #define TxPin 2 //the pin that is used to send data

 int sensorPin = 4;
 int ledPin = 3;
 int count = 50;

 void setup(){
  pinMode (ledPin, OUTPUT);
  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
  man.setupTransmit(TxPin, MAN_1200); //set transimt pin
}

void loop(){
  if (count == 50){
   digitalWrite (ledPin, HIGH);
   count = 0;
   }
   int data = analogRead(sensorPin);
   man.transmit(data); //transmits and reads the data
   delay (100);
   count ++;
 }

Here is the error message:

/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp: In function 'void MANRX_SetupReceive(uint8_t)':
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:366: error: 'TCCR2A' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:366: error: 'WGM21' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:368: error: 'TCCR2B' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:368: error: 'CS21' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:369: error: 'OCR2A' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:379: error: 'TIMSK2' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:379: error: 'OCIE2A' was not declared in this scope
/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:380: error: 'TCNT2' was not declared in this scope


texts: Arduino Mega failure after first use of Mega Shield power connector

texts:
I have an XDRduino Mega clone with ATmega2560 and ATmega16U2 USB support chip.  I also have a Sensor Shield (same vendor), which provides screw terminals to Vin and Ground.

I connected the board with USB, loaded "Blink", and then changed the time interval.  Next I connected a 20x4 LCD using the Sensor Shield and a breadboard and loaded LCD "Hello world".  All seemed fine with the new board.

Each time I powered on or reset the Mega, the TX and RX LEDs flashed a couple of times and then my sketch started running.

Then I disconnected it from the PC (no USB for power anymore) and connected a (working from another project) S-60-12 power supply, DC Output 12V 5A to the shield screw terminals.  I verified polarity -V to GND, +V to VCC.

OK, I swear I hooked it up correctly.  But if you tell me that hooking it up backwards would explain all the symptoms below, then yes I'll believe you that I screwed up {sob}.

(And yes, you're right, there is no diode protection on Vin, just on the dc power jack.  Dummy me.  Double dummy me, as there was a screw type power plug laying unused on the bench {groan}.)

About 4 seconds later, I heard a snap and immediately pulled the plug on the power supply.  Yes, something probably smoked, but let's refine at bit, please.

I moved the Mega to my PC, (disconnecting the external power supply so to use only USB for power).  It is no longer recognized as a USB device, and the Arduino IDE (1.6.5) no longer finds the USB serial port.

Voltages at 3.3V pin and 5V pin are correct.  I've also probed the regulator and comparator and all looks well for the power circuitry. F1 is not blown (or there would be no power as USB is the only source).

Item: The TX and RX leads are on solid.  I expected them to flash then turn off.  (Power LED is on solid, which is normal.)

Item: The reset pin for the Mega reads 1.41 V.  It's connected through a 10K pullup to +5 V (reads 4.63 at USB pin, 4.53 at the 5V pin).  This seems way too low.

Item: The reset pin for the 16U2 reads V+ (4.35) and is has a 10K pull-up.

Item: AREF is 50 mV.  I believe it should be 1.1 V or 2.56 V.

Question: Is it reasonable to think the 2560 may be dead, and the LEDs are on because the 16U2 can't talk to it?  Any way to test this theory?

(If the 16U2 were bad, it would still be possible to program the 2560 via the ICSP header, thus salvaging something...)

Question: The 16U2 won't do the USB connection dance with the PC because the 2560 is dead?  Should the 16U2 to try to connect no matter what the state of the 2560?.

Question:  If the 16U2 is dead, should TX and RX LEDs be lit?

Question:  If I had reversed the hookup, should not the regulator (P1117 chip) have saved me?

Question:  Has anyone else had a failing component (other than the 2560 & 16U2) with these symptoms?


texts: Vin pin vs USB vs Barrel connector: Wemos D1 R2

texts:
@Majenko says in the leading (19 Upvote) answer here not to use VIN and USB socket at the same time.

  You must never ever connect VIN to a power source and connect the USB socket. That can destroy the USB port in your computer. There is zero back-powering protection on [LoLin v3 board] board.

I need to do diagnostics on my Wemos (LOLIN) D1 R2 V2.1.0 while it's connected via 9-12V barrel jack and the Vin pin connected to an L9110H H-bridge as an output (bridge input).

Does the Wemos (LOLIN) D1 R2 V2.1.0 (ESP8266) work like this as well? Would I be able to run diagnosics with Serial through my USB socket while running this setup?


texts:
when i execute the python script, the arduino response but the code between the if(Serial.available()) not responding.

python script

 import  time, serial
 arduino = serial.Serial('COM7', 9600)
 time.sleep(2)
 while True:
    arduino.write(str(input("1")))                  # write position to serial port
    # and the pysthon script cant read the code below this line
    reachedPos = str(arduino.readline())            # read serial port for arduino echo
    data.append(reachedPos)
    arduino.close()

arduino script

 #include <Servo.h>
 Servo servo;
 int angle = 0;
 String in;
 int pos = 1;

void setup() {
 servo.attach(7);
 Serial.begin(9600);
 servo.write(0);

}

void loop() {
if(Serial.available())  // if data available in serial port
{
in = Serial.readStringUntil('\n');
Serial.print(in);
pos = in.toInt();
  if(pos == 1){
if(angle == 0){
  servo.write(180);
  delay(10);
  angle = 180;
  delay(1000);
}

if(angle == 180){
  servo.write(0);
  delay(10);
  angle = 0;
  delay(1000);
}}
}
}

What is the problem?
Te arduino code works fine


texts: How can I upload a sketch remotely from a distant location onto an arduino that is power by a battery

texts: Of course after developing a success full embedded product the next step would be making upgrades to compete favorably with new products in the market. Well making upgrades would require making adjustments in the sketch and Uploading it onto already made prototypes to cub the costs involved in by the hardware of a remotely located prototype. How can one upload a sketch from his location on to the prototype without going there psychically to upload through the port?


texts: SIM 900 + Arduino Mega attachGPRS problem, GPRS_READY

texts:
I have connected my GSM module to my Arduino. Using AT commands I am able to connect to internet.
  Using the following link of tutorials, I tried to connect to internet
http://arduino.cc/en/Tutorial/GSMExamplesXivelyClient
  In this the device is showing not connected. So I tried to debug it. In the attachGPRS
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)

gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD = 2

and GPRS_READY = 4

Why is this happening? What is GPRS_READY ?


texts:
I found a bunch of Arduinos (seemingly), but I can't identify the type.

I first thought of a Micro, but the chip is a MEGA328PAU and the Micro should have a MEGA32U4 instead:

I know it's also not a Nano, because the Nano is a bit longer:

Next, I looked up the List of Board Specs. Based on the chip, the following models remain:

Lilypad, can easily be excluded due to its shape
Lilypad SimpleSnap, can easily be excluded due to its shape
Uno, can easily be excluded due to its size
Ethernet, can easily be excluded, because of the Ethernet port
Mini
Pro
Pro Mini

So I am left with Mini, Pro Mini and Pro. The back of the board is not very helpful, since it IMHO misses the markers in the silk sceen:

It definitely looks like the Pro Mini from Arduino Store, but the Arduino store seems not to offer the Mini and Pro, so I don't have a comparison.

What type of Arduino is this? And, if possible, do you have a visual comparison of the three remaining types?


texts:
I am trying to build a system, that plays specific audios (.wav files) from a SD-Card, according to the key combination that has been pressed.
I am using:

4x4 Membrane
4 Ohm Speaker
MicroSD Card Adapter Module
TIP120 Transistor (for amplification)
Arduino NANO clone (https://www.amazon.de/gp/product/B0755XYBG4)

So I broke the project down in various steps:

playing .wav file from the SD Card (works fine)
using keypad (works fine)
combinig both (as you may have guessed: does not work)

Here are the codes I used for every step:
1)
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

void setup() {
  tmrpcm.speakerPin = 9;
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }

  tmrpcm.setVolume(5);
  tmrpcm.play("test.wav");
}

void loop() {}

This plays test.wav one time after uploading or resetting.
2)
#include <Keypad.h>

// Definition für das Keypad von Elegoo
const byte ROWS = 4; // vier Zeilen
const byte COLS = 4; // vier Spalten
// Symbole auf den Tasten
const byte rows[ROWS] = {2, 3, 12, 5};//connect to the row pinouts of the keypad
const byte cols[COLS] = {6, 7, 8, 11};//connect to the column pinouts of the keypad

char keys[ROWS][COLS] = { //create 2D arry for keys
  {'D', 'C', 'B', 'A'},
  {'#', '9', '6', '3'},
  {'0', '8', '5', '2'},
  {'*', '7', '4', '1'},
};

// Instanz von Keypad erzeugen, Keymap und Pins übergeben
Keypad customKeypad = Keypad(makeKeymap(keys), rows, cols, ROWS, COLS);

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

void loop() {
  // Gedrückte Taste abfragen
  char customKey = customKeypad.waitForKey();
  Serial.println(customKey);
}

This code prints out every pressed key.
3)
#include <Keypad.h>
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

// Definition für das Keypad von Elegoo
const byte ROWS = 4; // vier Zeilen
const byte COLS = 4; // vier Spalten
// Symbole auf den Tasten
const byte rows[ROWS] = {2, 3, 12, 5};//connect to the row pinouts of the keypad
const byte cols[COLS] = {6, 7, 8, 11};//connect to the column pinouts of the keypad

char keys[ROWS][COLS] = { //create 2D arry for keys
  {'D', 'C', 'B', 'A'},
  {'#', '9', '6', '3'},
  {'0', '8', '5', '2'},
  {'*', '7', '4', '1'},
};

// Instanz von Keypad erzeugen, Keymap und Pins übergeben
Keypad customKeypad = Keypad(makeKeymap(keys), rows, cols, ROWS, COLS);

void setup() {
    tmrpcm.speakerPin = 9;
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("SD fail");
    return;
  }
}

void loop() {
  // Gedrückte Taste abfragen
  char customKey = customKeypad.waitForKey();
  Serial.println(customKey);

  if (customKey == 8) {
    tmrpcm.setVolume(5);
    tmrpcm.play("test.wav");
  }
}

This code should play test.wav if key 8 is pressed.
THE PROBLEM
So the problem is not that there is no sound at all, but its just completely distorted. The sound quality never was great but sufficient. Now it sounds like "too much signal" is coming onto the speaker and interferes with the audio. Even if there shouldn't be any audio playing, machine-like sounds are produced by the speaker. By slowly working through the code I managed to find the line that probably causes the problem:
char customKey = customKeypad.waitForKey();
Serial.println(customKey);

If put it in a comment and put
tmrpcm.setVolume(5);
tmrpcm.play("test.wav");

in the setup function the audio is played.
I tried a lot and it doesn't matter where you put the getKey line (or change it to waitForKey()), as long as this line is somewhere in a function the sound is distorted.
Why does this happen? How can i work around it?
Can anybody please help me with this? :)
wiring diagram


texts: How do I receive more that 64 bytes with Arduino

texts:
I am using QtSerialPort to send and receive data from Arduino. I am sending more than 64 bytes (125, 220, more), I receive the data with Arduino, and trying to sending back the same data, but Arduino sending only 64 bytes in its response. Then I am thinking that the problem is with Arduino buffer. I am trying to clear the data but without result.

Here is my Arduino code:

void loop() {
    if (Serial.available() > 0) {
        int i = 0;
        delay(500);
        int size = Serial.available();
        while (i < size)
            buffer[i++] = Serial.read();

        Serial.print(buffer);
        //delay(500);
        int j = 0;
        while (j < size)
            buffer[j++] = '\0';
        //while (Serial.available()) Serial.read(); I tried it
        //Serial.flush();   Also tried it, but nothing.
    }
}


texts: Attempting to monitor serial output for a string to trigger function, apparently matching string is output but the function doesn't trigger

texts:
I'm working on my second Arduino project, and am somewhat stuck.

I'm running a PIR module from my Arduino Uno with the following sketch:

/*
 *  PIR Sensor test
 */

 int pirPin = 6;

 int minSecsBetweenEmails = 60; // 60 seconds

 long lastSend = -minSecsBetweenEmails * 1000l;

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

  Serial.begin(9600);
 }

 void loop() {
  long now = millis();
  if (digitalRead(pirPin) == HIGH)
    {
       if (now > (lastSend + minSecsBetweenEmails * 1000l))
        {
            Serial.println("MOVEMENT");
            lastSend = now;
        }
      else
        {
          Serial.println("Too soon");
        }
    }
        delay(500);
 }

I'm monitoring the COM3 port using the following in JupyterLab with PySerial.

import time
import serial
import smtplib

to = 'myemail@myemail.com'
GMAIL_USER = 'myemail@myemail.com'
GMAIL_PASS = '**********'

SUBJECT = 'MOTION pir'
TEXT = 'PIR sensor detected motion'

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

def send_email():
    print("Sending Email")
    smtpserver = smtplib.smtp("smtp.gmail.com",587)
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(GMAIL_USER, GMAIL_PASS)
    header = str('To:' + TO + '\n' + 'From: ' + GMAIL_USER)
    header = header + '\n' + 'Subject:' + SUBJECT + '\n'
    print (header)
    msg - header + '\n' + TEXT + ' \n\n'
    smtpserver.sendmail(GMAIL_USER, TO, msg)
    smtpserver.close()

while True:
        message = ser.readline()
        print(message.decode('utf-8'))
        if message[0] == 'MOVEMENT' :
            send_email()
            time.sleep(0.5)

I believe my problem is with the ser.readline() function. I've been reading the docs, they seem to say I need to provide some kind of endpoint or timeout for the function to provide for EOF, but my goal was to have the

if message [0] == 'MOVEMENT' :

continuously evaluate the output lines from COM3...

Any input at all would be very much appreciated.

EDIT: Thanks to all three of you for your help! By changing the Python as shown below I was able to fulfill the if message[0] == 'MOVEMENT' :statement

Python should have been:

import time
import serial
import smtplib

to = 'myemail@myemail.com'
GMAIL_USER = 'myemail@myemail.com'
GMAIL_PASS = '**********'

SUBJECT = 'MOTION pir'
TEXT = 'PIR sensor detected motion'

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

def send_email():
    print("Sending Email")
    smtpserver = smtplib.smtp("smtp.gmail.com",587)
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(GMAIL_USER, GMAIL_PASS)
    header = str('To:' + TO + '\n' + 'From: ' + GMAIL_USER)
    header = header + '\n' + 'Subject:' + SUBJECT + '\n'
    print (header)
    msg - header + '\n' + TEXT + ' \n\n'
    smtpserver.sendmail(GMAIL_USER, TO, msg)
    smtpserver.close()

while True:
        message = ser.readline()
        print(message)
        if message == b'MOVEMENT\r\n' :
            send_email()
            time.sleep(0.5)


texts:
I am using the Grove - Slide Potentiometer (http://wiki.seeedstudio.com/Grove-Slide_Potentiometer). How can I set the potValue so that at maximum it will 128?

int potPin= A0;
int readValue;
int potValue;

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

void loop() {
 readValue = analogRead(potPin);
 potValue = (255./500.) * readValue;
 Serial.print("You are writing a value of ");
 Serial.println(potValue);
}


texts: Unable to interface using Softserial with ESP8266 and Arduino uno

texts:
I am trying to use a ESP8266 in an Arduino project, but I'm unable to get the basic Software serial interface working with it.

I have the ESP connected to a secondary 3.3v power supply. When connecting the RX and TX pins to the Uno's RX and TX, and uploading bare minimum code, I am able to interface with the module. Doing this I can connect to networks, send and receive packets, etc.

However, when connecting the ESP to any other pins and trying to implement a software serial interface, I am unable to get any response from the module. When sending it data I see the on board blue LED flash, so I think its receiving the data? I've found tons of example codes and Youtube videos that do what I'm trying to do. But following their steps I'm still not able to get any response.

I've tried using voltage divider circuits for the ESP's RX pin so its not getting 5v, but that hasn't seemed to change anything either. Any troubleshooting advice would be greatly appreciated.

One of the basic codes I've tried to get this to work:

#include <SoftwareSerial.h>

SoftwareSerial wifi(8,9);

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

  Serial.println("started!");

}

void loop(){
  if(Serial.available() > 0){
    byte b = Serial.read();
    Serial.write(b);
    wifi.write(b);
  }

  if(wifi.available() > 0){
    byte b = Serial.read();
    Serial.write(b);
  }
}


texts: Motor isnt spinning when using L298N motor controller

texts:
I have a L298 motor controller connected to a motor with a 6 volt power sources. the motor however isn't spinning any ideas I'm using a esp 8266 node mcu board. I would like to use pwm but for right now I'm just trying to get it to work so I disabled the pwm.

//int d0 = 16;
const int d0 = 16;
const int d4 = 2;

//=======================================================================
//                    Power on setup
//=======================================================================
void setup() {
  Serial.begin(115200);
  pinMode(d0,OUTPUT);
  //pinMode(d1,OUTPUT);
  pinMode(d4,OUTPUT);
}

//=======================================================================
//                    Main Program Loop
//=======================================================================
void loop() {
  //PWM Value varries from 0 to 1023
  Serial.println("10 % PWM");
  //analogWrite(d0,102);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("20 % PWM");
  //analogWrite(d0,205);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("40 % PWM");
  //analogWrite(d0,410);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("70 % PWM");
  //analogWrite(d0,714);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("100 % PWM");
  //analogWrite(d0,1024);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

}


texts: how to send input values from host computer to arduino,such that speficing the number of rotations for a stepper motor etc


texts:
I want to connect NRf24 module with digispark and use USB capabilities at same time.
currently, i use this conexion diagram:
               NC      PB5  1|o   |8  Vcc --- nRF24L01  VCC, pin2 --- LED --- 5V
nRF24L01  CE, pin3 --- PB3  2|    |7  PB2 --- nRF24L01  SCK, pin5
nRF24L01 CSN, pin4 --- PB4  3|    |6  PB1 --- nRF24L01 MOSI, pin6
nRF24L01 GND, pin1 --- GND  4|    |5  PB0 --- nRF24L01 MISO, pin7

Bu my problem is that as you see in this diagram CE and CSN are in the USB + and - pins:

I just want that my module receive data so, i think that if i power up every time CE pin and i change CSN pin to PB5 this may work but, in fact this don't
I can't use 3 pin connexion because i don't have capacitor and my project is for Wednesday
Thanks in advance for your help


texts:
I am trying to send color() data from Processing to Arduino.

Here is my code from Processing:

import processing.serial.*;
Serial myPort;

void setup(){
  myPort = new Serial(this, Serial.list()[7], 9600);
}

void draw(){
  color[] c1 = {color(99,0,0),color(255,0,0) };
  for (int i = 0; i < c1.length; i++ ){
    int value = int(red(c1[0]));
    myPort.write(value);
    println(value);
    delay(2000);
  }
}

It sends the 99.0 data to Arduino. Here is the Arduino code for getting:

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

void loop(){
  while(Serial.available() > 0){
    int recieved = Serial.read();
      Serial.print(recieved);
    }
}

The problem is when Arduino receive data it doesn't take one by one. When i watch Arduino serial monitor, the data comes at different chunks like, 9...99...999..9.. etc.

I am trying to send several color info from Processing into arduino, it might be a long array of value. What is the best way to achieve this?


texts: I'm using GPIO api and configure it as input pull down. It reads value 0. However, when I use power meter, and connect this gpio and ground, it shows 3.3V. Is it normal or maybe some other peripheral module actually pull this gpio high? To reduce power consumption, should I connect this gpio to 3V3 and configure it as input pull high? Thanks.


texts:
I'm new to Arduino. For my first project,  I want to make aviation strobe lights. My challenge is to use ONE Arduino to blink both sets of lights. My issue is,  I DON'T want them to be synchronized. I saved a sketch of the blink example from the Arduino IDE software after editing it to do what I want. But, the LED's are synchronized. One LED strobes twice,  while the other strobes once as I want them to. However, they begin their loops together currently and stay synchronized,  which isn't what I want.

So my question is: What is the code I need to write to make each LED blink unsynchronized from the other without having to use 2 Arduino units?

Code:

int led = 11;
int led2 = 12;

void setup() {
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
}

void loop() {
  digitalWrite(led, HIGH);
  delay(50);
  digitalWrite(led, LOW);
  delay(1000);
  digitalWrite(led2,  HIGH);
  delay(50)
  digitalWrite(led2, LOW);
  delay(100) ;
  digitalWrite(led2,  HIGH);
  delay(50)
  digitalWrite(led2, LOW);
  delay(1000);
}


texts: I want to attach multiple servos to Arduino but all them must receive same command. If it possible to connect all servos to one command pin (I don't want to use "for" in code to minimize processor time for operation)?


texts:
ok, I feel like this should be simple, but I am at a loss

Simple code mock up to send 4 bytes(mimicking a float)  over I2C from Arduino to rpi. I am trying to create a state machine so that I can request certain "registers" containing 4 bytes each. I send a byte from pi to arduino indicating what "register" I want, then read back 4 bytes.  I was attemping to reset the state back to NO_STATE after the end of the switch statement, but it effects the bytes received by the pi, and I dont see how.

#include <Wire.h>
#define SLAVE_ADDRESS 0x04

//States
#define NO_STATE 0x00
#define GET_BAT_TEMP 0x03

byte state = NO_STATE;
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  Wire.begin(SLAVE_ADDRESS);
  Wire.onReceive(receiveData);
  Wire.onRequest(sendData);
}

void loop() {
  delay(100);
}

// callback for received data
void receiveData(int byteCount){

  while(Wire.available()) {
    state = Wire.read();
  }
  Serial.print("Got:");
  Serial.println(state);
}

// callback for sending data
void sendData(){
  Serial.println("Sending...");
  byte b[4]={1,1,1,1};

  switch (state){
    case NO_STATE:
      //bad state   not sure if can return only byte, may need to return 4 zeros or somthing
      Wire.write(0);
      Wire.write(0);
      Wire.write(0);
      Wire.write(0);
      break;
    case GET_BAT_TEMP:
      //send battery temp
      Wire.write(3);
      Wire.write(3);
      Wire.write(3);
      Wire.write(3);
      break;
    default:
      Wire.write(9);
      Wire.write(9);
      Wire.write(9);
      Wire.write(9);
      //send back error code
  }
  //reset state to none
  state=NO_STATE;

}

with this code I receive [3,0,0,0]

if I comment out the line

//state=NO_STATE;

I then receive back [3,3,3,3]

which is what I would expect. But I do not see how reseting the state "after" all the bytes are sent would cause an issue

output from arduino shows entering that function only once, and sending the 4 bytes

Got:3
Sending...
Sending...
Sending...
Sending...


texts: I2C 2 way communication between Arduino Uno and Arduino Mega

texts:
If I remove the transmission code from slave this works properly but I need to transmit from slave.

Here is my master code

#include <Wire.h>
void setup() {
  Wire.begin(3);
  Wire.onReceive(receiveEvent);
}
byte x = 0;

void loop() {
  Wire.beginTransmission(9);
  Wire.write("s");
  Wire.write(x);
  Wire.endTransmission();
  x++;
  delay(500);
}

void receiveEvent(int howMany) {
  if(Wire.available()){
    int x = Wire.read();
    Serial.println(x);
  }
}

Here is my slave code:

#include <Wire.h>
void setup() {
  Wire.begin(9);                // join i2c bus with address #9
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop() {
  delay(100);
}

void receiveEvent(int howMany) {
  if(Wire.available()){
    char c = Wire.read();
    Serial.print(c);
    if(c == 's'){
      int x = Wire.read();
      Serial.println(x);
      //transmit to master
      Wire.beginTransmission(3);
      Wire.write(1);
      Wire.endTransmission();
    } else {
      Wire.read();
    }
  }
}

Is it possible not to use Wire.onRequest(requestCallback); to send data to master? Kindly help.


texts: LCD Display Flicker When Arduino Main Board Supply Voltage to GSM Shield Board

texts:
I have a 16x2 LCD display that is connected to an Arduino microcontroller.
It is working fine but the LCD display flickers when I connect the Vin and GND of the main board to its slave GSM Shield.

I used main board Vin and GND to power up the GSM Shield so I only have one power supply. I was able to power up GSM Shield by adding jumper to Vin and GSM +Vin.

In additional question, is there any other way to power up Arduino GSM Shield without connecting it to another power source to still keep having only one plug for power?


texts: FastLED library: How can I adjust the brightness of a single pixel on an absolute scale?

texts:
I'm using the FastLED library to control a digital RGB LED strip.

While this library seems very comprehensive in capability and ease of use, I do not yet see a way to simply set the brightness value of a individual pixel on an absolute scale. In other words, I want to simply set the brightness of a pixel, without passing a hue or saturation, and without it effecting other pixels.

FastLED.setBrightness() scales down the brightness of all pixels.
leds[i].fadeLightBy() scales down an individual pixel, but if it's called again for the same pixel before updating the LEDs, then the pixel will be faded again from it's already-faded value.

Is there truly no built-in method for setting the brightness of individual pixels to a particular value?


texts: Enternal Analog Reference mode not compiling in Arduino + Intel Galileo Gen 2

texts:
I am trying to use external voltage reference in Intel Galileo gen 2 operating in Arduino mode.

So I created a setup code like this:

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

  // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL); // use AREF for reference voltage
}

I selected the board as Intel Galileo Gen 2 in Tools option. When I compiled I am getting the following error:

LM35_temp_sensor.ino:21:19: error: 'EXTERNAL' was not declared in this scope

But when I change the board to Arduino Uno in Tools option, the program in compiling fine.

This means that Intel Galileo Gen 2 does not support external analog voltage reference?


texts: Use SPI and I2C in the same circuit (ATtiny85/84)

texts:
There is a previous question about this same topic here, but it does not answer my question.

I want to use a generic I2C OLED 128x64 px display and an SPI RF24 radio in the same sketch. I know that it's theoretically possible to do so as long as they're not used at the same time - my question concerns the implementation of this circuit. Can I just leave the two devices as-is without needing some kind of external apparatus to switch power to each one of them?

I know that for SPI a chip will just ignore everything when its CS pin is pulled high, and from my tests the SPI communications don't affect the SDA line of the I2C - the problem comes when I try and use the CLK and SCL line with this setup. The pullup resistor in my circuit is stopping the I2C SCL line from working. When I remove the wire (green in the breadboard schematic shown) that connects the CLK to one end of the diode the I2C starts working and the display updates, but the radio doesn't work. If I remove the pullup resistor from the circuit the I2C starts working again, but the radio doesn't work anymore. I tried switching the CLK signal with a transistor, but it doesn't look like the 2n2222 transistor I was using is fast enough to switch the CLK signal. Will I have to go with the tiny84, or is there a way to get this to work on the ATtiny85?


texts: Problem with reading multiple potentiometer values on Arduino Uno

texts:
I'm working on an Arduino sketch that will read in values from two potentiometers. The code for this is below:

int lastPotentiometerOneValue = 0;
int lastPotentiometerTwoValue = 0;

void setup() {
  // initialize serial communication at 57600 bits per second:
  Serial.begin(57600);
}

void loop() {
  delay(10);
  readAndSendPotentiometerDataIfChanged();
}

void readAndSendPotentiometerDataIfChanged(void) {

  //Potentiometer One
  int newPotentiometerOneValue = analogRead(A0) / 10.2;
  if (newPotentiometerOneValue == lastPotentiometerOneValue) return;

  Serial.print("!pos1");
  Serial.print(newPotentiometerOneValue);
  Serial.print(";");
  lastPotentiometerOneValue = newPotentiometerOneValue;

  //Potentiometer Two
  int newPotentiometerTwoValue = analogRead(A1) / 10;
  if (newPotentiometerTwoValue == lastPotentiometerTwoValue) return;

  Serial.print("!pos2");
  Serial.print(newPotentiometerTwoValue);
  Serial.print(";");
  lastPotentiometerTwoValue = newPotentiometerTwoValue;
}

The schematic for my circuit is below (I've left out the code for reading the state of the push-button in my listing above, as that's in a separate method from the method that reads in the potentiometer data):

However, there seems to be a rather subtle error I'm experiencing. If I turn Potentiometer One, it will display the correct output in the serial monitor. If I turn Potentiometer Two, no value will be displayed. However, if I remove Potentiometer Two from the circuit board and turn Potentiometer One, then the serial monitor will display the Potentiometer Two as having the same data as Potentiometer Two.

I'm sure the problem is with my circuit, but I'm not quite sure what I'm doing wrong. Does anyone have some insight? Thank you!


texts: What is the difference between Tools > Board settings in Arduino IDE? ex: ESP32-Dev v. Huzzah32

texts:
I had a recent memory issue where the resolution was to change the Tools > Partition setting.  However this setting wasn't available in the Arduino IDE for the boards I was using (Huzzah32 and NodeMCU-32s).  I changed the board setting to ESP32-Dev Module, and the addition menu items under Tools appeared.  My project compiles and works fine now.

However it never occurred to me to set the Board to the "wrong" type.  What's the purpose of a vendor specific board setting when the more generic one appears to work fine?  What settings should you use and under what circumstance?

My guess is that the vendor specific board settings are more about the peripheral hardware on the boards (USB ports, LEDs, etc) and that the more of those you are using the more likely you'll need to use a board specific setting.   In my case, since my project uses just the WiFi and Bluetooth built into the ESP32 chip itself, that I'm ok, but if I was using a bunch of GPIO and other things I'd need to use the actual Huzzah32.  Is that right?


texts:
I am currently testing a small Arduino Nano project (schematic below) and have encountered issues when communicating between a HC-05 Bluetooth module and the Arduino. I am using a simple LED bulb which I am trying to turn on and off from a phone which is connected to the HC-05. The HC-05 is powered separately by some batteries instead of being powered by the Arduino itself. The Bluetooth connection is functional, and so is the actual LED functionality on the Arduino, but there seems to be a problem when I am trying to send stuff through the RX/TX connection. I previously attempted this without a voltage divider and had the same problem. Am I using the right resistors for the voltage divider or should I step them up to 1k and 2k respectively? I measured the voltage on the RX/TX and for some reason it only amounts to around 1.5V (instead of the desired 3.3V). Is there any other issue I am not seeing?

Edit: I also measured the voltage on the RX/TX without the voltage divider and somehow it's straight up 0. Why would that be?


texts: How to power two stacked motor shields with one 3S Lipo battery (11.1V)?

texts:
I have these 2 motor shields:
Adafruit Motor Shield V2 and
Seed Motor Shield V2.

They are stacked on top of an Arduino UNO.

My question is, how can I power 2 of those motor shields with one 3S Lipo battery(Turnigy 3S 2200mAh 20C), given that I have 6 identical 4.6-6V DC gearmotors?

Thanks!


texts: Updated Arduino IDE and Arduino not working

texts:
I've had the 1.0.5 IDE on my PC, which worked great. Now I've just decided to update to 1.6.6. After some stupid Java errors and trial and error, I got it to work.

I recompiled my project. Massive errors. Fixed the errors and compiled again.

It stated "Uploading..." That took much longer than before, but I saw the "This takes xxx memory and xxx bytes on the device" yadi yadi ya.

I decided to unplug the Arduino, swap some jumpers and reconnect it (as I've always done). Only this time - I hear 3 beeps from my PC (the sound you hear with broken USB devices). The COM port is no longer recognized.

How do  I fix this? Did that IDE upgrade just brick my Arduino?


texts: Why is my CNC shield smoking? Is it safe to keep on for long periods of time?

texts: I am working on a project that involves moving stepper motors, and the device will have to be on for upwards of hours. I am moving the bipolar NEMA17 stepper motors using a Protoneer CNC shield V3 on top of an Arduino UNO and DRV8825 stepper drivers. Though I haven't left the motors on for too long, whenever I do for longer periods, maybe 5 minutes or more, smoke starts being emitted around the 4 pins I connect my motors with. My question is that, if anyone has had a similar issue before, if they could explain why this occurs. I would also like to know if the stepper drivers are actually being protected by the heatsinks, because they can get ridiculously hot even after a few minutes and I'm worried that they wouldn't be able to last more than 15 minutes before exploding. Hopefully there's enough information here for someone to understand what's going on, but I'd glad to give more if that helps get a better idea of what's going on here. Thank you!


texts: Error while boot loading Atmega 2560 using Arduino Mega 2560

texts:
I have developed custom board using Atmega 2560. I am doing boot loading process using the process of migrate from an Arduino board to a standalone microcontroller.

I have followed this steps...

1) Upload the ArduinoISP sketch onto your Arduino board.

2) Wire up the Arduino board and microcontroller as connections mentioned on Arduino Site.

3) Select "Arduino/Genuino Mega/ Mega 2560" from the Tools > Board menu.

4) Select "Arduino as ISP" from Tools > Programmer

5) Run Tools > Burn Bootloader

While doing this process I am getting this Error...

  avrdude: Yikes!  Invalid device signature.
           Double check connections and try again, or use -F to override
           this check.
  Error while burning bootloader.

I have done connection like this...

MISO  -  D50
MOSI  -  D51
SCK   -  D52
Reset -  D53/Reset
+5V   -  Vcc
GND   -  GND

What wrong I am doing? Or any step I have missed?


texts: Few questions related to programming microcontrollers

texts:
I'm learning "Arduino" (I don't have previous knowledge of microcontrollers). I have few questions:

What is the difference between programming a microcontroller in C and programming in "Arduino?"
Is it a good idea for beginners to start programming microcontrollers in Arduino and then start learning to program in C?
I have Arduino Uno with an Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? What are differences between various microcontrollers which can be used with this board?
If a microcontroller is already programmed, can we download the program from it to a PC and edit it in Arduino IDE? Or it is like a .exe on a PC, once compiled we can't get source, all we can do is reverse engineer?

That's it :)


texts: Trying to map a room with Arduino controlled bot

texts:
What you see above is a map of my room. The boxes in black are obstacles and the box in red is my bot.

Now I want my bot to go around the room, avoiding all obstacles, but at the same time, covering the entire floor. Think of it like the robot is painting the floor and it has to paint the entire floor avoiding all obstacles.

Now my first approach was to put 3 HC-SR ultrasonic sensors on 3 sides and listen to them in a sequence, deciding which path is best and then going there. But this method leaves out quite a lot of floor area uncovered.

So how can I cover the entire floor area here?
 Presently I am working with Arduino UNO and HC-SR04 but wouldn't hesitate to throw my Pi3 or a few more sensors in there...-


texts: Is it possible using a hc-05 bluetooth module as master and pair it to a hc-06 module?

texts:
I have configured a hc-05 bluetooth module as master and a hc-06 module as slave an since the LED on the hc-05 is blinking in a 2s delay they should be paired but no matter what I do I can't send data between the two Arduinos.
Here is the code for the slave
(I use the example code from the EasyTransfer module github repo: https://github.com/madsci1016/Arduino-EasyTransfer):
    #include <Wire.h>
    #include <EasyTransferI2C.h>

    //create object
    EasyTransferI2C ET;

    struct RECEIVE_DATA_STRUCTURE{
      //put your variable definitions here for the data you want to receive
      //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
      int16_t blinks;
      int16_t pause;
    };

    //give a name to the group of data
    RECEIVE_DATA_STRUCTURE mydata;

    //define slave i2c address
    #define I2C_SLAVE_ADDRESS 9

    void setup(){
      Wire.begin(I2C_SLAVE_ADDRESS);
      //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
      ET.begin(details(mydata), &Wire);
      //define handler function on receiving data
      Wire.onReceive(receive);

      pinMode(13, OUTPUT);

    }

    void loop() {
      //check and see if a data packet has come in.
      if(ET.receiveData()){
        //this is how you access the variables. [name of the group].[variable name]
        //since we have data, we will blink it out.
        for(int i = mydata.blinks; i>0; i--){
          digitalWrite(13, HIGH);
          delay(mydata.pause * 100);
          digitalWrite(13, LOW);
          delay(mydata.pause * 100);
        }
      }
    }

    void receive(int numBytes)

here is the code for the master:
#include <Wire.h>
#include <EasyTransferI2C.h>

//create object
EasyTransferI2C ET;

struct SEND_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to send
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int16_t blinks;
  int16_t pause;
};

//give a name to the group of data
SEND_DATA_STRUCTURE mydata;

//define slave i2c address
#define I2C_SLAVE_ADDRESS 9

void setup(){
  Wire.begin();
  //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
  ET.begin(details(mydata), &Wire);

  pinMode(13, OUTPUT);

  randomSeed(analogRead(0));

}

void loop(){
  //this is how you access the variables. [name of the group].[variable name]
  mydata.blinks = random(5);
  mydata.pause = random(5);
  //send the data
  ET.sendData(I2C_SLAVE_ADDRESS);

  //Just for fun, we will blink it out too
   for(int i = mydata.blinks; i>0; i--){
      digitalWrite(13, HIGH);
      delay(mydata.pause * 100);
      digitalWrite(13, LOW);
      delay(mydata.pause * 100);
    }

  delay(5000);
}


texts: Inaccurate voltage readings on an esp32 as opposed to multimeter

texts:
I am working on detecting the amplitude of a signal coming from a guitar pickup. I am using an esp32 and an LM386 module for amplifying the signal.
I get quite stable readings with a multimeter, but the readings on the Arduino IDE show peaks and also peaks come when no signal should be there.

Here is a link for short videos of both the esp32 readings and the multimeter:
https://drive.google.com/drive/folders/1gpvkN_sz627jG0TNPpUps82105EB89OF?usp=sharing
Thanks!
EDIT (Adding simple code being used) :
int ampedVoltagePin = 12;

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

void loop() {
  Serial.println(analogRead(ampedVoltagePin));
  delay(100);
}

EDIT (Adding diagram):


texts: Why does a delay make my stepper stop? And why does the break command raise an error?

texts:
I am using a stepper motor for a project that I want it to stop. I tried for loops, while, and an if statement. All of these were placed inside the void loop, because it raised an error.

My code with the if loop:

//This program does about 1 rotation or 4100 steps. The program should be able to stop the stepper motor after it does one rotation.
int Pin1 = 8;
int Pin2 = 9;
int Pin3 = 10;
int Pin4 = 11;
int _step = 0;
int _on = 4100;
int _switches = 0;
boolean direct = false;
void setup() {
  pinMode (Pin1, OUTPUT);
  pinMode (Pin2, OUTPUT);
  pinMode (Pin3, OUTPUT);
  pinMode (Pin4, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (_on > 0) {
    switch(_step)
    {
      case 0:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, HIGH);
      break;
      case 1:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, HIGH);
        digitalWrite (Pin4, HIGH);
      break;
      case 2:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, HIGH);
        digitalWrite (Pin4, LOW);
      break;
      case 3:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, HIGH);
        digitalWrite (Pin3, HIGH);
        digitalWrite (Pin4, LOW);
      break;
      case 4:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, HIGH);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, LOW);
      break;
      case 5:
        digitalWrite (Pin1, HIGH);
        digitalWrite (Pin2, HIGH);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, LOW);
      break;
      case 6:
        digitalWrite (Pin1, HIGH);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, LOW);
      break;
      case 7:
        digitalWrite (Pin1, HIGH);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, HIGH);
      break;
      case 8:
        digitalWrite (Pin1, LOW);
        digitalWrite (Pin2, LOW);
        digitalWrite (Pin3, LOW);
        digitalWrite (Pin4, LOW);
      break;
    }

    if(direct == false) {
      _step++;
      _switches++;
      direct = false;
    }else{
      _step--;
      _switches--;
      direct = true;
    }

    Serial.println(_switches);

    if(_step>7) {
      _step=0;
    }

    if(_step<0) {
      _step=7;
    }
    _on--;
    delay(1); // This solves it.
  }
  break; //This raises an error when used with for loop.
}

Can anyone help on why the delay makes it stop? And why the break command raises and error?

Arduino UNO. 5 wire stepper.


texts: Is it bad practice to multitask without timing constraints

texts:
Going through resources such as several things at the same time and with some greatly appreciated assistance on here I'm finally getting a grasp on how to multitask a microcontroller.
Most examples use the millis() approach to nonblocking programming. However, even in the link above the button state is being polled every loop (from what I understood).
So what confuses me is: is it bad practice to write functions, which poll sensor(s) and input(s) without timing constraints, i.e. at every iteration of loop?
Is this still consider nonblocking programming?
I've written some mock code to better illustrate what I mean. Thank you very much for reading through.
void loop() {
    Button();
    Sensor();
    LED();
    // ...
}

void Button() {
  // Read button(s)
  button_state = digitalRead(button_pin);
  if (button_state == LOW) {
    // ...
  };
};

void Sensor() {
  // Read sensor
  int sensor_state = analogRead(sensor_pin);
  if (sensor_state >= 150) {
    // ...
  };
};


texts: How to use ESPAsyncWebServer with SoftwareSerial communicating ESP01f

texts: I'm creating a web server with using host.com/?ll="some". But I read that I can use for it ESPAsyncWebServer for this things. And how can I use it without flashing esp? If possible give me link to the libraries.


texts: Arduino Yun can no longer send to Dropbox

texts:
A long time ago I had set up an Arduino Yun to send files to Dropbox... I tried now and it ends in "killed" when trying to install the latest Dropbox Python module.

pip install (six, urllib3, etc etc) does work individually without running out of memory. Unfortunately when I install all but Dropbox, and then put the Dropbox module code folder in the current directory, it does start to import Dropbox with import dropbox but ends up with the KILLED message.

Is there a way I can connect to my current Dropbox without it using all of the 60mb of RAM and quitting... I keep getting the error with version 2.1:

  Error.Cannot connect to Dropbox
  [400] u'v1_retired'


texts: Trying to use Tap Detection solution using ADXL345 with Arduino

texts:
I am using ADXL345 sensor connecting with Arduino via I2C interface, I am able to test the data at tri-axial axis but as there are some other features also, which I am going to try with Tap detection method as I didn't use TAP THRESH register and instead of that I am using the registers (in decimal) of Tap latency - 33, Tap Duration - 34, Tap Window - 35.

For which I just started with raw code,

#include <Wire.h>

// ADXL345 I2C address is 0x53(83)
#define Addr 0x53

void setup()
{
  // Initialise I2C communication as MASTER
  Wire.begin();
  // Initialise serial communication, set baud rate = 9600
  Serial.begin(9600);

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select bandwidth rate register
  Wire.write(0x2C);
  // Normal mode, Output data rate = 100 Hz
  Wire.write(0x0A);
  // Stop I2C transmission
  Wire.endTransmission();

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select power control register
  Wire.write(0x2D);
  // Auto-sleep disable
  Wire.write(0x08);
  // Stop I2C transmission
  Wire.endTransmission();

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select data format register
  Wire.write(0x31);
  // Self test disabled, 4-wire interface, Full resolution, Range = +/-2g
  Wire.write(0x08);
  // Stop I2C transmission
  Wire.endTransmission();
  delay(300);
 }

 void loop()
 {
   unsigned int data[3];
   for(int i = 0; i < 3; i++)
   {
    // Start I2C Transmission
    Wire.beginTransmission(Addr);
    // Select data register
    Wire.write((33 + i));
    // Stop I2C transmission
    Wire.endTransmission();

    // Request 1 byte of data
    Wire.requestFrom(Addr, 1);

    //Read Three Bytes
    if(Wire.available() == 1)
    {
      data[i] = Wire.read();
    }
 }
   int TAP_DUR = data[1];
   int TAP_LAT = data[2];
   int TAP_WIN = data[3];

   Serial.print("TAP DURATION: ");
   Serial.println(TAP_DUR);
   Serial.print("TAP Latency: ");
   Serial.println(TAP_LAT);
   Serial.print("Tap Window : ");
   Serial.println(TAP_WIN);
   delay(3000);
   }

which is not working properly, and giving the result like this

TAP DURATION: 0
TAP Latency: 0
Tap Window : 22272
TAP DURATION: 0
TAP Latency: 0
Tap Window : 22272
TAP DURATION: 0
TAP Latency: 0
Tap Window : 22272

The main aim is to test the no of tap count and duration between single tap and double tap rather than using any library I need to work with the code I have been making.

Suggestion and bits of advice to make it work will be welcome.


texts:
I want my LED to turn on gradually without using the delay() function and blocking the code.

Here's the code i came up with:

int led_pin = 6;
unsigned long millisTimer = 0;
int PWMdelay = 5000;
int condition = 0;
int i = 0;
void setup() {
    pinMode(led_pin, OUTPUT);
}
void loop() {
    if(condition == 1){
    if ((millis() - millisTimer) > PWMdelay){
        if(i<255){
            i++;
            millisTimer = millis();
        }

    }
        analogWrite(led_pin, i);
    }
}

Is this the "right way" of slowing the PMW duration from 0 to 255 or there are alternative/better/easier ways?


texts: nodeMCU - Millis() - Simple Counter - How long is LED on?

texts:
PROGRESS, now I have this (WITH GREAT HELP):

void setup() {
   Serial.begin(9600);
// initialize digital pin 13 as an output.
}
uint32_t timer_start = 0;
int timer_running = false;

void loop()
 {
// Get LDR information
  int sensorValue = analogRead(A0);         // read the input on analog pin 0
  float voltage = sensorValue * (5.0 / 1023.0);     // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V)
  float lux = voltage * 100;

 if (lux>150) {
    if (!timer_running) {
      // Timer is not already running, so capture the start time
      timer_start = millis();
      timer_running = true;
    }
  } else {
    if (timer_running) {
      // The timer is currently running; stop it calculate/print the run time
      timer_running = false;
      Serial.println((millis()-timer_start) / 1000.0, 3); // format however you like here

    }
  }

 }

This now tells me how many millis the gymnast is in the air, divided by 1000.0 with 3 decimals. If I start the Serial Monitor when the gymnast is in the trampoline bed, then I can get the seconds of air_time the gymnast has. Is there a way to have this script running ONLY for 10 loops?


texts:
I have an arduino thing, and the hardware I plan to connect to it (a triac zero-crossing based dimmer) provides a synchronization signal from the mains power phase it connects to.

Main power does of course vary some from the nominal 60Hz, however the exact frequency gets adjusted over the course of the day to ensure there are almost exactly 5184000 cycles per day and pretty much exactly 36288000 cycles per week, and is used by mains-powered wall clocks to keep time.

Since my application will need to keep accurate time-of-day across weeks or months without adjustment, it would be advantageous to be able to use this time source.

I can of course write my own code to increment a counter every time the arduino receives a pulse, but if a library that can handle this already exists, I would prefer to use that, in particular since then I won't have to write code to track days and months, handle DST, or any of that stuff.

What libraries exist (if any) to handle timekeeping based on a fixed-pulse-rate input source?


texts: How to get air speed, which sensor to use?

texts:
I want to measure the airspeed on a flying vehicle and get the data with arduino. Note that, there will not be any control mechanism on the flying object, it will be flying mechanicaly/passively, I mean no flight controller or something like that will be present.

However, I could not understand whether there is a sensor to measure the airspeed directly or is airspeed something you analyze by using other datas(temperature, pressure etc.)

I saw there are sensors which are sold as "airspeed sensor" however it is not so common that I cannot find examples in which the incoming data is shown.

Anybody ever experienced with this issue may lighten me.

Thanks in advance.


texts: Clock Problem when Migrating from Arduino IDE Mighty Core to Atmel Studio

texts:
I've been programming an ATMega1284 using the Arduino IDE with the MightyCore package.
I'm now trying to migrate to Atmel Studio.
Atmel Studio (7.0) will now compile the sketch and all required libraries (that took some time) and upload the output via USBAsp to the ATMega (Essentially just calling avrdude). However...
The uploaded sketch is running differently. It seems slower. For example, the Tone() function seems to output a lower pitch. My best guess is that Atmel Studio has the xtal/clock setting wrong, but I can't find where to inspect/change it?
I'm using a 12mhz external xtal, and can only communicate with the chip via UART. If I upload the sketch from Arduino IDE then it reverts back to normal.


texts:
Recently I ordered some ATtiny85's from Jameco, and I've been trying to upload code to them through an Arduino Uno, following the instructions from this video on YouTube. I've been getting a lot of unexpected errors and I am now wondering if the chips I bought are the problem. Here are the specs from the Jameco website:

Flash (Kbytes): 8 Kbytes
Pin Count: 8
Max. Operating Frequency: 20 MHz
Power Supply: 2.7 - 5.5V
Operational Range: Industrial (A) (-40°C to 85°C)
CPU: 8-bit AVR
Number of Touch Channels: 3
Hardware QTouch Acquisition: No
Max I/O Pins: 6
Ext Interrupts: 6
USB Speed: No
USB Interface: No

Does the "USB Speed: No; USB Interface: No" mean these aren't programmable by my set up? Or is there is anything else I should know about these chips? Do I need to get new ones that are different?


texts: ESP32 Arduino Bluetooth Serial does not reconnect after disconnecting

texts:
The basic ESP32 Arduino Bluetooth Serial example pairs and connects as expected, BUT once I disconnect the Bluetooth terminal it stops responding to new events at all,
once I reset the esp32, it starts working again with the same problem. (it doesn't matter if it keeps being paired or not)
I have tested it with the windows Bluetooth terminal and with the Bluetooth Any terminal. (from the windows store)
I have downloaded the latest esp32-Arduino library from GitHub and I still get the same problem.
I have tested it with several esp32 modules, and they all respond with the same problem.
So it looks like a bug in the library code.
See the simple Arduino example code below:
#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run make menuconfig to and enable it #endif

BluetoothSerial SerialBT;

void setup() { Serial.begin(115200); SerialBT.begin("ESP32test"); //Bluetooth device name Serial.println("The device started, now you can pair it with bluetooth!"); }

void loop() { if (Serial.available()) { SerialBT.write(Serial.read()); } if (SerialBT.available()) { Serial.write(SerialBT.read()); } delay(20); }

Does anyone know of another Bluetooth serial library that does work?
Thank You!


texts: How to send Multiple decoded IR signals in one script

texts:
My final goal is to use my Arduino microcontroller as an "automatic remote". For now I would like to know how to send decoded NEC protocols one after another in a script.

I am using the Nano V 3.0 with a IR led I salvaged from an old remote. I used a VS838 and a 338R IR receiving module to decode the signals, both work 100%

I know how to send one protocol in a loop.

e.g

#include <IRremote.h>

IRsend irsend;

void setup()
{
}

void loop() {
    for (int i = 0; i < 2; i++) {
        irsend.sendNEC(0x10676897, 32);
        delay(40);
    }
    delay(5000); //5 second delay between each signal burst
}

I also know how to send the same protocol repetitively.

(Although it won't work in the loop I reckon it'll work in the final script)

e.g

#include <IRremote.h>

IRsend irsend;

void setup()
{
}

void loop() {
    for (int i = 0; i < 2; i++) {
        irsend.sendNEC(0xFFFFFFFF, 32);
        delay(40);
    }
    delay(5000); //5 second delay between each signal burst
}

However, I would like to include 106722DD, 10676897 ,10678877 and send them in one single C++ Script.

I was thinking something like calling each script through a loop might suffice but I have no idea how to do it in C++

Any help will be appreciated.


texts: Arduino Mega Shield Library for Eagle CAD

texts: I'm a noob to PCB designing and electronic stuff. I want to design a pcb shield which is compatible with an Arduino mega 2560. I'm using Eagle CAD. I checked the sparkfun library but I couldn't find a way to design Mega Shield. Can anybody give me a library or any alternative way to do this?